feat(explorer): improve display of multi cancellations (#3151)
This commit is contained in:
parent
51187029aa
commit
52183555a9
@ -0,0 +1,26 @@
|
|||||||
|
import { t } from '@vegaprotocol/i18n';
|
||||||
|
|
||||||
|
interface CancelSummaryProps {
|
||||||
|
orderId?: string;
|
||||||
|
marketId?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple component for rendering a reasonable string from an order cancellation
|
||||||
|
*/
|
||||||
|
export const CancelSummary = ({ orderId, marketId }: CancelSummaryProps) => {
|
||||||
|
return <span className="font-bold">{getLabel(orderId, marketId)}</span>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function getLabel(
|
||||||
|
orderId: string | undefined,
|
||||||
|
marketId: string | undefined
|
||||||
|
): string {
|
||||||
|
if (!orderId && !marketId) {
|
||||||
|
return t('All orders');
|
||||||
|
} else if (marketId && !orderId) {
|
||||||
|
return t('All in market');
|
||||||
|
}
|
||||||
|
|
||||||
|
return '-';
|
||||||
|
}
|
@ -2,6 +2,7 @@ import type { BatchCancellationInstruction } from '../../../../routes/types/bloc
|
|||||||
import { TxOrderType } from '../../tx-order-type';
|
import { TxOrderType } from '../../tx-order-type';
|
||||||
import { MarketLink } from '../../../links';
|
import { MarketLink } from '../../../links';
|
||||||
import OrderSummary from '../../../order-summary/order-summary';
|
import OrderSummary from '../../../order-summary/order-summary';
|
||||||
|
import { CancelSummary } from '../../../order-summary/order-cancellation';
|
||||||
|
|
||||||
interface BatchCancelProps {
|
interface BatchCancelProps {
|
||||||
index: number;
|
index: number;
|
||||||
@ -19,7 +20,14 @@ export const BatchCancel = ({ index, submission }: BatchCancelProps) => {
|
|||||||
<TxOrderType orderType={'OrderCancellation'} />
|
<TxOrderType orderType={'OrderCancellation'} />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
{submission.orderId ? (
|
||||||
<OrderSummary id={submission.orderId} modifier="cancelled" />
|
<OrderSummary id={submission.orderId} modifier="cancelled" />
|
||||||
|
) : (
|
||||||
|
<CancelSummary
|
||||||
|
orderId={submission.orderId}
|
||||||
|
marketId={submission.marketId}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<MarketLink id={submission.marketId} />
|
<MarketLink id={submission.marketId} />
|
||||||
|
@ -5,6 +5,8 @@ import type { TendermintBlocksResponse } from '../../../routes/blocks/tendermint
|
|||||||
import { TxDetailsShared } from './shared/tx-details-shared';
|
import { TxDetailsShared } from './shared/tx-details-shared';
|
||||||
import { TableCell, TableRow, TableWithTbody } from '../../table';
|
import { TableCell, TableRow, TableWithTbody } from '../../table';
|
||||||
import DeterministicOrderDetails from '../../order-details/deterministic-order-details';
|
import DeterministicOrderDetails from '../../order-details/deterministic-order-details';
|
||||||
|
import { CancelSummary } from '../../order-summary/order-cancellation';
|
||||||
|
import Hash from '../../links/hash';
|
||||||
|
|
||||||
interface TxDetailsOrderCancelProps {
|
interface TxDetailsOrderCancelProps {
|
||||||
txData: BlockExplorerTransactionResult | undefined;
|
txData: BlockExplorerTransactionResult | undefined;
|
||||||
@ -24,8 +26,8 @@ export const TxDetailsOrderCancel = ({
|
|||||||
return <>{t('Awaiting Block Explorer transaction details')}</>;
|
return <>{t('Awaiting Block Explorer transaction details')}</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const marketId: string = txData.command.orderCancellation.marketId || '-';
|
const marketId: string = txData.command.orderCancellation.marketId;
|
||||||
const orderId: string = txData.command.orderCancellation.orderId || '-';
|
const orderId: string = txData.command.orderCancellation.orderId;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -38,18 +40,24 @@ export const TxDetailsOrderCancel = ({
|
|||||||
<TableRow modifier="bordered">
|
<TableRow modifier="bordered">
|
||||||
<TableCell>{t('Order')}</TableCell>
|
<TableCell>{t('Order')}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<code>{orderId}</code>
|
{orderId ? (
|
||||||
|
<Hash text={orderId} />
|
||||||
|
) : (
|
||||||
|
<CancelSummary orderId={orderId} marketId={marketId} />
|
||||||
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
{marketId ? (
|
||||||
<TableRow modifier="bordered">
|
<TableRow modifier="bordered">
|
||||||
<TableCell>{t('Market')}</TableCell>
|
<TableCell>{t('Market')}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<MarketLink id={marketId} />
|
<MarketLink id={marketId} />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
) : null}
|
||||||
</TableWithTbody>
|
</TableWithTbody>
|
||||||
|
|
||||||
{orderId !== '-' ? <DeterministicOrderDetails id={orderId} /> : null}
|
{orderId ? <DeterministicOrderDetails id={orderId} /> : null}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user