diff --git a/opencti-platform/opencti-front/src/private/components/observations/Indicators.tsx b/opencti-platform/opencti-front/src/private/components/observations/Indicators.tsx index e523a1826cbd..94cb06199c74 100644 --- a/opencti-platform/opencti-front/src/private/components/observations/Indicators.tsx +++ b/opencti-platform/opencti-front/src/private/components/observations/Indicators.tsx @@ -1,12 +1,10 @@ import React from 'react'; -import makeStyles from '@mui/styles/makeStyles'; import ListLines from '../../../components/list_lines/ListLines'; import IndicatorsLines, { indicatorsLinesQuery } from './indicators/IndicatorsLines'; import IndicatorCreation from './indicators/IndicatorCreation'; -import IndicatorsRightBar from './indicators/IndicatorsRightBar'; import Security from '../../../utils/Security'; import { KNOWLEDGE_KNUPDATE } from '../../../utils/hooks/useGranted'; -import { UserContext } from '../../../utils/hooks/useAuth'; +import useAuth from '../../../utils/hooks/useAuth'; import ToolBar from '../data/ToolBar'; import ExportContextProvider from '../../../utils/ExportContextProvider'; import { usePaginationLocalStorage } from '../../../utils/hooks/useLocalStorage'; @@ -14,23 +12,15 @@ import useEntityToggle from '../../../utils/hooks/useEntityToggle'; import useQueryLoading from '../../../utils/hooks/useQueryLoading'; import { IndicatorLine_node$data } from './indicators/__generated__/IndicatorLine_node.graphql'; import { IndicatorsLinesPaginationQuery, IndicatorsLinesPaginationQuery$variables } from './indicators/__generated__/IndicatorsLinesPaginationQuery.graphql'; -import { ModuleHelper } from '../../../utils/platformModulesHelper'; import { IndicatorLineDummyComponent } from './indicators/IndicatorLine'; -import { useBuildEntityTypeBasedFilterContext, emptyFilterGroup, findFilterFromKey, useGetDefaultFilterObject } from '../../../utils/filters/filtersUtils'; +import { emptyFilterGroup, useBuildEntityTypeBasedFilterContext, useGetDefaultFilterObject } from '../../../utils/filters/filtersUtils'; import { useFormatter } from '../../../components/i18n'; import Breadcrumbs from '../../../components/Breadcrumbs'; -const useStyles = makeStyles(() => ({ - container: { - paddingRight: 250, - }, -})); - const LOCAL_STORAGE_KEY = 'indicators-list'; const Indicators = () => { const { t_i18n } = useFormatter(); - const classes = useStyles(); const { viewStorage, paginationOptions, @@ -41,7 +31,7 @@ const Indicators = () => { numberOfElements: { number: 0, symbol: '', original: 0 }, filters: { ...emptyFilterGroup, - filters: useGetDefaultFilterObject(['sightedBy'], ['Indicator']), + filters: useGetDefaultFilterObject(['pattern_type', 'x_opencti_main_observable_type'], ['Indicator']), }, searchTerm: '', sortBy: 'created', @@ -78,35 +68,17 @@ const Indicators = () => { queryPaginationOptions, ); - const patternTypes = findFilterFromKey(filters?.filters ?? [], 'pattern_type')?.values ?? []; - const observableTypes = findFilterFromKey(filters?.filters ?? [], 'x_opencti_main_observable_type')?.values ?? []; - const handleToggleIndicatorType = (type: string) => { - if (patternTypes.includes(type)) { - storageHelpers.handleRemoveFilter('pattern_type', 'eq', type); - } else { - storageHelpers.handleAddFilter('pattern_type', type); - } - }; - const handleToggleObservableType = (type: string) => { - if (observableTypes.includes(type)) { - storageHelpers.handleRemoveFilter('x_opencti_main_observable_type', 'eq', type); - } else { - storageHelpers.handleAddFilter( - 'x_opencti_main_observable_type', - type, - ); - } - }; - const handleClearObservableTypes = () => { - storageHelpers.handleRemoveFilter('x_opencti_main_observable_type'); - }; - const renderLines = (platformModuleHelpers: ModuleHelper | undefined) => { + const { + platformModuleHelpers: { isRuntimeFieldEnable }, + } = useAuth(); + const isRuntimeSort = isRuntimeFieldEnable() ?? false; + + const renderLines = () => { let numberOfSelectedElements = Object.keys(selectedElements || {}).length; if (selectAll) { numberOfSelectedElements = (numberOfElements?.original ?? 0) - Object.keys(deSelectedElements || {}).length; } - const isRuntimeSort = platformModuleHelpers?.isRuntimeFieldEnable(); const dataColumns = { pattern_type: { label: 'Pattern type', @@ -121,12 +93,12 @@ const Indicators = () => { createdBy: { label: 'Author', width: '12%', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, creator: { label: 'Creators', width: '12%', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, objectLabel: { label: 'Labels', @@ -146,7 +118,7 @@ const Indicators = () => { objectMarking: { label: 'Marking', width: '10%', - isSortable: isRuntimeSort ?? false, + isSortable: isRuntimeSort, }, }; return ( @@ -186,7 +158,7 @@ const Indicators = () => { /> ))} - } + } > { ); }; return ( - - {({ platformModuleHelpers }) => ( - -
- - {renderLines(platformModuleHelpers)} - - - - -
-
- )} -
+ +
+ + {renderLines()} + + + +
+
); }; diff --git a/opencti-platform/opencti-front/src/private/components/observations/indicators/IndicatorCreation.tsx b/opencti-platform/opencti-front/src/private/components/observations/indicators/IndicatorCreation.tsx index c99444656ca5..d28c9a5f6c3a 100644 --- a/opencti-platform/opencti-front/src/private/components/observations/indicators/IndicatorCreation.tsx +++ b/opencti-platform/opencti-front/src/private/components/observations/indicators/IndicatorCreation.tsx @@ -38,15 +38,6 @@ import { useSchemaCreationValidation } from '../../../../utils/hooks/useEntitySe import CustomFileUploader from '../../common/files/CustomFileUploader'; const useStyles = makeStyles((theme) => ({ - createButton: { - position: 'fixed', - bottom: 30, - right: 280, - transition: theme.transitions.create('right', { - easing: theme.transitions.easing.sharp, - duration: theme.transitions.duration.enteringScreen, - }), - }, createButtonContextual: { position: 'fixed', bottom: 30, @@ -400,6 +391,7 @@ const IndicatorCreation: FunctionComponent = ({ paginati const { t_i18n } = useFormatter(); const classes = useStyles(); const [open, setOpen] = useState(false); + console.log('open', open); const handleOpen = () => setOpen(true); const handleClose = () => setOpen(false); const onReset = () => handleClose(); @@ -412,6 +404,7 @@ const IndicatorCreation: FunctionComponent = ({ paginati ); if (contextual) { + console.log('conetxtual'); return (
= ({ paginati return ( {({ onClose }) => ( ((theme) => ({ - drawerPaper: { - minHeight: '100vh', - width: 250, - right: 0, - padding: '0 0 20px 0', - transition: theme.transitions.create('right', { - easing: theme.transitions.easing.sharp, - duration: theme.transitions.duration.enteringScreen, - }), - }, - drawerPaperExports: { - minHeight: '100vh', - width: 250, - right: 310, - padding: '0 0 20px 0', - transition: theme.transitions.create('right', { - easing: theme.transitions.easing.easeOut, - duration: theme.transitions.duration.leavingScreen, - }), - }, - item: { - padding: '0 0 0 6px', - }, - toolbar: theme.mixins.toolbar, -})); - -interface IndicatorsRightBarProps { - indicatorTypes: string[]; - observableTypes: string[]; - handleToggleIndicatorType: (name: string) => void; - handleToggleObservableType: (name: string) => void; - handleClearObservableTypes: () => void; - openExports?: boolean; -} - -const IndicatorsRightBar: FunctionComponent = ({ - indicatorTypes, - observableTypes, - handleToggleIndicatorType, - handleToggleObservableType, - handleClearObservableTypes, - openExports, -}) => { - const classes = useStyles(); - const { t_i18n } = useFormatter(); - const { - bannerSettings: { bannerHeightNumber }, - } = useAuth(); - const settingsMessagesBannerHeight = useSettingsMessagesBannerHeight(); - return ( - -
- { - const patternTypes = props?.vocabularies?.edges; - return ( - - {t_i18n('Pattern type')} - - } - > - {patternTypes - && patternTypes.map((patternType) => ( - handleToggleIndicatorType(patternType.node.name) - } - classes={{ root: classes.item }} - > - - - - ))} - - ); - }} - /> - { - if (props && props.subTypes) { - const subTypesEdges = props.subTypes.edges; - const sortByLabel = sortBy(compose(toLower, prop('tlabel'))); - const translatedOrderedList = sortByLabel( - subTypesEdges - .map((n) => n.node) - .map((n) => assoc('tlabel', t_i18n(`entity_${n.label}`), n)), - ); - return ( - - {t_i18n('Observable type')} - - - - - - - } - > - {translatedOrderedList.map((subType) => ( - handleToggleObservableType(subType.label)} - classes={{ root: classes.item }} - > - - - - ))} - - ); - } - return
; - }} - /> - - ); -}; - -export default IndicatorsRightBar;