refactor: lazy load renderer dialogs
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { Suspense } from 'react'
|
||||||
import {
|
import {
|
||||||
ArrowUpCircle,
|
ArrowUpCircle,
|
||||||
Database,
|
Database,
|
||||||
@@ -16,12 +16,13 @@ import type {
|
|||||||
UpdateStatus
|
UpdateStatus
|
||||||
} from '../../../../main/types/update.types'
|
} from '../../../../main/types/update.types'
|
||||||
import type { CurrentUser, Page } from '../../hooks/useAppBootstrap'
|
import type { CurrentUser, Page } from '../../hooks/useAppBootstrap'
|
||||||
import UpdateDialog from '../UpdateDialog'
|
|
||||||
import { Toast } from '../ui/Toast'
|
import { Toast } from '../ui/Toast'
|
||||||
import CleanerPage from '../../pages/CleanerPage'
|
import CleanerPage from '../../pages/CleanerPage'
|
||||||
import ExtractorPage from '../../pages/ExtractorPage'
|
import ExtractorPage from '../../pages/ExtractorPage'
|
||||||
import SettingsPage from '../../pages/SettingsPage'
|
import SettingsPage from '../../pages/SettingsPage'
|
||||||
|
|
||||||
|
const UpdateDialog = React.lazy(() => import('../UpdateDialog'))
|
||||||
|
|
||||||
interface AuthenticatedAppShellProps {
|
interface AuthenticatedAppShellProps {
|
||||||
currentUser: CurrentUser | null
|
currentUser: CurrentUser | null
|
||||||
currentPage: Page
|
currentPage: Page
|
||||||
@@ -192,6 +193,7 @@ export function AuthenticatedAppShell({
|
|||||||
|
|
||||||
<Toast />
|
<Toast />
|
||||||
|
|
||||||
|
<Suspense fallback={null}>
|
||||||
<UpdateDialog
|
<UpdateDialog
|
||||||
isOpen={showUpdateDialog}
|
isOpen={showUpdateDialog}
|
||||||
userType={currentUser?.userType ?? null}
|
userType={currentUser?.userType ?? null}
|
||||||
@@ -204,6 +206,7 @@ export function AuthenticatedAppShell({
|
|||||||
}
|
}
|
||||||
onRefreshCatalog={onRefreshCatalog}
|
onRefreshCatalog={onRefreshCatalog}
|
||||||
/>
|
/>
|
||||||
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
import React from 'react'
|
import React, { Suspense } from 'react'
|
||||||
import { CleanerExecutionBar } from '../components/cleaner/CleanerExecutionBar'
|
import { CleanerExecutionBar } from '../components/cleaner/CleanerExecutionBar'
|
||||||
import { CleanerResultsTable } from '../components/cleaner/CleanerResultsTable'
|
import { CleanerResultsTable } from '../components/cleaner/CleanerResultsTable'
|
||||||
import { CleanerSidebar } from '../components/cleaner/CleanerSidebar'
|
import { CleanerSidebar } from '../components/cleaner/CleanerSidebar'
|
||||||
import { CleanerToolbar } from '../components/cleaner/CleanerToolbar'
|
import { CleanerToolbar } from '../components/cleaner/CleanerToolbar'
|
||||||
import MaterialTypeManagementDialog from '../components/MaterialTypeManagementDialog'
|
|
||||||
import ExecutionReportDialog from '../components/ExecutionReportDialog'
|
|
||||||
import ReportViewerDialog from '../components/ReportViewerDialog'
|
|
||||||
import { ConfirmDialog } from '../components/ui/ConfirmDialog'
|
import { ConfirmDialog } from '../components/ui/ConfirmDialog'
|
||||||
import { useCleaner } from '../hooks/useCleaner'
|
import { useCleaner } from '../hooks/useCleaner'
|
||||||
|
|
||||||
|
const MaterialTypeManagementDialog = React.lazy(
|
||||||
|
() => import('../components/MaterialTypeManagementDialog')
|
||||||
|
)
|
||||||
|
const ExecutionReportDialog = React.lazy(() => import('../components/ExecutionReportDialog'))
|
||||||
|
const ReportViewerDialog = React.lazy(() => import('../components/ReportViewerDialog'))
|
||||||
|
|
||||||
const CleanerPage: React.FC = () => {
|
const CleanerPage: React.FC = () => {
|
||||||
const typeManagementButtonRef = React.useRef<HTMLButtonElement>(null)
|
const typeManagementButtonRef = React.useRef<HTMLButtonElement>(null)
|
||||||
const executeButtonRef = React.useRef<HTMLButtonElement>(null)
|
const executeButtonRef = React.useRef<HTMLButtonElement>(null)
|
||||||
@@ -129,7 +132,7 @@ const CleanerPage: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Material Type Management Dialog */}
|
<Suspense fallback={null}>
|
||||||
<MaterialTypeManagementDialog
|
<MaterialTypeManagementDialog
|
||||||
isOpen={isTypeDialogOpen}
|
isOpen={isTypeDialogOpen}
|
||||||
onClose={() => setIsTypeDialogOpen(false)}
|
onClose={() => setIsTypeDialogOpen(false)}
|
||||||
@@ -137,8 +140,9 @@ const CleanerPage: React.FC = () => {
|
|||||||
currentUsername={currentUsername}
|
currentUsername={currentUsername}
|
||||||
triggerRef={typeManagementButtonRef}
|
triggerRef={typeManagementButtonRef}
|
||||||
/>
|
/>
|
||||||
|
</Suspense>
|
||||||
|
|
||||||
{/* Execution Report Dialog */}
|
<Suspense fallback={null}>
|
||||||
<ExecutionReportDialog
|
<ExecutionReportDialog
|
||||||
isOpen={isReportDialogOpen}
|
isOpen={isReportDialogOpen}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
@@ -157,14 +161,16 @@ const CleanerPage: React.FC = () => {
|
|||||||
retriedOrders={reportData?.retriedOrders}
|
retriedOrders={reportData?.retriedOrders}
|
||||||
successfulRetries={reportData?.successfulRetries}
|
successfulRetries={reportData?.successfulRetries}
|
||||||
/>
|
/>
|
||||||
|
</Suspense>
|
||||||
|
|
||||||
{/* Report Viewer Dialog */}
|
<Suspense fallback={null}>
|
||||||
<ReportViewerDialog
|
<ReportViewerDialog
|
||||||
isOpen={isReportViewerOpen}
|
isOpen={isReportViewerOpen}
|
||||||
onClose={() => setIsReportViewerOpen(false)}
|
onClose={() => setIsReportViewerOpen(false)}
|
||||||
isAdmin={isAdmin}
|
isAdmin={isAdmin}
|
||||||
currentUsername={currentUsername}
|
currentUsername={currentUsername}
|
||||||
/>
|
/>
|
||||||
|
</Suspense>
|
||||||
|
|
||||||
{/* Confirmation Dialog */}
|
{/* Confirmation Dialog */}
|
||||||
{confirmDialog && <ConfirmDialog {...confirmDialog} />}
|
{confirmDialog && <ConfirmDialog {...confirmDialog} />}
|
||||||
|
|||||||
Reference in New Issue
Block a user