Skip to content

Commit

Permalink
Merge branch 'development' of ssh://github.com/multiversx/mx-explorer…
Browse files Browse the repository at this point in the history
…-dapp into staking-v4-redesign-step-2
  • Loading branch information
radumojic committed May 17, 2024
2 parents 434986c + d0cb0a6 commit b63ce23
Show file tree
Hide file tree
Showing 48 changed files with 1,134 additions and 147 deletions.
14 changes: 10 additions & 4 deletions src/components/AccountName/AccountName.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useEffect, useState } from 'react';
import classNames from 'classnames';

import { HEROTAG_SUFFIX } from 'appConstants';
import { ReactComponent as IdentityLogo } from 'assets/img/logos/identity.svg';
Expand All @@ -10,12 +9,14 @@ import { AccountAssetType, WithClassnameType } from 'types';

export interface AccountNameUIType extends WithClassnameType {
address: string;
username?: string;
assets?: AccountAssetType;
fetchAssets?: boolean;
}

export const AccountName = ({
address,
username,
assets,
fetchAssets = false,
className,
Expand Down Expand Up @@ -46,14 +47,19 @@ export const AccountName = ({
}, [address, fetchAssets, assets]);

const displayAssets = assets || fetchedAssets;
const displayName = username || displayAssets?.name;

if (displayAssets?.name) {
const name = formatHerotag(displayAssets.name);
if (!address) {
return '-';
}

if (displayName) {
const name = formatHerotag(displayName);
const description = `${name} (${address})`;

return (
<>
{displayAssets.name.endsWith(HEROTAG_SUFFIX) && (
{displayName.endsWith(HEROTAG_SUFFIX) && (
<Overlay
title='Herotag'
className='herotag'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Filters/SelectFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const SelectFilter = ({
}

const defaultValues = options.filter(
(option) => existingValues && existingValues.includes(option.value)
(option) => existingValues && existingValues.includes(String(option.value))
);

const updateSelectValue = (selectValue: string) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import classNames from 'classnames';
import { Anchor, Dropdown } from 'react-bootstrap';
import { useSearchParams } from 'react-router-dom';

import { faFilter } from 'icons/regular';
import { faFilter as faFilterSolid } from 'icons/solid';
import { TransactionInPoolTypeEnum } from 'types';

export const TransactionInPoolTypeFilter = ({
text,
hideFilters
}: {
text: React.ReactNode;
hideFilters?: boolean;
}) => {
const [searchParams, setSearchParams] = useSearchParams();
const { type, page, size, ...rest } = Object.fromEntries(searchParams);

const typeLink = (type: TransactionInPoolTypeEnum) => {
const nextUrlParams = {
...rest,
...(type ? { type } : {})
};

setSearchParams(nextUrlParams);
};

if (hideFilters) {
return text;
}

return (
<div
className={classNames({
'text-primary-100': type !== undefined
})}
>
{text}
<Dropdown
className='d-inline-flex'
onSelect={(eventKey: any) => {
return typeLink(eventKey ?? '');
}}
>
<Dropdown.Toggle
className='btn-link-unstyled side-action cursor-pointer'
variant='link'
>
<FontAwesomeIcon
icon={type !== undefined ? faFilterSolid : faFilter}
className={type !== undefined ? 'text-primary' : ''}
/>
</Dropdown.Toggle>
<Dropdown.Menu>
<Dropdown.Item as={Anchor} className='text-neutral-400' eventKey=''>
All
</Dropdown.Item>
{Object.keys(TransactionInPoolTypeEnum).map(
(transactionType, key) => {
return (
<Dropdown.Item
as={Anchor}
eventKey={transactionType}
className={`dropdown-item text-cyan-400 ${
type === transactionType ? 'active' : ''
}`}
key={key}
>
{transactionType}
</Dropdown.Item>
);
}
)}
</Dropdown.Menu>
</Dropdown>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export * from './AgeColumnFilters';
export * from './FromColumnFilters';
export * from './MethodColumnFilters';
export * from './MethodList';
export * from './ShardColumnFilters';
export * from './StatusColumnFilters';
export * from './ToColumnFilters';
export * from './TransactionInPoolTypeFilter';
export * from './ValueColumnFilters';
1 change: 1 addition & 0 deletions src/components/Filters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './SelectFilter';
export * from './ShardFilter';
export * from './TableSearch';
export * from './TokenSelectFilter';
export * from './TransactionsFilters';
7 changes: 7 additions & 0 deletions src/components/Links/AccountLink/AccountLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { AccountAssetType, WithClassnameType } from 'types';

export interface AccountLinkType extends WithClassnameType {
address: string;
username?: string;
assets?: AccountAssetType;
linkClassName?: string;
fetchAssets?: boolean;
Expand All @@ -25,6 +26,7 @@ export interface AccountLinkType extends WithClassnameType {
export const AccountLink = ({
address,
assets,
username,
fetchAssets = false,
showLockedAccounts = true,
hasHighlight,
Expand All @@ -35,6 +37,10 @@ export const AccountLink = ({
const dispatch = useDispatch();
const { highlightedText } = useSelector(interfaceSelector);

if (!address) {
return '-';
}

return (
<div
className={classNames(
Expand Down Expand Up @@ -62,6 +68,7 @@ export const AccountLink = ({
>
<AccountName
address={address}
username={username}
assets={assets}
fetchAssets={fetchAssets}
className={linkClassName}
Expand Down
6 changes: 4 additions & 2 deletions src/components/PageSize/PageSize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import { WithClassnameType } from 'types';

export interface PageSizeUIType extends WithClassnameType {
maxSize?: number;
defaultSize?: number;
}

export const PageSize = ({
defaultSize = PAGE_SIZE,
maxSize = MAX_RESULTS,
className
}: PageSizeUIType) => {
Expand All @@ -20,9 +22,9 @@ export const PageSize = ({
const { page, size, ...rest } = params;
const paramSize = stringIsInteger(String(size)) ? parseInt(size) : PAGE_SIZE;

const currentSize = Math.min(paramSize, maxSize);
const currentSize = Math.min(paramSize, maxSize, defaultSize);
const sizeArray = [
...new Set([PAGE_SIZE, 10, 50, 75, 100, currentSize])
...new Set([PAGE_SIZE, 10, 50, 75, 100, currentSize, defaultSize])
].sort(function (a, b) {
return a - b;
});
Expand Down
122 changes: 122 additions & 0 deletions src/components/TransactionsInPoolTable/TransactionsInPoolTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { ELLIPSIS } from 'appConstants';
import {
Pager,
PageSize,
TableWrapper,
Loader,
PageState,
PulsatingLed
} from 'components';
import { useGetTransactionInPoolFilters } from 'hooks';
import { faCode, faExchangeAlt } from 'icons/regular';
import { TransactionInPoolType, TransactionFiltersEnum } from 'types';

import { TransactionsInPoolHeader, TransactionInPoolRow } from './components';

export interface TransactionsInPoolTableUIType {
transactionsInPool: TransactionInPoolType[];
totalTransactionsInPool: number | typeof ELLIPSIS;
title?: React.ReactNode;
dataChanged?: boolean;
isDataReady?: boolean;
inactiveFilters?: TransactionFiltersEnum[];
}

const ColSpanWrapper = ({ children }: { children: React.ReactNode }) => (
<tr>
<td colSpan={7}>{children}</td>
</tr>
);

export const TransactionsInPoolTable = ({
transactionsInPool,
totalTransactionsInPool,
title = (
<h5 data-testid='title' className='table-title d-flex align-items-center'>
Live Transactions In Pool <PulsatingLed className='ms-2 mt-1' />
</h5>
),
dataChanged = false,
isDataReady,
inactiveFilters
}: TransactionsInPoolTableUIType) => {
const { type } = useGetTransactionInPoolFilters();
return (
<div className='transactions-table transactions-in-pool-table'>
<div className='card'>
<div className='card-header'>
<div className='card-header-item table-card-header d-flex justify-content-between align-items-center flex-wrap gap-3'>
{title}
<Pager
total={totalTransactionsInPool}
show={transactionsInPool.length > 0}
className='d-flex ms-auto me-auto me-sm-0'
/>
</div>
</div>

<div className='card-body'>
<TableWrapper dataChanged={dataChanged}>
<table
className='table trim-size-sm mb-0'
data-testid='transactionsTable'
>
<TransactionsInPoolHeader inactiveFilters={inactiveFilters} />
<tbody>
{isDataReady === undefined && (
<ColSpanWrapper>
<Loader />
</ColSpanWrapper>
)}
{isDataReady === false && (
<ColSpanWrapper>
<PageState
icon={faExchangeAlt}
title={`No ${type ? `${type} ` : ''}Transactions in Pool`}
className='py-spacer my-auto'
/>
</ColSpanWrapper>
)}

{isDataReady === true && (
<>
{transactionsInPool.length > 0 ? (
<>
{transactionsInPool.map((transactionInPool, key) => (
<TransactionInPoolRow
transaction={transactionInPool}
key={`${transactionInPool.txHash}-${key}`}
/>
))}
</>
) : (
<>
<ColSpanWrapper>
<PageState
icon={faCode}
title={`No ${
type ? `${type} ` : ''
}Transactions in Pool`}
className='py-spacer my-auto'
/>
</ColSpanWrapper>
</>
)}
</>
)}
</tbody>
</table>
</TableWrapper>
</div>

<div className='card-footer table-footer'>
<PageSize />
<Pager
total={totalTransactionsInPool}
show={transactionsInPool.length > 0}
/>
</div>
</div>
</div>
);
};
Loading

0 comments on commit b63ce23

Please sign in to comment.