1- import React , { useEffect } from 'react' ;
1+ import React , { useEffect , Suspense } from 'react' ;
22import { Admin , Resource } from 'react-admin' ;
3+ import { Box , CircularProgress , Typography } from '@mui/material' ;
4+ import {
5+ Security as SecurityIcon ,
6+ Assessment as ComplianceIcon ,
7+ Computer as SystemIcon ,
8+ BugReport as ThreatScannerIcon ,
9+ Notifications as NotificationsIcon ,
10+ Gavel as MitreIcon ,
11+ Settings as ConfigurationIcon ,
12+ Shield as YaraRulesIcon ,
13+ FindInPage as YaraMatchesIcon ,
14+ Timeline as TimelineIcon ,
15+ } from '@mui/icons-material' ;
316// Using production providers with real backend API
417import { enhancedCastellanDataProvider } from './dataProvider/castellanDataProvider' ;
518import { enhancedAuthProvider } from './auth/authProvider' ;
619import { Layout } from './components/Layout' ;
7- import { Dashboard } from './components/Dashboard' ;
820import { initializeCachePreloader } from './utils/cachePreloader' ;
921import './utils/cacheInspector' ; // Load cache debugging tools
22+ import './utils/performanceTesting' ; // Load performance testing suite
1023
11- // Import resources
12- import {
13- SecurityEventList ,
14- SecurityEventShow ,
15- SecurityEventEdit ,
16- SecurityEventCreate ,
17- } from './resources/SecurityEvents' ; // Reverted to original for stability
18- import {
19- SystemStatusList ,
20- SystemStatusShow ,
21- } from './resources/SystemStatus' ;
24+ // Lazy load Dashboard for better performance
25+ const Dashboard = React . lazy ( ( ) => import ( './components/Dashboard' ) . then ( module => ( { default : module . Dashboard } ) ) ) ;
2226
23- // Import functional compliance reports components
24- import {
25- ComplianceReportList ,
26- ComplianceReportShow ,
27- ComplianceReportCreate ,
28- } from './resources/ComplianceReports' ;
27+ // Lazy-loaded resource imports for better performance and code splitting
28+ const SecurityEventList = React . lazy ( ( ) => import ( './resources/SecurityEvents' ) . then ( module => ( { default : module . SecurityEventList } ) ) ) ;
29+ const SecurityEventShow = React . lazy ( ( ) => import ( './resources/SecurityEvents' ) . then ( module => ( { default : module . SecurityEventShow } ) ) ) ;
30+ const SecurityEventEdit = React . lazy ( ( ) => import ( './resources/SecurityEvents' ) . then ( module => ( { default : module . SecurityEventEdit } ) ) ) ;
31+ const SecurityEventCreate = React . lazy ( ( ) => import ( './resources/SecurityEvents' ) . then ( module => ( { default : module . SecurityEventCreate } ) ) ) ;
2932
30- // Import threat scanner resource
31- import {
32- ThreatScannerList ,
33- ThreatScannerShow ,
34- } from './resources/ThreatScanner' ;
33+ const SystemStatusList = React . lazy ( ( ) => import ( './resources/SystemStatus' ) . then ( module => ( { default : module . SystemStatusList } ) ) ) ;
34+ const SystemStatusShow = React . lazy ( ( ) => import ( './resources/SystemStatus' ) . then ( module => ( { default : module . SystemStatusShow } ) ) ) ;
3535
36- // Import MITRE techniques resource
37- import {
38- MitreTechniquesList ,
39- MitreTechniquesShow ,
40- } from './resources/MitreTechniques' ;
36+ const ComplianceReportList = React . lazy ( ( ) => import ( './resources/ComplianceReports' ) . then ( module => ( { default : module . ComplianceReportList } ) ) ) ;
37+ const ComplianceReportShow = React . lazy ( ( ) => import ( './resources/ComplianceReports' ) . then ( module => ( { default : module . ComplianceReportShow } ) ) ) ;
38+ const ComplianceReportCreate = React . lazy ( ( ) => import ( './resources/ComplianceReports' ) . then ( module => ( { default : module . ComplianceReportCreate } ) ) ) ;
4139
42- // Import YARA resources
43- import {
44- YaraRulesList ,
45- YaraRulesShow ,
46- YaraRulesCreate ,
47- YaraRulesEdit ,
48- } from './resources/YaraRules' ;
40+ const ThreatScannerList = React . lazy ( ( ) => import ( './resources/ThreatScanner' ) . then ( module => ( { default : module . ThreatScannerList } ) ) ) ;
41+ const ThreatScannerShow = React . lazy ( ( ) => import ( './resources/ThreatScanner' ) . then ( module => ( { default : module . ThreatScannerShow } ) ) ) ;
4942
50- import {
51- YaraMatchesList ,
52- YaraMatchesShow ,
53- } from './resources/YaraMatches' ;
43+ const MitreTechniquesList = React . lazy ( ( ) => import ( './resources/MitreTechniques' ) . then ( module => ( { default : module . MitreTechniquesList } ) ) ) ;
44+ const MitreTechniquesShow = React . lazy ( ( ) => import ( './resources/MitreTechniques' ) . then ( module => ( { default : module . MitreTechniquesShow } ) ) ) ;
5445
55- // Import timeline resource
56- import {
57- TimelineList ,
58- } from './resources/Timeline' ;
46+ const YaraRulesList = React . lazy ( ( ) => import ( './resources/YaraRules' ) . then ( module => ( { default : module . YaraRulesList } ) ) ) ;
47+ const YaraRulesShow = React . lazy ( ( ) => import ( './resources/YaraRules' ) . then ( module => ( { default : module . YaraRulesShow } ) ) ) ;
48+ const YaraRulesCreate = React . lazy ( ( ) => import ( './resources/YaraRules' ) . then ( module => ( { default : module . YaraRulesCreate } ) ) ) ;
49+ const YaraRulesEdit = React . lazy ( ( ) => import ( './resources/YaraRules' ) . then ( module => ( { default : module . YaraRulesEdit } ) ) ) ;
5950
60- // Import notification settings resource
61- import {
62- NotificationSettingsList ,
63- NotificationSettingsShow ,
64- NotificationSettingsCreate ,
65- NotificationSettingsEdit ,
66- } from './resources/NotificationSettings' ;
51+ const YaraMatchesList = React . lazy ( ( ) => import ( './resources/YaraMatches' ) . then ( module => ( { default : module . YaraMatchesList } ) ) ) ;
52+ const YaraMatchesShow = React . lazy ( ( ) => import ( './resources/YaraMatches' ) . then ( module => ( { default : module . YaraMatchesShow } ) ) ) ;
6753
68- // Import configuration resource
69- import {
70- ConfigurationList ,
71- ConfigurationShow ,
72- } from './resources/Configuration' ;
54+ const TimelineList = React . lazy ( ( ) => import ( './resources/Timeline' ) . then ( module => ( { default : module . TimelineList } ) ) ) ;
55+
56+ const NotificationSettingsList = React . lazy ( ( ) => import ( './resources/NotificationSettings' ) . then ( module => ( { default : module . NotificationSettingsList } ) ) ) ;
57+ const NotificationSettingsShow = React . lazy ( ( ) => import ( './resources/NotificationSettings' ) . then ( module => ( { default : module . NotificationSettingsShow } ) ) ) ;
58+ const NotificationSettingsCreate = React . lazy ( ( ) => import ( './resources/NotificationSettings' ) . then ( module => ( { default : module . NotificationSettingsCreate } ) ) ) ;
59+ const NotificationSettingsEdit = React . lazy ( ( ) => import ( './resources/NotificationSettings' ) . then ( module => ( { default : module . NotificationSettingsEdit } ) ) ) ;
60+
61+ const ConfigurationList = React . lazy ( ( ) => import ( './resources/Configuration' ) . then ( module => ( { default : module . ConfigurationList } ) ) ) ;
62+ const ConfigurationShow = React . lazy ( ( ) => import ( './resources/Configuration' ) . then ( module => ( { default : module . ConfigurationShow } ) ) ) ;
7363
7464// CastellanProFree - No edition detection needed
7565
76- // Import Material-UI icons for resources
77- import {
78- Security as SecurityIcon ,
79- Assessment as ComplianceIcon ,
80- Computer as SystemIcon ,
81- BugReport as ThreatScannerIcon ,
82- Notifications as NotificationsIcon ,
83- Gavel as MitreIcon ,
84- Settings as ConfigurationIcon ,
85- Shield as YaraRulesIcon ,
86- FindInPage as YaraMatchesIcon ,
87- Timeline as TimelineIcon ,
88- } from '@mui/icons-material' ;
66+ // Loading fallback component for lazy-loaded resources
67+ const LoadingFallback = ( ) => (
68+ < Box
69+ sx = { {
70+ display : 'flex' ,
71+ flexDirection : 'column' ,
72+ alignItems : 'center' ,
73+ justifyContent : 'center' ,
74+ height : '200px' ,
75+ gap : 2
76+ } }
77+ >
78+ < CircularProgress size = { 40 } />
79+ < Typography variant = "body2" color = "textSecondary" >
80+ Loading component...
81+ </ Typography >
82+ </ Box >
83+ ) ;
8984
9085const App = ( ) => {
9186 // Initialize cache preloader for immediate data availability
@@ -94,12 +89,13 @@ const App = () => {
9489 } , [ ] ) ;
9590
9691 return (
97- < Admin
98- dataProvider = { enhancedCastellanDataProvider }
99- authProvider = { enhancedAuthProvider }
100- layout = { Layout }
101- dashboard = { Dashboard }
102- >
92+ < Suspense fallback = { < LoadingFallback /> } >
93+ < Admin
94+ dataProvider = { enhancedCastellanDataProvider }
95+ authProvider = { enhancedAuthProvider }
96+ layout = { Layout }
97+ dashboard = { Dashboard }
98+ >
10399 { /* Security Events Resource - Available in CastellanProFree */ }
104100 < Resource
105101 name = "security-events"
@@ -196,6 +192,7 @@ const App = () => {
196192 recordRepresentation = { ( ) => 'System Configuration' }
197193 />
198194 </ Admin >
195+ </ Suspense >
199196 ) ;
200197} ;
201198
0 commit comments