diff --git a/opencti-platform/opencti-front/src/components/dataGrid/DataTableWithoutFragment.tsx b/opencti-platform/opencti-front/src/components/dataGrid/DataTableWithoutFragment.tsx index 2db4cb5dbf107..f8a68c69355fc 100644 --- a/opencti-platform/opencti-front/src/components/dataGrid/DataTableWithoutFragment.tsx +++ b/opencti-platform/opencti-front/src/components/dataGrid/DataTableWithoutFragment.tsx @@ -19,6 +19,7 @@ type OCTIDataTableWithoutFragmentProps = Pick & { data: unknown, diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatterns.tsx b/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatterns.tsx index b20e538e50a23..d3ea419e5c66e 100644 --- a/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatterns.tsx +++ b/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatterns.tsx @@ -46,12 +46,16 @@ const StixDomainObjectAttackPatterns: FunctionComponent(LOCAL_STORAGE_KEY, { - searchTerm: '', - openExports: false, - filters: emptyFilterGroup, - view: 'matrix', - }); + } = usePaginationLocalStorage( + LOCAL_STORAGE_KEY, + { + searchTerm: '', + openExports: false, + filters: emptyFilterGroup, + view: 'matrix', + numberOfElements: { number: 0, symbol: '', original: 0 }, + }, + ); const { searchTerm, filters, view, openExports } = viewStorage; const userFilters = useRemoveIdAndIncorrectKeysFromFilterGroupObject(filters, ['Attack-Pattern']); const contextFilters = { @@ -93,6 +97,7 @@ const StixDomainObjectAttackPatterns: FunctionComponent )} diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatternsKillChain.tsx b/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatternsKillChain.tsx index dac80ecc6aa77..c92496029026d 100644 --- a/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatternsKillChain.tsx +++ b/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatternsKillChain.tsx @@ -69,6 +69,7 @@ interface StixDomainObjectAttackPatternsKillChainProps { availableFilterKeys: string[]; defaultStartTime: string; defaultStopTime: string; + storageKey: string; } const StixDomainObjectAttackPatternsKillChain: FunctionComponent = ({ @@ -87,6 +88,7 @@ const StixDomainObjectAttackPatternsKillChain: FunctionComponent { const { t_i18n } = useFormatter(); const [currentColorsReversed, setCurrentColorsReversed] = useState(false); @@ -397,6 +399,7 @@ const StixDomainObjectAttackPatternsKillChain: FunctionComponent )} {currentView === 'courses-of-action' && ( diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatternsKillChainContainer.tsx b/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatternsKillChainContainer.tsx index 12c2c3d1f7b54..c4687951c51a1 100644 --- a/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatternsKillChainContainer.tsx +++ b/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatternsKillChainContainer.tsx @@ -25,6 +25,7 @@ interface StixDomainObjectAttackPatternsKillChainProps { disableExport: boolean; openExports?: boolean; availableFilterKeys: string[]; + storageKey: string; } export const stixDomainObjectAttackPatternsKillChainContainerFragment = graphql` @@ -132,6 +133,7 @@ const StixDomainObjectAttackPatternsKillChainContainer: FunctionComponent { const dataPreloaded = usePreloadedQuery( stixDomainObjectAttackPatternsKillChainQuery, @@ -158,6 +160,7 @@ const StixDomainObjectAttackPatternsKillChainContainer: FunctionComponent ); }; diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatternsKillChainMatrixInLine.tsx b/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatternsKillChainMatrixInLine.tsx index 8da75df13ba99..0971398287711 100644 --- a/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatternsKillChainMatrixInLine.tsx +++ b/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectAttackPatternsKillChainMatrixInLine.tsx @@ -1,4 +1,4 @@ -import React, { FunctionComponent } from 'react'; +import React, { FunctionComponent, useEffect, useState } from 'react'; import { StixDomainObjectAttackPatternsKillChainContainer_data$data, } from '@components/common/stix_domain_objects/__generated__/StixDomainObjectAttackPatternsKillChainContainer_data.graphql'; @@ -6,41 +6,56 @@ import Tooltip from '@mui/material/Tooltip'; import DataTableWithoutFragment from '../../../../components/dataGrid/DataTableWithoutFragment'; import { FilterGroup } from '../../../../utils/filters/filtersHelpers-types'; import { truncate } from '../../../../utils/String'; - -const LOCAL_STORAGE_KEY = 'stixDomainObjectAttackPatternsKillChainMatrixInline'; +import { usePaginationLocalStorage } from '../../../../utils/hooks/useLocalStorage'; interface StixDomainObjectAttackPatternsKillChainMatrixProps { data: StixDomainObjectAttackPatternsKillChainContainer_data$data; filters?: FilterGroup; + storageKey: string; } const StixDomainObjectAttackPatternsKillChainMatrixInline: FunctionComponent = ( { data, filters, + storageKey, }, ) => { const attackPatterns = (data.attackPatterns?.edges ?? []).map((n) => n.node); + const { _, helpers: { handleSetNumberOfElements } } = usePaginationLocalStorage(storageKey, {}); + + const [previousCount, setPreviousCount] = useState(attackPatterns.length); + + useEffect(() => { + if (attackPatterns.length !== previousCount || attackPatterns.length !== 0) { + handleSetNumberOfElements({ + number: attackPatterns.length, + symbol: '', + original: attackPatterns.length, + }); + setPreviousCount(attackPatterns.length); + } + }, [attackPatterns.length, previousCount, handleSetNumberOfElements]); + return ( ({truncate(name, size * 0.113)}), }, - objectLabel: { percentWidth: 15, isSortable: false }, - created: { percentWidth: 12, isSortable: true }, - objectMarking: { percentWidth: 10, isSortable: true }, + objectLabel: { percentWidth: 15 }, + created: { percentWidth: 12 }, + objectMarking: { percentWidth: 10 }, }} - storageKey={LOCAL_STORAGE_KEY} + storageKey={storageKey} data={attackPatterns} globalCount={attackPatterns.length} - allowBackgroundtasks={true} + allowBackgroundtasks taskScope={'KNOWLEDGE'} toolbarFilters={filters} />