Commit 67703471 authored by tom goriunov's avatar tom goriunov Committed by GitHub

Support new CSV export limit in the UI (#2237)

Fixes #2215
parent 6da61c8a
...@@ -61,7 +61,7 @@ import type { ...@@ -61,7 +61,7 @@ import type {
BlockEpochElectionRewardDetailsResponse, BlockEpochElectionRewardDetailsResponse,
} from 'types/api/block'; } from 'types/api/block';
import type { ChartMarketResponse, ChartSecondaryCoinPriceResponse, ChartTransactionResponse } from 'types/api/charts'; import type { ChartMarketResponse, ChartSecondaryCoinPriceResponse, ChartTransactionResponse } from 'types/api/charts';
import type { BackendVersionConfig } from 'types/api/configs'; import type { BackendVersionConfig, CsvExportConfig } from 'types/api/configs';
import type { import type {
SmartContract, SmartContract,
SmartContractVerificationConfigRaw, SmartContractVerificationConfigRaw,
...@@ -917,6 +917,9 @@ export const RESOURCES = { ...@@ -917,6 +917,9 @@ export const RESOURCES = {
config_backend_version: { config_backend_version: {
path: '/api/v2/config/backend-version', path: '/api/v2/config/backend-version',
}, },
config_csv_export: {
path: '/api/v2/config/csv-export',
},
// CSV EXPORT // CSV EXPORT
csv_export_token_holders: { csv_export_token_holders: {
...@@ -1114,6 +1117,7 @@ never; ...@@ -1114,6 +1117,7 @@ never;
/* eslint-disable @typescript-eslint/indent */ /* eslint-disable @typescript-eslint/indent */
export type ResourcePayloadB<Q extends ResourceName> = export type ResourcePayloadB<Q extends ResourceName> =
Q extends 'config_backend_version' ? BackendVersionConfig : Q extends 'config_backend_version' ? BackendVersionConfig :
Q extends 'config_csv_export' ? CsvExportConfig :
Q extends 'address_metadata_info' ? AddressMetadataInfo : Q extends 'address_metadata_info' ? AddressMetadataInfo :
Q extends 'address_metadata_tag_types' ? PublicTagTypesResponse : Q extends 'address_metadata_tag_types' ? PublicTagTypesResponse :
Q extends 'blob' ? Blob : Q extends 'blob' ? Blob :
......
export interface BackendVersionConfig { export interface BackendVersionConfig {
backend_version: string; backend_version: string;
} }
export interface CsvExportConfig {
limit: number;
}
...@@ -15,6 +15,7 @@ test('base view +@mobile +@dark-mode', async({ render, page, mockApiResponse }) ...@@ -15,6 +15,7 @@ test('base view +@mobile +@dark-mode', async({ render, page, mockApiResponse })
}, },
}; };
await mockApiResponse('address', addressMock.validator, { pathParams: { hash: addressMock.hash } }); await mockApiResponse('address', addressMock.validator, { pathParams: { hash: addressMock.hash } });
await mockApiResponse('config_csv_export', { limit: 42123 });
const component = await render(<Box sx={{ '.recaptcha': { w: '304px', h: '78px' } }}><CsvExport/></Box>, { hooksConfig }); const component = await render(<Box sx={{ '.recaptcha': { w: '304px', h: '78px' } }}><CsvExport/></Box>, { hooksConfig });
......
...@@ -88,7 +88,13 @@ const CsvExport = () => { ...@@ -88,7 +88,13 @@ const CsvExport = () => {
}, },
}); });
const isLoading = addressQuery.isPending || (exportTypeParam === 'holders' && tokenQuery.isPending); const configQuery = useApiQuery('config_csv_export', {
queryOptions: {
enabled: Boolean(addressHash),
},
});
const isLoading = addressQuery.isPending || configQuery.isPending || (exportTypeParam === 'holders' && tokenQuery.isPending);
const backLink = React.useMemo(() => { const backLink = React.useMemo(() => {
const hasGoBackLink = appProps.referrer && appProps.referrer.includes('/address'); const hasGoBackLink = appProps.referrer && appProps.referrer.includes('/address');
...@@ -147,6 +153,8 @@ const CsvExport = () => { ...@@ -147,6 +153,8 @@ const CsvExport = () => {
return null; return null;
} }
const limit = (configQuery.data?.limit || 10_000).toLocaleString(undefined, { maximumFractionDigits: 3, notation: 'compact' });
if (exportTypeParam === 'holders') { if (exportTypeParam === 'holders') {
return ( return (
<Flex mb={ 10 } whiteSpace="pre-wrap" flexWrap="wrap"> <Flex mb={ 10 } whiteSpace="pre-wrap" flexWrap="wrap">
...@@ -160,7 +168,7 @@ const CsvExport = () => { ...@@ -160,7 +168,7 @@ const CsvExport = () => {
noSymbol noSymbol
/> />
<span> to CSV file. </span> <span> to CSV file. </span>
<span>Exports are limited to the top 10K holders by amount held.</span> <span>Exports are limited to the top { limit } holders by amount held.</span>
</Flex> </Flex>
); );
} }
...@@ -176,7 +184,7 @@ const CsvExport = () => { ...@@ -176,7 +184,7 @@ const CsvExport = () => {
<span>{ nbsp }</span> <span>{ nbsp }</span>
{ filterType && filterValue && <span>with applied filter by { filterType } ({ filterValue }) </span> } { filterType && filterValue && <span>with applied filter by { filterType } ({ filterValue }) </span> }
<span>to CSV file. </span> <span>to CSV file. </span>
<span>Exports are limited to the last 10K { exportType.text }.</span> <span>Exports are limited to the last { limit } { exportType.text }.</span>
</Flex> </Flex>
); );
})(); })();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment