Skip to content

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

chore: split dashboard routes (#10251)

boojack372ef9e59035
diff --git a/frontend/src/components/KBar/KBarWrapper.vue b/frontend/src/components/KBar/KBarWrapper.vue
index b25921484c..13f2fdb76d 100644
--- a/frontend/src/components/KBar/KBarWrapper.vue
+++ b/frontend/src/components/KBar/KBarWrapper.vue
@@ -32,6 +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 { useActuatorV1Store, useCurrentUserV1 } from "@/store";
import { UNKNOWN_USER_NAME } from "@/types";
import KBarFooter from "./KBarFooter.vue";
@@ -85,7 +86,7 @@ export default defineComponent({
shortcut: ["g", "h"],
section: t("kbar.navigation"),
keywords: "navigation",
- perform: () => router.push({ name: "workspace.home" }),
+ perform: () => router.push({ name: WORKSPACE_HOME_MODULE }),
}),
]);
diff --git a/frontend/src/components/SyncDatabaseSchema/index.vue b/frontend/src/components/SyncDatabaseSchema/index.vue
index c344e42525..6d315e1076 100644
--- a/frontend/src/components/SyncDatabaseSchema/index.vue
+++ b/frontend/src/components/SyncDatabaseSchema/index.vue
@@ -65,6 +65,7 @@ import { computed, reactive, ref } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { StepTab } from "@/components/v2";
+import { WORKSPACE_HOME_MODULE } from "@/router/dashboard/workspace";
import { useProjectV1Store } from "@/store";
import { UNKNOWN_ID, ComposedProject } from "@/types";
import { Engine } from "@/types/proto/v1/common";
@@ -265,7 +266,7 @@ const generateIssueName = (databaseNameList: string[]) => {
const cancelSetup = () => {
router.replace({
- name: "workspace.home",
+ name: WORKSPACE_HOME_MODULE,
});
};
</script>
diff --git a/frontend/src/router/dashboard/database.ts b/frontend/src/router/dashboard/database.ts
new file mode 100644
index 0000000000..89679a1b2f
--- /dev/null
+++ b/frontend/src/router/dashboard/database.ts
@@ -0,0 +1,73 @@
+import { pull } from "lodash-es";
+import { RouteLocationNormalized, RouteRecordRaw } from "vue-router";
+import ProjectSidebar from "@/components/Project/ProjectSidebar.vue";
+import DatabaseLayout from "@/layouts/DatabaseLayout.vue";
+import { t } from "@/plugins/i18n";
+import { hasFeature, useDatabaseV1Store } from "@/store";
+import { QuickActionType } from "@/types";
+import { idFromSlug } from "@/utils";
+import DashboardSidebar from "@/views/DashboardSidebar.vue";
+
+const databaseRoutes: RouteRecordRaw[] = [
+ {
+ path: "db",
+ name: "workspace.database",
+ meta: {
+ title: () => t("common.databases"),
+ quickActionListByRole: () => {
+ const DBA_AND_OWNER_QUICK_ACTION_LIST: QuickActionType[] = [
+ "quickaction.bb.database.create",
+ ];
+ const DEVELOPER_QUICK_ACTION_LIST: QuickActionType[] = [
+ "quickaction.bb.database.create",
+ "quickaction.bb.issue.grant.request.querier",
+ "quickaction.bb.issue.grant.request.exporter",
+ ];
+
+ if (hasFeature("bb.feature.dba-workflow")) {
+ pull(DEVELOPER_QUICK_ACTION_LIST, "quickaction.bb.database.create");
+ }
+
+ return new Map([
+ ["OWNER", DBA_AND_OWNER_QUICK_ACTION_LIST],
+ ["DBA", DBA_AND_OWNER_QUICK_ACTION_LIST],
+ ["DEVELOPER", DEVELOPER_QUICK_ACTION_LIST],
+ ]);
+ },
+ },
+ components: {
+ content: () => import("@/views/DatabaseDashboard.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: { content: true, leftSidebar: true },
+ },
+ {
+ path: "db/:databaseSlug",
+ components: {
+ content: DatabaseLayout,
+ leftSidebar: ProjectSidebar,
+ },
+ props: { content: true, leftSidebar: true },
+ children: [
+ {
+ path: "",
+ name: "workspace.database.detail",
+ meta: {
+ title: (route: RouteLocationNormalized) => {
+ const slug = route.params.databaseSlug as string;
+ if (slug.toLowerCase() == "new") {
+ return t("common.new");
+ }
+ return useDatabaseV1Store().getDatabaseByUID(
+ String(idFromSlug(slug))
+ ).databaseName;
+ },
+ },
+ component: () => import("@/views/DatabaseDetail.vue"),
+ props: true,
+ },
+ ],
+ },
+];
+
+export default databaseRoutes;
diff --git a/frontend/src/router/dashboard/environment.ts b/frontend/src/router/dashboard/environment.ts
new file mode 100644
index 0000000000..588e6d2beb
--- /dev/null
+++ b/frontend/src/router/dashboard/environment.ts
@@ -0,0 +1,51 @@
+import { RouteLocationNormalized, RouteRecordRaw } from "vue-router";
+import { t } from "@/plugins/i18n";
+import { useEnvironmentV1Store } from "@/store";
+import { QuickActionType } from "@/types";
+import { idFromSlug } from "@/utils";
+import DashboardSidebar from "@/views/DashboardSidebar.vue";
+
+const environmentRoutes: RouteRecordRaw[] = [
+ {
+ path: "environment",
+ name: "workspace.environment",
+ meta: {
+ title: () => t("common.environments"),
+ quickActionListByRole: () => {
+ const DBA_AND_OWNER_QUICK_ACTION_LIST: QuickActionType[] = [
+ "quickaction.bb.environment.create",
+ "quickaction.bb.environment.reorder",
+ ];
+ return new Map([
+ ["OWNER", DBA_AND_OWNER_QUICK_ACTION_LIST],
+ ["DBA", DBA_AND_OWNER_QUICK_ACTION_LIST],
+ ["DEVELOPER", []],
+ ]);
+ },
+ },
+ components: {
+ content: () => import("@/views/EnvironmentDashboard.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: { content: true, leftSidebar: true },
+ },
+ {
+ path: "environment/:environmentSlug",
+ name: "workspace.environment.detail",
+ meta: {
+ title: (route: RouteLocationNormalized) => {
+ const slug = route.params.environmentSlug as string;
+ return useEnvironmentV1Store().getEnvironmentByUID(
+ String(idFromSlug(slug))
+ ).title;
+ },
+ },
+ components: {
+ content: () => import("@/views/EnvironmentDetail.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: { content: true },
+ },
+];
+
+export default environmentRoutes;
diff --git a/frontend/src/router/dashboard/index.ts b/frontend/src/router/dashboard/index.ts
new file mode 100644
index 0000000000..52f750980a
--- /dev/null
+++ b/frontend/src/router/dashboard/index.ts
@@ -0,0 +1,36 @@
+import { RouteRecordRaw } from "vue-router";
+import BodyLayout from "@/layouts/BodyLayout.vue";
+import DashboardLayout from "@/layouts/DashboardLayout.vue";
+import databaseRoutes from "./database";
+import environmentRoutes from "./environment";
+import instanceRoutes from "./instance";
+import issueRoutes from "./issue";
+import projectRoutes from "./project";
+import projectV1Routes from "./projectV1";
+import workspaceRoutes from "./workspace";
+import workspaceSettingRoutes from "./workspaceSetting";
+
+const dashboardRoutes: RouteRecordRaw[] = [
+ {
+ path: "/",
+ component: DashboardLayout,
+ children: [
+ {
+ path: "",
+ components: { body: BodyLayout },
+ children: [
+ ...workspaceRoutes,
+ ...workspaceSettingRoutes,
+ ...environmentRoutes,
+ ...instanceRoutes,
+ ...projectRoutes,
+ ...projectV1Routes,
+ ...issueRoutes,
+ ...databaseRoutes,
+ ],
+ },
+ ],
+ },
+];
+
+export default dashboardRoutes;
diff --git a/frontend/src/router/dashboard/instance.ts b/frontend/src/router/dashboard/instance.ts
new file mode 100644
index 0000000000..942701c5b8
--- /dev/null
+++ b/frontend/src/router/dashboard/instance.ts
@@ -0,0 +1,76 @@
+import { RouteLocationNormalized, RouteRecordRaw } from "vue-router";
+import ProjectSidebar from "@/components/Project/ProjectSidebar.vue";
+import InstanceLayout from "@/layouts/InstanceLayout.vue";
+import { t } from "@/plugins/i18n";
+import { useChangeHistoryStore, useInstanceV1Store } from "@/store";
+import { idFromSlug, uidFromSlug } from "@/utils";
+import DashboardSidebar from "@/views/DashboardSidebar.vue";
+
+const instanceRoutes: RouteRecordRaw[] = [
+ {
+ path: "instance",
+ name: "workspace.instance",
+ meta: {
+ title: () => t("common.instances"),
+ quickActionListByRole: () => {
+ return new Map([
+ ["OWNER", ["quickaction.bb.instance.create"]],
+ ["DBA", ["quickaction.bb.instance.create"]],
+ ]);
+ },
+ },
+ components: {
+ content: () => import("@/views/InstanceDashboard.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: { content: true, leftSidebar: true },
+ },
+ {
+ path: "instance/:instanceSlug",
+ components: {
+ content: InstanceLayout,
+ leftSidebar: DashboardSidebar,
+ },
+ props: { content: true },
+ children: [
+ {
+ path: "",
+ name: "workspace.instance.detail",
+ meta: {
+ title: (route: RouteLocationNormalized) => {
+ const slug = route.params.instanceSlug as string;
+ if (slug.toLowerCase() == "new") {
+ return t("common.new");
+ }
+ return useInstanceV1Store().getInstanceByUID(
+ String(idFromSlug(slug))
+ ).title;
+ },
+ },
+ component: () => import("@/views/InstanceDetail.vue"),
+ props: true,
+ },
+ ],
+ },
+ {
+ path: "instances/:instance/databases/:database/changeHistories/:changeHistorySlug",
+ name: "workspace.database.history.detail",
+ meta: {
+ title: (route) => {
+ const parent = `instances/${route.params.instance}/databases/${route.params.database}`;
+ const uid = uidFromSlug(route.params.changeHistorySlug as string);
+ const name = `${parent}/changeHistories/${uid}`;
+ const history = useChangeHistoryStore().getChangeHistoryByName(name);
+
+ return history?.version ?? "";
+ },
+ },
+ components: {
+ content: () => import("@/views/ChangeHistoryDetail.vue"),
+ leftSidebar: ProjectSidebar,
+ },
+ props: { content: true, leftSidebar: true },
+ },
+];
+
+export default instanceRoutes;
diff --git a/frontend/src/router/dashboard/issue.ts b/frontend/src/router/dashboard/issue.ts
new file mode 100644
index 0000000000..bf61a88f97
--- /dev/null
+++ b/frontend/src/router/dashboard/issue.ts
@@ -0,0 +1,33 @@
+import { RouteRecordRaw } from "vue-router";
+import ProjectSidebar from "@/components/Project/ProjectSidebar.vue";
+import { t } from "@/plugins/i18n";
+import DashboardSidebar from "@/views/DashboardSidebar.vue";
+
+const issueRoutes: RouteRecordRaw[] = [
+ {
+ path: "issue",
+ name: "workspace.issue",
+ meta: {
+ title: () => t("common.issues"),
+ },
+ components: {
+ content: () => import("@/views/IssueDashboard.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: { content: true, leftSidebar: true },
+ },
+ {
+ path: "issue/:issueSlug",
+ name: "workspace.issue.detail",
+ meta: {
+ overrideTitle: true,
+ },
+ components: {
+ content: () => import("@/views/IssueDetailV1.vue"),
+ leftSidebar: ProjectSidebar,
+ },
+ props: { content: true, leftSidebar: true },
+ },
+];
+
+export default issueRoutes;
diff --git a/frontend/src/router/dashboard/project.ts b/frontend/src/router/dashboard/project.ts
new file mode 100644
index 0000000000..543cf0972c
--- /dev/null
+++ b/frontend/src/router/dashboard/project.ts
@@ -0,0 +1,149 @@
+import { RouteLocationNormalized, RouteRecordRaw } from "vue-router";
+import ProjectSidebar from "@/components/Project/ProjectSidebar.vue";
+import { t } from "@/plugins/i18n";
+import { useProjectV1Store, useProjectWebhookV1Store } from "@/store";
+import { DEFAULT_PROJECT_ID } from "@/types";
+import { idFromSlug } from "@/utils";
+import DashboardSidebar from "@/views/DashboardSidebar.vue";
+
+const projectRoutes: RouteRecordRaw[] = [
+ {
+ path: "project",
+ name: "workspace.project",
+ meta: {
+ title: () => t("common.projects"),
+ quickActionListByRole: () => {
+ return new Map([
+ ["OWNER", ["quickaction.bb.project.create"]],
+ ["DBA", ["quickaction.bb.project.create"]],
+ ["DEVELOPER", ["quickaction.bb.project.create"]],
+ ]);
+ },
+ },
+ components: {
+ content: () => import("@/views/ProjectDashboard.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: { content: true, leftSidebar: true },
+ },
+ {
+ path: "project/:projectSlug",
+ components: {
+ content: () => import("@/layouts/ProjectLayout.vue"),
+ leftSidebar: ProjectSidebar,
+ },
+ props: { content: true, leftSidebar: true },
+ children: [
+ {
+ path: "",
+ name: "workspace.project.detail",
+ meta: {
+ title: (route: RouteLocationNormalized) => {
+ const slug = route.params.projectSlug as string;
+ const projectId = idFromSlug(slug);
+ if (projectId === DEFAULT_PROJECT_ID) {
+ return t("database.unassigned-databases");
+ }
+ const projectV1 = useProjectV1Store().getProjectByUID(
+ String(projectId)
+ );
+ return projectV1.title;
+ },
+ },
+ component: () => import("@/views/ProjectDetail.vue"),
+ props: true,
+ },
+ {
+ path: "webhook/new",
+ name: "workspace.project.hook.create",
+ meta: {
+ title: () => t("project.webhook.create-webhook"),
+ },
+ component: () => import("@/views/ProjectWebhookCreate.vue"),
+ props: true,
+ },
+ {
+ path: "webhook/:projectWebhookSlug",
+ name: "workspace.project.hook.detail",
+ meta: {
+ title: (route: RouteLocationNormalized) => {
+ const projectSlug = route.params.projectSlug as string;
+ const projectWebhookSlug = route.params
+ .projectWebhookSlug as string;
+ const project = useProjectV1Store().getProjectByUID(
+ String(idFromSlug(projectSlug))
+ );
+ const webhook =
+ useProjectWebhookV1Store().getProjectWebhookFromProjectById(
+ project,
+ idFromSlug(projectWebhookSlug)
+ );
+
+ return `${t("common.webhook")} - ${webhook?.title ?? "unknown"}`;
+ },
+ },
+ component: () => import("@/views/ProjectWebhookDetail.vue"),
+ props: true,
+ },
+ {
+ path: "branches/:branchName",
+ name: "workspace.project.branch.detail",
+ meta: {
+ overrideTitle: true,
+ },
+ component: () => import("@/views/branch/BranchDetail.vue"),
+ props: true,
+ },
+ {
+ path: "branches/:branchName/rollout",
+ name: "workspace.project.branch.rollout",
+ meta: {
+ overrideTitle: true,
+ },
+ component: () => import("@/views/branch/BranchRollout.vue"),
+ props: true,
+ },
+ {
+ path: "branches/:branchName/merge",
+ name: "workspace.project.branch.merge",
+ meta: {
+ title: () => t("branch.merge-rebase.merge-branch"),
+ },
+ component: () => import("@/views/branch/BranchMerge.vue"),
+ props: true,
+ },
+ {
+ path: "branches/:branchName/rebase",
+ name: "workspace.project.branch.rebase",
+ meta: {
+ title: () => t("branch.merge-rebase.rebase-branch"),
+ },
+ component: () => import("@/views/branch/BranchRebase.vue"),
+ props: true,
+ },
+ {
+ path: "changelists/:changelistName",
+ name: "workspace.project.changelist.detail",
+ meta: {
+ overrideTitle: true,
+ },
+ component: () => import("@/components/Changelist/ChangelistDetail/"),
+ props: true,
+ },
+ {
+ path: "database-groups/:databaseGroupName",
+ name: "workspace.project.database-group.detail",
+ component: () => import("@/views/DatabaseGroupDetail.vue"),
+ props: true,
+ },
+ {
+ path: "database-groups/:databaseGroupName/table-groups/:schemaGroupName",
+ name: "workspace.project.database-group.table-group.detail",
+ component: () => import("@/views/SchemaGroupDetail.vue"),
+ props: true,
+ },
+ ],
+ },
+];
+
+export default projectRoutes;
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
new file mode 100644
index 0000000000..a03f545604
--- /dev/null
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -0,0 +1,35 @@
+import { RouteRecordRaw } from "vue-router";
+import ProjectSidebar from "@/components/Project/ProjectSidebar.vue";
+
+const projectV1Routes: RouteRecordRaw[] = [
+ {
+ path: "projects/:projectId",
+ components: {
+ content: () => import("@/layouts/ProjectV1Layout.vue"),
+ leftSidebar: ProjectSidebar,
+ },
+ props: { content: true, leftSidebar: true },
+ children: [
+ {
+ path: "databases",
+ name: "workspace.project.database.dashboard",
+ meta: {
+ overrideTitle: true,
+ },
+ component: () => import("@/views/project/ProjectDatabaseDashboard.vue"),
+ props: true,
+ },
+ {
+ path: "issues",
+ name: "workspace.project.issue.dashboard",
+ meta: {
+ overrideTitle: true,
+ },
+ component: () => import("@/views/project/ProjectIssueDashboard.vue"),
+ props: true,
+ },
+ ],
+ },
+];
+
+export default projectV1Routes;
diff --git a/frontend/src/router/dashboard/workspace.ts b/frontend/src/router/dashboard/workspace.ts
new file mode 100644
index 0000000000..d60d784826
--- /dev/null
+++ b/frontend/src/router/dashboard/workspace.ts
@@ -0,0 +1,150 @@
+import { pull, startCase } from "lodash-es";
+import { RouteLocationNormalized, RouteRecordRaw } from "vue-router";
+import { t } from "@/plugins/i18n";
+import { hasFeature, useUserStore } from "@/store";
+import { QuickActionType, 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";
+
+const workspaceRoutes: RouteRecordRaw[] = [
+ {
+ path: "",
+ name: WORKSPACE_HOME_MODULE,
+ meta: {
+ quickActionListByRole: () => {
+ const DBA_AND_OWNER_QUICK_ACTION_LIST: QuickActionType[] = [
+ "quickaction.bb.database.schema.update",
+ "quickaction.bb.database.data.update",
+ "quickaction.bb.database.create",
+ "quickaction.bb.instance.create",
+ ];
+ const DEVELOPER_QUICK_ACTION_LIST: QuickActionType[] = [
+ "quickaction.bb.database.schema.update",
+ "quickaction.bb.database.data.update",
+ "quickaction.bb.issue.grant.request.querier",
+ "quickaction.bb.issue.grant.request.exporter",
+ ];
+ if (hasFeature("bb.feature.dba-workflow")) {
+ pull(DEVELOPER_QUICK_ACTION_LIST, "quickaction.bb.database.create");
+ }
+ return new Map([
+ ["OWNER", DBA_AND_OWNER_QUICK_ACTION_LIST],
+ ["DBA", DBA_AND_OWNER_QUICK_ACTION_LIST],
+ ["DEVELOPER", DEVELOPER_QUICK_ACTION_LIST],
+ ]);
+ },
+ },
+ components: {
+ content: Home,
+ leftSidebar: DashboardSidebar,
+ },
+ props: {
+ content: true,
+ leftSidebar: true,
+ },
+ },
+ {
+ path: "403",
+ name: "error.403",
+ components: {
+ content: () => import("@/views/Page403.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: {
+ content: true,
+ leftSidebar: true,
+ },
+ },
+ {
+ path: "404",
+ name: "error.404",
+ components: {
+ content: () => import("@/views/Page404.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: {
+ content: true,
+ leftSidebar: true,
+ },
+ },
+ {
+ path: "inbox",
+ name: "workspace.inbox",
+ meta: { title: () => t("common.inbox") },
+ components: {
+ content: () => import("@/views/Inbox.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: {
+ content: true,
+ leftSidebar: true,
+ },
+ },
+ {
+ path: "slow-query",
+ name: "workspace.slow-query",
+ meta: { title: () => startCase(t("slow-query.slow-queries")) },
+ components: {
+ content: () => import("@/views/SlowQuery/SlowQueryDashboard.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: {
+ content: true,
+ leftSidebar: true,
+ },
+ },
+ {
+ path: "export-center",
+ name: "workspace.export-center",
+ meta: { title: () => startCase(t("export-center.self")) },
+ components: {
+ content: () => import("@/views/ExportCenter/index.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: {
+ content: true,
+ leftSidebar: true,
+ },
+ },
+ {
+ path: "anomaly-center",
+ name: "workspace.anomaly-center",
+ meta: { title: () => t("anomaly-center") },
+ components: {
+ content: () => import("@/views/AnomalyCenterDashboard.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: {
+ content: true,
+ leftSidebar: true,
+ },
+ },
+ {
+ // "u" stands for user. Strictly speaking, it's not accurate because we
+ // may refer to other principal type in the future. But from the endusers'
+ // perspective, they are more familiar with the "user" concept.
+ // We make an exception to use a shorthand here because it's a commonly
+ // accessed endpoint, and maybe in the future, we will further provide a
+ // shortlink such as users/<<email>>
+ path: "users/:principalEmail",
+ name: "workspace.profile",
+ meta: {
+ title: (route: RouteLocationNormalized) => {
+ const principalEmail = route.params.principalEmail as string;
+ const user =
+ useUserStore().getUserByEmail(principalEmail) ?? unknownUser();
+ return user.title;
+ },
+ },
+ components: {
+ content: () => import("@/views/ProfileDashboard.vue"),
+ leftSidebar: SettingSidebar,
+ },
+ props: { content: true },
+ },
+];
+
+export default workspaceRoutes;
diff --git a/frontend/src/router/dashboard/workspaceSetting.ts b/frontend/src/router/dashboard/workspaceSetting.ts
new file mode 100644
index 0000000000..7cb2a3013c
--- /dev/null
+++ b/frontend/src/router/dashboard/workspaceSetting.ts
@@ -0,0 +1,242 @@
+import { startCase } from "lodash-es";
+import { RouteLocationNormalized, RouteRecordRaw } from "vue-router";
+import { t } from "@/plugins/i18n";
+import {
+ useIdentityProviderStore,
+ useSQLReviewStore,
+ useVCSV1Store,
+} from "@/store";
+import { idFromSlug } from "@/utils";
+import SettingSidebar from "@/views/SettingSidebar.vue";
+
+const workspaceSettingRoutes: RouteRecordRaw[] = [
+ {
+ path: "setting",
+ name: "setting",
+ meta: { title: () => t("common.settings") },
+ components: {
+ content: () => import("@/layouts/SettingLayout.vue"),
+ leftSidebar: SettingSidebar,
+ },
+ props: {
+ content: true,
+ leftSidebar: true,
+ },
+ children: [
+ {
+ path: "",
+ name: "setting.profile",
+ meta: { title: () => t("settings.sidebar.profile") },
+ component: () => import("@/views/ProfileDashboard.vue"),
+ alias: "profile",
+ props: true,
+ },
+ {
+ path: "profile/two-factor",
+ name: "setting.profile.two-factor",
+ meta: {
+ title: () => t("two-factor.self"),
+ },
+ component: () => import("@/views/TwoFactorSetup.vue"),
+ props: true,
+ },
+ {
+ path: "general",
+ name: "setting.workspace.general",
+ meta: { title: () => t("settings.sidebar.general") },
+ component: () => import("@/views/SettingWorkspaceGeneral.vue"),
+ props: true,
+ },
+ {
+ path: "agent",
+ name: "setting.workspace.agent",
+ meta: { title: () => t("common.agents") },
+ component: () => import("@/views/SettingWorkspaceAgent.vue"),
+ props: true,
+ },
+ {
+ path: "member",
+ name: "setting.workspace.member",
+ meta: { title: () => t("settings.sidebar.members") },
+ component: () => import("@/views/SettingWorkspaceMember.vue"),
+ props: true,
+ },
+ {
+ path: "role",
+ name: "setting.workspace.role",
+ meta: { title: () => t("settings.sidebar.custom-roles") },
+ component: () => import("@/views/SettingWorkspaceRole.vue"),
+ props: true,
+ },
+ {
+ path: "sso",
+ name: "setting.workspace.sso",
+ meta: { title: () => t("settings.sidebar.sso") },
+ component: () => import("@/views/SettingWorkspaceSSO.vue"),
+ },
+ {
+ path: "sso/new",
+ name: "setting.workspace.sso.create",
+ meta: { title: () => t("settings.sidebar.sso") },
+ component: () => import("@/views/SettingWorkspaceSSODetail.vue"),
+ },
+ {
+ path: "sso/:ssoName",
+ name: "setting.workspace.sso.detail",
+ meta: {
+ title: (route: RouteLocationNormalized) => {
+ const name = route.params.ssoName as string;
+ return (
+ useIdentityProviderStore().getIdentityProviderByName(name)
+ ?.title || t("settings.sidebar.sso")
+ );
+ },
+ },
+ component: () => import("@/views/SettingWorkspaceSSODetail.vue"),
+ props: true,
+ },
+ {
+ path: "sensitive-data",
+ name: "setting.workspace.sensitive-data",
+ meta: { title: () => t("settings.sidebar.sensitive-data") },
+ component: () => import("@/views/SettingWorkspaceSensitiveData.vue"),
+ props: true,
+ },
+ {
+ path: "access-control",
+ name: "setting.workspace.access-control",
+ meta: { title: () => t("settings.sidebar.access-control") },
+ component: () => import("@/views/SettingWorkspaceAccessControl.vue"),
+ props: true,
+ },
+ {
+ path: "risk-center",
+ name: "setting.workspace.risk-center",
+ meta: { title: () => t("custom-approval.risk.risk-center") },
+ component: () => import("@/views/SettingWorkspaceRiskCenter.vue"),
+ props: true,
+ },
+ {
+ path: "custom-approval",
+ name: "setting.workspace.custom-approval",
+ meta: { title: () => t("custom-approval.self") },
+ component: () => import("@/views/SettingWorkspaceCustomApproval.vue"),
+ props: true,
+ },
+ {
+ path: "slow-query",
+ name: "setting.workspace.slow-query",
+ meta: { title: () => startCase(t("slow-query.self")) },
+ component: () => import("@/views/SettingWorkspaceSlowQuery.vue"),
+ props: true,
+ },
+ {
+ path: "schema-template",
+ name: "setting.workspace.schema-template",
+ meta: { title: () => startCase(t("schema-template.self")) },
+ component: () => import("@/views/SettingWorkspaceSchemaTemplate.vue"),
+ props: true,
+ },
+ {
+ path: "gitops",
+ name: "setting.workspace.gitops",
+ meta: { title: () => t("settings.sidebar.gitops") },
+ component: () => import("@/views/SettingWorkspaceVCS.vue"),
+ props: true,
+ },
+ {
+ path: "gitops/new",
+ name: "setting.workspace.gitops.create",
+ meta: { title: () => t("repository.add-git-provider") },
+ component: () => import("@/views/SettingWorkspaceVCSCreate.vue"),
+ props: true,
+ },
+ {
+ path: "gitops/:vcsSlug",
+ name: "setting.workspace.gitops.detail",
+ meta: {
+ title: (route: RouteLocationNormalized) => {
+ const slug = route.params.vcsSlug as string;
+ return useVCSV1Store().getVCSByUid(idFromSlug(slug))?.title ?? "";
+ },
+ },
+ component: () => import("@/views/SettingWorkspaceVCSDetail.vue"),
+ props: true,
+ },
+ {
+ path: "mail-delivery",
+ name: "setting.workspace.mail-delivery",
+ meta: { title: () => t("settings.sidebar.mail-delivery") },
+ component: () => import("@/views/SettingWorkspaceMailDelivery.vue"),
+ },
+ {
+ path: "subscription",
+ name: "setting.workspace.subscription",
+ meta: { title: () => t("settings.sidebar.subscription") },
+ component: () => import("@/views/SettingWorkspaceSubscription.vue"),
+ props: true,
+ },
+ {
+ path: "sql-review",
+ name: "setting.workspace.sql-review",
+ meta: {
+ title: () => t("sql-review.title"),
+ },
+ component: () => import("@/views/SettingWorkspaceSQLReview.vue"),
+ props: true,
+ },
+ {
+ path: "sql-review/new",
+ name: "setting.workspace.sql-review.create",
+ meta: {
+ title: () => t("sql-review.create.breadcrumb"),
+ },
+ component: () => import("@/views/SettingWorkspaceSQLReviewCreate.vue"),
+ props: true,
+ },
+ {
+ path: "sql-review/:sqlReviewPolicySlug",
+ name: "setting.workspace.sql-review.detail",
+ meta: {
+ title: (route: RouteLocationNormalized) => {
+ const slug = route.params.sqlReviewPolicySlug as string;
+ return (
+ useSQLReviewStore().getReviewPolicyByEnvironmentUID(
+ String(idFromSlug(slug))
+ )?.name ?? ""
+ );
+ },
+ },
+ component: () => import("@/views/SettingWorkspaceSQLReviewDetail.vue"),
+ props: true,
+ },
+ {
+ path: "audit-log",
+ name: "setting.workspace.audit-log",
+ meta: {
+ title: () => t("settings.sidebar.audit-log"),
+ },
+ component: () => import("@/views/SettingWorkspaceAuditLog.vue"),
+ props: true,
+ },
+ {
+ path: "debug-log",
+ name: "setting.workspace.debug-log",
+ meta: {
+ title: () => t("settings.sidebar.debug-log"),
+ },
+ component: () => import("@/views/SettingWorkspaceDebugLog.vue"),
+ props: true,
+ },
+ {
+ path: "archive",
+ name: "setting.workspace.archive",
+ meta: { title: () => t("common.archived") },
+ component: () => import("@/views/Archive.vue"),
+ props: true,
+ },
+ ],
+ },
+];
+
+export default workspaceSettingRoutes;
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index b6e509cfa1..114e221d35 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -1,18 +1,6 @@
import { useTitle } from "@vueuse/core";
-import { pull, startCase } from "lodash-es";
import { nextTick, ref } from "vue";
-import {
- createRouter,
- createWebHistory,
- RouteLocationNormalized,
- RouteRecordRaw,
-} from "vue-router";
-import ProjectSidebar from "@/components/Project/ProjectSidebar.vue";
-import BodyLayout from "@/layouts/BodyLayout.vue";
-import DashboardLayout from "@/layouts/DashboardLayout.vue";
-import DatabaseLayout from "@/layouts/DatabaseLayout.vue";
-import InstanceLayout from "@/layouts/InstanceLayout.vue";
-import { t } from "@/plugins/i18n";
+import { createRouter, createWebHistory } from "vue-router";
import {
hasFeature,
useVCSV1Store,
@@ -36,12 +24,7 @@ import {
useChangelistStore,
usePageMode,
} from "@/store";
-import {
- DEFAULT_PROJECT_ID,
- QuickActionType,
- unknownUser,
- UNKNOWN_ID,
-} from "@/types";
+import { UNKNOWN_ID } from "@/types";
import { DatabaseMetadataView } from "@/types/proto/v1/database_service";
import {
hasSettingPagePermission,
@@ -50,9 +33,6 @@ import {
sheetNameFromSlug,
uidFromSlug,
} from "@/utils";
-import DashboardSidebar from "@/views/DashboardSidebar.vue";
-import Home from "@/views/Home.vue";
-import SettingSidebar from "@/views/SettingSidebar.vue";
import authRoutes, {
AUTH_2FA_SETUP_MODULE,
AUTH_MFA_MODULE,
@@ -60,777 +40,13 @@ import authRoutes, {
AUTH_SIGNIN_MODULE,
AUTH_SIGNUP_MODULE,
} from "./auth";
+import dashboardRoutes from "./dashboard";
+import { WORKSPACE_HOME_MODULE } from "./dashboard/workspace";
import sqlEditorRoutes, { SQL_EDITOR_HOME_MODULE } from "./sqlEditor";
-const HOME_MODULE = "workspace.home";
-
-const routes: RouteRecordRaw[] = [
- {
- path: "/",
- component: DashboardLayout,
- children: [
- {
- path: "",
- components: { body: BodyLayout },
- children: [
- {
- path: "",
- name: HOME_MODULE,
- meta: {
- quickActionListByRole: () => {
- const DBA_AND_OWNER_QUICK_ACTION_LIST: QuickActionType[] = [
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.data.update",
- "quickaction.bb.database.create",
- "quickaction.bb.instance.create",
- ];
- const DEVELOPER_QUICK_ACTION_LIST: QuickActionType[] = [
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.data.update",
- "quickaction.bb.issue.grant.request.querier",
- "quickaction.bb.issue.grant.request.exporter",
- ];
- if (hasFeature("bb.feature.dba-workflow")) {
- pull(
- DEVELOPER_QUICK_ACTION_LIST,
- "quickaction.bb.database.create"
- );
- }
- return new Map([
- ["OWNER", DBA_AND_OWNER_QUICK_ACTION_LIST],
- ["DBA", DBA_AND_OWNER_QUICK_ACTION_LIST],
- ["DEVELOPER", DEVELOPER_QUICK_ACTION_LIST],
- ]);
- },
- },
- components: {
- content: Home,
- leftSidebar: DashboardSidebar,
- },
- props: {
- content: true,
- leftSidebar: true,
- },
- },
- {
- path: "403",
- name: "error.403",
- components: {
- content: () => import("../views/Page403.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: {
- content: true,
- leftSidebar: true,
- },
- },
- {
- path: "404",
- name: "error.404",
- components: {
- content: () => import("../views/Page404.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: {
- content: true,
- leftSidebar: true,
- },
- },
- {
- path: "inbox",
- name: "workspace.inbox",
- meta: { title: () => t("common.inbox") },
- components: {
- content: () => import("../views/Inbox.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: {
- content: true,
- leftSidebar: true,
- },
- },
- {
- path: "slow-query",
- name: "workspace.slow-query",
- meta: { title: () => startCase(t("slow-query.slow-queries")) },
- components: {
- content: () =>
- import("../views/SlowQuery/SlowQueryDashboard.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: {
- content: true,
- leftSidebar: true,
- },
- },
- {
- path: "export-center",
- name: "workspace.export-center",
- meta: { title: () => startCase(t("export-center.self")) },
- components: {
- content: () => import("../views/ExportCenter/index.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: {
- content: true,
- leftSidebar: true,
- },
- },
- {
- path: "anomaly-center",
- name: "workspace.anomaly-center",
- meta: { title: () => t("anomaly-center") },
- components: {
- content: () => import("../views/AnomalyCenterDashboard.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: {
- content: true,
- leftSidebar: true,
- },
- },
- {
- // "u" stands for user. Strictly speaking, it's not accurate because we
- // may refer to other principal type in the future. But from the endusers'
- // perspective, they are more familiar with the "user" concept.
- // We make an exception to use a shorthand here because it's a commonly
- // accessed endpoint, and maybe in the future, we will further provide a
- // shortlink such as users/<<email>>
- path: "users/:principalEmail",
- name: "workspace.profile",
- meta: {
- title: (route: RouteLocationNormalized) => {
- const principalEmail = route.params.principalEmail as string;
- const user =
- useUserStore().getUserByEmail(principalEmail) ??
- unknownUser();
- return user.title;
- },
- },
- components: {
- content: () => import("../views/ProfileDashboard.vue"),
- leftSidebar: SettingSidebar,
- },
- props: { content: true },
- },
- {
- path: "setting",
- name: "setting",
- meta: { title: () => t("common.settings") },
- components: {
- content: () => import("../layouts/SettingLayout.vue"),
- leftSidebar: SettingSidebar,
- },
- props: {
- content: true,
- leftSidebar: true,
- },
- children: [
- {
- path: "",
- name: "setting.profile",
- meta: { title: () => t("settings.sidebar.profile") },
- component: () => import("../views/ProfileDashboard.vue"),
- alias: "profile",
- props: true,
- },
- {
- path: "profile/two-factor",
- name: "setting.profile.two-factor",
- meta: {
- title: () => t("two-factor.self"),
- },
- component: () => import("../views/TwoFactorSetup.vue"),
- props: true,
- },
- {
- path: "general",
- name: "setting.workspace.general",
- meta: { title: () => t("settings.sidebar.general") },
- component: () => import("../views/SettingWorkspaceGeneral.vue"),
- props: true,
- },
- {
- path: "agent",
- name: "setting.workspace.agent",
- meta: { title: () => t("common.agents") },
- component: () => import("../views/SettingWorkspaceAgent.vue"),
- props: true,
- },
- {
- path: "member",
- name: "setting.workspace.member",
- meta: { title: () => t("settings.sidebar.members") },
- component: () => import("../views/SettingWorkspaceMember.vue"),
- props: true,
- },
- {
- path: "role",
- name: "setting.workspace.role",
- meta: { title: () => t("settings.sidebar.custom-roles") },
- component: () => import("../views/SettingWorkspaceRole.vue"),
- props: true,
- },
- {
- path: "sso",
- name: "setting.workspace.sso",
- meta: { title: () => t("settings.sidebar.sso") },
- component: () => import("../views/SettingWorkspaceSSO.vue"),
- },
- {
- path: "sso/new",
- name: "setting.workspace.sso.create",
- meta: { title: () => t("settings.sidebar.sso") },
- component: () =>
- import("../views/SettingWorkspaceSSODetail.vue"),
- },
- {
- path: "sso/:ssoName",
- name: "setting.workspace.sso.detail",
- meta: {
- title: (route: RouteLocationNormalized) => {
- const name = route.params.ssoName as string;
- return (
- useIdentityProviderStore().getIdentityProviderByName(name)
- ?.title || t("settings.sidebar.sso")
- );
- },
- },
- component: () =>
- import("../views/SettingWorkspaceSSODetail.vue"),
- props: true,
- },
- {
- path: "sensitive-data",
- name: "setting.workspace.sensitive-data",
- meta: { title: () => t("settings.sidebar.sensitive-data") },
- component: () =>
- import("../views/SettingWorkspaceSensitiveData.vue"),
- props: true,
- },
- {
- path: "access-control",
- name: "setting.workspace.access-control",
- meta: { title: () => t("settings.sidebar.access-control") },
- component: () =>
- import("../views/SettingWorkspaceAccessControl.vue"),
- props: true,
- },
- {
- path: "risk-center",
- name: "setting.workspace.risk-center",
- meta: { title: () => t("custom-approval.risk.risk-center") },
- component: () =>
- import("../views/SettingWorkspaceRiskCenter.vue"),
- props: true,
- },
- {
- path: "custom-approval",
- name: "setting.workspace.custom-approval",
- meta: { title: () => t("custom-approval.self") },
- component: () =>
- import("../views/SettingWorkspaceCustomApproval.vue"),
- props: true,
- },
- {
- path: "slow-query",
- name: "setting.workspace.slow-query",
- meta: { title: () => startCase(t("slow-query.self")) },
- component: () =>
- import("../views/SettingWorkspaceSlowQuery.vue"),
- props: true,
- },
- {
- path: "schema-template",
- name: "setting.workspace.schema-template",
- meta: { title: () => startCase(t("schema-template.self")) },
- component: () =>
- import("../views/SettingWorkspaceSchemaTemplate.vue"),
- props: true,
- },
- {
- path: "gitops",
- name: "setting.workspace.gitops",
- meta: { title: () => t("settings.sidebar.gitops") },
- component: () => import("../views/SettingWorkspaceVCS.vue"),
- props: true,
- },
- {
- path: "gitops/new",
- name: "setting.workspace.gitops.create",
- meta: { title: () => t("repository.add-git-provider") },
- component: () =>
- import("../views/SettingWorkspaceVCSCreate.vue"),
- props: true,
- },
- {
- path: "gitops/:vcsSlug",
- name: "setting.workspace.gitops.detail",
- meta: {
- title: (route: RouteLocationNormalized) => {
- const slug = route.params.vcsSlug as string;
- return (
- useVCSV1Store().getVCSByUid(idFromSlug(slug))?.title ?? ""
- );
- },
- },
- component: () =>
- import("../views/SettingWorkspaceVCSDetail.vue"),
- props: true,
- },
- {
- path: "mail-delivery",
- name: "setting.workspace.mail-delivery",
- meta: { title: () => t("settings.sidebar.mail-delivery") },
- component: () =>
- import("../views/SettingWorkspaceMailDelivery.vue"),
- },
- {
- path: "subscription",
- name: "setting.workspace.subscription",
- meta: { title: () => t("settings.sidebar.subscription") },
- component: () =>
- import("../views/SettingWorkspaceSubscription.vue"),
- props: true,
- },
- {
- path: "sql-review",
- name: "setting.workspace.sql-review",
- meta: {
- title: () => t("sql-review.title"),
- },
- component: () =>
- import("../views/SettingWorkspaceSQLReview.vue"),
- props: true,
- },
- {
- path: "sql-review/new",
- name: "setting.workspace.sql-review.create",
- meta: {
- title: () => t("sql-review.create.breadcrumb"),
- },
- component: () =>
- import("../views/SettingWorkspaceSQLReviewCreate.vue"),
- props: true,
- },
- {
- path: "sql-review/:sqlReviewPolicySlug",
- name: "setting.workspace.sql-review.detail",
- meta: {
- title: (route: RouteLocationNormalized) => {
- const slug = route.params.sqlReviewPolicySlug as string;
- return (
- useSQLReviewStore().getReviewPolicyByEnvironmentUID(
- String(idFromSlug(slug))
- )?.name ?? ""
- );
- },
- },
- component: () =>
- import("../views/SettingWorkspaceSQLReviewDetail.vue"),
- props: true,
- },
- {
- path: "audit-log",
- name: "setting.workspace.audit-log",
- meta: {
- title: () => t("settings.sidebar.audit-log"),
- },
- component: () =>
- import("../views/SettingWorkspaceAuditLog.vue"),
- props: true,
- },
- {
- path: "debug-log",
- name: "setting.workspace.debug-log",
- meta: {
- title: () => t("settings.sidebar.debug-log"),
- },
- component: () =>
- import("../views/SettingWorkspaceDebugLog.vue"),
- props: true,
- },
- {
- path: "archive",
- name: "setting.workspace.archive",
- meta: { title: () => t("common.archived") },
- component: () => import("../views/Archive.vue"),
- props: true,
- },
- ],
- },
- {
- path: "issue",
- name: "workspace.issue",
- meta: {
- title: () => t("common.issues"),
- },
- components: {
- content: () => import("../views/IssueDashboard.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: { content: true, leftSidebar: true },
- },
- {
- path: "environment",
- name: "workspace.environment",
- meta: {
- title: () => t("common.environments"),
- quickActionListByRole: () => {
- const DBA_AND_OWNER_QUICK_ACTION_LIST: QuickActionType[] = [
- "quickaction.bb.environment.create",
- "quickaction.bb.environment.reorder",
- ];
- return new Map([
- ["OWNER", DBA_AND_OWNER_QUICK_ACTION_LIST],
- ["DBA", DBA_AND_OWNER_QUICK_ACTION_LIST],
- ["DEVELOPER", []],
- ]);
- },
- },
- components: {
- content: () => import("../views/EnvironmentDashboard.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: { content: true, leftSidebar: true },
- },
- {
- path: "environment/:environmentSlug",
- name: "workspace.environment.detail",
- meta: {
- title: (route: RouteLocationNormalized) => {
- const slug = route.params.environmentSlug as string;
- return useEnvironmentV1Store().getEnvironmentByUID(
- String(idFromSlug(slug))
- ).title;
- },
- },
- components: {
- content: () => import("../views/EnvironmentDetail.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: { content: true },
- },
- {
- path: "project",
- name: "workspace.project",
- meta: {
- title: () => t("common.projects"),
- quickActionListByRole: () => {
- return new Map([
- ["OWNER", ["quickaction.bb.project.create"]],
- ["DBA", ["quickaction.bb.project.create"]],
- ["DEVELOPER", ["quickaction.bb.project.create"]],
- ]);
- },
- },
- components: {
- content: () => import("../views/ProjectDashboard.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: { content: true, leftSidebar: true },
- },
- {
- path: "project/:projectSlug",
- components: {
- content: () => import("../layouts/ProjectLayout.vue"),
- leftSidebar: ProjectSidebar,
- },
- props: { content: true, leftSidebar: true },
- children: [
- {
- path: "",
- name: "workspace.project.detail",
- meta: {
- title: (route: RouteLocationNormalized) => {
- const slug = route.params.projectSlug as string;
- const projectId = idFromSlug(slug);
- if (projectId === DEFAULT_PROJECT_ID) {
- return t("database.unassigned-databases");
- }
- const projectV1 = useProjectV1Store().getProjectByUID(
- String(projectId)
- );
- return projectV1.title;
- },
- },
- component: () => import("../views/ProjectDetail.vue"),
- props: true,
- },
- {
- path: "webhook/new",
- name: "workspace.project.hook.create",
- meta: {
- title: () => t("project.webhook.create-webhook"),
- },
- component: () => import("../views/ProjectWebhookCreate.vue"),
- props: true,
- },
- {
- path: "webhook/:projectWebhookSlug",
- name: "workspace.project.hook.detail",
- meta: {
- title: (route: RouteLocationNormalized) => {
- const projectSlug = route.params.projectSlug as string;
- const projectWebhookSlug = route.params
- .projectWebhookSlug as string;
- const project = useProjectV1Store().getProjectByUID(
- String(idFromSlug(projectSlug))
- );
- const webhook =
- useProjectWebhookV1Store().getProjectWebhookFromProjectById(
- project,
- idFromSlug(projectWebhookSlug)
- );
-
- return `${t("common.webhook")} - ${
- webhook?.title ?? "unknown"
- }`;
- },
- },
- component: () => import("../views/ProjectWebhookDetail.vue"),
- props: true,
- },
- {
- path: "branches/:branchName",
- name: "workspace.project.branch.detail",
- meta: {
- overrideTitle: true,
- },
- component: () => import("../views/branch/BranchDetail.vue"),
- props: true,
- },
- {
- path: "branches/:branchName/rollout",
- name: "workspace.project.branch.rollout",
- meta: {
- overrideTitle: true,
- },
- component: () => import("../views/branch/BranchRollout.vue"),
- props: true,
- },
- {
- path: "branches/:branchName/merge",
- name: "workspace.project.branch.merge",
- meta: {
- title: () => t("branch.merge-rebase.merge-branch"),
- },
- component: () => import("../views/branch/BranchMerge.vue"),
- props: true,
- },
- {
- path: "branches/:branchName/rebase",
- name: "workspace.project.branch.rebase",
- meta: {
- title: () => t("branch.merge-rebase.rebase-branch"),
- },
- component: () => import("../views/branch/BranchRebase.vue"),
- props: true,
- },
- {
- path: "changelists/:changelistName",
- name: "workspace.project.changelist.detail",
- meta: {
- overrideTitle: true,
- },
- component: () =>
- import("../components/Changelist/ChangelistDetail/"),
- props: true,
- },
- {
- path: "database-groups/:databaseGroupName",
- name: "workspace.project.database-group.detail",
- component: () => import("../views/DatabaseGroupDetail.vue"),
- props: true,
- },
- {
- path: "database-groups/:databaseGroupName/table-groups/:schemaGroupName",
- name: "workspace.project.database-group.table-group.detail",
- component: () => import("../views/SchemaGroupDetail.vue"),
- props: true,
- },
- ],
- },
- {
- path: "projects/:projectId",
- components: {
- content: () => import("../layouts/ProjectV1Layout.vue"),
- leftSidebar: ProjectSidebar,
- },
- props: { content: true, leftSidebar: true },
- children: [
- {
- path: "databases",
- name: "workspace.project.database.dashboard",
- meta: {
- overrideTitle: true,
- },
- component: () =>
- import("../views/project/ProjectDatabaseDashboard.vue"),
- props: true,
- },
- {
- path: "issues",
- name: "workspace.project.issue.dashboard",
- meta: {
- overrideTitle: true,
- },
- component: () =>
- import("../views/project/ProjectIssueDashboard.vue"),
- props: true,
- },
- ],
- },
- {
- path: "instance",
- name: "workspace.instance",
- meta: {
- title: () => t("common.instances"),
- quickActionListByRole: () => {
- return new Map([
- ["OWNER", ["quickaction.bb.instance.create"]],
- ["DBA", ["quickaction.bb.instance.create"]],
- ]);
- },
- },
- components: {
- content: () => import("../views/InstanceDashboard.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: { content: true, leftSidebar: true },
- },
- {
- path: "db",
- name: "workspace.database",
- meta: {
- title: () => t("common.databases"),
- quickActionListByRole: () => {
- const DBA_AND_OWNER_QUICK_ACTION_LIST: QuickActionType[] = [
- "quickaction.bb.database.create",
- ];
- const DEVELOPER_QUICK_ACTION_LIST: QuickActionType[] = [
- "quickaction.bb.database.create",
- "quickaction.bb.issue.grant.request.querier",
- "quickaction.bb.issue.grant.request.exporter",
- ];
-
- if (hasFeature("bb.feature.dba-workflow")) {
- pull(
- DEVELOPER_QUICK_ACTION_LIST,
- "quickaction.bb.database.create"
- );
- }
-
- return new Map([
- ["OWNER", DBA_AND_OWNER_QUICK_ACTION_LIST],
- ["DBA", DBA_AND_OWNER_QUICK_ACTION_LIST],
- ["DEVELOPER", DEVELOPER_QUICK_ACTION_LIST],
- ]);
- },
- },
- components: {
- content: () => import("../views/DatabaseDashboard.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: { content: true, leftSidebar: true },
- },
- {
- path: "db/:databaseSlug",
- components: {
- content: DatabaseLayout,
- leftSidebar: ProjectSidebar,
- },
- props: { content: true, leftSidebar: true },
- children: [
- {
- path: "",
- name: "workspace.database.detail",
- meta: {
- title: (route: RouteLocationNormalized) => {
- const slug = route.params.databaseSlug as string;
- if (slug.toLowerCase() == "new") {
- return t("common.new");
- }
- return useDatabaseV1Store().getDatabaseByUID(
- String(idFromSlug(slug))
- ).databaseName;
- },
- },
- component: () => import("../views/DatabaseDetail.vue"),
- props: true,
- },
- ],
- },
- {
- path: "instances/:instance/databases/:database/changeHistories/:changeHistorySlug",
- name: "workspace.database.history.detail",
- meta: {
- title: (route) => {
- const parent = `instances/${route.params.instance}/databases/${route.params.database}`;
- const uid = uidFromSlug(
- route.params.changeHistorySlug as string
- );
- const name = `${parent}/changeHistories/${uid}`;
- const history =
- useChangeHistoryStore().getChangeHistoryByName(name);
-
- return history?.version ?? "";
- },
- },
- components: {
- content: () => import("../views/ChangeHistoryDetail.vue"),
- leftSidebar: ProjectSidebar,
- },
- props: { content: true, leftSidebar: true },
- },
- {
- path: "instance/:instanceSlug",
- components: {
- content: InstanceLayout,
- leftSidebar: DashboardSidebar,
- },
- props: { content: true },
- children: [
- {
- path: "",
- name: "workspace.instance.detail",
- meta: {
- title: (route: RouteLocationNormalized) => {
- const slug = route.params.instanceSlug as string;
- if (slug.toLowerCase() == "new") {
- return t("common.new");
- }
- return useInstanceV1Store().getInstanceByUID(
- String(idFromSlug(slug))
- ).title;
- },
- },
- component: () => import("../views/InstanceDetail.vue"),
- props: true,
- },
- ],
- },
- {
- path: "issue/:issueSlug",
- name: "workspace.issue.detail",
- meta: {
- overrideTitle: true,
- },
- components: {
- content: () => import("../views/IssueDetailV1.vue"),
- leftSidebar: ProjectSidebar,
- },
- props: { content: true, leftSidebar: true },
- },
- ],
- },
- ],
- },
-];
-
export const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
- routes: [...authRoutes, ...routes, ...sqlEditorRoutes],
+ routes: [...authRoutes, ...dashboardRoutes, ...sqlEditorRoutes],
linkExactActiveClass: "bg-link-hover",
scrollBehavior(to /*, from, savedPosition */) {
if (to.hash) {
@@ -875,8 +91,10 @@ router.beforeEach((to, from, next) => {
const fromModule = from.name
? from.name.toString().split(".")[0]
- : HOME_MODULE;
- const toModule = to.name ? to.name.toString().split(".")[0] : HOME_MODULE;
+ : WORKSPACE_HOME_MODULE;
+ const toModule = to.name
+ ? to.name.toString().split(".")[0]
+ : WORKSPACE_HOME_MODULE;
if (toModule != fromModule) {
routerStore.setBackPath(from.fullPath);
@@ -911,7 +129,7 @@ router.beforeEach((to, from, next) => {
location.replace(to.query.redirect);
return;
}
- next({ name: HOME_MODULE, replace: true });
+ next({ name: WORKSPACE_HOME_MODULE, replace: true });
} else {
next();
}
@@ -1007,7 +225,7 @@ router.beforeEach((to, from, next) => {
to.name === "error.403" ||
to.name === "error.404" ||
to.name === "error.500" ||
- to.name === "workspace.home" ||
+ to.name === WORKSPACE_HOME_MODULE ||
to.name === "workspace.inbox" ||
to.name === "workspace.slow-query" ||
to.name === "workspace.sync-schema" ||
diff --git a/frontend/src/views/Page403.vue b/frontend/src/views/Page403.vue
index 488b3e0f93..fd4bc8da91 100644
--- a/frontend/src/views/Page403.vue
+++ b/frontend/src/views/Page403.vue
@@ -20,6 +20,7 @@
<script lang="ts">
import { useRouter } from "vue-router";
+import { WORKSPACE_HOME_MODULE } from "@/router/dashboard/workspace";
export default {
name: "ThePage403",
@@ -27,7 +28,7 @@ export default {
const router = useRouter();
const goHome = () => {
- router.push({ name: "workspace.home" });
+ router.push({ name: WORKSPACE_HOME_MODULE });
};
return {
diff --git a/frontend/src/views/Page404.vue b/frontend/src/views/Page404.vue
index 079fe40666..accdeb69af 100644
--- a/frontend/src/views/Page404.vue
+++ b/frontend/src/views/Page404.vue
@@ -20,6 +20,7 @@
<script lang="ts">
import { useRouter } from "vue-router";
+import { WORKSPACE_HOME_MODULE } from "@/router/dashboard/workspace";
export default {
name: "ThePage404",
@@ -27,7 +28,7 @@ export default {
const router = useRouter();
const goHome = () => {
- router.push({ name: "workspace.home" });
+ router.push({ name: WORKSPACE_HOME_MODULE });
};
return {