Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor(frontend): migrate project landing page and error pages to React (#19878)

Danny Xud1efecd83e8d
diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.json
index 42942aa9e8..cedc6ae5bc 100644
--- a/frontend/src/react/locales/en-US.json
+++ b/frontend/src/react/locales/en-US.json
@@ -122,6 +122,7 @@
"reorder": "Reorder",
"required-permission": "Required permissions",
"required-workspace-permission": "Following permissions are required to initialize the workspace UX",
+ "resource-not-found": "Resource not found",
"restore": "Restore",
"restored": "Restored",
"revert": "Revert",
@@ -442,6 +443,7 @@
"select": "Select environment"
},
"error-page": {
+ "go-back-home": "Go back home",
"not-found": "Not Found"
},
"export-center": {
diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.json
index f424d795d0..e366808c37 100644
--- a/frontend/src/react/locales/es-ES.json
+++ b/frontend/src/react/locales/es-ES.json
@@ -130,6 +130,7 @@
"reorder": "Reordenar",
"required-permission": "Permisos necesarios",
"required-workspace-permission": "Se requieren los siguientes permisos para inicializar el espacio de trabajo UX",
+ "resource-not-found": "Recurso no encontrado",
"restore": "Restaurar",
"restored": "Restored",
"revert": "Revertir",
@@ -442,6 +443,7 @@
"select": "Seleccionar entorno"
},
"error-page": {
+ "go-back-home": "Volver al inicio",
"not-found": "No encontrado"
},
"export-center": {
diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.json
index df2f319973..ca2041e31b 100644
--- a/frontend/src/react/locales/ja-JP.json
+++ b/frontend/src/react/locales/ja-JP.json
@@ -130,6 +130,7 @@
"reorder": "並び替え",
"required-permission": "必要な権限",
"required-workspace-permission": "ワークスペース UX の初期化には以下の権限が必要です",
+ "resource-not-found": "リソースが見つかりません",
"restore": "復元する",
"restored": "Restored",
"revert": "元に戻す",
@@ -442,6 +443,7 @@
"select": "環境を選ぶ"
},
"error-page": {
+ "go-back-home": "ホームページに戻る",
"not-found": "ページが見つかりません"
},
"export-center": {
diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.json
index a6fcef2be3..53cce924cc 100644
--- a/frontend/src/react/locales/vi-VN.json
+++ b/frontend/src/react/locales/vi-VN.json
@@ -130,6 +130,7 @@
"reorder": "Sắp xếp lại",
"required-permission": "Quyền hạn cần thiết",
"required-workspace-permission": "Các quyền sau đây cần thiết để khởi tạo không gian làm việc UX",
+ "resource-not-found": "Không tìm thấy tài nguyên",
"restore": "Khôi phục",
"restored": "Restored",
"revert": "Hoàn tác",
@@ -442,6 +443,7 @@
"select": "Chọn môi trường"
},
"error-page": {
+ "go-back-home": "Về trang chủ",
"not-found": "Không tìm thấy"
},
"export-center": {
diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.json
index 323d85e143..9b16cda04d 100644
--- a/frontend/src/react/locales/zh-CN.json
+++ b/frontend/src/react/locales/zh-CN.json
@@ -130,6 +130,7 @@
"reorder": "排序",
"required-permission": "所需权限",
"required-workspace-permission": "初始化工作空间 UX 需要以下权限",
+ "resource-not-found": "未找到请求的资源",
"restore": "恢复",
"restored": "已恢复",
"revert": "恢复",
@@ -442,6 +443,7 @@
"select": "选择环境"
},
"error-page": {
+ "go-back-home": "回到主页",
"not-found": "页面未找到"
},
"export-center": {
diff --git a/frontend/src/react/mount.ts b/frontend/src/react/mount.ts
index a45cabd0a1..8e0cb3e9f0 100644
--- a/frontend/src/react/mount.ts
+++ b/frontend/src/react/mount.ts
@@ -5,10 +5,12 @@ const projectPageLoaders = import.meta.glob("./pages/project/*.tsx");
const pluginComponentLoaders = import.meta.glob(
"./plugins/agent/components/AgentWindow.tsx"
);
+const workspacePageLoaders = import.meta.glob("./pages/workspace/*.tsx");
const pageLoaders = {
...settingsPageLoaders,
...projectPageLoaders,
...pluginComponentLoaders,
+ ...workspacePageLoaders,
};
// biome-ignore lint/suspicious/noExplicitAny: React types conflict with Vue JSX in vue-tsc
@@ -47,6 +49,7 @@ const pageDirs = [
"./pages/settings",
"./pages/project",
"./plugins/agent/components",
+ "./pages/workspace",
];
async function loadPage(name: string): Promise<ReactComponent> {
diff --git a/frontend/src/react/pages/project/ProjectLandingPage.tsx b/frontend/src/react/pages/project/ProjectLandingPage.tsx
new file mode 100644
index 0000000000..ecacea385f
--- /dev/null
+++ b/frontend/src/react/pages/project/ProjectLandingPage.tsx
@@ -0,0 +1,31 @@
+import { useEffect } from "react";
+import { router } from "@/router";
+import {
+ PROJECT_V1_ROUTE_DATABASES,
+ PROJECT_V1_ROUTE_ISSUES,
+} from "@/router/dashboard/projectV1";
+import { useProjectV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+import { hasProjectPermissionV2 } from "@/utils";
+
+export function ProjectLandingPage({ projectId }: { projectId: string }) {
+ const projectName = `${projectNamePrefix}${projectId}`;
+
+ useEffect(() => {
+ const projectStore = useProjectV1Store();
+ let cancelled = false;
+ projectStore.getOrFetchProjectByName(projectName).then((project) => {
+ if (cancelled) return;
+ if (hasProjectPermissionV2(project, "bb.issues.list")) {
+ router.replace({ name: PROJECT_V1_ROUTE_ISSUES });
+ } else {
+ router.replace({ name: PROJECT_V1_ROUTE_DATABASES });
+ }
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, [projectName]);
+
+ return <div />;
+}
diff --git a/frontend/src/react/pages/workspace/Page403.tsx b/frontend/src/react/pages/workspace/Page403.tsx
new file mode 100644
index 0000000000..b83692f923
--- /dev/null
+++ b/frontend/src/react/pages/workspace/Page403.tsx
@@ -0,0 +1,78 @@
+import { ChevronLeft, ShieldAlert } from "lucide-react";
+import { useMemo } from "react";
+import { useTranslation } from "react-i18next";
+import { Button } from "@/react/components/ui/button";
+import { router } from "@/router";
+import { WORKSPACE_ROOT_MODULE } from "@/router/dashboard/workspaceRoutes";
+import type { Permission } from "@/types";
+
+export function Page403() {
+ const { t } = useTranslation();
+
+ const query = useMemo(() => {
+ const route = router.currentRoute.value;
+ return route.query as Record<string, string | undefined>;
+ }, []);
+
+ const permissions = useMemo<Permission[]>(() => {
+ const raw = query.permissions;
+ if (raw) return raw.split(",").filter(Boolean) as Permission[];
+ return [];
+ }, [query]);
+
+ const resources = useMemo(() => {
+ const raw = query.resources;
+ if (raw) return raw.split(",").filter(Boolean);
+ return [];
+ }, [query]);
+
+ const fromPath = query.from;
+ const requestAPI = query.api;
+
+ const goHome = () => {
+ router.push({ name: WORKSPACE_ROOT_MODULE });
+ };
+
+ return (
+ <div className="mx-6 my-2">
+ <div className="rounded-md border border-red-200 bg-red-50 p-4">
+ <div className="flex items-start gap-3">
+ <ShieldAlert className="h-5 w-5 text-red-600 mt-0.5 shrink-0" />
+ <div className="flex flex-col gap-2">
+ <div className="font-medium text-red-800">
+ {t("common.missing-required-permission", { permissions: "" })}
+ </div>
+ {fromPath && <div>Path: {fromPath}</div>}
+ {requestAPI && <div>API: {requestAPI}</div>}
+ {resources.length > 0 && (
+ <div>
+ {t("common.resources")}
+ <ul className="list-disc pl-4">
+ {resources.map((r) => (
+ <li key={r}>{r}</li>
+ ))}
+ </ul>
+ </div>
+ )}
+ {permissions.length > 0 && (
+ <div>
+ {t("common.required-permission")}
+ <ul className="list-disc pl-4">
+ {permissions.map((p) => (
+ <li key={p}>{p}</li>
+ ))}
+ </ul>
+ </div>
+ )}
+ <div className="mt-2">
+ <Button variant="outline" size="sm" onClick={goHome}>
+ <ChevronLeft className="h-4 w-4" />
+ {t("error-page.go-back-home")}
+ </Button>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/frontend/src/react/pages/workspace/Page404.tsx b/frontend/src/react/pages/workspace/Page404.tsx
new file mode 100644
index 0000000000..fc9bc11da8
--- /dev/null
+++ b/frontend/src/react/pages/workspace/Page404.tsx
@@ -0,0 +1,29 @@
+import { ChevronLeft } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import logoIcon from "@/assets/logo-icon.svg";
+import { Button } from "@/react/components/ui/button";
+import { router } from "@/router";
+import { WORKSPACE_ROOT_MODULE } from "@/router/dashboard/workspaceRoutes";
+
+export function Page404() {
+ const { t } = useTranslation();
+
+ const goHome = () => {
+ router.push({ name: WORKSPACE_ROOT_MODULE });
+ };
+
+ return (
+ <div className="w-full px-4 grid place-items-center py-24">
+ <img className="w-16 h-auto opacity-80" src={logoIcon} alt="Bytebase" />
+ <p className="mt-4 text-balance text-center">
+ {t("common.resource-not-found")}
+ </p>
+ <div className="mt-12">
+ <Button variant="outline" size="sm" onClick={goHome}>
+ <ChevronLeft className="h-4 w-4" />
+ {t("error-page.go-back-home")}
+ </Button>
+ </div>
+ </div>
+ );
+}
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
index bce2206424..08c7f9644c 100644
--- a/frontend/src/router/dashboard/projectV1.ts
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -147,8 +147,11 @@ const projectV1Routes: RouteRecordRaw[] = [
path: "",
name: PROJECT_V1_ROUTE_DETAIL,
// We will check user's permission to decide the redirect page.
- component: () => import("@/views/project/ProjectLandingPage.vue"),
- props: true,
+ component: () => import("@/react/ReactPageMount.vue"),
+ props: (route: RouteLocationNormalized) => ({
+ page: "ProjectLandingPage",
+ ...route.params,
+ }),
},
{
path: "databases",
diff --git a/frontend/src/router/dashboard/workspace.ts b/frontend/src/router/dashboard/workspace.ts
index 7dcb195f9e..5c0ffed7f5 100644
--- a/frontend/src/router/dashboard/workspace.ts
+++ b/frontend/src/router/dashboard/workspace.ts
@@ -138,11 +138,11 @@ const workspaceRoutes: RouteRecordRaw[] = [
title: () => t("error-page.forbidden"),
},
components: {
- content: () => import("@/views/Page403.vue"),
+ content: () => import("@/react/ReactPageMount.vue"),
leftSidebar: () => import("@/react/ReactSidebarMount.vue"),
},
props: {
- content: true,
+ content: () => ({ page: "Page403" }),
leftSidebar: true,
},
},
@@ -153,11 +153,11 @@ const workspaceRoutes: RouteRecordRaw[] = [
title: () => t("error-page.not-found"),
},
components: {
- content: () => import("@/views/Page404.vue"),
+ content: () => import("@/react/ReactPageMount.vue"),
leftSidebar: () => import("@/react/ReactSidebarMount.vue"),
},
props: {
- content: true,
+ content: () => ({ page: "Page404" }),
leftSidebar: true,
},
},
diff --git a/frontend/src/views/Page403.vue b/frontend/src/views/Page403.vue
deleted file mode 100644
index 5b7e702a63..0000000000
--- a/frontend/src/views/Page403.vue
+++ /dev/null
@@ -1,59 +0,0 @@
-<template>
- <NoPermissionPlaceholder
- class="mx-6 my-2"
- :path="fromPath"
- :api="requestAPI"
- :resources="resources"
- :permissions="permissions"
- >
- <template #action>
- <div class="mt-2">
- <NButton size="small" @click.prevent="goHome">
- <template #icon><ChevronLeftIcon /></template>
- {{ $t("error-page.go-back-home") }}
- </NButton>
- </div>
- </template>
- </NoPermissionPlaceholder>
-</template>
-
-<script lang="ts" setup>
-import { ChevronLeftIcon } from "lucide-vue-next";
-import { NButton } from "naive-ui";
-import { computed } from "vue";
-import { useRoute, useRouter } from "vue-router";
-import NoPermissionPlaceholder from "@/components/Permission/NoPermissionPlaceholder.vue";
-import { WORKSPACE_ROOT_MODULE } from "@/router/dashboard/workspaceRoutes";
-import type { Permission } from "@/types";
-
-const route = useRoute();
-const router = useRouter();
-
-const permissions = computed<Permission[]>(() => {
- const permQuery = route.query.permissions;
- if (typeof permQuery === "string" && permQuery) {
- return permQuery.split(",").filter((r) => r) as Permission[];
- }
- return [];
-});
-
-const resources = computed(() => {
- const resources = route.query.resources;
- if (typeof resources === "string") {
- return resources.split(",").filter((r) => r);
- }
- return [];
-});
-
-const fromPath = computed(() => {
- return route.query.from as string;
-});
-
-const requestAPI = computed(() => {
- return route.query.api as string;
-});
-
-const goHome = () => {
- router.push({ name: WORKSPACE_ROOT_MODULE });
-};
-</script>
diff --git a/frontend/src/views/Page404.vue b/frontend/src/views/Page404.vue
deleted file mode 100644
index ba97fbfbcc..0000000000
--- a/frontend/src/views/Page404.vue
+++ /dev/null
@@ -1,31 +0,0 @@
-<template>
- <div class="w-full px-4 grid place-items-center py-24">
- <img
- class="w-16 h-auto opacity-80"
- src="@/assets/logo-icon.svg"
- alt="Bytebase"
- />
- <p class="mt-4 text-balance text-center">
- {{ $t("common.resource-not-found") }}
- </p>
- <div class="mt-12">
- <NButton size="small" @click.prevent="goHome">
- <template #icon><ChevronLeftIcon /></template>
- {{ $t("error-page.go-back-home") }}
- </NButton>
- </div>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { ChevronLeftIcon } from "lucide-vue-next";
-import { NButton } from "naive-ui";
-import { useRouter } from "vue-router";
-import { WORKSPACE_ROOT_MODULE } from "@/router/dashboard/workspaceRoutes";
-
-const router = useRouter();
-
-const goHome = () => {
- router.push({ name: WORKSPACE_ROOT_MODULE });
-};
-</script>
diff --git a/frontend/src/views/project/ProjectLandingPage.vue b/frontend/src/views/project/ProjectLandingPage.vue
deleted file mode 100644
index ea2e290ffe..0000000000
--- a/frontend/src/views/project/ProjectLandingPage.vue
+++ /dev/null
@@ -1,36 +0,0 @@
-<template>
- <div />
-</template>
-
-<script lang="ts" setup>
-import { computed, watchEffect } from "vue";
-import { useRouter } from "vue-router";
-import {
- PROJECT_V1_ROUTE_DATABASES,
- PROJECT_V1_ROUTE_ISSUES,
-} from "@/router/dashboard/projectV1";
-import { useProjectV1Store } from "@/store";
-import { projectNamePrefix } from "@/store/modules/v1/common";
-import { hasProjectPermissionV2 } from "@/utils";
-
-const props = defineProps<{
- projectId: string;
-}>();
-
-const projectName = computed(() => `${projectNamePrefix}${props.projectId}`);
-const projectStore = useProjectV1Store();
-const router = useRouter();
-
-watchEffect(async () => {
- const project = await projectStore.getOrFetchProjectByName(projectName.value);
- if (hasProjectPermissionV2(project, "bb.issues.list")) {
- router.replace({
- name: PROJECT_V1_ROUTE_ISSUES,
- });
- } else {
- router.replace({
- name: PROJECT_V1_ROUTE_DATABASES,
- });
- }
-});
-</script>