diff --git a/opencti-platform/opencti-front/src/private/components/Search.js b/opencti-platform/opencti-front/src/private/components/Search.js index dd02a183eb0c6..009b1fe823146 100644 --- a/opencti-platform/opencti-front/src/private/components/Search.js +++ b/opencti-platform/opencti-front/src/private/components/Search.js @@ -183,7 +183,7 @@ class Search extends Component { creator: { label: 'Creator', width: '12%', - isSortable: true, + isSortable: isRuntimeSort, }, objectLabel: { label: 'Labels', diff --git a/opencti-platform/opencti-front/src/private/components/analysis/ExternalReferences.tsx b/opencti-platform/opencti-front/src/private/components/analysis/ExternalReferences.tsx index 784a0f6fb11b8..9570eb1b71056 100644 --- a/opencti-platform/opencti-front/src/private/components/analysis/ExternalReferences.tsx +++ b/opencti-platform/opencti-front/src/private/components/analysis/ExternalReferences.tsx @@ -40,7 +40,7 @@ const ExternalReferences: FunctionComponent = () => { }, ); const { sortBy, orderAsc, searchTerm, filters, numberOfElements } = viewStorage; - const isRuntimeSort = helper?.isRuntimeFieldEnable(); + const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false; const dataColumns = { source_name: { label: 'Source name', @@ -60,7 +60,7 @@ const ExternalReferences: FunctionComponent = () => { creator: { label: 'Creator', width: '12%', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, created: { label: 'Creation date', diff --git a/opencti-platform/opencti-front/src/private/components/analysis/Groupings.tsx b/opencti-platform/opencti-front/src/private/components/analysis/Groupings.tsx index 8c31afab40079..835230ade5741 100644 --- a/opencti-platform/opencti-front/src/private/components/analysis/Groupings.tsx +++ b/opencti-platform/opencti-front/src/private/components/analysis/Groupings.tsx @@ -1,4 +1,4 @@ -import React, { FunctionComponent } from 'react'; +import React, { FunctionComponent, useContext } from 'react'; import ListLines from '../../../components/list_lines/ListLines'; import GroupingsLines, { groupingsLinesQuery } from './groupings/GroupingsLines'; import GroupingCreation from './groupings/GroupingCreation'; @@ -14,7 +14,6 @@ import { GroupingsLinesPaginationQuery$variables, } from './groupings/__generated__/GroupingsLinesPaginationQuery.graphql'; import { GroupingLine_node$data } from './groupings/__generated__/GroupingLine_node.graphql'; -import { ModuleHelper } from '../../../utils/platformModulesHelper'; import { GroupingLineDummy } from './groupings/GroupingLine'; const LOCAL_STORAGE_KEY = 'view-groupings'; @@ -33,6 +32,7 @@ const Groupings: FunctionComponent = ( onChangeOpenExports, }, ) => { + const { helper } = useContext(UserContext); const additionnalFilters = []; if (authorId) { additionnalFilters.push({ @@ -84,7 +84,7 @@ const Groupings: FunctionComponent = ( paginationOptions, ); - const renderLines = (helper: ModuleHelper | undefined) => { + const renderLines = () => { let exportContext = null; if (objectId) { exportContext = `of-entity-${objectId}`; @@ -101,7 +101,7 @@ const Groupings: FunctionComponent = ( ...finalFilters, entity_type: [{ id: 'Grouping', value: 'Grouping' }], }; - const isRuntimeSort = helper?.isRuntimeFieldEnable(); + const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false; const dataColumns = { name: { label: 'Name', @@ -116,12 +116,12 @@ const Groupings: FunctionComponent = ( createdBy: { label: 'Author', width: '12%', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, creator: { label: 'Creator', width: '12%', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, objectLabel: { label: 'Labels', @@ -140,7 +140,7 @@ const Groupings: FunctionComponent = ( }, objectMarking: { label: 'Marking', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, width: '8%', }, }; @@ -222,16 +222,12 @@ const Groupings: FunctionComponent = ( }; return ( - - {({ helper }) => ( -
- {renderLines(helper)} - - - -
- )} -
+
+ {renderLines()} + + + +
); }; diff --git a/opencti-platform/opencti-front/src/private/components/analysis/Reports.tsx b/opencti-platform/opencti-front/src/private/components/analysis/Reports.tsx index 1c63ceaef962e..279a4ea2943cf 100644 --- a/opencti-platform/opencti-front/src/private/components/analysis/Reports.tsx +++ b/opencti-platform/opencti-front/src/private/components/analysis/Reports.tsx @@ -1,4 +1,4 @@ -import React, { FunctionComponent } from 'react'; +import React, { FunctionComponent, useContext } from 'react'; import ListLines from '../../../components/list_lines/ListLines'; import ReportsLines, { reportsLinesQuery } from './reports/ReportsLines'; import ReportCreation from './reports/ReportCreation'; @@ -12,7 +12,6 @@ import { ReportsLinesPaginationQuery$variables, } from './reports/__generated__/ReportsLinesPaginationQuery.graphql'; import { Filters } from '../../../components/list_lines'; -import { ModuleHelper } from '../../../utils/platformModulesHelper'; import { ReportLine_node$data } from './reports/__generated__/ReportLine_node.graphql'; import useEntityToggle from '../../../utils/hooks/useEntityToggle'; import useQueryLoading from '../../../utils/hooks/useQueryLoading'; @@ -32,6 +31,7 @@ const Reports: FunctionComponent = ({ authorId, onChangeOpenExports, }) => { + const { helper } = useContext(UserContext); const additionnalFilters = []; if (authorId) { additionnalFilters.push({ @@ -86,7 +86,7 @@ const Reports: FunctionComponent = ({ reportsLinesQuery, paginationOptions, ); - const renderLines = (helper: ModuleHelper | undefined) => { + const renderLines = () => { let exportContext = null; if (objectId) { exportContext = `of-entity-${objectId}`; @@ -96,7 +96,7 @@ const Reports: FunctionComponent = ({ let renderFilters = filters; renderFilters = { ...renderFilters, entity_type: [{ id: 'Report', value: 'Report' }] }; - const isRuntimeSort = helper?.isRuntimeFieldEnable(); + const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false; const dataColumns = { name: { label: 'Title', @@ -111,12 +111,12 @@ const Reports: FunctionComponent = ({ createdBy: { label: 'Author', width: '12%', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, creator: { label: 'Creator', width: '12%', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, objectLabel: { label: 'Labels', @@ -135,7 +135,7 @@ const Reports: FunctionComponent = ({ }, objectMarking: { label: 'Marking', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, width: '8%', }, }; @@ -221,18 +221,14 @@ const Reports: FunctionComponent = ({ }; return ( - - {({ helper }) => ( - +
- {renderLines(helper)} + {renderLines()}
-
- )} -
+ ); }; diff --git a/opencti-platform/opencti-front/src/private/components/arsenal/Vulnerabilities.tsx b/opencti-platform/opencti-front/src/private/components/arsenal/Vulnerabilities.tsx index cf81b00f20af4..8d8e9024134a3 100644 --- a/opencti-platform/opencti-front/src/private/components/arsenal/Vulnerabilities.tsx +++ b/opencti-platform/opencti-front/src/private/components/arsenal/Vulnerabilities.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useContext } from 'react'; import ListLines from '../../../components/list_lines/ListLines'; import VulnerabilitiesLines, { vulnerabilitiesLinesQuery, @@ -14,8 +14,11 @@ import { VulnerabilitiesLinesPaginationQuery$variables, } from './vulnerabilities/__generated__/VulnerabilitiesLinesPaginationQuery.graphql'; import { usePaginationLocalStorage } from '../../../utils/hooks/useLocalStorage'; +import { UserContext } from '../../../utils/hooks/useAuth'; const Vulnerabilities = () => { + const { helper } = useContext(UserContext); + const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false; const { viewStorage, helpers, paginationOptions } = usePaginationLocalStorage( 'view-vulnerabilities', { @@ -65,7 +68,7 @@ const Vulnerabilities = () => { creator: { label: 'Creator', width: '12%', - isSortable: true, + isSortable: isRuntimeSort, }, }; diff --git a/opencti-platform/opencti-front/src/private/components/cases/Feedbacks.tsx b/opencti-platform/opencti-front/src/private/components/cases/Feedbacks.tsx index 737efaf855aab..ed09aeab40d10 100644 --- a/opencti-platform/opencti-front/src/private/components/cases/Feedbacks.tsx +++ b/opencti-platform/opencti-front/src/private/components/cases/Feedbacks.tsx @@ -70,7 +70,7 @@ const Feedbacks: FunctionComponent = () => { openExports, numberOfElements, } = viewStorage; - const isRuntimeSort = helper?.isRuntimeFieldEnable(); + const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false; const dataColumns = { name: { label: 'Name', @@ -85,12 +85,12 @@ const Feedbacks: FunctionComponent = () => { createdBy: { label: 'Author', width: '12%', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, creator: { label: 'Creator', width: '12%', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, objectLabel: { label: 'Labels', @@ -110,7 +110,7 @@ const Feedbacks: FunctionComponent = () => { objectMarking: { label: 'Marking', width: '8%', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, }; const queryRef = useQueryLoading( diff --git a/opencti-platform/opencti-front/src/private/components/cases/Incidents.tsx b/opencti-platform/opencti-front/src/private/components/cases/Incidents.tsx index ffca2cf8adcae..7ad508199b513 100644 --- a/opencti-platform/opencti-front/src/private/components/cases/Incidents.tsx +++ b/opencti-platform/opencti-front/src/private/components/cases/Incidents.tsx @@ -73,7 +73,7 @@ const Incidents: FunctionComponent = () => { openExports, numberOfElements, } = viewStorage; - const isRuntimeSort = helper?.isRuntimeFieldEnable(); + const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false; const dataColumns = { name: { label: 'Name', @@ -93,12 +93,12 @@ const Incidents: FunctionComponent = () => { createdBy: { label: 'Author', width: '11%', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, creator: { label: 'Creator', width: '11%', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, objectLabel: { label: 'Labels', @@ -118,7 +118,7 @@ const Incidents: FunctionComponent = () => { objectMarking: { label: 'Marking', width: '8%', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, }; const queryRef = useQueryLoading( diff --git a/opencti-platform/opencti-front/src/private/components/common/containers/ContainerStixCyberObservables.tsx b/opencti-platform/opencti-front/src/private/components/common/containers/ContainerStixCyberObservables.tsx index 980db7b1c5773..ec10f6d04d13b 100644 --- a/opencti-platform/opencti-front/src/private/components/common/containers/ContainerStixCyberObservables.tsx +++ b/opencti-platform/opencti-front/src/private/components/common/containers/ContainerStixCyberObservables.tsx @@ -232,7 +232,7 @@ const ContainerStixCyberObservablesComponent: FunctionComponent { - const isRuntimeSort = helper?.isRuntimeFieldEnable(); + const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false; return { entity_type: { label: 'Type', @@ -242,7 +242,7 @@ const ContainerStixCyberObservablesComponent: FunctionComponent { paginationOptions, ); // eslint-disable-next-line class-methods-use-this - const isRuntimeSort = helper?.isRuntimeFieldEnable(); + const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false; const buildColumns = { name: { @@ -120,7 +120,7 @@ const Incidents: FunctionComponent = () => { }, objectMarking: { label: 'Marking', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, }; const renderCards = () => { diff --git a/opencti-platform/opencti-front/src/private/components/observations/Indicators.js b/opencti-platform/opencti-front/src/private/components/observations/Indicators.js index 91cb2841fb3b6..325d9ccb038b6 100644 --- a/opencti-platform/opencti-front/src/private/components/observations/Indicators.js +++ b/opencti-platform/opencti-front/src/private/components/observations/Indicators.js @@ -261,7 +261,7 @@ class Indicators extends Component { creator: { label: 'Creator', width: '10%', - isSortable: true, + isSortable: isRuntimeSort, }, valid_until: { label: 'Valid until', diff --git a/opencti-platform/opencti-front/src/private/components/observations/StixCyberObservables.tsx b/opencti-platform/opencti-front/src/private/components/observations/StixCyberObservables.tsx index 9c19355575204..7de2e4b0c3a9c 100644 --- a/opencti-platform/opencti-front/src/private/components/observations/StixCyberObservables.tsx +++ b/opencti-platform/opencti-front/src/private/components/observations/StixCyberObservables.tsx @@ -1,4 +1,4 @@ -import { FunctionComponent } from 'react'; +import { FunctionComponent, useContext } from 'react'; import makeStyles from '@mui/styles/makeStyles'; import { React } from 'mdi-material-ui'; import StixCyberObservableCreation from './stix_cyber_observables/StixCyberObservableCreation'; @@ -13,7 +13,6 @@ import StixCyberObservablesLines, { import ToolBar from '../data/ToolBar'; import { Theme } from '../../../components/Theme'; import { Filters } from '../../../components/list_lines'; -import { ModuleHelper } from '../../../utils/platformModulesHelper'; import { StixCyberObservablesLinesPaginationQuery$data, } from './stix_cyber_observables/__generated__/StixCyberObservablesLinesPaginationQuery.graphql'; @@ -40,6 +39,8 @@ const LOCAL_STORAGE_KEY = 'view-stix-cyber-observables'; const StixCyberObservables: FunctionComponent = () => { const classes = useStyles(); + const { helper } = useContext(UserContext); + const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false; const { viewStorage, paginationOptions, helpers } = usePaginationLocalStorage( LOCAL_STORAGE_KEY, @@ -109,8 +110,7 @@ const StixCyberObservables: FunctionComponent = () => { selectAll, ); - const buildColumns = (helper: ModuleHelper | undefined) => { - const isRuntimeSort = helper?.isRuntimeFieldEnable(); + const buildColumns = () => { return { entity_type: { label: 'Type', @@ -159,13 +159,11 @@ const StixCyberObservables: FunctionComponent = () => { } const finalFilters = { ...viewStorage.filters, entity_type: finalType }; return ( - - {({ helper }) => ( -
- + { 'sightedBy', 'creator', ]} - > - + ( - + render={({ props }: { props: StixCyberObservablesLinesPaginationQuery$data }) => ( + )} - /> - - + + { handleClearSelectedElements={handleClearSelectedElements} variant="large" handleCopy={handleCopy} - /> -
- )} -
+ /> + ); }; diff --git a/opencti-platform/opencti-front/src/private/components/observations/indicators/IndicatorEntities.js b/opencti-platform/opencti-front/src/private/components/observations/indicators/IndicatorEntities.js index 45c836e6f5e73..8f63047d28898 100644 --- a/opencti-platform/opencti-front/src/private/components/observations/indicators/IndicatorEntities.js +++ b/opencti-platform/opencti-front/src/private/components/observations/indicators/IndicatorEntities.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import * as PropTypes from 'prop-types'; import { compose } from 'ramda'; import withStyles from '@mui/styles/withStyles'; +import { UserContext } from '../../../../utils/hooks/useAuth'; import { QueryRenderer } from '../../../../relay/environment'; import inject18n from '../../../../components/i18n'; import ListLines from '../../../../components/list_lines/ListLines'; @@ -38,7 +39,8 @@ class IndicatorEntities extends Component { this.setState({ searchTerm: value }); } - renderLines(paginationOptions) { + renderLines(helper, paginationOptions) { + const isRuntimeSort = helper.isRuntimeFieldEnable(); const { indicatorId } = this.props; const { sortBy, orderAsc } = this.state; const link = `/dashboard/observations/indicators/${indicatorId}/knowledge`; @@ -61,12 +63,12 @@ class IndicatorEntities extends Component { createdBy: { label: 'Author', width: '12%', - isSortable: false, + isSortable: isRuntimeSort, }, creator: { label: 'Creator', width: '12%', - isSortable: false, + isSortable: isRuntimeSort, }, start_time: { label: 'First obs.', @@ -131,7 +133,9 @@ class IndicatorEntities extends Component { }; return (
- {view === 'lines' ? this.renderLines(paginationOptions) : ''} + + {({ helper }) => (<> + {view === 'lines' ? this.renderLines(helper, paginationOptions) : ''} + )} +
); }