diff --git a/apps/trading-e2e/src/integration/home.cy.ts b/apps/trading-e2e/src/integration/home.cy.ts index bba24abf4..6f082ea2b 100644 --- a/apps/trading-e2e/src/integration/home.cy.ts +++ b/apps/trading-e2e/src/integration/home.cy.ts @@ -51,6 +51,7 @@ const generateProposal = (code: string): ProposalListFieldsFragment => ({ describe('home', { tags: '@regression' }, () => { beforeEach(() => { + cy.clearLocalStorage(); cy.mockTradingPage(); cy.mockSubscription(); }); @@ -226,9 +227,6 @@ describe('home', { tags: '@regression' }, () => { }); describe('redirect should take last visited market into consideration', () => { - beforeEach(() => { - cy.clearLocalStorage(); - }); it('marketId comes from existing market', () => { cy.window().then((window) => { window.localStorage.setItem('marketId', 'market-1'); diff --git a/apps/trading-e2e/src/integration/trading-portfolio.cy.ts b/apps/trading-e2e/src/integration/trading-portfolio.cy.ts index a44a7c0c6..611a0bede 100644 --- a/apps/trading-e2e/src/integration/trading-portfolio.cy.ts +++ b/apps/trading-e2e/src/integration/trading-portfolio.cy.ts @@ -37,5 +37,21 @@ describe('Portfolio page', { tags: '@smoke' }, () => { '[data-testid="tab-ledger-entries"] .ag-center-cols-container .ag-row' ).should('have.length', ledgerEntriesQuery().ledgerEntries.edges.length); }); + + it('account filters should be callable', () => { + cy.visit('/#/portfolio'); + cy.getByTestId('"Ledger entries"').click(); + cy.get('[role="columnheader"][col-id="senderAccountType"]').realHover(); + cy.get( + '[role="columnheader"][col-id="senderAccountType"] .ag-header-cell-menu-button' + ).click(); + cy.get('fieldset.ag-simple-filter-body-wrapper') + .should('be.visible') + .within((fields) => { + cy.wrap(fields).find('label').should('have.length', 16); + }); + cy.getByTestId('"Ledger entries"').click(); + cy.get('fieldset.ag-simple-filter-body-wrapper').should('not.exist'); + }); }); }); diff --git a/libs/apollo-client/src/lib/apollo-client.ts b/libs/apollo-client/src/lib/apollo-client.ts index 2f4063356..815f523a9 100644 --- a/libs/apollo-client/src/lib/apollo-client.ts +++ b/libs/apollo-client/src/lib/apollo-client.ts @@ -28,6 +28,7 @@ export function createClient(base?: string, cacheConfig?: InMemoryCacheConfig) { // Replace http with ws, preserving if its a secure connection eg. https => wss urlWS.protocol = urlWS.protocol.replace('http', 'ws'); const timeoutLink = new ApolloLinkTimeout(10000); + const enlargedTimeoutLink = new ApolloLinkTimeout(100000); const retryLink = new RetryLink({ delay: { initial: 300, @@ -76,8 +77,14 @@ export function createClient(base?: string, cacheConfig?: InMemoryCacheConfig) { } }); + const composedTimeoutLink = split( + ({ getContext }) => Boolean(getContext()['isEnlargedTimeout']), + enlargedTimeoutLink, + timeoutLink + ); + return new ApolloClient({ - link: from([errorLink, timeoutLink, retryLink, splitLink]), + link: from([errorLink, composedTimeoutLink, retryLink, splitLink]), cache: new InMemoryCache(cacheConfig), }); } diff --git a/libs/ledger/src/lib/LedgerEntries.graphql b/libs/ledger/src/lib/LedgerEntries.graphql index 33f0a80d5..f9f033ad8 100644 --- a/libs/ledger/src/lib/LedgerEntries.graphql +++ b/libs/ledger/src/lib/LedgerEntries.graphql @@ -15,11 +15,19 @@ query LedgerEntries( $partyId: ID! $pagination: Pagination $dateRange: DateRange + $senderAccountType: [AccountType!] + $receiverAccountType: [AccountType!] ) { ledgerEntries( filter: { - SenderAccountFilter: { partyIds: [$partyId] } - ReceiverAccountFilter: { partyIds: [$partyId] } + SenderAccountFilter: { + partyIds: [$partyId] + accountTypes: $senderAccountType + } + ReceiverAccountFilter: { + partyIds: [$partyId] + accountTypes: $receiverAccountType + } } pagination: $pagination dateRange: $dateRange diff --git a/libs/ledger/src/lib/__generated__/LedgerEntries.ts b/libs/ledger/src/lib/__generated__/LedgerEntries.ts index c06ed22d1..d41d4732a 100644 --- a/libs/ledger/src/lib/__generated__/LedgerEntries.ts +++ b/libs/ledger/src/lib/__generated__/LedgerEntries.ts @@ -9,6 +9,8 @@ export type LedgerEntriesQueryVariables = Types.Exact<{ partyId: Types.Scalars['ID']; pagination?: Types.InputMaybe; dateRange?: Types.InputMaybe; + senderAccountType?: Types.InputMaybe | Types.AccountType>; + receiverAccountType?: Types.InputMaybe | Types.AccountType>; }>; @@ -29,9 +31,9 @@ export const LedgerEntryFragmentDoc = gql` } `; export const LedgerEntriesDocument = gql` - query LedgerEntries($partyId: ID!, $pagination: Pagination, $dateRange: DateRange) { + query LedgerEntries($partyId: ID!, $pagination: Pagination, $dateRange: DateRange, $senderAccountType: [AccountType!], $receiverAccountType: [AccountType!]) { ledgerEntries( - filter: {SenderAccountFilter: {partyIds: [$partyId]}, ReceiverAccountFilter: {partyIds: [$partyId]}} + filter: {SenderAccountFilter: {partyIds: [$partyId], accountTypes: $senderAccountType}, ReceiverAccountFilter: {partyIds: [$partyId], accountTypes: $receiverAccountType}} pagination: $pagination dateRange: $dateRange ) { @@ -65,6 +67,8 @@ export const LedgerEntriesDocument = gql` * partyId: // value for 'partyId' * pagination: // value for 'pagination' * dateRange: // value for 'dateRange' + * senderAccountType: // value for 'senderAccountType' + * receiverAccountType: // value for 'receiverAccountType' * }, * }); */ diff --git a/libs/ledger/src/lib/ledger-entries-data-provider.ts b/libs/ledger/src/lib/ledger-entries-data-provider.ts index bb1f7e133..c99f5fa95 100644 --- a/libs/ledger/src/lib/ledger-entries-data-provider.ts +++ b/libs/ledger/src/lib/ledger-entries-data-provider.ts @@ -106,6 +106,9 @@ const ledgerEntriesOnlyProvider = makeDataProvider({ append, first: 100, }, + additionalContext: { + isEnlargedTimeout: true, + }, }); export const ledgerEntriesProvider = makeDerivedDataProvider< @@ -147,6 +150,8 @@ export const useLedgerEntriesDataProvider = ({ () => ({ partyId, dateRange: filter?.vegaTime?.value, + senderAccountType: filter?.senderAccountType?.value ?? null, + receiverAccountType: filter?.receiverAccountType?.value ?? null, }), [partyId, filter] ); diff --git a/libs/ledger/src/lib/ledger-manager.tsx b/libs/ledger/src/lib/ledger-manager.tsx index e7993cd73..e7af0188e 100644 --- a/libs/ledger/src/lib/ledger-manager.tsx +++ b/libs/ledger/src/lib/ledger-manager.tsx @@ -3,14 +3,17 @@ import type * as Schema from '@vegaprotocol/types'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import type { FilterChangedEvent } from 'ag-grid-community'; import type { AgGridReact } from 'ag-grid-react'; -import { useRef, useState } from 'react'; +import { useCallback, useRef, useState } from 'react'; import { useLedgerEntriesDataProvider } from './ledger-entries-data-provider'; import { LedgerTable } from './ledger-table'; +import type * as Types from '@vegaprotocol/types'; export interface Filter { vegaTime?: { value: Schema.DateRange; }; + senderAccountType?: { value: Types.AccountType[] }; + receiverAccountType?: { value: Types.AccountType[] }; } type LedgerManagerProps = { partyId: string }; @@ -24,14 +27,17 @@ export const LedgerManager = ({ partyId }: LedgerManagerProps) => { gridRef, }); - const onFilterChanged = (event: FilterChangedEvent) => { - const updatedFilter = event.api.getFilterModel(); - if (Object.keys(updatedFilter).length) { - setFilter(updatedFilter); - } else if (filter) { - setFilter(undefined); - } - }; + const onFilterChanged = useCallback( + (event: FilterChangedEvent) => { + const updatedFilter = event.api.getFilterModel(); + if (Object.keys(updatedFilter).length) { + setFilter(updatedFilter); + } else if (filter) { + setFilter(undefined); + } + }, + [filter] + ); return (
diff --git a/libs/ledger/src/lib/ledger-table.tsx b/libs/ledger/src/lib/ledger-table.tsx index 005b5ac95..8e3999db8 100644 --- a/libs/ledger/src/lib/ledger-table.tsx +++ b/libs/ledger/src/lib/ledger-table.tsx @@ -3,6 +3,7 @@ import { DateRangeFilter, fromNanoSeconds, getDateTimeFormat, + SetFilter, t, truncateByChars, } from '@vegaprotocol/react-helpers'; @@ -50,6 +51,7 @@ export const LedgerTable = forwardRef( resizable: true, sortable: true, tooltipComponent: TransferTooltipCellComponent, + filterParams: { buttons: ['reset'] }, }} {...props} > @@ -64,6 +66,10 @@ export const LedgerTable = forwardRef( /> ( /> ; } /** @@ -196,6 +197,7 @@ function makeDataProviderInternal< pagination, fetchPolicy, resetDelay, + additionalContext, }: DataProviderParams< QueryData, Data, @@ -275,6 +277,7 @@ function makeDataProviderInternal< pagination: paginationVariables, }, fetchPolicy: fetchPolicy || 'no-cache', + context: additionalContext, }); const insertionData = getData(res.data, variables); const insertionPageInfo = pagination.getPageInfo(res.data); @@ -311,6 +314,7 @@ function makeDataProviderInternal< ? { ...variables, pagination: { first: pagination.first } } : variables, fetchPolicy: fetchPolicy || 'no-cache', + context: additionalContext, }); data = getData(res.data, variables); if (data && pagination) {