11import React , { Suspense , lazy } from 'react' ;
22import { 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';
2222import useSettingsFallbackUrl from '../../../utils/hooks/useSettingsFallbackUrl' ;
2323
2424const 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' ) ) ;
3225const Settings = lazy ( ( ) => import ( './Settings' ) ) ;
3326const 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' ) ) ;
4727const Experience = lazy ( ( ) => import ( './Experience' ) ) ;
4828const 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
5033const 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 />
0 commit comments