Skip to content

Commit 25e887b

Browse files
committed
Dashboard and beta
1 parent 5892ab1 commit 25e887b

4 files changed

Lines changed: 57 additions & 0 deletions

File tree

src/components/shared/Settings/useFlags.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ import type { BetaFlagsStorage } from "./types";
77

88
const storage = getStorage<keyof BetaFlagsStorage, BetaFlagsStorage>();
99

10+
/**
11+
* Non-hook flag check for use outside React (e.g., route beforeLoad).
12+
*/
13+
export function isFlagEnabled(flagName: keyof typeof ExistingFlags): boolean {
14+
return (
15+
storage.getItem("betaFlags")?.[flagName] ??
16+
ExistingFlags[flagName]?.default ??
17+
false
18+
);
19+
}
20+
1021
export function useFlags() {
1122
return {
1223
getFlags: () => storage.getItem("betaFlags"),

src/flags.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,12 @@ export const ExistingFlags: ConfigFlags = {
3838
default: false,
3939
category: "beta",
4040
},
41+
42+
["dashboard"]: {
43+
name: "Dashboard",
44+
description:
45+
"Enable the new Dashboard page, a redesigned homepage experience.",
46+
default: false,
47+
category: "beta",
48+
},
4149
};

src/routes/Dashboard/Dashboard.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { BlockStack, InlineStack } from "@/components/ui/layout";
2+
import { Text } from "@/components/ui/typography";
3+
4+
export const Dashboard = () => {
5+
return (
6+
<BlockStack gap="4" className="container mx-auto w-3/4 p-4">
7+
<InlineStack align="space-between" blockAlign="center">
8+
<Text as="h1" size="xl" weight="bold">
9+
Dashboard
10+
</Text>
11+
<Text
12+
as="span"
13+
size="xs"
14+
weight="semibold"
15+
className="px-2 py-1 rounded-full bg-amber-100 text-amber-800"
16+
>
17+
Beta
18+
</Text>
19+
</InlineStack>
20+
</BlockStack>
21+
);
22+
};

src/routes/router.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import { AuthorizationResultScreen as HuggingFaceAuthorizationResultScreen } fro
1313
import { AddSecretView } from "@/components/shared/SecretsManagement/components/AddSecretView";
1414
import { ReplaceSecretView } from "@/components/shared/SecretsManagement/components/ReplaceSecretView";
1515
import { SecretsListView } from "@/components/shared/SecretsManagement/components/SecretsListView";
16+
import { isFlagEnabled } from "@/components/shared/Settings/useFlags";
1617
import { BASE_URL, IS_GITHUB_PAGES } from "@/utils/constants";
1718

1819
import RootLayout from "../components/layout/RootLayout";
20+
import { Dashboard } from "./Dashboard/Dashboard";
1921
import Editor from "./Editor";
2022
import Home from "./Home";
2123
import { ImportPage } from "./Import";
@@ -39,8 +41,10 @@ export const RUNS_BASE_PATH = "/runs";
3941
export const QUICK_START_PATH = "/quick-start";
4042
const SETTINGS_PATH = "/settings";
4143
const IMPORT_PATH = "/app/editor/import-pipeline";
44+
const DASHBOARD_PATH = "/dashboard";
4245
export const APP_ROUTES = {
4346
HOME: "/",
47+
DASHBOARD: DASHBOARD_PATH,
4448
QUICK_START: QUICK_START_PATH,
4549
IMPORT: IMPORT_PATH,
4650
PIPELINE_EDITOR: `${EDITOR_PATH}/$name`,
@@ -76,6 +80,17 @@ const indexRoute = createRoute({
7680
component: Home,
7781
});
7882

83+
const dashboardRoute = createRoute({
84+
getParentRoute: () => mainLayout,
85+
path: APP_ROUTES.DASHBOARD,
86+
component: Dashboard,
87+
beforeLoad: () => {
88+
if (!isFlagEnabled("dashboard")) {
89+
throw redirect({ to: APP_ROUTES.HOME });
90+
}
91+
},
92+
});
93+
7994
const quickStartRoute = createRoute({
8095
getParentRoute: () => mainLayout,
8196
path: APP_ROUTES.QUICK_START,
@@ -194,6 +209,7 @@ const settingsRouteTree = settingsLayoutRoute.addChildren([
194209

195210
const appRouteTree = mainLayout.addChildren([
196211
indexRoute,
212+
dashboardRoute,
197213
quickStartRoute,
198214
settingsRouteTree,
199215
importRoute,

0 commit comments

Comments
 (0)