Skip to content

Commit 5214427

Browse files
Add error boundary to global layout (#1676)
Fixes OPS-3111 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Enhanced error handling for improved application stability. * **Refactor** * Reorganized layout component structure for better maintainability. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 77df44d commit 5214427

1 file changed

Lines changed: 75 additions & 72 deletions

File tree

packages/react-ui/src/app/features/navigation/layout/global-layout.tsx

Lines changed: 75 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import { useCallback, useEffect, useState } from 'react';
88
import { Outlet, useLocation } from 'react-router-dom';
99

10+
import { OpsErrorBoundary } from '@/app/common/error-boundaries/ops-error-boundary';
1011
import { AllowOnlyLoggedInUserOnlyGuard } from '@/app/common/guards/allow-logged-in-user-only-guard';
1112
import { FronteggAuthGuard } from '@/app/common/guards/frontegg-auth-guard';
1213
import { useResizablePanelGroup } from '@/app/common/hooks/use-resizable-panel-group';
@@ -103,78 +104,80 @@ export function GlobalLayout() {
103104
}
104105

105106
return (
106-
<FronteggAuthGuard>
107-
<AllowOnlyLoggedInUserOnlyGuard>
108-
<div className="h-screen w-screen overflow-hidden">
109-
<ResizablePanelGroup
110-
direction="horizontal"
111-
id="page-container"
112-
onLayout={onResize}
113-
className="h-full"
114-
>
115-
<LeftSidebarResizablePanel
116-
minSize={
117-
isMinimized
118-
? GLOBAL_SIDEBAR_MINIMIZED_WIDTH
119-
: GLOBAL_SIDEBAR_MIN_SIZE
120-
}
121-
maxSize={
122-
isMinimized
123-
? GLOBAL_SIDEBAR_MINIMIZED_WIDTH
124-
: LEFT_SIDEBAR_MAX_SIZE
125-
}
126-
collapsedSize={
127-
isMinimized
128-
? GLOBAL_SIDEBAR_MINIMIZED_WIDTH
129-
: LEFT_SIDEBAR_MIN_SIZE
130-
}
131-
isDragging={isDragging}
132-
className={cn(
133-
LEFT_SIDEBAR_MIN_EFFECTIVE_WIDTH,
134-
'shadow-sidebar z-[12]',
135-
{
136-
'min-w-[70px] max-w-[70px]': isMinimized,
137-
},
138-
{
139-
'max-w-[400px]': !isMinimized,
140-
},
141-
)}
107+
<OpsErrorBoundary>
108+
<FronteggAuthGuard>
109+
<AllowOnlyLoggedInUserOnlyGuard>
110+
<div className="h-screen w-screen overflow-hidden">
111+
<ResizablePanelGroup
112+
direction="horizontal"
113+
id="page-container"
114+
onLayout={onResize}
115+
className="h-full"
142116
>
143-
<DashboardSideMenu />
144-
</LeftSidebarResizablePanel>
145-
146-
<ResizableHandle
147-
className="bg-transparent"
148-
disabled={isMinimized}
149-
onDragging={setIsDragging}
150-
style={{
151-
width: '0px',
152-
}}
153-
/>
154-
155-
<AiChatResizablePanel onDragging={setIsDragging} />
156-
157-
<ResizablePanel
158-
id={RESIZABLE_PANEL_IDS.MAIN}
159-
order={3}
160-
className="flex-1 h-full overflow-hidden min-w-[900px] contain-layout"
161-
defaultSize={GLOBAL_MAIN_PANEL_DEFAULT_SIZE}
162-
minSize={GLOBAL_MAIN_PANEL_MIN_SIZE}
163-
>
164-
<div className="relative h-full w-full">
165-
<AiConfigurationPrompt
166-
className={cn({
167-
'bottom-[60px]':
168-
location.pathname.startsWith('/flows/') ||
169-
location.pathname.startsWith('/runs/'),
170-
})}
171-
/>
172-
<Outlet />
173-
</div>
174-
</ResizablePanel>
175-
</ResizablePanelGroup>
176-
</div>
177-
</AllowOnlyLoggedInUserOnlyGuard>
178-
</FronteggAuthGuard>
117+
<LeftSidebarResizablePanel
118+
minSize={
119+
isMinimized
120+
? GLOBAL_SIDEBAR_MINIMIZED_WIDTH
121+
: GLOBAL_SIDEBAR_MIN_SIZE
122+
}
123+
maxSize={
124+
isMinimized
125+
? GLOBAL_SIDEBAR_MINIMIZED_WIDTH
126+
: LEFT_SIDEBAR_MAX_SIZE
127+
}
128+
collapsedSize={
129+
isMinimized
130+
? GLOBAL_SIDEBAR_MINIMIZED_WIDTH
131+
: LEFT_SIDEBAR_MIN_SIZE
132+
}
133+
isDragging={isDragging}
134+
className={cn(
135+
LEFT_SIDEBAR_MIN_EFFECTIVE_WIDTH,
136+
'shadow-sidebar z-[12]',
137+
{
138+
'min-w-[70px] max-w-[70px]': isMinimized,
139+
},
140+
{
141+
'max-w-[400px]': !isMinimized,
142+
},
143+
)}
144+
>
145+
<DashboardSideMenu />
146+
</LeftSidebarResizablePanel>
147+
148+
<ResizableHandle
149+
className="bg-transparent"
150+
disabled={isMinimized}
151+
onDragging={setIsDragging}
152+
style={{
153+
width: '0px',
154+
}}
155+
/>
156+
157+
<AiChatResizablePanel onDragging={setIsDragging} />
158+
159+
<ResizablePanel
160+
id={RESIZABLE_PANEL_IDS.MAIN}
161+
order={3}
162+
className="flex-1 h-full overflow-hidden min-w-[900px] contain-layout"
163+
defaultSize={GLOBAL_MAIN_PANEL_DEFAULT_SIZE}
164+
minSize={GLOBAL_MAIN_PANEL_MIN_SIZE}
165+
>
166+
<div className="relative h-full w-full">
167+
<AiConfigurationPrompt
168+
className={cn({
169+
'bottom-[60px]':
170+
location.pathname.startsWith('/flows/') ||
171+
location.pathname.startsWith('/runs/'),
172+
})}
173+
/>
174+
<Outlet />
175+
</div>
176+
</ResizablePanel>
177+
</ResizablePanelGroup>
178+
</div>
179+
</AllowOnlyLoggedInUserOnlyGuard>
180+
</FronteggAuthGuard>
181+
</OpsErrorBoundary>
179182
);
180183
}

0 commit comments

Comments
 (0)