Skip to content

Commit 3d323fe

Browse files
committed
feat: implement ConsoleLayout and LoadingScreen components for improved app structure
1 parent 8998f51 commit 3d323fe

File tree

3 files changed

+63
-18
lines changed

3 files changed

+63
-18
lines changed

apps/console/src/App.tsx

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import { BrowserRouter, Routes, Route, Navigate, useNavigate, useLocation } from 'react-router-dom';
22
import { useState, useEffect } from 'react';
33
import { ObjectStackClient } from '@objectstack/client';
4-
import { AppShell } from '@object-ui/layout';
54
import { ObjectForm } from '@object-ui/plugin-form';
65
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '@object-ui/components';
76
import { ObjectStackDataSource } from './dataSource';
87
import appConfig from '../objectstack.config';
98

10-
// New Components
11-
import { AppSidebar } from './components/AppSidebar';
9+
// Components
10+
import { ConsoleLayout } from './components/ConsoleLayout';
11+
import { LoadingScreen } from './components/LoadingScreen';
1212
import { ObjectView } from './components/ObjectView';
13-
import { AppHeader } from './components/AppHeader';
1413
import { DashboardView } from './components/DashboardView';
1514
import { PageView } from './components/PageView';
1615

@@ -24,7 +23,6 @@ function AppContent() {
2423
const apps = appConfig.apps || [];
2524

2625
// Determine active app based on URL or default
27-
// Filter active apps and find default app
2826
const activeApps = apps.filter((a: any) => a.active !== false);
2927
const defaultApp = activeApps.find((a: any) => a.isDefault === true) || activeApps[0];
3028
const [activeAppName, setActiveAppName] = useState<string>(defaultApp?.name || 'default');
@@ -91,20 +89,15 @@ function AppContent() {
9189
}
9290
};
9391

94-
if (!client || !dataSource) return <div className="flex items-center justify-center h-screen text-muted-foreground animate-pulse">Initializing ObjectStack Console...</div>;
95-
if (!activeApp) return <div className="p-4">No Apps configured.</div>;
92+
if (!client || !dataSource) return <LoadingScreen />;
93+
if (!activeApp) return <div className="p-4 flex items-center justify-center h-screen">No Apps configured.</div>;
9694

9795
return (
98-
<AppShell
99-
sidebar={
100-
<AppSidebar
101-
activeAppName={activeAppName}
102-
onAppChange={handleAppChange}
103-
/>
104-
}
105-
navbar={
106-
<AppHeader appName={activeApp.label} objects={allObjects} />
107-
}
96+
<ConsoleLayout
97+
activeAppName={activeAppName}
98+
activeApp={activeApp}
99+
onAppChange={handleAppChange}
100+
objects={allObjects}
108101
>
109102
<Routes>
110103
<Route path="/" element={
@@ -156,7 +149,7 @@ function AppContent() {
156149
</div>
157150
</DialogContent>
158151
</Dialog>
159-
</AppShell>
152+
</ConsoleLayout>
160153
);
161154
}
162155

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react';
2+
import { AppShell } from '@object-ui/layout';
3+
import { AppSidebar } from './AppSidebar';
4+
import { AppHeader } from './AppHeader';
5+
6+
interface ConsoleLayoutProps {
7+
children: React.ReactNode;
8+
activeAppName: string;
9+
activeApp: any;
10+
onAppChange: (name: string) => void;
11+
objects: any[];
12+
}
13+
14+
export function ConsoleLayout({
15+
children,
16+
activeAppName,
17+
activeApp,
18+
onAppChange,
19+
objects
20+
}: ConsoleLayoutProps) {
21+
return (
22+
<AppShell
23+
sidebar={
24+
<AppSidebar
25+
activeAppName={activeAppName}
26+
onAppChange={onAppChange}
27+
/>
28+
}
29+
header={undefined}
30+
navbar={
31+
<AppHeader
32+
appName={activeApp?.label || activeAppName}
33+
objects={objects}
34+
/>
35+
}
36+
>
37+
{children}
38+
</AppShell>
39+
);
40+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
3+
export function LoadingScreen() {
4+
return (
5+
<div className="flex flex-col items-center justify-center h-screen bg-background">
6+
<div className="flex items-center gap-2">
7+
<div className="h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent" />
8+
<span className="text-sm text-muted-foreground">Initializing ObjectStack Console...</span>
9+
</div>
10+
</div>
11+
);
12+
}

0 commit comments

Comments
 (0)