Skip to content

Commit bd4e032

Browse files
authored
[frontend] prevent re-rending of settings right menu (#15339)
1 parent 4a04e7c commit bd4e032

24 files changed

Lines changed: 308 additions & 257 deletions

File tree

opencti-platform/opencti-front/src/private/components/settings/KillChainPhases.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22
import { graphql } from 'react-relay';
33
import { useFormatter } from '../../../components/i18n';
44
import KillChainPhaseCreation from './kill_chain_phases/KillChainPhaseCreation';
5-
import LabelsVocabulariesMenu from './LabelsVocabulariesMenu';
65
import Breadcrumbs from '../../../components/Breadcrumbs';
76
import { usePaginationLocalStorage } from '../../../utils/hooks/useLocalStorage';
87
import DataTable from '../../../components/dataGrid/DataTable';
@@ -147,7 +146,6 @@ const KillChainPhases = () => {
147146

148147
return (
149148
<div style={{ marginRight: 200 }} data-testid="kill-chain-phases-page">
150-
<LabelsVocabulariesMenu />
151149
<Breadcrumbs elements={[{ label: t_i18n('Settings') }, { label: t_i18n('Taxonomies') }, { label: t_i18n('Kill chain phases'), current: true }]} />
152150
{queryRef && (
153151
<DataTable

opencti-platform/opencti-front/src/private/components/settings/Labels.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { graphql } from 'react-relay';
44
import makeStyles from '@mui/styles/makeStyles';
55
import LabelPopover from './labels/LabelPopover';
66
import LabelCreation from './labels/LabelCreation';
7-
import LabelsVocabulariesMenu from './LabelsVocabulariesMenu';
87
import Breadcrumbs from '../../../components/Breadcrumbs';
98
import { usePaginationLocalStorage } from '../../../utils/hooks/useLocalStorage';
109
import { useFormatter } from '../../../components/i18n';
@@ -157,7 +156,6 @@ const Labels = () => {
157156

158157
return (
159158
<div className={classes.container} data-testid="labels-page">
160-
<LabelsVocabulariesMenu />
161159
<Breadcrumbs elements={[{ label: t_i18n('Settings') }, { label: t_i18n('Taxonomies') }, { label: t_i18n('Labels'), current: true }]} />
162160
{queryRef && (
163161
<DataTable

opencti-platform/opencti-front/src/private/components/settings/Notifiers.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { NotifierLine_node$data } from './notifiers/__generated__/NotifierLine_n
1111
import { NotifierLineDummy } from './notifiers/NotifierLine';
1212
import NotifierCreation from './notifiers/NotifierCreation';
1313
import { useFormatter } from '../../../components/i18n';
14-
import CustomizationMenu from './CustomizationMenu';
1514
import { emptyFilterGroup } from '../../../utils/filters/filtersUtils';
1615
import Breadcrumbs from '../../../components/Breadcrumbs';
1716
import useConnectedDocumentModifier from '../../../utils/hooks/useConnectedDocumentModifier';
@@ -73,7 +72,6 @@ const Notifiers = () => {
7372
);
7473
return (
7574
<div className={classes.container} data-testid="notifiers-page">
76-
<CustomizationMenu />
7775
<Breadcrumbs elements={[{ label: t_i18n('Settings') }, { label: t_i18n('Customization') }, { label: t_i18n('Notifiers'), current: true }]} />
7876
<ListLines
7977
helpers={storageHelpers}

opencti-platform/opencti-front/src/private/components/settings/Retention.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import useAuth from '../../../utils/hooks/useAuth';
1010
import { usePaginationLocalStorage } from '../../../utils/hooks/useLocalStorage';
1111
import { useFormatter } from '../../../components/i18n';
1212
import { RETENTION_MANAGER } from '../../../utils/platformModulesHelper';
13-
import CustomizationMenu from './CustomizationMenu';
1413
import Breadcrumbs from '../../../components/Breadcrumbs';
1514
import useQueryLoading from '../../../utils/hooks/useQueryLoading';
1615
import { DataColumns } from '../../../components/list_lines';
@@ -81,14 +80,12 @@ const Retention = () => {
8180
<Alert severity="info">
8281
{t_i18n(platformModuleHelpers.generateDisableMessage(RETENTION_MANAGER))}
8382
</Alert>
84-
<CustomizationMenu />
8583
</div>
8684
);
8785
}
8886
const queryRef = useQueryLoading<RetentionLinesPaginationQuery>(RetentionLinesQuery, paginationOptions);
8987
return (
9088
<div className={classes.container} data-testid="retention-page">
91-
<CustomizationMenu />
9289
<Breadcrumbs elements={[{ label: t_i18n('Settings') }, { label: t_i18n('Customization') }, { label: t_i18n('Retention'), current: true }]} />
9390
<ListLines
9491
dataColumns={dataColumns}

opencti-platform/opencti-front/src/private/components/settings/Root.tsx

Lines changed: 11 additions & 214 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Suspense, lazy } from 'react';
22
import { Navigate, Route, Routes } from 'react-router-dom';
3-
import useGranted, {
3+
import {
44
SETTINGS_SETCUSTOMIZATION,
55
SETTINGS_SETLABELS,
66
SETTINGS_SECURITYACTIVITY,
@@ -22,49 +22,17 @@ import Loader from '../../../components/Loader';
2222
import useSettingsFallbackUrl from '../../../utils/hooks/useSettingsFallbackUrl';
2323

2424
const Security = lazy(() => import('../../../utils/Security'));
25-
const CaseTemplates = lazy(() => import('./case_templates/CaseTemplates'));
26-
const CaseTemplateTasks = lazy(() => import('./case_templates/CaseTemplateTasks'));
27-
const KillChainPhases = lazy(() => import('./KillChainPhases'));
28-
const Labels = lazy(() => import('./Labels'));
29-
const Notifiers = lazy(() => import('./Notifiers'));
30-
const Retention = lazy(() => import('./Retention'));
31-
const Rules = lazy(() => import('./rules/Rules'));
3225
const Settings = lazy(() => import('./Settings'));
3326
const FileIndexing = lazy(() => import('./file_indexing/FileIndexing'));
34-
const StatusTemplates = lazy(() => import('./status_templates/StatusTemplates'));
35-
const RootSubType = lazy(() => import('./sub_types/Root'));
36-
const SubTypes = lazy(() => import('./sub_types/SubTypes'));
37-
const Vocabularies = lazy(() => import('./Vocabularies'));
38-
const VocabularyCategories = lazy(() => import('./VocabularyCategories'));
39-
const Audit = lazy(() => import('./activity/audit/Root'));
40-
const Configuration = lazy(() => import('./activity/configuration/Configuration'));
41-
const Alerting = lazy(() => import('./activity/alerting/Alerting'));
42-
const DecayRuleTabs = lazy(() => import('./decay/DecayRuleTabs'));
43-
const DecayRule = lazy(() => import('./decay/DecayRule'));
44-
const ExclusionLists = lazy(() => import('./exclusion_lists/ExclusionLists'));
45-
const FintelDesigns = lazy(() => import('./fintel_design/FintelDesigns'));
46-
const FintelDesign = lazy(() => import('./fintel_design/FintelDesign'));
4727
const Experience = lazy(() => import('./Experience'));
4828
const RootAccesses = lazy(() => import('./accesses/Root'));
29+
const RootActivity = lazy(() => import('./activity/Root'));
30+
const RootCustomization = lazy(() => import('./customization/Root'));
31+
const RootVocabularies = lazy(() => import('./vocabularies/Root'));
4932

5033
const Root = () => {
51-
const isGrantedToLabels = useGranted([SETTINGS_SETLABELS]);
52-
const isGrantedToVocabularies = useGranted([SETTINGS_SETVOCABULARIES]);
53-
const isGrantedToKillChainPhases = useGranted([SETTINGS_SETKILLCHAINPHASES]);
54-
const isGrantedToCaseTemplates = useGranted([SETTINGS_SETCASETEMPLATES]);
55-
const isGrantedToStatusTemplates = useGranted([SETTINGS_SETSTATUSTEMPLATES]);
56-
5734
const fallbackUrl = useSettingsFallbackUrl();
5835

59-
const generateTaxonomyLink = () => {
60-
if (isGrantedToLabels) return '/dashboard/settings/vocabularies/labels';
61-
if (isGrantedToKillChainPhases) return '/dashboard/settings/vocabularies/kill_chain_phases';
62-
if (isGrantedToCaseTemplates) return '/dashboard/settings/vocabularies/case_templates';
63-
if (isGrantedToStatusTemplates) return '/dashboard/settings/vocabularies/status_templates';
64-
if (isGrantedToVocabularies) return '/dashboard/settings/vocabularies/fields';
65-
return '/dashboard';
66-
};
67-
6836
return (
6937
<div data-testid="settings-page">
7038
<Suspense fallback={<Loader />}>
@@ -92,34 +60,10 @@ const Root = () => {
9260
)}
9361
/>
9462
<Route
95-
path="/activity"
96-
element={(
97-
<Security needs={[SETTINGS_SECURITYACTIVITY]} placeholder={<Navigate to={fallbackUrl} />}>
98-
<Navigate to="/dashboard/settings/activity/audit" replace={true} />
99-
</Security>
100-
)}
101-
/>
102-
<Route
103-
path="/activity/audit"
104-
element={(
105-
<Security needs={[SETTINGS_SECURITYACTIVITY]} placeholder={<Navigate to={fallbackUrl} />}>
106-
<Audit />
107-
</Security>
108-
)}
109-
/>
110-
<Route
111-
path="/activity/configuration"
112-
element={(
113-
<Security needs={[SETTINGS_SECURITYACTIVITY]} placeholder={<Navigate to={fallbackUrl} />}>
114-
<Configuration />
115-
</Security>
116-
)}
117-
/>
118-
<Route
119-
path="/activity/alerting"
63+
path="/activity/*"
12064
element={(
12165
<Security needs={[SETTINGS_SECURITYACTIVITY]} placeholder={<Navigate to={fallbackUrl} />}>
122-
<Alerting />
66+
<RootActivity />
12367
</Security>
12468
)}
12569
/>
@@ -140,168 +84,21 @@ const Root = () => {
14084
)}
14185
/>
14286
<Route
143-
path="/customization"
144-
element={(
145-
<Security needs={[SETTINGS_SETCUSTOMIZATION]} placeholder={<Navigate to={fallbackUrl} />}>
146-
<Navigate to="/dashboard/settings/customization/entity_types" replace={true} />
147-
</Security>
148-
)}
149-
/>
150-
<Route
151-
path="/customization/entity_types"
152-
element={(
153-
<Security needs={[SETTINGS_SETCUSTOMIZATION]} placeholder={<Navigate to={fallbackUrl} />}>
154-
<SubTypes />
155-
</Security>
156-
)}
157-
/>
158-
<Route
159-
path="/customization/retention"
160-
element={(
161-
<Security needs={[SETTINGS_SETCUSTOMIZATION]} placeholder={<Navigate to={fallbackUrl} />}>
162-
<Retention />
163-
</Security>
164-
)}
165-
/>
166-
<Route
167-
path="/customization/entity_types/:subTypeId/*"
168-
element={(
169-
<Security needs={[SETTINGS_SETCUSTOMIZATION]} placeholder={<Navigate to={fallbackUrl} />}>
170-
<RootSubType />
171-
</Security>
172-
)}
173-
/>
174-
<Route
175-
path="/customization/rules"
176-
element={(
177-
<Security needs={[SETTINGS_SETCUSTOMIZATION]} placeholder={<Navigate to={fallbackUrl} />}>
178-
<Rules />
179-
</Security>
180-
)}
181-
/>
182-
<Route
183-
path="customization/decay"
184-
element={(
185-
<Security needs={[SETTINGS_SETCUSTOMIZATION]} placeholder={<Navigate to={fallbackUrl} />}>
186-
<DecayRuleTabs />
187-
</Security>
188-
)}
189-
/>
190-
<Route
191-
path="customization/decay/:decayRuleId/*"
192-
element={(
193-
<Security needs={[SETTINGS_SETCUSTOMIZATION]} placeholder={<Navigate to={fallbackUrl} />}>
194-
<DecayRule />
195-
</Security>
196-
)}
197-
/>
198-
<Route
199-
path="customization/exclusion_lists"
200-
element={(
201-
<Security needs={[SETTINGS_SETCUSTOMIZATION]} placeholder={<Navigate to={fallbackUrl} />}>
202-
<ExclusionLists />
203-
</Security>
204-
)}
205-
/>
206-
<Route
207-
path="customization/fintel_designs"
208-
element={(
209-
<Security needs={[SETTINGS_SETCUSTOMIZATION]} placeholder={<Navigate to={fallbackUrl} />}>
210-
<FintelDesigns />
211-
</Security>
212-
)}
213-
/>
214-
<Route
215-
path="customization/fintel_designs/:fintelDesignId/*"
216-
element={(
217-
<Security needs={[SETTINGS_SETCUSTOMIZATION]} placeholder={<Navigate to={fallbackUrl} />}>
218-
<FintelDesign />
219-
</Security>
220-
)}
221-
/>
222-
<Route
223-
path="/customization/notifiers"
87+
path="/customization/*"
22488
element={(
22589
<Security needs={[SETTINGS_SETCUSTOMIZATION]} placeholder={<Navigate to={fallbackUrl} />}>
226-
<Notifiers />
227-
</Security>
228-
)}
229-
/>
230-
<Route path="/vocabularies" element={<Navigate to={generateTaxonomyLink()} />} />
231-
<Route
232-
path="/vocabularies/labels"
233-
element={(
234-
<Security
235-
needs={[SETTINGS_SETLABELS]}
236-
placeholder={<Navigate to={fallbackUrl} />}
237-
>
238-
<Labels />
239-
</Security>
240-
)}
241-
/>
242-
<Route
243-
path="/vocabularies/kill_chain_phases"
244-
element={(
245-
<Security
246-
needs={[SETTINGS_SETKILLCHAINPHASES]}
247-
placeholder={<Navigate to={fallbackUrl} />}
248-
>
249-
<KillChainPhases />
250-
</Security>
251-
)}
252-
/>
253-
<Route
254-
path="/vocabularies/status_templates"
255-
element={(
256-
<Security
257-
needs={[SETTINGS_SETSTATUSTEMPLATES]}
258-
placeholder={<Navigate to={fallbackUrl} />}
259-
>
260-
<StatusTemplates />
261-
</Security>
262-
)}
263-
/>
264-
<Route
265-
path="/vocabularies/case_templates"
266-
element={(
267-
<Security
268-
needs={[SETTINGS_SETCASETEMPLATES]}
269-
placeholder={<Navigate to={fallbackUrl} />}
270-
>
271-
<CaseTemplates />
272-
</Security>
273-
)}
274-
/>
275-
<Route
276-
path="/vocabularies/case_templates/:caseTemplateId/*"
277-
element={(
278-
<Security
279-
needs={[SETTINGS_SETCASETEMPLATES]}
280-
placeholder={<Navigate to={fallbackUrl} />}
281-
>
282-
<CaseTemplateTasks />
283-
</Security>
284-
)}
285-
/>
286-
<Route
287-
path="/vocabularies/fields"
288-
element={(
289-
<Security
290-
needs={[SETTINGS_SETVOCABULARIES]}
291-
placeholder={<Navigate to={fallbackUrl} />}
292-
>
293-
<VocabularyCategories />
90+
<RootCustomization />
29491
</Security>
29592
)}
29693
/>
29794
<Route
298-
path="/vocabularies/fields/:category"
95+
path="/vocabularies/*"
29996
element={(
30097
<Security
301-
needs={[SETTINGS_SETVOCABULARIES]}
98+
needs={[SETTINGS_SETLABELS, SETTINGS_SETKILLCHAINPHASES, SETTINGS_SETSTATUSTEMPLATES, SETTINGS_SETCASETEMPLATES, SETTINGS_SETVOCABULARIES]}
30299
placeholder={<Navigate to={fallbackUrl} />}
303100
>
304-
<Vocabularies />
101+
<RootVocabularies />
305102
</Security>
306103
)}
307104
/>

opencti-platform/opencti-front/src/private/components/settings/Vocabularies.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { usePaginationLocalStorage } from '../../../utils/hooks/useLocalStorage'
99
import useQueryLoading from '../../../utils/hooks/useQueryLoading';
1010
import { useVocabularyCategory_Vocabularynode$data } from '../../../utils/hooks/__generated__/useVocabularyCategory_Vocabularynode.graphql';
1111
import { useFormatter } from '../../../components/i18n';
12-
import LabelsVocabulariesMenu from './LabelsVocabulariesMenu';
1312
import VocabularyCreation from './attributes/VocabularyCreation';
1413
import useVocabularyCategory, { vocabFragment } from '../../../utils/hooks/useVocabularyCategory';
1514
import { emptyFilterGroup, isFilterGroupNotEmpty } from '../../../utils/filters/filtersUtils';
@@ -167,7 +166,6 @@ const Vocabularies = () => {
167166

168167
return (
169168
<div style={{ marginRight: 200 }}>
170-
<LabelsVocabulariesMenu />
171169
<Breadcrumbs elements={[
172170
{ label: t_i18n('Settings') },
173171
{ label: t_i18n('Taxonomies') },

opencti-platform/opencti-front/src/private/components/settings/VocabularyCategories.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useEffect } from 'react';
22
import { useTheme } from '@mui/material';
33
import { useFormatter } from '../../../components/i18n';
4-
import LabelsVocabulariesMenu from './LabelsVocabulariesMenu';
54
import { useVocabularyCategoryAsQuery, VocabularyDefinition } from '../../../utils/hooks/useVocabularyCategory';
65
import Breadcrumbs from '../../../components/Breadcrumbs';
76
import useConnectedDocumentModifier from '../../../utils/hooks/useConnectedDocumentModifier';
@@ -68,7 +67,6 @@ const VocabularyCategories = () => {
6867

6968
return (
7069
<div style={{ paddingRight: 200 }} data-testid="vocabularies-page">
71-
<LabelsVocabulariesMenu />
7270
<Breadcrumbs
7371
elements={[
7472
{ label: t_i18n('Settings') },

0 commit comments

Comments
 (0)