fix(trading): allotment breaking [main] (#4875)

This commit is contained in:
Matthew Russell 2023-09-25 17:26:06 -04:00 committed by GitHub
parent 2d4be5fcb3
commit ef4a740b91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 43 additions and 48 deletions

View File

@ -4,7 +4,7 @@ import { AssetTypeMapping, AssetStatusMapping } from '@vegaprotocol/assets';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import { ButtonLink } from '@vegaprotocol/ui-toolkit'; import { ButtonLink } from '@vegaprotocol/ui-toolkit';
import type { AgGridReact } from 'ag-grid-react'; import type { AgGridReact } from 'ag-grid-react';
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid'; import { AgGrid } from '@vegaprotocol/datagrid';
import type { VegaICellRendererParams } from '@vegaprotocol/datagrid'; import type { VegaICellRendererParams } from '@vegaprotocol/datagrid';
import { useRef, useLayoutEffect } from 'react'; import { useRef, useLayoutEffect } from 'react';
import { BREAKPOINT_MD } from '../../config/breakpoints'; import { BREAKPOINT_MD } from '../../config/breakpoints';

View File

@ -4,7 +4,7 @@ import { t } from '@vegaprotocol/i18n';
import { ButtonLink } from '@vegaprotocol/ui-toolkit'; import { ButtonLink } from '@vegaprotocol/ui-toolkit';
import type { AgGridReact } from 'ag-grid-react'; import type { AgGridReact } from 'ag-grid-react';
import type { ColDef } from 'ag-grid-community'; import type { ColDef } from 'ag-grid-community';
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid'; import { AgGrid } from '@vegaprotocol/datagrid';
import type { import type {
VegaICellRendererParams, VegaICellRendererParams,
VegaValueGetterParams, VegaValueGetterParams,

View File

@ -2,7 +2,7 @@ import type { ProposalListFieldsFragment } from '@vegaprotocol/proposals';
import { VoteProgress } from '@vegaprotocol/proposals'; import { VoteProgress } from '@vegaprotocol/proposals';
import type { AgGridReact } from 'ag-grid-react'; import type { AgGridReact } from 'ag-grid-react';
import { ExternalLink } from '@vegaprotocol/ui-toolkit'; import { ExternalLink } from '@vegaprotocol/ui-toolkit';
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid'; import { AgGrid } from '@vegaprotocol/datagrid';
import type { import type {
VegaICellRendererParams, VegaICellRendererParams,
VegaValueFormatterParams, VegaValueFormatterParams,
@ -105,7 +105,7 @@ export const ProposalsTable = ({ data }: ProposalsTableProps) => {
? new BigNumber(0) ? new BigNumber(0)
: yesTokens.multipliedBy(100).dividedBy(totalTokensVoted); : yesTokens.multipliedBy(100).dividedBy(totalTokensVoted);
return ( return (
<div className="uppercase flex h-full items-center justify-center pt-2"> <div className="flex items-center justify-center h-full pt-2 uppercase">
<VoteProgress <VoteProgress
threshold={requiredMajorityPercentage} threshold={requiredMajorityPercentage}
progress={yesPercentage} progress={yesPercentage}

View File

@ -3,7 +3,7 @@ import { forwardRef, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { Button, Icon } from '@vegaprotocol/ui-toolkit'; import { Button, Icon } from '@vegaprotocol/ui-toolkit';
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid'; import { AgGrid } from '@vegaprotocol/datagrid';
import { useAppState } from '../../../../contexts/app-state/app-state-context'; import { useAppState } from '../../../../contexts/app-state/app-state-context';
import { BigNumber } from '../../../../lib/bignumber'; import { BigNumber } from '../../../../lib/bignumber';
import { import {
@ -85,17 +85,17 @@ const TopThirdCellRenderer = (
}} }}
className="grid grid-cols-[60px_1fr] w-full h-full py-4 px-0 text-sm text-white text-center overflow-scroll" className="grid grid-cols-[60px_1fr] w-full h-full py-4 px-0 text-sm text-white text-center overflow-scroll"
> >
<div className="text-xs text-left px-3"> <div className="px-3 text-xs text-left">
{params?.data?.rankingDisplay} {params?.data?.rankingDisplay}
</div> </div>
<div className="whitespace-normal px-3"> <div className="px-3 whitespace-normal">
<div className="mb-4"> <div className="mb-4">
<Button <Button
data-testid="show-all-validators" data-testid="show-all-validators"
rightIcon={ rightIcon={
<Icon <Icon
name="arrow-right" name="arrow-right"
className="fill-current mr-2 align-text-top" className="mr-2 align-text-top fill-current"
/> />
} }
className="inline-flex items-center" className="inline-flex items-center"
@ -103,7 +103,7 @@ const TopThirdCellRenderer = (
{t('Reveal top validators')} {t('Reveal top validators')}
</Button> </Button>
</div> </div>
<p className="font-semibold text-white mb-0"> <p className="mb-0 font-semibold text-white">
{t( {t(
'Validators with too great a stake share will have the staking rewards for their delegators penalised.' 'Validators with too great a stake share will have the staking rewards for their delegators penalised.'
)} )}

View File

@ -1,7 +1,7 @@
import { forwardRef, useMemo, useRef } from 'react'; import { forwardRef, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid'; import { AgGrid } from '@vegaprotocol/datagrid';
import { useAppState } from '../../../../contexts/app-state/app-state-context'; import { useAppState } from '../../../../contexts/app-state/app-state-context';
import { BigNumber } from '../../../../lib/bignumber'; import { BigNumber } from '../../../../lib/bignumber';
import { import {

View File

@ -4,7 +4,7 @@ import type {
VegaICellRendererParams, VegaICellRendererParams,
VegaValueFormatterParams, VegaValueFormatterParams,
} from '@vegaprotocol/datagrid'; } from '@vegaprotocol/datagrid';
import { AgGridLazy as AgGrid, COL_DEFS } from '@vegaprotocol/datagrid'; import { AgGrid, COL_DEFS } from '@vegaprotocol/datagrid';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import type { ProductType } from '@vegaprotocol/types'; import type { ProductType } from '@vegaprotocol/types';

View File

@ -1,5 +1,5 @@
import type { TypedDataAgGrid } from '@vegaprotocol/datagrid'; import type { TypedDataAgGrid } from '@vegaprotocol/datagrid';
import { AgGridLazy as AgGrid, PriceFlashCell } from '@vegaprotocol/datagrid'; import { AgGrid, PriceFlashCell } from '@vegaprotocol/datagrid';
import type { MarketMaybeWithData } from '@vegaprotocol/markets'; import type { MarketMaybeWithData } from '@vegaprotocol/markets';
import { useColumnDefs } from './use-column-defs'; import { useColumnDefs } from './use-column-defs';

View File

@ -18,7 +18,7 @@ import {
VegaIconNames, VegaIconNames,
TooltipCellComponent, TooltipCellComponent,
} from '@vegaprotocol/ui-toolkit'; } from '@vegaprotocol/ui-toolkit';
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid'; import { AgGrid } from '@vegaprotocol/datagrid';
import type { import type {
IGetRowsParams, IGetRowsParams,
IRowNode, IRowNode,

View File

@ -13,7 +13,7 @@ import type {
VegaICellRendererParams, VegaICellRendererParams,
} from '@vegaprotocol/datagrid'; } from '@vegaprotocol/datagrid';
import { ProgressBarCell } from '@vegaprotocol/datagrid'; import { ProgressBarCell } from '@vegaprotocol/datagrid';
import { AgGridLazy as AgGrid, PriceCell } from '@vegaprotocol/datagrid'; import { AgGrid, PriceCell } from '@vegaprotocol/datagrid';
import type { ColDef } from 'ag-grid-community'; import type { ColDef } from 'ag-grid-community';
import { accountValuesComparator } from './accounts-table'; import { accountValuesComparator } from './accounts-table';
import { MarginHealthChart } from './margin-health-chart'; import { MarginHealthChart } from './margin-health-chart';

View File

@ -1,4 +1,4 @@
export * from './lib/ag-grid/ag-grid-lazy'; export * from './lib/ag-grid/ag-grid';
export * from './lib/column-definitions'; export * from './lib/column-definitions';

View File

@ -1,17 +0,0 @@
import { forwardRef, lazy } from 'react';
import type { AgGridReactProps, AgGridReact } from 'ag-grid-react';
type Props = AgGridReactProps & {
style?: React.CSSProperties;
gridRef?: React.Ref<AgGridReact>;
};
export const AgGridLazyInternal = lazy(() =>
import('./ag-grid-lazy-themed').then((module) => ({
default: module.AgGridThemed,
}))
);
export const AgGridLazy = forwardRef<AgGridReact, Props>((props, ref) => (
<AgGridLazyInternal {...props} gridRef={ref} />
));

View File

@ -0,0 +1,12 @@
import { forwardRef } from 'react';
import type { AgGridReactProps, AgGridReact } from 'ag-grid-react';
import { AgGridThemed } from './ag-grid-themed';
type Props = AgGridReactProps & {
style?: React.CSSProperties;
gridRef?: React.Ref<AgGridReact>;
};
export const AgGrid = forwardRef<AgGridReact, Props>((props, ref) => (
<AgGridThemed {...props} gridRef={ref} />
));

View File

@ -1,13 +1,12 @@
import { act, render, waitFor } from '@testing-library/react'; import { act, render, waitFor } from '@testing-library/react';
import { import { useDataGridEvents } from './use-datagrid-events';
useDataGridEvents, import { AgGridThemed } from './ag-grid/ag-grid-themed';
GRID_EVENT_DEBOUNCE_TIME,
} from './use-datagrid-events';
import { AgGridThemed } from './ag-grid/ag-grid-lazy-themed';
import type { MutableRefObject } from 'react'; import type { MutableRefObject } from 'react';
import { useRef } from 'react'; import { useRef } from 'react';
import type { AgGridReact } from 'ag-grid-react'; import type { AgGridReact } from 'ag-grid-react';
const GRID_EVENT_DEBOUNCE_TIME = 500;
const gridProps = { const gridProps = {
rowData: [{ id: 1 }], rowData: [{ id: 1 }],
columnDefs: [ columnDefs: [

View File

@ -6,7 +6,7 @@ import {
isNumeric, isNumeric,
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import type { ColDef } from 'ag-grid-community'; import type { ColDef } from 'ag-grid-community';
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid'; import { AgGrid } from '@vegaprotocol/datagrid';
import type { import type {
VegaICellRendererParams, VegaICellRendererParams,
VegaValueFormatterParams, VegaValueFormatterParams,

View File

@ -15,7 +15,7 @@ import {
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import * as Schema from '@vegaprotocol/types'; import * as Schema from '@vegaprotocol/types';
import { import {
AgGridLazy as AgGrid, AgGrid,
positiveClassNames, positiveClassNames,
negativeClassNames, negativeClassNames,
MarketNameCell, MarketNameCell,
@ -300,7 +300,7 @@ const FeesBreakdownTooltip = ({
return ( return (
<div <div
data-testid="fee-breakdown-tooltip" data-testid="fee-breakdown-tooltip"
className="max-w-sm bg-vega-light-100 dark:bg-vega-dark-100 border border-vega-light-200 dark:border-vega-dark-200 px-4 py-2 z-20 rounded text-sm break-word text-black dark:text-white" className="z-20 max-w-sm px-4 py-2 text-sm text-black border rounded bg-vega-light-100 dark:bg-vega-dark-100 border-vega-light-200 dark:border-vega-dark-200 break-word dark:text-white"
> >
{role === MAKER && ( {role === MAKER && (
<> <>

View File

@ -7,7 +7,7 @@ import {
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import type { TypedDataAgGrid } from '@vegaprotocol/datagrid'; import type { TypedDataAgGrid } from '@vegaprotocol/datagrid';
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid'; import { AgGrid } from '@vegaprotocol/datagrid';
import { TooltipCellComponent } from '@vegaprotocol/ui-toolkit'; import { TooltipCellComponent } from '@vegaprotocol/ui-toolkit';
import type { import type {
ColDef, ColDef,

View File

@ -17,7 +17,7 @@ import {
import type { ForwardedRef } from 'react'; import type { ForwardedRef } from 'react';
import { memo, forwardRef, useMemo } from 'react'; import { memo, forwardRef, useMemo } from 'react';
import { import {
AgGridLazy as AgGrid, AgGrid,
SetFilter, SetFilter,
DateRangeFilter, DateRangeFilter,
negativeClassNames, negativeClassNames,

View File

@ -18,7 +18,7 @@ import {
} from '@vegaprotocol/ui-toolkit'; } from '@vegaprotocol/ui-toolkit';
import { memo, useMemo } from 'react'; import { memo, useMemo } from 'react';
import { import {
AgGridLazy as AgGrid, AgGrid,
SetFilter, SetFilter,
DateRangeFilter, DateRangeFilter,
negativeClassNames, negativeClassNames,

View File

@ -8,7 +8,7 @@ import type {
VegaICellRendererParams, VegaICellRendererParams,
} from '@vegaprotocol/datagrid'; } from '@vegaprotocol/datagrid';
import { import {
AgGridLazy as AgGrid, AgGrid,
COL_DEFS, COL_DEFS,
PriceFlashCell, PriceFlashCell,
signedNumberCssClassRules, signedNumberCssClassRules,

View File

@ -100,7 +100,8 @@ describe('ProposalsList', () => {
const container = within( const container = within(
document.querySelector(rowContainerSelector) as HTMLElement document.querySelector(rowContainerSelector) as HTMLElement
); );
expect(container.getAllByRole('row')).toHaveLength(
expect(await container.findAllByRole('row')).toHaveLength(
// @ts-ignore data is mocked // @ts-ignore data is mocked
mock?.result?.data.proposalsConnection.edges.length mock?.result?.data.proposalsConnection.edges.length
); );

View File

@ -1,5 +1,5 @@
import type { FC } from 'react'; import type { FC } from 'react';
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid'; import { AgGrid } from '@vegaprotocol/datagrid';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import * as Types from '@vegaprotocol/types'; import * as Types from '@vegaprotocol/types';
import { removePaginationWrapper } from '@vegaprotocol/utils'; import { removePaginationWrapper } from '@vegaprotocol/utils';

View File

@ -4,7 +4,7 @@ import type {
VegaICellRendererParams, VegaICellRendererParams,
VegaValueFormatterParams, VegaValueFormatterParams,
} from '@vegaprotocol/datagrid'; } from '@vegaprotocol/datagrid';
import { AgGridLazy as AgGrid, NumericCell } from '@vegaprotocol/datagrid'; import { AgGrid, NumericCell } from '@vegaprotocol/datagrid';
import { import {
addDecimal, addDecimal,
addDecimalsFormatNumber, addDecimalsFormatNumber,

View File

@ -20,7 +20,7 @@ import type {
VegaICellRendererParams, VegaICellRendererParams,
VegaValueFormatterParams, VegaValueFormatterParams,
} from '@vegaprotocol/datagrid'; } from '@vegaprotocol/datagrid';
import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid'; import { AgGrid } from '@vegaprotocol/datagrid';
import { EtherscanLink } from '@vegaprotocol/environment'; import { EtherscanLink } from '@vegaprotocol/environment';
import type { WithdrawalFieldsFragment } from './__generated__/Withdrawal'; import type { WithdrawalFieldsFragment } from './__generated__/Withdrawal';
import { import {