feat: add console workspace shell
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { lazy, Suspense } from "react";
|
||||
import { Navigate, Route, Routes } from "react-router-dom";
|
||||
import { ConsoleHome } from "./ConsoleHome.js";
|
||||
import { ConsoleWorkspace } from "../workspace/ConsoleWorkspace.js";
|
||||
import { useConsoleWorkspace } from "../workspace/context.js";
|
||||
import { PresentationRoute } from "../presentation/PresentationRoute.js";
|
||||
|
||||
const PresenterRoute = lazy(() => import("../presentation/presenter/PresenterRoute.js").then((module) => ({
|
||||
@@ -13,12 +14,42 @@ const PresenterRouteFallback = () => (
|
||||
</main>
|
||||
);
|
||||
|
||||
const WorkspaceRoutePending = ({ label }: { readonly label: string }) => {
|
||||
const { connection } = useConsoleWorkspace();
|
||||
const connected = connection.phase === "connected";
|
||||
|
||||
return (
|
||||
<section className="workspace-route-pending">
|
||||
<p className="workspace-route-pending__eyebrow">Workspace route</p>
|
||||
<h1>{label}</h1>
|
||||
<p>
|
||||
{connected
|
||||
? `${label} is ready for its workflow surface.`
|
||||
: `${label} is unavailable until a workflow server is connected.`}
|
||||
</p>
|
||||
{!connected && <p>Connect a workflow server to view {label}.</p>}
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
export const AppRoutes = () => (
|
||||
<Routes>
|
||||
<Route path="/" element={<ConsoleHome />} />
|
||||
<Route path="/console" element={<ConsoleHome />} />
|
||||
<Route path="/" element={<Navigate to="/console/discover" replace />} />
|
||||
<Route path="/console" element={<ConsoleWorkspace />}>
|
||||
<Route index element={<Navigate to="discover" replace />} />
|
||||
<Route path="discover" element={<WorkspaceRoutePending label="Discover" />} />
|
||||
<Route path="drafts" element={<WorkspaceRoutePending label="Drafts" />} />
|
||||
<Route path="drafts/:workspaceId" element={<WorkspaceRoutePending label="Draft" />} />
|
||||
<Route path="artifacts" element={<WorkspaceRoutePending label="Artifacts" />} />
|
||||
<Route path="artifacts/:artifactId/:version" element={<WorkspaceRoutePending label="Artifact" />} />
|
||||
<Route path="deployments" element={<WorkspaceRoutePending label="Deployments" />} />
|
||||
<Route path="deployments/:deploymentId" element={<WorkspaceRoutePending label="Deployment" />} />
|
||||
<Route path="runs" element={<WorkspaceRoutePending label="Runs" />} />
|
||||
<Route path="runs/:runId" element={<WorkspaceRoutePending label="Run" />} />
|
||||
<Route path="results" element={<WorkspaceRoutePending label="Results" />} />
|
||||
</Route>
|
||||
<Route path="/present" element={<PresentationRoute />} />
|
||||
<Route path="/presenter" element={<Suspense fallback={<PresenterRouteFallback />}><PresenterRoute /></Suspense>} />
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
<Route path="*" element={<Navigate to="/console/discover" replace />} />
|
||||
</Routes>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user