refactor: route console lifecycle workspace
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { lazy, Suspense } from "react";
|
||||
import { Navigate, Route, Routes } from "react-router-dom";
|
||||
import { ConsoleWorkspace } from "../workspace/ConsoleWorkspace.js";
|
||||
import { useConsoleWorkspace } from "../workspace/context.js";
|
||||
import { DiscoverRoute } from "../workspace/routes/DiscoverRoute.js";
|
||||
import { DraftDetailRoute } from "../workspace/routes/DraftDetailRoute.js";
|
||||
import { DraftIndexRoute } from "../workspace/routes/DraftIndexRoute.js";
|
||||
import { LifecycleRoute } from "../workspace/routes/LifecycleRoute.js";
|
||||
import { PresentationRoute } from "../presentation/PresentationRoute.js";
|
||||
|
||||
const PresenterRoute = lazy(() => import("../presentation/presenter/PresenterRoute.js").then((module) => ({
|
||||
@@ -17,24 +17,6 @@ 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={<Navigate to="/console/discover" replace />} />
|
||||
@@ -43,13 +25,12 @@ export const AppRoutes = () => (
|
||||
<Route path="discover" element={<DiscoverRoute />} />
|
||||
<Route path="drafts" element={<DraftIndexRoute />} />
|
||||
<Route path="drafts/:workspaceId" element={<DraftDetailRoute />} />
|
||||
<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 path="artifacts" element={<LifecycleRoute kind="artifact" />} />
|
||||
<Route path="artifacts/:artifactId/:version" element={<LifecycleRoute kind="artifact" />} />
|
||||
<Route path="deployments" element={<LifecycleRoute kind="deployment" />} />
|
||||
<Route path="deployments/:deploymentId" element={<LifecycleRoute kind="deployment" />} />
|
||||
<Route path="runs" element={<LifecycleRoute kind="run" />} />
|
||||
<Route path="runs/:runId" element={<LifecycleRoute kind="run" />} />
|
||||
</Route>
|
||||
<Route path="/present" element={<PresentationRoute />} />
|
||||
<Route path="/presenter" element={<Suspense fallback={<PresenterRouteFallback />}><PresenterRoute /></Suspense>} />
|
||||
|
||||
Reference in New Issue
Block a user