Skip to content

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

chore: update routing (#10366)

ecmadao81fae6a38306
diff --git a/frontend/src/components/CommonSidebar.vue b/frontend/src/components/CommonSidebar.vue
index 43e4d40e2f..9703455721 100644
--- a/frontend/src/components/CommonSidebar.vue
+++ b/frontend/src/components/CommonSidebar.vue
@@ -5,15 +5,15 @@
<div v-for="(item, i) in filteredSidebarList" :key="i">
<router-link
v-if="item.type === 'route'"
- :to="item.path ?? ''"
- :class="[parentRouteClass, getItemClass(item.path)]"
+ :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.path)]"
+ :class="[parentRouteClass, getItemClass(item)]"
@click="onClick(item, `${i}`, $event)"
>
<component :is="item.icon" class="mr-2 w-5 h-5 text-gray-500" />
@@ -28,9 +28,9 @@
</div>
<a
v-if="item.type === 'link'"
- :class="[parentRouteClass, getItemClass(item.path)]"
+ :class="[parentRouteClass, getItemClass(item)]"
:href="item.path"
- @click="$emit('select', item.path, $event)"
+ @click="$emit('select', item, $event)"
>
<component :is="item.icon" class="mr-2 w-5 h-5 text-gray-500" />
{{ item.title }}
@@ -46,22 +46,22 @@
<template v-for="(child, j) in item.children" :key="`${i}-${j}`">
<a
v-if="child.type === 'link'"
- :class="[childRouteClass, getItemClass(child.path)]"
+ :class="[childRouteClass, getItemClass(child)]"
:href="child.path"
- @click="$emit('select', child.path, $event)"
+ @click="$emit('select', child, $event)"
>
{{ child.title }}
</a>
<router-link
- v-else-if="child.type === 'route' && child.path"
- :to="child.path"
- :class="[childRouteClass, getItemClass(child.path)]"
+ 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.path)]"
+ :class="[childRouteClass, getItemClass(child)]"
@click="onClick(child, `${i}-${j}`, $event)"
>
{{ child.title }}
@@ -79,6 +79,9 @@ import { computed, VNode, reactive, watch } 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;
@@ -94,16 +97,16 @@ const props = withDefaults(
defineProps<{
itemList: SidebarItem[];
showLogo?: boolean;
- getItemClass: (path: string | undefined) => string[];
+ getItemClass: (item: SidebarItem) => string[];
}>(),
{
showLogo: true,
- getItemClass: (_: string | undefined) => [],
+ getItemClass: (_: SidebarItem) => [],
}
);
const emit = defineEmits<{
- (event: "select", path: string | undefined, e: MouseEvent): void;
+ (event: "select", item: SidebarItem, e: MouseEvent): void;
}>();
const state = reactive<LocalState>({
@@ -128,7 +131,16 @@ const filteredSidebarList = computed(() => {
if (item.type === "divider") {
return true;
}
- return !item.hide && (!!item.path || item.children.length > 0);
+ 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;
});
});
@@ -147,7 +159,7 @@ watch(
const onClick = (sidebar: SidebarItem, key: string, e: MouseEvent) => {
if (sidebar.path) {
- return emit("select", sidebar.path, e);
+ return emit("select", sidebar, e);
}
if (state.expandedSidebar.has(key)) {
state.expandedSidebar.delete(key);
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/ExportCenterButton.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/ExportCenterButton.vue
index 038d41fa60..702b2cea4d 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/ExportCenterButton.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/ExportCenterButton.vue
@@ -11,13 +11,14 @@
<script setup lang="ts">
import { useRouter } from "vue-router";
import { useIssueContext } from "@/components/IssueV1";
+import { WORKSPACE_ROUTE_EXPORT_CENTER } from "@/router/dashboard/workspaceRoutes";
const router = useRouter();
const { issue } = useIssueContext();
const toExportCenter = () => {
router.push({
- name: "workspace.export-center",
+ name: WORKSPACE_ROUTE_EXPORT_CENTER,
hash: `#${issue.value.uid}`,
});
};
diff --git a/frontend/src/components/KBar/KBarWrapper.vue b/frontend/src/components/KBar/KBarWrapper.vue
index 13f2fdb76d..bedcb5b22a 100644
--- a/frontend/src/components/KBar/KBarWrapper.vue
+++ b/frontend/src/components/KBar/KBarWrapper.vue
@@ -32,7 +32,7 @@ import { defineComponent, computed } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { useOverlayStackContext } from "@/components/misc/OverlayStackManager.vue";
-import { WORKSPACE_HOME_MODULE } from "@/router/dashboard/workspace";
+import { WORKSPACE_HOME_MODULE } from "@/router/dashboard/workspaceRoutes";
import { useActuatorV1Store, useCurrentUserV1 } from "@/store";
import { UNKNOWN_USER_NAME } from "@/types";
import KBarFooter from "./KBarFooter.vue";
diff --git a/frontend/src/components/Project/ProjectIssuesPanel.vue b/frontend/src/components/Project/ProjectIssuesPanel.vue
index c3d0aeaac7..cfcb367734 100644
--- a/frontend/src/components/Project/ProjectIssuesPanel.vue
+++ b/frontend/src/components/Project/ProjectIssuesPanel.vue
@@ -53,14 +53,7 @@
</IssueSearch>
<div class="relative min-h-[20rem]">
- <div
- v-if="state.loading && !state.loadingMore"
- class="absolute inset-0 bg-white/50 pt-[10rem] flex flex-col items-center"
- >
- <BBSpin />
- </div>
<PagedIssueTableV1
- v-else
:key="keyForTab(tab)"
v-model:loading="state.loading"
v-model:loading-more="state.loadingMore"
@@ -70,7 +63,14 @@
:page-size="50"
>
<template #table="{ issueList, loading }">
+ <div
+ v-if="state.loading"
+ class="absolute inset-0 bg-white/50 pt-[10rem] flex flex-col items-center"
+ >
+ <BBSpin />
+ </div>
<IssueTableV1
+ v-else
mode="PROJECT"
:show-placeholder="!loading"
:issue-list="issueList"
@@ -257,6 +257,7 @@ const state = reactive<LocalState>({
loading: false,
loadingMore: false,
});
+
const tab = computed<TabValue>({
set(tab) {
if (tab === "") return;
diff --git a/frontend/src/components/Project/ProjectSidebarV1.vue b/frontend/src/components/Project/ProjectSidebarV1.vue
index de42384053..79b063ea35 100644
--- a/frontend/src/components/Project/ProjectSidebarV1.vue
+++ b/frontend/src/components/Project/ProjectSidebarV1.vue
@@ -62,7 +62,6 @@ import { useCurrentProject } from "./useCurrentProject";
interface ProjectSidebarItem extends SidebarItem {
title: string;
type: "div";
- path?: string;
hide?: boolean;
children?: ProjectSidebarItem[];
}
@@ -273,9 +272,9 @@ const projectSidebarItemList = computed((): ProjectSidebarItem[] => {
return filterprojectSidebarByPermissions(sidebarList);
});
-const getItemClass = (path: string | undefined) => {
+const getItemClass = (item: SidebarItem) => {
const list = ["outline-item"];
- if (route.name === path) {
+ if (route.name === item.path) {
list.push("router-link-active", "bg-link-hover");
return list;
}
@@ -283,7 +282,7 @@ const getItemClass = (path: string | undefined) => {
switch (route.name) {
case PROJECT_V1_ROUTE_WEBHOOK_CREATE:
case PROJECT_V1_ROUTE_WEBHOOK_DETAIL:
- if (path === PROJECT_V1_ROUTE_WEBHOOKS) {
+ if (item.path === PROJECT_V1_ROUTE_WEBHOOKS) {
list.push("router-link-active", "bg-link-hover");
}
break;
@@ -291,34 +290,34 @@ const getItemClass = (path: string | undefined) => {
case PROJECT_V1_ROUTE_BRANCH_ROLLOUT:
case PROJECT_V1_ROUTE_BRANCH_MERGE:
case PROJECT_V1_ROUTE_BRANCH_REBASE:
- if (path === PROJECT_V1_ROUTE_BRANCHES) {
+ if (item.path === PROJECT_V1_ROUTE_BRANCHES) {
list.push("router-link-active", "bg-link-hover");
}
break;
case PROJECT_V1_ROUTE_CHANGELIST_DETAIL:
- if (path === PROJECT_V1_ROUTE_CHANGELISTS) {
+ if (item.path === PROJECT_V1_ROUTE_CHANGELISTS) {
list.push("router-link-active", "bg-link-hover");
}
break;
case PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL:
case PROJECT_V1_ROUTE_DATABASE_GROUP_TABLE_GROUP_DETAIL:
- if (path === PROJECT_V1_ROUTE_DATABASE_GROUPS) {
+ if (item.path === PROJECT_V1_ROUTE_DATABASE_GROUPS) {
list.push("router-link-active", "bg-link-hover");
}
break;
case "workspace.issue.detail":
case PROJECT_V1_ROUTE_ISSUE_DETAIL:
- if (path === PROJECT_V1_ROUTE_ISSUES) {
+ if (item.path === PROJECT_V1_ROUTE_ISSUES) {
list.push("router-link-active", "bg-link-hover");
}
break;
case "workspace.database.history.detail":
- if (path === PROJECT_V1_ROUTE_CHANGE_HISTORIES) {
+ if (item.path === PROJECT_V1_ROUTE_CHANGE_HISTORIES) {
list.push("router-link-active", "bg-link-hover");
}
break;
case "workspace.database.detail":
- if (path === PROJECT_V1_ROUTE_DATABASES) {
+ if (item.path === PROJECT_V1_ROUTE_DATABASES) {
list.push("router-link-active", "bg-link-hover");
}
break;
@@ -326,12 +325,12 @@ const getItemClass = (path: string | undefined) => {
return list;
};
-const onSelect = (path: string | undefined, e: MouseEvent | undefined) => {
- if (!path) {
+const onSelect = (item: SidebarItem, e: MouseEvent | undefined) => {
+ if (!item.path) {
return;
}
const route = router.resolve({
- name: path,
+ name: item.path,
params: {
projectId: getProjectName(project.value.name),
},
@@ -345,25 +344,11 @@ const onSelect = (path: string | undefined, e: MouseEvent | undefined) => {
};
const flattenNavigationItems = computed(() => {
- return projectSidebarItemList.value.flatMap<{
- path: string;
- title: string;
- hide?: boolean;
- }>((item) => {
+ return projectSidebarItemList.value.flatMap<ProjectSidebarItem>((item) => {
if (item.children && item.children.length > 0) {
- return item.children.map((child) => ({
- path: child.path ?? "",
- title: child.title,
- hide: child.hide,
- }));
+ return item.children;
}
- return [
- {
- path: item.path ?? "",
- title: item.title,
- hide: item.hide,
- },
- ];
+ return item;
});
});
@@ -374,7 +359,7 @@ const navigationKbarActions = computed(() => {
name: item.title,
section: t("kbar.navigation"),
keywords: [item.title.toLowerCase(), item.path].join(" "),
- perform: () => onSelect(item.path, undefined),
+ perform: () => onSelect(item, undefined),
})
);
return actions;
diff --git a/frontend/src/components/SyncDatabaseSchema/index.vue b/frontend/src/components/SyncDatabaseSchema/index.vue
index 5922f10978..a882133b2d 100644
--- a/frontend/src/components/SyncDatabaseSchema/index.vue
+++ b/frontend/src/components/SyncDatabaseSchema/index.vue
@@ -66,7 +66,7 @@ import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { StepTab } from "@/components/v2";
import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
-import { WORKSPACE_HOME_MODULE } from "@/router/dashboard/workspace";
+import { WORKSPACE_HOME_MODULE } from "@/router/dashboard/workspaceRoutes";
import { useProjectV1Store } from "@/store";
import { UNKNOWN_ID, ComposedProject } from "@/types";
import { Engine } from "@/types/proto/v1/common";
diff --git a/frontend/src/router/dashboard/database.ts b/frontend/src/router/dashboard/database.ts
index 7ef3f3df4e..f1b8e04d36 100644
--- a/frontend/src/router/dashboard/database.ts
+++ b/frontend/src/router/dashboard/database.ts
@@ -5,8 +5,8 @@ import { t } from "@/plugins/i18n";
import { useDatabaseV1Store } from "@/store";
import { uidFromSlug } from "@/utils";
import DashboardSidebar from "@/views/DashboardSidebar.vue";
+import { DATABASE_ROUTE_DASHBOARD } from "./workspaceRoutes";
-export const DATABASE_ROUTE_DASHBOARD = "workspace.database";
export const DATABASE_ROUTE_DETAIL = `${DATABASE_ROUTE_DASHBOARD}.detail`;
const databaseRoutes: RouteRecordRaw[] = [
diff --git a/frontend/src/router/dashboard/environmentV1.ts b/frontend/src/router/dashboard/environmentV1.ts
index 174bf99d96..a11960a433 100644
--- a/frontend/src/router/dashboard/environmentV1.ts
+++ b/frontend/src/router/dashboard/environmentV1.ts
@@ -4,10 +4,9 @@ import { useEnvironmentV1Store } from "@/store";
import { environmentNamePrefix } from "@/store/modules/v1/common";
import { unknownEnvironment } from "@/types";
import DashboardSidebar from "@/views/DashboardSidebar.vue";
+import { ENVIRONMENT_V1_ROUTE_DASHBOARD } from "./workspaceRoutes";
-export const ENVIRONMENT_V1_ROUTE = "workspace.environment";
-export const ENVIRONMENT_V1_ROUTE_DASHBOARD = `${ENVIRONMENT_V1_ROUTE}.dashboard`;
-export const ENVIRONMENT_V1_ROUTE_DETAIL = `${ENVIRONMENT_V1_ROUTE}.detail`;
+export const ENVIRONMENT_V1_ROUTE_DETAIL = `${ENVIRONMENT_V1_ROUTE_DASHBOARD}.detail`;
const environmentV1Routes: RouteRecordRaw[] = [
{
diff --git a/frontend/src/router/dashboard/instance.ts b/frontend/src/router/dashboard/instance.ts
index c93465e652..c0279652ad 100644
--- a/frontend/src/router/dashboard/instance.ts
+++ b/frontend/src/router/dashboard/instance.ts
@@ -5,11 +5,12 @@ import { t } from "@/plugins/i18n";
import { useChangeHistoryStore, useInstanceV1Store } from "@/store";
import { uidFromSlug, idFromSlug } from "@/utils";
import DashboardSidebar from "@/views/DashboardSidebar.vue";
+import { INSTANCE_ROUTE_DASHBOARD } from "./workspaceRoutes";
const instanceRoutes: RouteRecordRaw[] = [
{
path: "instance",
- name: "workspace.instance",
+ name: INSTANCE_ROUTE_DASHBOARD,
meta: {
title: () => t("common.instances"),
getQuickActionList: () => {
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
index c0611a93c7..6372e5808c 100644
--- a/frontend/src/router/dashboard/projectV1.ts
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -2,6 +2,7 @@ import { RouteRecordRaw } from "vue-router";
import ProjectSidebarV1 from "@/components/Project/ProjectSidebarV1.vue";
import { t } from "@/plugins/i18n";
import DashboardSidebar from "@/views/DashboardSidebar.vue";
+import { PROJECT_V1_ROUTE_DASHBOARD } from "./workspaceRoutes";
export const PROJECT_V1_ROUTE = "workspace.projectV1";
export const PROJECT_V1_ROUTE_DETAIL = `${PROJECT_V1_ROUTE}.detail`;
@@ -34,7 +35,7 @@ export const PROJECT_V1_ROUTE_SETTINGS = `${PROJECT_V1_ROUTE}.settings`;
const projectV1Routes: RouteRecordRaw[] = [
{
path: "project",
- name: "workspace.project",
+ name: PROJECT_V1_ROUTE_DASHBOARD,
meta: {
title: () => t("common.projects"),
getQuickActionList: () => {
@@ -194,6 +195,20 @@ const projectV1Routes: RouteRecordRaw[] = [
},
],
},
+ {
+ path: "change-histories",
+ name: PROJECT_V1_ROUTE_CHANGE_HISTORIES,
+ meta: {
+ overrideTitle: true,
+ requiredProjectPermissionList: () => [
+ "bb.projects.get",
+ "bb.changeHistories.list",
+ ],
+ },
+ component: () =>
+ import("@/views/project/ProjectChangeHistoryDashboard.vue"),
+ props: true,
+ },
{
path: "issues",
name: PROJECT_V1_ROUTE_ISSUES,
diff --git a/frontend/src/router/dashboard/workspace.ts b/frontend/src/router/dashboard/workspace.ts
index 0aba5ff568..24bf7dfb83 100644
--- a/frontend/src/router/dashboard/workspace.ts
+++ b/frontend/src/router/dashboard/workspace.ts
@@ -6,8 +6,12 @@ import { unknownUser } from "@/types";
import DashboardSidebar from "@/views/DashboardSidebar.vue";
import Home from "@/views/Home.vue";
import SettingSidebar from "@/views/SettingSidebar.vue";
-
-export const WORKSPACE_HOME_MODULE = "workspace.home";
+import {
+ WORKSPACE_HOME_MODULE,
+ WORKSPACE_ROUTE_SLOW_QUERY,
+ WORKSPACE_ROUTE_EXPORT_CENTER,
+ WORKSPACE_ROUTE_ANOMALY_CENTER,
+} from "./workspaceRoutes";
const workspaceRoutes: RouteRecordRaw[] = [
{
@@ -60,7 +64,7 @@ const workspaceRoutes: RouteRecordRaw[] = [
},
{
path: "slow-query",
- name: "workspace.slow-query",
+ name: WORKSPACE_ROUTE_SLOW_QUERY,
meta: { title: () => startCase(t("slow-query.slow-queries")) },
components: {
content: () => import("@/views/SlowQuery/SlowQueryDashboard.vue"),
@@ -73,7 +77,7 @@ const workspaceRoutes: RouteRecordRaw[] = [
},
{
path: "export-center",
- name: "workspace.export-center",
+ name: WORKSPACE_ROUTE_EXPORT_CENTER,
meta: { title: () => startCase(t("export-center.self")) },
components: {
content: () => import("@/views/ExportCenter/index.vue"),
@@ -86,7 +90,7 @@ const workspaceRoutes: RouteRecordRaw[] = [
},
{
path: "anomaly-center",
- name: "workspace.anomaly-center",
+ name: WORKSPACE_ROUTE_ANOMALY_CENTER,
meta: { title: () => t("anomaly-center") },
components: {
content: () => import("@/views/AnomalyCenterDashboard.vue"),
diff --git a/frontend/src/router/dashboard/workspaceRoutes.ts b/frontend/src/router/dashboard/workspaceRoutes.ts
new file mode 100644
index 0000000000..bfc73070b4
--- /dev/null
+++ b/frontend/src/router/dashboard/workspaceRoutes.ts
@@ -0,0 +1,9 @@
+export const WORKSPACE_HOME_MODULE = "workspace.home";
+export const WORKSPACE_ROUTE_SLOW_QUERY = "workspace.slow-query";
+export const WORKSPACE_ROUTE_EXPORT_CENTER = "workspace.export-center";
+export const WORKSPACE_ROUTE_ANOMALY_CENTER = "workspace.anomaly-center";
+
+export const DATABASE_ROUTE_DASHBOARD = "workspace.database";
+export const INSTANCE_ROUTE_DASHBOARD = "workspace.instance";
+export const PROJECT_V1_ROUTE_DASHBOARD = "workspace.project";
+export const ENVIRONMENT_V1_ROUTE_DASHBOARD = `workspace.environment`;
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index a45999b882..acf2b065c8 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -32,9 +32,17 @@ import authRoutes, {
AUTH_SIGNUP_MODULE,
} from "./auth";
import dashboardRoutes from "./dashboard";
-import { ENVIRONMENT_V1_ROUTE } from "./dashboard/environmentV1";
import { PROJECT_V1_ROUTE } from "./dashboard/projectV1";
-import { WORKSPACE_HOME_MODULE } from "./dashboard/workspace";
+import {
+ DATABASE_ROUTE_DASHBOARD,
+ ENVIRONMENT_V1_ROUTE_DASHBOARD,
+ INSTANCE_ROUTE_DASHBOARD,
+ PROJECT_V1_ROUTE_DASHBOARD,
+ WORKSPACE_HOME_MODULE,
+ WORKSPACE_ROUTE_SLOW_QUERY,
+ WORKSPACE_ROUTE_EXPORT_CENTER,
+ WORKSPACE_ROUTE_ANOMALY_CENTER,
+} from "./dashboard/workspaceRoutes";
import {
SETTING_ROUTE,
SETTING_ROUTE_WORKSPACE_GITOPS_DETAIL,
@@ -196,13 +204,12 @@ router.beforeEach((to, from, next) => {
to.name === "error.404" ||
to.name === "error.500" ||
to.name === WORKSPACE_HOME_MODULE ||
- to.name === "workspace.slow-query" ||
- to.name === "workspace.sync-schema" ||
- to.name === "workspace.export-center" ||
- to.name === "workspace.anomaly-center" ||
- to.name === "workspace.project" ||
- to.name === "workspace.instance" ||
- to.name === "workspace.database" ||
+ to.name === WORKSPACE_ROUTE_SLOW_QUERY ||
+ to.name === WORKSPACE_ROUTE_EXPORT_CENTER ||
+ to.name === WORKSPACE_ROUTE_ANOMALY_CENTER ||
+ to.name === PROJECT_V1_ROUTE_DASHBOARD ||
+ to.name === INSTANCE_ROUTE_DASHBOARD ||
+ to.name === DATABASE_ROUTE_DASHBOARD ||
to.name === "workspace.issue" ||
to.name === SQL_EDITOR_HOME_MODULE ||
(to.name?.toString().startsWith(SETTING_ROUTE) &&
@@ -214,7 +221,7 @@ router.beforeEach((to, from, next) => {
return;
}
- if (to.name?.toString().startsWith(ENVIRONMENT_V1_ROUTE)) {
+ if (to.name?.toString().startsWith(ENVIRONMENT_V1_ROUTE_DASHBOARD)) {
next();
return;
}
diff --git a/frontend/src/views/DashboardSidebar.vue b/frontend/src/views/DashboardSidebar.vue
index ee0d4cb61f..27b450de4c 100644
--- a/frontend/src/views/DashboardSidebar.vue
+++ b/frontend/src/views/DashboardSidebar.vue
@@ -25,6 +25,16 @@ import { useRoute, useRouter } from "vue-router";
import { SidebarItem } from "@/components/CommonSidebar.vue";
import { useGlobalDatabaseActions } from "@/components/KBar/useDatabaseActions";
import { useProjectActions } from "@/components/KBar/useProjectActions";
+import {
+ DATABASE_ROUTE_DASHBOARD,
+ ENVIRONMENT_V1_ROUTE_DASHBOARD,
+ INSTANCE_ROUTE_DASHBOARD,
+ PROJECT_V1_ROUTE_DASHBOARD,
+ WORKSPACE_HOME_MODULE,
+ WORKSPACE_ROUTE_SLOW_QUERY,
+ WORKSPACE_ROUTE_EXPORT_CENTER,
+ WORKSPACE_ROUTE_ANOMALY_CENTER,
+} from "@/router/dashboard/workspaceRoutes";
import {
useCurrentUserV1,
useCurrentUserIamPolicy,
@@ -52,9 +62,11 @@ const shouldShowInstanceEntry = computed(() => {
return hasWorkspacePermissionV2(currentUserV1.value, "bb.instances.list");
});
-const getItemClass = (path: string | undefined): string[] => {
- const { path: current } = route;
- const isActiveRoute = path === current || current.startsWith(`${path}/`);
+const getItemClass = (item: SidebarItem): string[] => {
+ const { name: current } = route;
+ const isActiveRoute =
+ item.name === current?.toString ||
+ current?.toString().startsWith(`${item.name}/`);
const classes: string[] = [];
if (isActiveRoute) {
classes.push("router-link-active", "bg-link-hover");
@@ -67,32 +79,32 @@ const dashboardSidebarItemList = computed((): SidebarItem[] => {
{
title: t("issue.my-issues"),
icon: h(HomeIcon),
- path: "/",
+ name: WORKSPACE_HOME_MODULE,
type: "route",
},
{
title: t("common.projects"),
icon: h(GalleryHorizontalEndIcon),
- path: "/project",
+ name: PROJECT_V1_ROUTE_DASHBOARD,
type: "route",
},
{
title: t("common.instances"),
icon: h(LayersIcon),
- path: "/instance",
+ name: INSTANCE_ROUTE_DASHBOARD,
type: "route",
hide: !shouldShowInstanceEntry.value,
},
{
title: t("common.databases"),
icon: h(DatabaseIcon),
- path: "/db",
+ name: DATABASE_ROUTE_DASHBOARD,
type: "route",
},
{
title: t("common.environments"),
icon: h(SquareStackIcon),
- path: "/environments",
+ name: ENVIRONMENT_V1_ROUTE_DASHBOARD,
type: "route",
},
{
@@ -101,20 +113,20 @@ const dashboardSidebarItemList = computed((): SidebarItem[] => {
{
title: t("slow-query.slow-queries"),
icon: h(TurtleIcon),
- path: "/slow-query",
+ name: WORKSPACE_ROUTE_SLOW_QUERY,
type: "route",
hide: !shouldShowSyncSchemaEntry.value,
},
{
title: t("export-center.self"),
icon: h(DownloadIcon),
- path: "/export-center",
+ name: WORKSPACE_ROUTE_EXPORT_CENTER,
type: "route",
},
{
title: t("anomaly-center"),
icon: h(ShieldAlertIcon),
- path: "/anomaly-center",
+ name: WORKSPACE_ROUTE_ANOMALY_CENTER,
type: "route",
},
];
@@ -129,7 +141,7 @@ const navigationKbarActions = computed(() => {
shortcut: ["g", "p"],
section: t("kbar.navigation"),
keywords: "navigation",
- perform: () => router.push({ name: "workspace.project" }),
+ perform: () => router.push({ name: PROJECT_V1_ROUTE_DASHBOARD }),
}),
defineAction({
id: "bb.navigation.databases",
@@ -137,7 +149,7 @@ const navigationKbarActions = computed(() => {
shortcut: ["g", "d"],
section: t("kbar.navigation"),
keywords: "navigation db",
- perform: () => router.push({ name: "workspace.database" }),
+ perform: () => router.push({ name: DATABASE_ROUTE_DASHBOARD }),
})
);
@@ -149,7 +161,7 @@ const navigationKbarActions = computed(() => {
shortcut: ["g", "i"],
section: t("kbar.navigation"),
keywords: "navigation",
- perform: () => router.push({ name: "workspace.instance" }),
+ perform: () => router.push({ name: INSTANCE_ROUTE_DASHBOARD }),
})
);
}
@@ -160,21 +172,9 @@ const navigationKbarActions = computed(() => {
shortcut: ["g", "e"],
section: t("kbar.navigation"),
keywords: "navigation",
- perform: () => router.push({ name: "workspace.environment.dashboar" }),
+ perform: () => router.push({ name: ENVIRONMENT_V1_ROUTE_DASHBOARD }),
})
);
- if (shouldShowSyncSchemaEntry.value) {
- actions.push(
- defineAction({
- id: "bb.navigation.sync-schema",
- name: "Sync Schema",
- shortcut: ["g", "s", "s"],
- section: t("kbar.navigation"),
- keywords: "sync schema",
- perform: () => router.push({ name: "workspace.sync-schema" }),
- })
- );
- }
actions.push(
defineAction({
id: "bb.navigation.slow-query",
@@ -182,7 +182,7 @@ const navigationKbarActions = computed(() => {
section: t("kbar.navigation"),
shortcut: ["g", "s", "q"],
keywords: "slow query",
- perform: () => router.push({ name: "workspace.slow-query" }),
+ perform: () => router.push({ name: WORKSPACE_ROUTE_SLOW_QUERY }),
}),
defineAction({
id: "bb.navigation.export-center",
@@ -190,7 +190,7 @@ const navigationKbarActions = computed(() => {
section: t("kbar.navigation"),
shortcut: ["g", "x", "c"],
keywords: "export center",
- perform: () => router.push({ name: "workspace.export-center" }),
+ perform: () => router.push({ name: WORKSPACE_ROUTE_EXPORT_CENTER }),
}),
defineAction({
id: "bb.navigation.anomaly-center",
@@ -198,7 +198,7 @@ const navigationKbarActions = computed(() => {
shortcut: ["g", "a", "c"],
section: t("kbar.navigation"),
keywords: "anomaly center",
- perform: () => router.push({ name: "workspace.anomaly-center" }),
+ perform: () => router.push({ name: WORKSPACE_ROUTE_ANOMALY_CENTER }),
})
);
return actions;
diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vue
index e0228b57c4..f6867c995f 100644
--- a/frontend/src/views/EnvironmentDashboard.vue
+++ b/frontend/src/views/EnvironmentDashboard.vue
@@ -63,7 +63,7 @@ import { onMounted, computed, reactive, watch, h } from "vue";
import { useRouter } from "vue-router";
import { Drawer } from "@/components/v2";
import { EnvironmentV1Name, MiniActionButton } from "@/components/v2";
-import { ENVIRONMENT_V1_ROUTE_DASHBOARD } from "@/router/dashboard/environmentV1";
+import { ENVIRONMENT_V1_ROUTE_DASHBOARD } from "@/router/dashboard/workspaceRoutes";
import {
useRegisterCommand,
useUIStateStore,
diff --git a/frontend/src/views/EnvironmentDetail.vue b/frontend/src/views/EnvironmentDetail.vue
index 2af1ac5213..ca01424064 100644
--- a/frontend/src/views/EnvironmentDetail.vue
+++ b/frontend/src/views/EnvironmentDetail.vue
@@ -49,10 +49,8 @@ import { useRouter } from "vue-router";
import BBModal from "@/bbkit/BBModal.vue";
import ArchiveBanner from "@/components/ArchiveBanner.vue";
import EnvironmentForm from "@/components/EnvironmentForm.vue";
-import {
- ENVIRONMENT_V1_ROUTE_DASHBOARD,
- ENVIRONMENT_V1_ROUTE_DETAIL,
-} from "@/router/dashboard/environmentV1";
+import { ENVIRONMENT_V1_ROUTE_DETAIL } from "@/router/dashboard/environmentV1";
+import { ENVIRONMENT_V1_ROUTE_DASHBOARD } from "@/router/dashboard/workspaceRoutes";
import { hasFeature, pushNotification, useBackupV1Store } from "@/store";
import { environmentNamePrefix } from "@/store/modules/v1/common";
import {
diff --git a/frontend/src/views/Page403.vue b/frontend/src/views/Page403.vue
index fd4bc8da91..9f8f563d06 100644
--- a/frontend/src/views/Page403.vue
+++ b/frontend/src/views/Page403.vue
@@ -20,7 +20,7 @@
<script lang="ts">
import { useRouter } from "vue-router";
-import { WORKSPACE_HOME_MODULE } from "@/router/dashboard/workspace";
+import { WORKSPACE_HOME_MODULE } from "@/router/dashboard/workspaceRoutes";
export default {
name: "ThePage403",
diff --git a/frontend/src/views/Page404.vue b/frontend/src/views/Page404.vue
index accdeb69af..6be115232e 100644
--- a/frontend/src/views/Page404.vue
+++ b/frontend/src/views/Page404.vue
@@ -20,7 +20,7 @@
<script lang="ts">
import { useRouter } from "vue-router";
-import { WORKSPACE_HOME_MODULE } from "@/router/dashboard/workspace";
+import { WORKSPACE_HOME_MODULE } from "@/router/dashboard/workspaceRoutes";
export default {
name: "ThePage404",
diff --git a/frontend/src/views/SettingSidebar.vue b/frontend/src/views/SettingSidebar.vue
index 126db87d36..319486e1ce 100644
--- a/frontend/src/views/SettingSidebar.vue
+++ b/frontend/src/views/SettingSidebar.vue
@@ -61,9 +61,9 @@ const hasSettingListPermission = computed(() => {
return hasWorkspacePermissionV2(currentUser.value, "bb.settings.set");
});
-const getItemClass = (path: string | undefined) => {
+const getItemClass = (item: SidebarItem) => {
const list = [];
- if (route.name === path) {
+ if (route.name === item.name) {
list.push("router-link-active", "bg-link-hover");
return list;
}
@@ -71,19 +71,19 @@ const getItemClass = (path: string | undefined) => {
switch (route.name) {
case SETTING_ROUTE_WORKSPACE_SSO_CREATE:
case SETTING_ROUTE_WORKSPACE_SSO_DETAIL:
- if (path === SETTING_ROUTE_WORKSPACE_SSO) {
+ if (item.name === SETTING_ROUTE_WORKSPACE_SSO) {
list.push("router-link-active", "bg-link-hover");
}
break;
case SETTING_ROUTE_WORKSPACE_SQL_REVIEW_CREATE:
case SETTING_ROUTE_WORKSPACE_SQL_REVIEW_DETAIL:
- if (path === SETTING_ROUTE_WORKSPACE_SQL_REVIEW) {
+ if (item.name === SETTING_ROUTE_WORKSPACE_SQL_REVIEW) {
list.push("router-link-active", "bg-link-hover");
}
break;
case SETTING_ROUTE_WORKSPACE_GITOPS_CREATE:
case SETTING_ROUTE_WORKSPACE_GITOPS_DETAIL:
- if (path === SETTING_ROUTE_WORKSPACE_GITOPS) {
+ if (item.name === SETTING_ROUTE_WORKSPACE_GITOPS) {
list.push("router-link-active", "bg-link-hover");
}
break;
@@ -91,12 +91,12 @@ const getItemClass = (path: string | undefined) => {
return list;
};
-const onSelect = (path: string | undefined, e: MouseEvent | undefined) => {
- if (!path) {
+const onSelect = (item: SidebarItem, e: MouseEvent | undefined) => {
+ if (!item.name) {
return;
}
const route = router.resolve({
- name: path,
+ name: item.name,
});
if (e?.ctrlKey || e?.metaKey) {
@@ -115,8 +115,8 @@ const settingSidebarItemList = computed((): SidebarItem[] => {
children: [
{
title: t("settings.sidebar.profile"),
- path: SETTING_ROUTE_PROFILE,
- type: "div",
+ name: SETTING_ROUTE_PROFILE,
+ type: "route",
},
],
},
@@ -127,30 +127,30 @@ const settingSidebarItemList = computed((): SidebarItem[] => {
children: [
{
title: t("settings.sidebar.general"),
- path: SETTING_ROUTE_WORKSPACE_GENERAL,
- type: "div",
+ name: SETTING_ROUTE_WORKSPACE_GENERAL,
+ type: "route",
},
{
title: t("settings.sidebar.members"),
- path: SETTING_ROUTE_WORKSPACE_MEMBER,
+ name: SETTING_ROUTE_WORKSPACE_MEMBER,
hide: !hasSettingListPermission.value,
- type: "div",
+ type: "route",
},
{
title: t("settings.sidebar.custom-roles"),
- path: SETTING_ROUTE_WORKSPACE_ROLE,
- type: "div",
+ name: SETTING_ROUTE_WORKSPACE_ROLE,
+ type: "route",
},
{
title: t("settings.sidebar.subscription"),
- path: SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,
- type: "div",
+ name: SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,
+ type: "route",
},
{
title: t("settings.sidebar.debug-log"),
- path: SETTING_ROUTE_WORKSPACE_DEBUG_LOG,
+ name: SETTING_ROUTE_WORKSPACE_DEBUG_LOG,
hide: !hasSettingListPermission.value,
- type: "div",
+ type: "route",
},
],
},
@@ -161,46 +161,46 @@ const settingSidebarItemList = computed((): SidebarItem[] => {
children: [
{
title: t("sql-review.title"),
- path: SETTING_ROUTE_WORKSPACE_SQL_REVIEW,
- type: "div",
+ name: SETTING_ROUTE_WORKSPACE_SQL_REVIEW,
+ type: "route",
},
{
title: t("slow-query.self"),
- path: SETTING_ROUTE_WORKSPACE_SLOW_QUERY,
- type: "div",
+ name: SETTING_ROUTE_WORKSPACE_SLOW_QUERY,
+ type: "route",
},
{
title: t("schema-template.self"),
- path: SETTING_ROUTE_WORKSPACE_SCHEMA_TEMPLATE,
- type: "div",
+ name: SETTING_ROUTE_WORKSPACE_SCHEMA_TEMPLATE,
+ type: "route",
},
{
title: t("custom-approval.risk.risk-center"),
- path: SETTING_ROUTE_WORKSPACE_RISK_CENTER,
- type: "div",
+ name: SETTING_ROUTE_WORKSPACE_RISK_CENTER,
+ type: "route",
},
{
title: t("custom-approval.self"),
- path: SETTING_ROUTE_WORKSPACE_CUSTOM_APPROVAL,
- type: "div",
+ name: SETTING_ROUTE_WORKSPACE_CUSTOM_APPROVAL,
+ type: "route",
},
{
title: t("settings.sidebar.sensitive-data"),
- path: SETTING_ROUTE_WORKSPACE_SENSITIVE_DATA,
+ name: SETTING_ROUTE_WORKSPACE_SENSITIVE_DATA,
hide: !hasSettingListPermission.value,
- type: "div",
+ type: "route",
},
{
title: t("settings.sidebar.access-control"),
- path: SETTING_ROUTE_WORKSPACE_ACCESS_CONTROL,
+ name: SETTING_ROUTE_WORKSPACE_ACCESS_CONTROL,
hide: !hasSettingListPermission.value,
- type: "div",
+ type: "route",
},
{
title: t("settings.sidebar.audit-log"),
- path: SETTING_ROUTE_WORKSPACE_AUDIT_LOG,
+ name: SETTING_ROUTE_WORKSPACE_AUDIT_LOG,
hide: !hasSettingListPermission.value,
- type: "div",
+ type: "route",
},
],
},
@@ -211,29 +211,29 @@ const settingSidebarItemList = computed((): SidebarItem[] => {
children: [
{
title: t("settings.sidebar.gitops"),
- path: SETTING_ROUTE_WORKSPACE_GITOPS,
+ name: SETTING_ROUTE_WORKSPACE_GITOPS,
hide: !hasSettingListPermission.value,
- type: "div",
+ type: "route",
},
{
title: t("settings.sidebar.sso"),
- path: SETTING_ROUTE_WORKSPACE_SSO,
+ name: SETTING_ROUTE_WORKSPACE_SSO,
hide: !hasSettingListPermission.value,
- type: "div",
+ type: "route",
},
{
title: t("settings.sidebar.mail-delivery"),
- path: SETTING_ROUTE_WORKSPACE_MAIL_DELIVERY,
+ name: SETTING_ROUTE_WORKSPACE_MAIL_DELIVERY,
hide: !hasSettingListPermission.value,
- type: "div",
+ type: "route",
},
],
},
{
title: t("common.archived"),
icon: h(Archive),
- path: SETTING_ROUTE_WORKSPACE_ARCHIVE,
- type: "div",
+ name: SETTING_ROUTE_WORKSPACE_ARCHIVE,
+ type: "route",
},
];