Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor(frontend): migrate project sidebar to React (#19863)
Danny Xu6d3604ff6206
diff --git a/.sonarcloud.properties b/.sonarcloud.propertiesindex 36617e2e94..c2c81c8834 100644--- a/.sonarcloud.properties+++ b/.sonarcloud.properties@@ -81,4 +81,5 @@ sonar.cpd.exclusions=\backend/plugin/db/**,\frontend/src/**/*.test.ts,\frontend/src/**/*.test.tsx,\+ frontend/src/react/mount*.ts,\proto/gen/**diff --git a/frontend/src/components/Project/ProjectSidebarV1.vue b/frontend/src/components/Project/ProjectSidebarV1.vuedeleted file mode 100644index 419b45fd62..0000000000--- a/frontend/src/components/Project/ProjectSidebarV1.vue+++ /dev/null@@ -1,61 +0,0 @@-<template>- <CommonSidebar- :key="'project'"- :item-list="projectSidebarItemList"- :get-item-class="getItemClass"- :logo-redirect="PROJECT_V1_ROUTE_DETAIL"- @select="onSelect"- />-</template>--<script setup lang="ts">-import { useRouter } from "vue-router";-import CommonSidebar from "@/components/v2/Sidebar/CommonSidebar.vue";-import type { SidebarItem } from "@/components/v2/Sidebar/type";-import { PROJECT_V1_ROUTE_DETAIL } from "@/router/dashboard/projectV1";-import { useRecentVisit } from "@/router/useRecentVisit";-import { useCurrentProjectV1 } from "@/store";-import { getProjectName } from "@/store/modules/v1/common";-import { useProjectSidebar } from "./useProjectSidebar";--defineProps<{- projectId?: string;- instanceId?: string;- databaseName?: string;- changelogId?: string;-}>();--const router = useRouter();-const { record } = useRecentVisit();--const { project } = useCurrentProjectV1();--const { projectSidebarItemList, checkIsActive } = useProjectSidebar(project);--const getItemClass = (item: SidebarItem) => {- const list = ["outline-item"];- if (checkIsActive(item)) {- list.push("router-link-active", "bg-link-hover");- }- return list;-};--const onSelect = (item: SidebarItem, e: MouseEvent | undefined) => {- if (!item.path) {- return;- }- const route = router.resolve({- name: item.path,- params: {- projectId: getProjectName(project.value.name),- },- });- record(route.fullPath);-- if (e?.ctrlKey || e?.metaKey) {- window.open(route.fullPath, "_blank");- } else {- router.push(route);- }-};-</script>diff --git a/frontend/src/components/Project/useProjectSidebar.ts b/frontend/src/components/Project/useProjectSidebar.tsdeleted file mode 100644index 937b1b5ee3..0000000000--- a/frontend/src/components/Project/useProjectSidebar.ts+++ /dev/null@@ -1,215 +0,0 @@-import {- CircleDot,- Database,- Settings,- ShieldCheck,- Users,- Workflow,-} from "lucide-vue-next";-import { computed, h, type MaybeRef, unref } from "vue";-import { useRoute } from "vue-router";-import type { SidebarItem } from "@/components/v2/Sidebar/type";-import { t } from "@/plugins/i18n";-import {- PROJECT_V1_ROUTE_ACCESS_GRANTS,- PROJECT_V1_ROUTE_AUDIT_LOGS,- PROJECT_V1_ROUTE_DATABASE_GROUPS,- PROJECT_V1_ROUTE_DATABASES,- PROJECT_V1_ROUTE_EXPORT_CENTER,- PROJECT_V1_ROUTE_GITOPS,- PROJECT_V1_ROUTE_ISSUES,- PROJECT_V1_ROUTE_MASKING_EXEMPTION,- PROJECT_V1_ROUTE_MEMBERS,- PROJECT_V1_ROUTE_PLANS,- PROJECT_V1_ROUTE_RELEASES,- PROJECT_V1_ROUTE_SERVICE_ACCOUNTS,- PROJECT_V1_ROUTE_SETTINGS,- PROJECT_V1_ROUTE_SYNC_SCHEMA,- PROJECT_V1_ROUTE_WEBHOOKS,- PROJECT_V1_ROUTE_WORKLOAD_IDENTITIES,-} from "@/router/dashboard/projectV1";-import { isDefaultProject } from "@/types";-import type { Project } from "@/types/proto-es/v1/project_service_pb";--interface ProjectSidebarItem extends SidebarItem {- title: string;- type: "div";- hide?: boolean;- children?: ProjectSidebarItem[];-}--export const useProjectSidebar = (project: MaybeRef<Project>) => {- const route = useRoute();-- const isDefault = computed((): boolean => {- return isDefaultProject(unref(project).name);- });-- const projectSidebarItemList = computed((): ProjectSidebarItem[] => {- const cicdRoutes: ProjectSidebarItem[] = [- {- title: "CI/CD",- icon: () => h(Workflow),- type: "div",- expand: true,- hide: isDefault.value,- children: [- {- title: t("plan.plans"),- path: PROJECT_V1_ROUTE_PLANS,- type: "div",- },- {- title: t("release.releases"),- path: PROJECT_V1_ROUTE_RELEASES,- type: "div",- },- {- title: t("gitops.self"),- path: PROJECT_V1_ROUTE_GITOPS,- type: "div",- },- ],- },- ];-- const databaseRoutes: ProjectSidebarItem[] = [- {- title: t("common.database"),- icon: () => h(Database),- type: "div",- expand: true,- children: [- {- title: t("common.databases"),- path: PROJECT_V1_ROUTE_DATABASES,- type: "div",- },- {- title: t("common.groups"),- path: PROJECT_V1_ROUTE_DATABASE_GROUPS,- type: "div",- },- {- title: t("database.sync-schema.title"),- path: PROJECT_V1_ROUTE_SYNC_SCHEMA,- type: "div",- },- ],- },- ];-- const sidebarList: ProjectSidebarItem[] = [- {- title: t("common.issues"),- path: PROJECT_V1_ROUTE_ISSUES,- icon: () => h(CircleDot),- type: "div",- hide: isDefault.value,- },- ...cicdRoutes,- ...databaseRoutes,- {- title: t("settings.sidebar.data-access"),- icon: () => h(ShieldCheck),- type: "div",- hide: isDefault.value,- expand: true,- children: [- {- title: t("sql-editor.access-grants"),- path: PROJECT_V1_ROUTE_ACCESS_GRANTS,- type: "div",- },- {- title: t("project.masking-exemption.self"),- path: PROJECT_V1_ROUTE_MASKING_EXEMPTION,- type: "div",- },- {- title: t("export-center.data-export"),- path: PROJECT_V1_ROUTE_EXPORT_CENTER,- type: "div",- },- ],- },- {- title: t("common.manage"),- icon: () => h(Users),- type: "div",- hide: isDefault.value,- expand: true,- children: [- {- title: t("common.members", 2 /* multiply*/),- path: PROJECT_V1_ROUTE_MEMBERS,- type: "div",- },- {- title: t("settings.members.service-accounts"),- path: PROJECT_V1_ROUTE_SERVICE_ACCOUNTS,- type: "div",- },- {- title: t("settings.members.workload-identities"),- path: PROJECT_V1_ROUTE_WORKLOAD_IDENTITIES,- type: "div",- },- {- title: t("common.webhooks"),- path: PROJECT_V1_ROUTE_WEBHOOKS,- type: "div",- },- {- title: t("settings.sidebar.audit-log"),- path: PROJECT_V1_ROUTE_AUDIT_LOGS,- type: "div",- },- ],- },- {- title: t("common.setting"),- icon: () => h(Settings),- path: PROJECT_V1_ROUTE_SETTINGS,- type: "div",- hide: isDefault.value,- },- ];-- return sidebarList;- });-- const flattenNavigationItems = computed(() => {- return projectSidebarItemList.value.flatMap<ProjectSidebarItem>((item) => {- if (item.children && item.children.length > 0) {- return item.children.map((child) => ({- ...child,- hide: item.hide || child.hide,- }));- }- return item;- });- });-- const checkIsActive = (item: SidebarItem) => {- const { name: current } = route;- const currentRoute = current?.toString() ?? "";- const isActiveRoute =- item.path === currentRoute || currentRoute.startsWith(`${item.path}.`);-- return isActiveRoute;- };-- const activeSidebar = computed(() => {- return flattenNavigationItems.value- .filter((item) => !item.hide && item.path)- .find((item) => checkIsActive(item));- });-- return {- projectSidebarItemList,- flattenNavigationItems,- activeSidebar,- checkIsActive,- };-};diff --git a/frontend/src/components/v2/Sidebar/CommonSidebar.vue b/frontend/src/components/v2/Sidebar/CommonSidebar.vuedeleted file mode 100644index 2b3850ae69..0000000000--- a/frontend/src/components/v2/Sidebar/CommonSidebar.vue+++ /dev/null@@ -1,216 +0,0 @@-<template>- <nav- class="flex-1 flex flex-col overflow-y-hidden border-r border-block-border"- >- <BytebaseLogo- v-if="showLogo"- class="p-2 shrink-0 m-auto"- :redirect="logoRedirect"- />- <slot name="prefix" />- <NScrollbar>- <div class="flex-1 px-2.5 flex flex-col gap-y-1">- <div v-for="(item, i) in filteredSidebarList" :key="i">- <router-link- v-if="item.type === 'route'"- :to="{ path: item.path, name: item.name }"- :class="[parentRouteClass, getItemClass(item)]"- >- <component :is="item.icon" class="mr-2 w-5 h-5 text-gray-500" />- {{ item.title }}- </router-link>- <div- v-else-if="item.type === 'div'"- :class="[parentRouteClass, getItemClass(item)]"- @click="onClick(item, `${i}`, $event)"- >- <component :is="item.icon" class="mr-2 w-5 h-5 text-gray-500" />- {{ item.title }}- <div v-if="item.children.length > 0" class="ml-auto text-gray-500">- <ChevronRight- v-if="!state.expandedSidebar.has(`${i}`)"- class="w-4 h-4"- />- <ChevronDown v-else class="w-4 h-4" />- </div>- </div>- <a- v-if="item.type === 'link'"- :class="[parentRouteClass, getItemClass(item)]"- :href="item.path"- @click="$emit('select', item, $event)"- >- <component :is="item.icon" class="mr-2 w-5 h-5 text-gray-500" />- {{ item.title }}- </a>- <div- v-else-if="item.type === 'divider'"- class="border-t border-gray-300 my-2.5 mr-4 ml-2"- />- <div- v-if="item.children.length > 0 && state.expandedSidebar.has(`${i}`)"- class="flex flex-col gap-y-1 mt-1"- >- <template v-for="(child, j) in item.children" :key="`${i}-${j}`">- <a- v-if="child.type === 'link'"- :class="[childRouteClass, getItemClass(child)]"- :href="child.path"- @click="$emit('select', child, $event)"- >- {{ child.title }}- </a>- <router-link- v-else-if="child.type === 'route'"- :to="{ path: child.path, name: child.name }"- :class="[childRouteClass, getItemClass(child)]"- >- {{ child.title }}- </router-link>- <div- v-else-if="child.type === 'div'"- :class="[childRouteClass, getItemClass(child)]"- @click="onClick(child, `${i}-${j}`, $event)"- >- {{ child.title }}- </div>- </template>- </div>- </div>- </div>- </NScrollbar>- </nav>-</template>--<script setup lang="ts">-import { ChevronDown, ChevronRight } from "lucide-vue-next";-import { NScrollbar } from "naive-ui";-import { computed, reactive, watch } from "vue";-import { useRoute } from "vue-router";-import BytebaseLogo from "@/components/BytebaseLogo.vue";-import type { SidebarItem } from "./type";--interface LocalState {- expandedSidebar: Set<string>;-}--const props = withDefaults(- defineProps<{- itemList: SidebarItem[];- showLogo?: boolean;- logoRedirect?: string;- getItemClass?: (item: SidebarItem) => string[];- }>(),- {- showLogo: true,- logoRedirect: "",- getItemClass: (_: SidebarItem) => [],- }-);--const emit = defineEmits<{- (event: "select", item: SidebarItem, e: MouseEvent): void;-}>();--const state = reactive<LocalState>({- expandedSidebar: new Set(),-});--// Track groups auto-expanded by route so we can collapse them on navigation-// without collapsing groups the user manually opened.-const autoExpanded = new Set<string>();-// Track groups the user has manually toggled — never override these.-const manualToggled = new Set<string>();--const parentRouteClass = computed(() => {- return "group flex items-center px-2 py-1.5 leading-normal font-medium rounded-md text-gray-700 outline-item text-sm!";-});--const childRouteClass = computed(() => {- return "group w-full flex items-center pl-9 pr-2 py-1 outline-item mb-0.5 rounded-md";-});--const filteredSidebarList = computed(() => {- return props.itemList- .map((item) => ({- ...item,- children: (item.children ?? []).filter((child) => !child.hide),- }))- .filter((item) => {- if (item.type === "divider") {- return true;- }- if (item.hide) {- return false;- }- if (item.children.length > 0) {- return true;- }- if (item.type === "div" || item.type === "link") {- return !!item.path;- }- return !!item.path || !!item.name;- });-});--const currentRoute = useRoute();--const expandForActiveRoute = () => {- // Remove previous auto-expansions (preserve manual ones)- for (const key of autoExpanded) {- state.expandedSidebar.delete(key);- }- autoExpanded.clear();- for (let i = 0; i < filteredSidebarList.value.length; i++) {- const item = filteredSidebarList.value[i];- const key = `${i}`;- if (item.children.length === 0) continue;- // Never override groups the user has manually toggled.- if (manualToggled.has(key)) continue;- if (item.expand) {- state.expandedSidebar.add(key);- continue;- }- // Use getItemClass to detect active children — it handles all- // route aliases (e.g. user-profile → users).- const hasActiveChild = item.children.some(- (child) => props.getItemClass(child).length > 0- );- if (hasActiveChild && !state.expandedSidebar.has(key)) {- state.expandedSidebar.add(key);- autoExpanded.add(key);- }- }-};--watch(- () => filteredSidebarList.value,- () => {- state.expandedSidebar.clear();- manualToggled.clear();- expandForActiveRoute();- },- { immediate: true }-);--watch(- () => currentRoute.name,- () => {- expandForActiveRoute();- }-);--const onClick = (sidebar: SidebarItem, key: string, e: MouseEvent) => {- if (sidebar.path) {- return emit("select", sidebar, e);- }- // Mark as manually toggled so route changes won't fight user intent.- manualToggled.add(key);- autoExpanded.delete(key);- if (state.expandedSidebar.has(key)) {- state.expandedSidebar.delete(key);- } else {- state.expandedSidebar.add(key);- }-};-</script>diff --git a/frontend/src/components/v2/Sidebar/WorkspaceSwitcher.vue b/frontend/src/components/v2/Sidebar/WorkspaceSwitcher.vuedeleted file mode 100644index 307344e349..0000000000--- a/frontend/src/components/v2/Sidebar/WorkspaceSwitcher.vue+++ /dev/null@@ -1,45 +0,0 @@-<template>- <div v-if="workspaceStore.workspaceList.length > 1" class="px-2.5 pb-2">- <NPopselect- :value="currentWorkspaceName"- :options="workspaceOptions"- trigger="click"- @update:value="onSwitch"- >- <button- class="w-full flex items-center gap-x-2 px-2 py-1.5 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-100 cursor-pointer"- >- <Building2 class="w-4 h-4 text-gray-500 shrink-0" />- <span class="truncate flex-1 text-left">- {{ workspaceStore.currentWorkspace?.title }}- </span>- <ChevronsUpDown class="w-3.5 h-3.5 text-gray-400 shrink-0" />- </button>- </NPopselect>- </div>-</template>--<script lang="ts" setup>-import { Building2, ChevronsUpDown } from "lucide-vue-next";-import { NPopselect } from "naive-ui";-import { computed } from "vue";-import { useWorkspaceV1Store } from "@/store";--const workspaceStore = useWorkspaceV1Store();--const currentWorkspaceName = computed(- () => workspaceStore.currentWorkspace?.name ?? ""-);--const workspaceOptions = computed(() =>- workspaceStore.workspaceList.map((ws) => ({- label: ws.title,- value: ws.name,- }))-);--const onSwitch = (workspaceName: string) => {- if (workspaceName === currentWorkspaceName.value) return;- workspaceStore.switchWorkspace(workspaceName);-};-</script>diff --git a/frontend/src/components/v2/Sidebar/type.ts b/frontend/src/components/v2/Sidebar/type.tsdeleted file mode 100644index a6cc01c9f2..0000000000--- a/frontend/src/components/v2/Sidebar/type.ts+++ /dev/null@@ -1,14 +0,0 @@-import type { VNode } from "vue";--export interface SidebarItem {- title?: string;- // If the type is route, we'd like to use the name instead of the path- name?: string;- // path is required if the type is div or link- path?: string;- icon?: () => VNode;- hide?: boolean;- type: "route" | "div" | "divider" | "link";- expand?: boolean;- children?: SidebarItem[];-}diff --git a/frontend/src/react/ReactProjectSidebarMount.vue b/frontend/src/react/ReactProjectSidebarMount.vuenew file mode 100644index 0000000000..4474d475c3--- /dev/null+++ b/frontend/src/react/ReactProjectSidebarMount.vue@@ -0,0 +1,34 @@+<template>+ <div ref="container" class="h-full" />+</template>++<script lang="ts" setup>+defineOptions({ inheritAttrs: false });++import { onMounted, onUnmounted, ref, watch } from "vue";+import { useI18n } from "vue-i18n";++const container = ref<HTMLElement>();+// biome-ignore lint/suspicious/noExplicitAny: React Root type from dynamic import+let root: any = null; // eslint-disable-line @typescript-eslint/no-explicit-any+const { locale } = useI18n();++async function render() {+ if (!container.value) return;+ const { mountProjectSidebar, updateProjectSidebarLocale } = await import(+ "./mountProjectSidebar"+ );+ if (!root) {+ root = await mountProjectSidebar(container.value, locale.value);+ } else {+ await updateProjectSidebarLocale(root, locale.value);+ }+}++onMounted(() => render());+watch(locale, () => render());+onUnmounted(() => {+ root?.unmount();+ root = null;+});+</script>diff --git a/frontend/src/react/components/ProjectSidebar.tsx b/frontend/src/react/components/ProjectSidebar.tsxnew file mode 100644index 0000000000..90baba1d88--- /dev/null+++ b/frontend/src/react/components/ProjectSidebar.tsx@@ -0,0 +1,482 @@+import {+ ChevronDown,+ ChevronRight,+ CircleDot,+ Database,+ Settings,+ ShieldCheck,+ Users,+ Workflow,+} from "lucide-react";+import type { ElementType } from "react";+import { useCallback, useEffect, useMemo, useRef, useState } from "react";+import { useTranslation } from "react-i18next";+import { effectScope } from "vue";+import logoFull from "@/assets/logo-full.svg";+import { useVueState } from "@/react/hooks/useVueState";+import { router } from "@/router";+import {+ PROJECT_V1_ROUTE_ACCESS_GRANTS,+ PROJECT_V1_ROUTE_AUDIT_LOGS,+ PROJECT_V1_ROUTE_DATABASE_GROUPS,+ PROJECT_V1_ROUTE_DATABASES,+ PROJECT_V1_ROUTE_DETAIL,+ PROJECT_V1_ROUTE_EXPORT_CENTER,+ PROJECT_V1_ROUTE_GITOPS,+ PROJECT_V1_ROUTE_ISSUES,+ PROJECT_V1_ROUTE_MASKING_EXEMPTION,+ PROJECT_V1_ROUTE_MEMBERS,+ PROJECT_V1_ROUTE_PLANS,+ PROJECT_V1_ROUTE_RELEASES,+ PROJECT_V1_ROUTE_SERVICE_ACCOUNTS,+ PROJECT_V1_ROUTE_SETTINGS,+ PROJECT_V1_ROUTE_SYNC_SCHEMA,+ PROJECT_V1_ROUTE_WEBHOOKS,+ PROJECT_V1_ROUTE_WORKLOAD_IDENTITIES,+} from "@/router/dashboard/projectV1";+import { useRecentVisit } from "@/router/useRecentVisit";+import {+ useActuatorV1Store,+ useProjectV1Store,+ useWorkspaceV1Store,+} from "@/store";+import { getProjectName, projectNamePrefix } from "@/store/modules/v1/common";++// ---------------------------------------------------------------------------+// Types+// ---------------------------------------------------------------------------++interface SidebarItem {+ title: string;+ path?: string;+ icon?: ElementType;+ hide?: boolean;+ type: "div";+ expand?: boolean;+ children?: SidebarItem[];+}++// ---------------------------------------------------------------------------+// Active-route detection+// ---------------------------------------------------------------------------++function getItemClass(item: SidebarItem, currentRouteName: string): string[] {+ const isActive =+ item.path === currentRouteName ||+ currentRouteName.startsWith(`${item.path}.`);+ if (isActive) {+ return ["router-link-active", "bg-link-hover"];+ }+ return [];+}++// ---------------------------------------------------------------------------+// Sidebar item list builder+// ---------------------------------------------------------------------------++function useSidebarItems(): SidebarItem[] {+ const { t } = useTranslation();++ const isDefault = useVueState(() => {+ const projectId =+ (router.currentRoute.value.params.projectId as string | undefined) ?? "";+ const projectName = projectId ? `${projectNamePrefix}${projectId}` : "";+ const defaultProject =+ useActuatorV1Store().serverInfo?.defaultProject ?? "";+ return !!defaultProject && projectName === defaultProject;+ });++ return useMemo(+ (): SidebarItem[] => [+ {+ title: t("common.issues"),+ path: PROJECT_V1_ROUTE_ISSUES,+ icon: CircleDot,+ type: "div",+ hide: isDefault,+ },+ {+ title: "CI/CD",+ icon: Workflow,+ type: "div",+ expand: true,+ hide: isDefault,+ children: [+ {+ title: t("plan.plans"),+ path: PROJECT_V1_ROUTE_PLANS,+ type: "div",+ },+ {+ title: t("release.releases"),+ path: PROJECT_V1_ROUTE_RELEASES,+ type: "div",+ },+ {+ title: t("gitops.self"),+ path: PROJECT_V1_ROUTE_GITOPS,+ type: "div",+ },+ ],+ },+ {+ title: t("common.database"),+ icon: Database,+ type: "div",+ expand: true,+ children: [+ {+ title: t("common.databases"),+ path: PROJECT_V1_ROUTE_DATABASES,+ type: "div",+ },+ {+ title: t("common.groups"),+ path: PROJECT_V1_ROUTE_DATABASE_GROUPS,+ type: "div",+ },+ {+ title: t("database.sync-schema.title"),+ path: PROJECT_V1_ROUTE_SYNC_SCHEMA,+ type: "div",+ },+ ],+ },+ {+ title: t("settings.sidebar.data-access"),+ icon: ShieldCheck,+ type: "div",+ hide: isDefault,+ expand: true,+ children: [+ {+ title: t("sql-editor.access-grants"),+ path: PROJECT_V1_ROUTE_ACCESS_GRANTS,+ type: "div",+ },+ {+ title: t("project.masking-exemption.self"),+ path: PROJECT_V1_ROUTE_MASKING_EXEMPTION,+ type: "div",+ },+ {+ title: t("export-center.data-export"),+ path: PROJECT_V1_ROUTE_EXPORT_CENTER,+ type: "div",+ },+ ],+ },+ {+ title: t("common.manage"),+ icon: Users,+ type: "div",+ hide: isDefault,+ expand: true,+ children: [+ {+ title: t("common.members", { count: 2 }),+ path: PROJECT_V1_ROUTE_MEMBERS,+ type: "div",+ },+ {+ title: t("settings.members.service-accounts"),+ path: PROJECT_V1_ROUTE_SERVICE_ACCOUNTS,+ type: "div",+ },+ {+ title: t("settings.members.workload-identities"),+ path: PROJECT_V1_ROUTE_WORKLOAD_IDENTITIES,+ type: "div",+ },+ {+ title: t("common.webhooks"),+ path: PROJECT_V1_ROUTE_WEBHOOKS,+ type: "div",+ },+ {+ title: t("settings.sidebar.audit-log"),+ path: PROJECT_V1_ROUTE_AUDIT_LOGS,+ type: "div",+ },+ ],+ },+ {+ title: t("common.setting"),+ icon: Settings,+ path: PROJECT_V1_ROUTE_SETTINGS,+ type: "div",+ hide: isDefault,+ },+ ],+ [t, isDefault]+ );+}++// ---------------------------------------------------------------------------+// Filter logic+// ---------------------------------------------------------------------------++function filterSidebarList(items: SidebarItem[]): SidebarItem[] {+ return items+ .map((item) => ({+ ...item,+ children: (item.children ?? []).filter((child) => !child.hide),+ }))+ .filter((item) => {+ if (item.hide) return false;+ if (item.children && item.children.length > 0) return true;+ return !!item.path;+ });+}++// ---------------------------------------------------------------------------+// Component+// ---------------------------------------------------------------------------++const parentRouteClass =+ "group flex items-center px-2 py-1.5 leading-normal font-medium rounded-md text-gray-700 outline-item text-sm!";+const childRouteClass =+ "group w-full flex items-center pl-9 pr-2 py-1 outline-item mb-0.5 rounded-md";++export function ProjectSidebar() {+ const rawItems = useSidebarItems();+ const filteredItems = useMemo(() => filterSidebarList(rawItems), [rawItems]);++ const currentRouteName = useVueState(+ () => router.currentRoute.value.name?.toString() ?? ""+ );++ const projectId = useVueState(+ () =>+ (router.currentRoute.value.params.projectId as string | undefined) ?? ""+ );++ const customLogo = useVueState(+ () => useWorkspaceV1Store().currentWorkspace?.logo ?? ""+ );++ const projectStore = useProjectV1Store();++ // Create a Vue effectScope so we can call the Vue composable useRecentVisit.+ const recordVisitRef = useRef<((path: string) => void) | null>(null);+ useEffect(() => {+ const scope = effectScope();+ scope.run(() => {+ const { record } = useRecentVisit();+ recordVisitRef.current = record;+ });+ return () => scope.stop();+ }, []);++ // Ensure the project is fetched into the store cache.+ // ProjectV1Layout also fetches it, but this guards against race conditions.+ useEffect(() => {+ if (projectId) {+ projectStore.getOrFetchProjectByName(+ `${projectNamePrefix}${projectId}`,+ true+ );+ }+ }, [projectId, projectStore]);++ const project = useVueState(() => {+ const pid =+ (router.currentRoute.value.params.projectId as string | undefined) ?? "";+ const projectName = pid ? `${projectNamePrefix}${pid}` : "";+ return projectStore.getProjectByName(projectName);+ });++ // -- Expand / collapse state -----------------------------------------------+ const [expandedSet, setExpandedSet] = useState<Set<string>>(new Set());+ const manualToggledRef = useRef<Set<string>>(new Set());+ const autoExpandedRef = useRef<Set<string>>(new Set());+ const prevFilteredRef = useRef<SidebarItem[] | null>(null);++ const expandForActiveRoute = useCallback(+ (items: SidebarItem[]) => {+ setExpandedSet((prev) => {+ const next = new Set(prev);++ for (const key of autoExpandedRef.current) {+ next.delete(key);+ }+ autoExpandedRef.current.clear();++ for (let i = 0; i < items.length; i++) {+ const item = items[i];+ const key = `${i}`;+ if (!item.children || item.children.length === 0) continue;+ if (manualToggledRef.current.has(key)) continue;+ if (item.expand) {+ next.add(key);+ continue;+ }+ const hasActiveChild = item.children.some(+ (child) => getItemClass(child, currentRouteName).length > 0+ );+ if (hasActiveChild && !next.has(key)) {+ next.add(key);+ autoExpandedRef.current.add(key);+ }+ }++ return next;+ });+ },+ [currentRouteName]+ );++ useEffect(() => {+ if (prevFilteredRef.current !== filteredItems) {+ prevFilteredRef.current = filteredItems;+ manualToggledRef.current.clear();+ autoExpandedRef.current.clear();+ setExpandedSet(new Set());+ }+ }, [filteredItems]);++ useEffect(() => {+ expandForActiveRoute(filteredItems);+ }, [currentRouteName, filteredItems, expandForActiveRoute]);++ // -- Navigation ------------------------------------------------------------++ const navigateToHome = useCallback(() => {+ router.push({+ name: PROJECT_V1_ROUTE_DETAIL,+ params: { projectId },+ });+ }, [projectId]);++ const onGroupClick = useCallback((item: SidebarItem, key: string) => {+ if (item.children && item.children.length > 0) {+ manualToggledRef.current.add(key);+ autoExpandedRef.current.delete(key);+ setExpandedSet((prev) => {+ const next = new Set(prev);+ if (next.has(key)) {+ next.delete(key);+ } else {+ next.add(key);+ }+ return next;+ });+ }+ }, []);++ const resolveHref = useCallback(+ (path: string) =>+ router.resolve({+ name: path,+ params: { projectId: getProjectName(project.name) },+ }).fullPath,+ [project.name]+ );++ const handleItemClick = useCallback(+ (e: React.MouseEvent, path: string) => {+ const route = router.resolve({+ name: path,+ params: { projectId: getProjectName(project.name) },+ });+ recordVisitRef.current?.(route.fullPath);+ if (e.ctrlKey || e.metaKey) {+ // Let the browser's native <a> Ctrl/Meta-click handle new-tab opening.+ return;+ }+ e.preventDefault();+ router.push(route);+ },+ [project.name]+ );++ // -- Logo ------------------------------------------------------------------++ const logoSrc = customLogo || logoFull;++ // -- Render ----------------------------------------------------------------++ const renderChildren = (children: SidebarItem[], parentIndex: number) => {+ return (+ <div className="flex flex-col gap-y-1 mt-1">+ {children.map((child, j) => {+ const classes = getItemClass(child, currentRouteName);+ if (child.path) {+ return (+ <a+ key={`${parentIndex}-${j}`}+ href={resolveHref(child.path)}+ className={`${childRouteClass} cursor-pointer no-underline text-inherit ${classes.join(" ")}`}+ onClick={(e) => handleItemClick(e, child.path!)}+ >+ {child.title}+ </a>+ );+ }+ return null;+ })}+ </div>+ );+ };++ const renderItem = (item: SidebarItem, index: number) => {+ const key = `${index}`;+ const Icon = item.icon;+ const hasChildren = item.children && item.children.length > 0;+ const isExpanded = expandedSet.has(key);++ // Leaf item (no children) — navigable+ if (!hasChildren && item.path) {+ const classes = getItemClass(item, currentRouteName);+ return (+ <a+ key={index}+ href={resolveHref(item.path)}+ className={`${parentRouteClass} cursor-pointer no-underline text-inherit ${classes.join(" ")}`}+ onClick={(e) => handleItemClick(e, item.path!)}+ >+ {Icon && <Icon className="mr-2 w-5 h-5 text-gray-500" />}+ {item.title}+ </a>+ );+ }++ // Group item with children+ const classes = getItemClass(item, currentRouteName);+ return (+ <div key={index}>+ <div+ className={`${parentRouteClass} cursor-pointer ${classes.join(" ")}`}+ onClick={() => onGroupClick(item, key)}+ >+ {Icon && <Icon className="mr-2 w-5 h-5 text-gray-500" />}+ {item.title}+ {hasChildren && (+ <div className="ml-auto text-gray-500">+ {isExpanded ? (+ <ChevronDown className="w-4 h-4" />+ ) : (+ <ChevronRight className="w-4 h-4" />+ )}+ </div>+ )}+ </div>+ {hasChildren && isExpanded && renderChildren(item.children!, index)}+ </div>+ );+ };++ return (+ <nav className="flex-1 flex flex-col overflow-y-hidden border-r border-block-border">+ <div+ className="p-2 shrink-0 m-auto cursor-pointer"+ onClick={navigateToHome}+ >+ <img src={logoSrc} alt="Bytebase" className="max-w-44" />+ </div>+ <div className="flex-1 overflow-y-auto px-2.5 flex flex-col gap-y-1">+ {filteredItems.map((item, i) => renderItem(item, i))}+ </div>+ </nav>+ );+}diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.jsonindex aa23317cf3..666ef92d7c 100644--- a/frontend/src/react/locales/en-US.json+++ b/frontend/src/react/locales/en-US.json@@ -195,7 +195,11 @@"view-details": "View Details","warning": "Warning","you": "you",- "email-ascii-only": "Email addresses only support ASCII characters (letters, numbers, and symbols like . _ - +)."+ "email-ascii-only": "Email addresses only support ASCII characters (letters, numbers, and symbols like . _ - +).",+ "issues": "Issues",+ "manage": "Manage",+ "setting": "Setting",+ "webhooks": "Webhooks"},"create-db": {"cluster": "Cluster",@@ -289,7 +293,10 @@"transfer-project": "Transfer Project","unassign": "Unassign","unassign-alert-description": "The selected databases will be removed from the project",- "unassign-alert-title": "Unassign databases"+ "unassign-alert-title": "Unassign databases",+ "sync-schema": {+ "title": "Sync Schema"+ }},"database-group": {"condition": {@@ -354,7 +361,8 @@},"workload-identity": {"select-placeholder": "Select a workload identity"- }+ },+ "self": "GitOps"},"identity-provider": {"claims-description": "The following claims were returned by the identity provider. This information can help you configure field mappings.",@@ -575,6 +583,9 @@"test-webhook": "Test Webhook","triggering-activity": "Triggering activities","webhook-url": "Webhook URL"+ },+ "masking-exemption": {+ "self": "Masking Exemptions"}},"quick-action": {@@ -1146,7 +1157,8 @@"revoke-access": "Revoke","revoke-confirm": "Are you sure you want to revoke this access grant?","self": "SQL Editor",- "view-issue": "View Issue"+ "view-issue": "View Issue",+ "access-grants": "Access Grants"},"sql-review": {"add-or-remove-rules": "Add or remove rules",@@ -1329,5 +1341,14 @@"description": "Copy the code and enter it in your TOTP app manually.","self": "Your two-factor secret"}+ },+ "export-center": {+ "data-export": "Data Export"+ },+ "plan": {+ "plans": "Plans"+ },+ "release": {+ "releases": "Releases"}}diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.jsonindex e3be2c182f..6142c14686 100644--- a/frontend/src/react/locales/es-ES.json+++ b/frontend/src/react/locales/es-ES.json@@ -195,7 +195,11 @@"view-details": "Ver Detalles","warning": "Advertencia","you": "tu",- "email-ascii-only": "Las direcciones de correo solo admiten caracteres ASCII (letras, números y símbolos como . _ - +)."+ "email-ascii-only": "Las direcciones de correo solo admiten caracteres ASCII (letras, números y símbolos como . _ - +).",+ "issues": "Incidencias",+ "manage": "Administrar",+ "setting": "Configuración",+ "webhooks": "Webhooks"},"create-db": {"cluster": "Clúster",@@ -289,7 +293,10 @@"transfer-project": "Transferir proyecto","unassign": "Desasignar","unassign-alert-description": "Las bases de datos seleccionadas serán eliminadas del proyecto",- "unassign-alert-title": "Desasignar bases de datos"+ "unassign-alert-title": "Desasignar bases de datos",+ "sync-schema": {+ "title": "Sincronizar esquema"+ }},"database-group": {"condition": {@@ -354,7 +361,8 @@},"workload-identity": {"select-placeholder": "Seleccionar una identidad de carga de trabajo"- }+ },+ "self": "GitOps"},"identity-provider": {"claims-description": "El proveedor de identidad devolvió las siguientes notificaciones. Esta información puede ayudarle a configurar las asignaciones de campos.",@@ -575,6 +583,9 @@"test-webhook": "Probar webhook","triggering-activity": "Actividades de disparo","webhook-url": "URL del webhook"+ },+ "masking-exemption": {+ "self": "Exenciones de Enmascaramiento"}},"quick-action": {@@ -1146,7 +1157,8 @@"revoke-access": "Revoke","revoke-confirm": "Are you sure you want to revoke this access grant?","self": "Editor de SQL",- "view-issue": "View Issue"+ "view-issue": "View Issue",+ "access-grants": "Access Grants"},"sql-review": {"add-or-remove-rules": "Add or remove rules",@@ -1329,5 +1341,14 @@"description": "Copie el código e ingréselo manualmente en su aplicación TOTP.","self": "Su secreto de dos factores"}+ },+ "export-center": {+ "data-export": "Exportación de datos"+ },+ "plan": {+ "plans": "Planes"+ },+ "release": {+ "releases": "Lanzamientos"}}diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.jsonindex fb3b5a3366..c736d23075 100644--- a/frontend/src/react/locales/ja-JP.json+++ b/frontend/src/react/locales/ja-JP.json@@ -195,7 +195,11 @@"view-details": "詳細を表示","warning": "警告する","you": "あなた",- "email-ascii-only": "メールアドレスは ASCII 文字のみ使用できます(英数字および . _ - + などの記号)。"+ "email-ascii-only": "メールアドレスは ASCII 文字のみ使用できます(英数字および . _ - + などの記号)。",+ "issues": "イシュー",+ "manage": "管理",+ "setting": "設定",+ "webhooks": "Webhook"},"create-db": {"cluster": "集まる",@@ -289,7 +293,10 @@"transfer-project": "プロジェクトの転送","unassign": "割り当てを解除する","unassign-alert-description": "選択したデータベースがプロジェクトから削除されます",- "unassign-alert-title": "データベースの割り当てを解除する"+ "unassign-alert-title": "データベースの割り当てを解除する",+ "sync-schema": {+ "title": "データベーステーブルの同期"+ }},"database-group": {"condition": {@@ -354,7 +361,8 @@},"workload-identity": {"select-placeholder": "ワークロードアイデンティティを選択"- }+ },+ "self": "GitOps"},"identity-provider": {"claims-description": "IDプロバイダーから以下のクレームが返されました。この情報は、フィールドマッピングの設定に役立ちます。",@@ -575,6 +583,9 @@"test-webhook": "Webhook のテスト","triggering-activity": "トリガーイベント","webhook-url": "Webhook URL"+ },+ "masking-exemption": {+ "self": "マスキング免除"}},"quick-action": {@@ -1146,7 +1157,8 @@"revoke-access": "Revoke","revoke-confirm": "Are you sure you want to revoke this access grant?","self": "SQLエディタ",- "view-issue": "View Issue"+ "view-issue": "View Issue",+ "access-grants": "Access Grants"},"sql-review": {"add-or-remove-rules": "Add or remove rules",@@ -1329,5 +1341,14 @@"description": "キーをコピーし、アプリケーションに手動で入力します。","self": "二要素認証キー"}+ },+ "export-center": {+ "data-export": "データエクスポート"+ },+ "plan": {+ "plans": "プラン"+ },+ "release": {+ "releases": "リリース"}}diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.jsonindex 34fe44466e..45b82b087f 100644--- a/frontend/src/react/locales/vi-VN.json+++ b/frontend/src/react/locales/vi-VN.json@@ -195,7 +195,11 @@"view-details": "Xem Chi tiết","warning": "Cảnh báo","you": "bạn",- "email-ascii-only": "Địa chỉ email chỉ hỗ trợ ký tự ASCII (chữ cái, số và ký hiệu như . _ - +)."+ "email-ascii-only": "Địa chỉ email chỉ hỗ trợ ký tự ASCII (chữ cái, số và ký hiệu như . _ - +).",+ "issues": "Vấn đề",+ "manage": "Quản lý",+ "setting": "Cài đặt",+ "webhooks": "Webhooks"},"create-db": {"cluster": "Cụm",@@ -289,7 +293,10 @@"transfer-project": "Chuyển dự án","unassign": "Hủy gán","unassign-alert-description": "Các cơ sở dữ liệu đã chọn sẽ bị xóa khỏi dự án",- "unassign-alert-title": "Hủy gán cơ sở dữ liệu"+ "unassign-alert-title": "Hủy gán cơ sở dữ liệu",+ "sync-schema": {+ "title": "Đồng bộ lược đồ"+ }},"database-group": {"condition": {@@ -354,7 +361,8 @@},"workload-identity": {"select-placeholder": "Chọn một workload identity"- }+ },+ "self": "GitOps"},"identity-provider": {"claims-description": "Các yêu cầu sau đây đã được nhà cung cấp danh tính trả về. Thông tin này có thể giúp bạn cấu hình ánh xạ trường.",@@ -575,6 +583,9 @@"test-webhook": "Kiểm tra Webhook","triggering-activity": "Hoạt động kích hoạt","webhook-url": "URL Webhook"+ },+ "masking-exemption": {+ "self": "Miễn trừ Che giấu"}},"quick-action": {@@ -1146,7 +1157,8 @@"revoke-access": "Revoke","revoke-confirm": "Are you sure you want to revoke this access grant?","self": "Trình soạn thảo SQL",- "view-issue": "View Issue"+ "view-issue": "View Issue",+ "access-grants": "Access Grants"},"sql-review": {"add-or-remove-rules": "Add or remove rules",@@ -1329,5 +1341,14 @@"description": "Sao chép mã và nhập nó vào ứng dụng TOTP của bạn theo cách thủ công.","self": "Bí mật hai yếu tố của bạn"}+ },+ "export-center": {+ "data-export": "Xuất dữ liệu"+ },+ "plan": {+ "plans": "Kế hoạch"+ },+ "release": {+ "releases": "Bản phát hành"}}diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.jsonindex d7a379366b..dc0e03e3c4 100644--- a/frontend/src/react/locales/zh-CN.json+++ b/frontend/src/react/locales/zh-CN.json@@ -195,7 +195,11 @@"view-details": "查看详情","warning": "警告","you": "您",- "email-ascii-only": "邮箱地址仅支持 ASCII 字符(英文字母、数字及 . _ - + 等符号)。"+ "email-ascii-only": "邮箱地址仅支持 ASCII 字符(英文字母、数字及 . _ - + 等符号)。",+ "issues": "工单",+ "manage": "管理",+ "setting": "设置",+ "webhooks": "Webhook"},"create-db": {"cluster": "集群",@@ -289,7 +293,10 @@"transfer-project": "转移项目","unassign": "取消分配","unassign-alert-description": "选定的数据库将从项目中移除",- "unassign-alert-title": "取消分配数据库"+ "unassign-alert-title": "取消分配数据库",+ "sync-schema": {+ "title": "库表同步"+ }},"database-group": {"condition": {@@ -354,7 +361,8 @@},"workload-identity": {"select-placeholder": "选择工作负载身份"- }+ },+ "self": "GitOps"},"identity-provider": {"claims-description": "身份提供商返回了以下 claims。此信息可帮助您配置用户信息映射。",@@ -575,6 +583,9 @@"test-webhook": "测试 Webhook","triggering-activity": "触发事件","webhook-url": "Webhook URL"+ },+ "masking-exemption": {+ "self": "脱敏豁免"}},"quick-action": {@@ -1146,7 +1157,8 @@"revoke-access": "撤销","revoke-confirm": "确定要撤销此访问授权吗?","self": "SQL 编辑器",- "view-issue": "查看工单"+ "view-issue": "查看工单",+ "access-grants": "访问授权"},"sql-review": {"add-or-remove-rules": "添加或删除规则",@@ -1329,5 +1341,14 @@"description": "复制密钥并在您的应用程序中手动输入。","self": "双重认证密钥"}+ },+ "export-center": {+ "data-export": "数据导出"+ },+ "plan": {+ "plans": "变更计划"+ },+ "release": {+ "releases": "发布包"}}diff --git a/frontend/src/react/mountProjectSidebar.ts b/frontend/src/react/mountProjectSidebar.tsnew file mode 100644index 0000000000..4691391040--- /dev/null+++ b/frontend/src/react/mountProjectSidebar.ts@@ -0,0 +1,87 @@+// Use import.meta.glob so vue-tsc does not follow the import into React .tsx files.+const sidebarLoader = import.meta.glob("./components/ProjectSidebar.tsx");++// biome-ignore lint/suspicious/noExplicitAny: React types conflict with Vue JSX in vue-tsc+type ReactDeps = any; // eslint-disable-line @typescript-eslint/no-explicit-any++let cachedDeps: ReactDeps | null = null;++async function loadCoreDeps() {+ if (cachedDeps) return cachedDeps;+ const [+ { createElement, StrictMode },+ { createRoot },+ { I18nextProvider },+ i18nModule,+ ] = await Promise.all([+ import("react"),+ import("react-dom/client"),+ import("react-i18next"),+ import("@/react/i18n"),+ ]);+ await i18nModule.i18nReady;+ cachedDeps = {+ createElement,+ StrictMode,+ createRoot,+ I18nextProvider,+ i18n: i18nModule.default,+ };+ return cachedDeps;+}++async function loadSidebar() {+ const loader = sidebarLoader["./components/ProjectSidebar.tsx"];+ if (!loader) throw new Error("ProjectSidebar not found");+ const mod = (await loader()) as Record<string, unknown>;+ return mod.ProjectSidebar as ReactDeps;+}++export async function mountProjectSidebar(+ container: HTMLElement,+ locale: string+) {+ const [deps, ProjectSidebar] = await Promise.all([+ loadCoreDeps(),+ loadSidebar(),+ ]);+ if (deps.i18n.language !== locale) {+ await deps.i18n.changeLanguage(locale);+ }+ const tree = deps.createElement(+ deps.StrictMode,+ null,+ deps.createElement(+ deps.I18nextProvider,+ { i18n: deps.i18n },+ deps.createElement(ProjectSidebar)+ )+ );+ const root = deps.createRoot(container);+ root.render(tree);+ return root;+}++export async function updateProjectSidebarLocale(+ // biome-ignore lint/suspicious/noExplicitAny: React Root type from dynamic import+ root: any, // eslint-disable-line @typescript-eslint/no-explicit-any+ locale: string+) {+ const [deps, ProjectSidebar] = await Promise.all([+ loadCoreDeps(),+ loadSidebar(),+ ]);+ if (deps.i18n.language !== locale) {+ await deps.i18n.changeLanguage(locale);+ }+ const tree = deps.createElement(+ deps.StrictMode,+ null,+ deps.createElement(+ deps.I18nextProvider,+ { i18n: deps.i18n },+ deps.createElement(ProjectSidebar)+ )+ );+ root.render(tree);+}diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.tsindex 910807fb2b..8bb9659769 100644--- a/frontend/src/router/dashboard/projectV1.ts+++ b/frontend/src/router/dashboard/projectV1.ts@@ -1,6 +1,6 @@import type { RouteLocationNormalized, RouteRecordRaw } from "vue-router";-import ProjectSidebarV1 from "@/components/Project/ProjectSidebarV1.vue";import { t } from "@/plugins/i18n";+import ReactProjectSidebarMount from "@/react/ReactProjectSidebarMount.vue";import { PROJECT_V1_ROUTE_DASHBOARD } from "./workspaceRoutes";export const PROJECT_V1_ROUTE_DETAIL = `${PROJECT_V1_ROUTE_DASHBOARD}.detail`;@@ -136,7 +136,7 @@ const projectV1Routes: RouteRecordRaw[] = [path: "projects/:projectId",components: {content: () => import("@/layouts/ProjectV1Layout.vue"),- leftSidebar: ProjectSidebarV1,+ leftSidebar: ReactProjectSidebarMount,},props: { content: true, leftSidebar: true },meta: {