chore(trading): make loading masks in tabs consistent along the app (#3155)
This commit is contained in:
parent
47b3d5b55f
commit
5dbc5d7997
@ -25,7 +25,8 @@ export const DepositsContainer = () => {
|
|||||||
<div className="h-full relative">
|
<div className="h-full relative">
|
||||||
<DepositsTable
|
<DepositsTable
|
||||||
rowData={data || []}
|
rowData={data || []}
|
||||||
noRowsOverlayComponent={() => null}
|
suppressLoadingOverlay
|
||||||
|
suppressNoRowsOverlay
|
||||||
ref={gridRef}
|
ref={gridRef}
|
||||||
{...bottomPlaceholderProps}
|
{...bottomPlaceholderProps}
|
||||||
/>
|
/>
|
||||||
|
@ -24,7 +24,8 @@ export const WithdrawalsContainer = () => {
|
|||||||
<WithdrawalsTable
|
<WithdrawalsTable
|
||||||
data-testid="withdrawals-history"
|
data-testid="withdrawals-history"
|
||||||
rowData={data}
|
rowData={data}
|
||||||
noRowsOverlayComponent={() => null}
|
suppressLoadingOverlay
|
||||||
|
suppressNoRowsOverlay
|
||||||
/>
|
/>
|
||||||
<div className="pointer-events-none absolute inset-0">
|
<div className="pointer-events-none absolute inset-0">
|
||||||
<AsyncRenderer
|
<AsyncRenderer
|
||||||
|
@ -15,6 +15,7 @@ jest.mock('@vegaprotocol/react-helpers', () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
describe('AccountManager', () => {
|
describe('AccountManager', () => {
|
||||||
|
describe('when rerender', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockedUseDataProvider
|
mockedUseDataProvider
|
||||||
.mockImplementationOnce((args) => {
|
.mockImplementationOnce((args) => {
|
||||||
@ -32,6 +33,10 @@ describe('AccountManager', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
it('change partyId should reload data provider', async () => {
|
it('change partyId should reload data provider', async () => {
|
||||||
const { rerender } = render(
|
const { rerender } = render(
|
||||||
<AccountManager
|
<AccountManager
|
||||||
@ -41,7 +46,8 @@ describe('AccountManager', () => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
(helpers.useDataProvider as jest.Mock).mock.calls[0][0].variables.partyId
|
(helpers.useDataProvider as jest.Mock).mock.calls[0][0].variables
|
||||||
|
.partyId
|
||||||
).toEqual('partyOne');
|
).toEqual('partyOne');
|
||||||
await act(() => {
|
await act(() => {
|
||||||
rerender(
|
rerender(
|
||||||
@ -53,7 +59,8 @@ describe('AccountManager', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
expect(
|
expect(
|
||||||
(helpers.useDataProvider as jest.Mock).mock.calls[1][0].variables.partyId
|
(helpers.useDataProvider as jest.Mock).mock.calls[1][0].variables
|
||||||
|
.partyId
|
||||||
).toEqual('partyTwo');
|
).toEqual('partyTwo');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -88,4 +95,33 @@ describe('AccountManager', () => {
|
|||||||
});
|
});
|
||||||
expect(getAllByRole(container as HTMLDivElement, 'row')).toHaveLength(2);
|
expect(getAllByRole(container as HTMLDivElement, 'row')).toHaveLength(2);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('splash loading should be displayed', async () => {
|
||||||
|
mockedUseDataProvider.mockImplementation((args) => {
|
||||||
|
return {
|
||||||
|
loading: true,
|
||||||
|
data: null,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
await act(() => {
|
||||||
|
render(
|
||||||
|
<AccountManager
|
||||||
|
partyId="partyOne"
|
||||||
|
onClickAsset={jest.fn}
|
||||||
|
isReadOnly={false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(
|
||||||
|
screen.getByText(
|
||||||
|
(content, element) =>
|
||||||
|
Boolean(
|
||||||
|
element?.className.endsWith('flex items-center justify-center')
|
||||||
|
) && content.startsWith('Loading')
|
||||||
|
)
|
||||||
|
).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -60,7 +60,8 @@ export const AccountManager = ({
|
|||||||
onClickDeposit={onClickDeposit}
|
onClickDeposit={onClickDeposit}
|
||||||
onClickWithdraw={onClickWithdraw}
|
onClickWithdraw={onClickWithdraw}
|
||||||
isReadOnly={isReadOnly}
|
isReadOnly={isReadOnly}
|
||||||
noRowsOverlayComponent={() => null}
|
suppressLoadingOverlay
|
||||||
|
suppressNoRowsOverlay
|
||||||
pinnedAsset={pinnedAsset}
|
pinnedAsset={pinnedAsset}
|
||||||
getRowHeight={getRowHeight}
|
getRowHeight={getRowHeight}
|
||||||
{...bottomPlaceholderProps}
|
{...bottomPlaceholderProps}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { useCallback, useRef } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
||||||
import type { Position } from '../';
|
import type { Position } from '../';
|
||||||
import { usePositionsData, PositionsTable } from '../';
|
import { usePositionsData, PositionsTable } from '../';
|
||||||
|
import type { FilterChangedEvent } from 'ag-grid-community';
|
||||||
import type { AgGridReact } from 'ag-grid-react';
|
import type { AgGridReact } from 'ag-grid-react';
|
||||||
import * as Schema from '@vegaprotocol/types';
|
import * as Schema from '@vegaprotocol/types';
|
||||||
import { useVegaTransactionStore } from '@vegaprotocol/wallet';
|
import { useVegaTransactionStore } from '@vegaprotocol/wallet';
|
||||||
@ -22,6 +23,7 @@ export const PositionsManager = ({
|
|||||||
noBottomPlaceholder,
|
noBottomPlaceholder,
|
||||||
}: PositionsManagerProps) => {
|
}: PositionsManagerProps) => {
|
||||||
const gridRef = useRef<AgGridReact | null>(null);
|
const gridRef = useRef<AgGridReact | null>(null);
|
||||||
|
const [dataCount, setDataCount] = useState(0);
|
||||||
const { data, error, loading, reload } = usePositionsData(
|
const { data, error, loading, reload } = usePositionsData(
|
||||||
partyId,
|
partyId,
|
||||||
gridRef,
|
gridRef,
|
||||||
@ -67,7 +69,12 @@ export const PositionsManager = ({
|
|||||||
gridRef,
|
gridRef,
|
||||||
setId,
|
setId,
|
||||||
});
|
});
|
||||||
|
useEffect(() => {
|
||||||
|
setDataCount(gridRef.current?.api?.getModel().getRowCount() ?? 0);
|
||||||
|
}, [data]);
|
||||||
|
const onFilterChanged = useCallback((event: FilterChangedEvent) => {
|
||||||
|
setDataCount(gridRef.current?.api?.getModel().getRowCount() ?? 0);
|
||||||
|
}, []);
|
||||||
return (
|
return (
|
||||||
<div className="h-full relative">
|
<div className="h-full relative">
|
||||||
<PositionsTable
|
<PositionsTable
|
||||||
@ -75,8 +82,10 @@ export const PositionsManager = ({
|
|||||||
ref={gridRef}
|
ref={gridRef}
|
||||||
onMarketClick={onMarketClick}
|
onMarketClick={onMarketClick}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
noRowsOverlayComponent={() => null}
|
suppressLoadingOverlay
|
||||||
|
suppressNoRowsOverlay
|
||||||
isReadOnly={isReadOnly}
|
isReadOnly={isReadOnly}
|
||||||
|
onFilterChanged={onFilterChanged}
|
||||||
{...(noBottomPlaceholder ? null : bottomPlaceholderProps)}
|
{...(noBottomPlaceholder ? null : bottomPlaceholderProps)}
|
||||||
/>
|
/>
|
||||||
<div className="pointer-events-none absolute inset-0">
|
<div className="pointer-events-none absolute inset-0">
|
||||||
@ -85,7 +94,7 @@ export const PositionsManager = ({
|
|||||||
error={error}
|
error={error}
|
||||||
data={data}
|
data={data}
|
||||||
noDataMessage={t('No positions')}
|
noDataMessage={t('No positions')}
|
||||||
noDataCondition={(data) => !(data && data.length)}
|
noDataCondition={(data) => !dataCount}
|
||||||
reload={reload}
|
reload={reload}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user