Skip to content

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

feat: workspace landing page (#14527)

ecmadao20963e1baacd
diff --git a/frontend/src/DummyRootView.ts b/frontend/src/DummyRootView.ts
index 4b7b204abe..8dcc687023 100644
--- a/frontend/src/DummyRootView.ts
+++ b/frontend/src/DummyRootView.ts
@@ -3,11 +3,11 @@ import { useRouter } from "vue-router";
import { getProjectName } from "@/store/modules/v1/common";
import { PresetRoleType } from "@/types";
import { PROJECT_V1_ROUTE_DETAIL } from "./router/dashboard/projectV1";
-import { WORKSPACE_ROUTE_MY_ISSUES } from "./router/dashboard/workspaceRoutes";
+import { WORKSPACE_ROUTE_LANDING } from "./router/dashboard/workspaceRoutes";
import { SQL_EDITOR_HOME_MODULE } from "./router/sqlEditor";
import { useRecentVisit } from "./router/useRecentVisit";
import { useAppFeature, useProjectV1List } from "./store";
-import { isDev, hasWorkspaceLevelRole } from "./utils";
+import { hasWorkspaceLevelRole } from "./utils";
export default defineComponent({
name: "DummyRootView",
@@ -41,7 +41,7 @@ export default defineComponent({
const fallback = () => {
if (hasWorkspaceRole.value || projectList.value.length !== 1) {
router.replace({
- name: WORKSPACE_ROUTE_MY_ISSUES,
+ name: WORKSPACE_ROUTE_LANDING,
});
} else {
router.replace({
@@ -57,11 +57,6 @@ export default defineComponent({
// - /sql-editor if defaultWorkspaceView == 'EDITOR'
// - lastVisit.path if not empty
// - /issues as fallback
- // Only turned on when isDev() is true
- if (!isDev()) {
- return fallback();
- }
-
if (!lastVisit.value) {
return fallback();
}
diff --git a/frontend/src/assets/landing.webp b/frontend/src/assets/landing.webp
new file mode 100644
index 0000000000..cebe6fae31
Binary files /dev/null and b/frontend/src/assets/landing.webp differ
diff --git a/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue b/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue
index c45f2fd340..08c1259b87 100644
--- a/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue
+++ b/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue
@@ -6,7 +6,7 @@
</label>
<FeatureBadge feature="bb.feature.access-control" />
</div>
- <div class="w-full flex flex-col gap-4">
+ <div>
<div class="w-full inline-flex items-center gap-x-2">
<Switch
:value="disableCopyDataPolicy"
diff --git a/frontend/src/components/InstanceForm/Form.vue b/frontend/src/components/InstanceForm/Form.vue
index 0aa69ce581..2922fbe208 100644
--- a/frontend/src/components/InstanceForm/Form.vue
+++ b/frontend/src/components/InstanceForm/Form.vue
@@ -212,7 +212,7 @@
<div
v-if="basicInfo.engine === Engine.REDIS"
- class="sm:col-span-4 sm:col-start-1"
+ class="sm:col-span-4 sm:col-start-1 space-y-2"
>
<label
for="connectionStringSchema"
diff --git a/frontend/src/components/Project/ProjectSwitchPopover.vue b/frontend/src/components/Project/ProjectSwitch/ProjectSwitchContent.vue
similarity index 55%
rename from frontend/src/components/Project/ProjectSwitchPopover.vue
rename to frontend/src/components/Project/ProjectSwitch/ProjectSwitchContent.vue
index d891344164..115f4803dc 100644
--- a/frontend/src/components/Project/ProjectSwitchPopover.vue
+++ b/frontend/src/components/Project/ProjectSwitch/ProjectSwitchContent.vue
@@ -1,91 +1,62 @@
<template>
- <NPopover
- v-model:show="state.showPopover"
- class="max-h-[80vh] w-[24rem] max-w-full"
- placement="bottom-start"
- scrollable
- trigger="click"
- :show-arrow="false"
- >
- <template #trigger>
- <NButton
- class="hidden sm:inline"
- size="small"
- @click="state.showPopover = !state.showPopover"
- >
- <div class="min-w-[8rem] text-left">
- <ProjectNameCell
- v-if="isValidProjectName(project.name)"
- mode="ALL_SHORT"
- :project="project"
+ <div class="w-full">
+ <div v-if="isValidProjectName(project.name)">
+ <NButton size="small" text @click="gotoWorkspace">
+ <template #icon>
+ <ChevronLeftIcon class="w-4 opacity-80" />
+ </template>
+ {{ $t("common.back-to-workspace") }}
+ </NButton>
+ </div>
+ <NTabs
+ :value="actualSelectedTab"
+ type="line"
+ @update:value="state.selectedTab = $event"
+ >
+ <template #suffix>
+ <div class="flex flex-row justify-end items-center gap-x-2">
+ <SearchBox
+ v-model:value="state.searchText"
+ :placeholder="$t('common.filter-by-name')"
+ :autofocus="false"
+ class="!w-40"
+ size="small"
/>
- <span v-else class="text-control-placeholder text-sm">
- {{ $t("project.select") }}
- </span>
+ <NTooltip v-if="allowToCreateProject" trigger="hover">
+ <template #trigger>
+ <NButton size="small" @click="state.showCreateDrawer = true">
+ <template #icon>
+ <PlusIcon class="w-4 h-auto" />
+ </template>
+ </NButton>
+ </template>
+ {{ $t("quick-action.new-project") }}
+ </NTooltip>
</div>
- <ChevronDownIcon class="w-5 h-auto text-gray-400" />
- </NButton>
- </template>
-
- <div class="w-full">
- <div v-if="isValidProjectName(project.name)">
- <NButton size="small" text @click="gotoWorkspace">
- <template #icon>
- <ChevronLeftIcon class="w-4 opacity-80" />
- </template>
- {{ $t("common.back-to-workspace") }}
- </NButton>
- </div>
- <NTabs
- :value="actualSelectedTab"
- type="line"
- @update:value="state.selectedTab = $event"
+ </template>
+ <NTabPane
+ v-for="tab in tabList"
+ :key="tab.id"
+ :name="tab.id"
+ :tab="tab.title"
+ :disabled="
+ tab.id === 'recent' &&
+ state.searchText.trim().length > 0 &&
+ filteredRecentProjectList.length === 0
+ "
>
- <template #suffix>
- <div class="flex flex-row justify-end items-center gap-x-2">
- <SearchBox
- v-model:value="state.searchText"
- :placeholder="$t('common.filter-by-name')"
- :autofocus="false"
- class="!w-40"
- size="small"
- />
- <NTooltip v-if="allowToCreateProject" trigger="hover">
- <template #trigger>
- <NButton size="small" @click="state.showCreateDrawer = true">
- <template #icon>
- <PlusIcon class="w-4 h-auto" />
- </template>
- </NButton>
- </template>
- {{ $t("quick-action.new-project") }}
- </NTooltip>
- </div>
- </template>
- <NTabPane
- v-for="tab in tabList"
- :key="tab.id"
- :name="tab.id"
- :tab="tab.title"
- :disabled="
- tab.id === 'recent' &&
- state.searchText.trim().length > 0 &&
- filteredRecentProjectList.length === 0
+ <ProjectV1Table
+ :project-list="tab.list"
+ :current-project="
+ isValidProjectName(project.name) ? project : undefined
"
- >
- <ProjectV1Table
- :project-list="tab.list"
- :current-project="
- isValidProjectName(project.name) ? project : undefined
- "
- :pagination="false"
- :keyword="state.searchText"
- @row-click="onProjectSelect"
- />
- </NTabPane>
- </NTabs>
- </div>
- </NPopover>
+ :pagination="false"
+ :keyword="state.searchText"
+ @row-click="onProjectSelect"
+ />
+ </NTabPane>
+ </NTabs>
+ </div>
<Drawer
:auto-focus="true"
@@ -98,17 +69,18 @@
</template>
<script lang="ts" setup>
-import { ChevronLeftIcon, PlusIcon, ChevronDownIcon } from "lucide-vue-next";
-import { NButton, NTabPane, NTabs, NTooltip, NPopover } from "naive-ui";
+import { ChevronLeftIcon, PlusIcon } from "lucide-vue-next";
+import { NButton, NTabPane, NTabs, NTooltip } from "naive-ui";
import { computed, reactive, onMounted, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
+import ProjectCreatePanel from "@/components/Project/ProjectCreatePanel.vue";
+import { useCurrentProject } from "@/components/Project/useCurrentProject";
import { useRecentProjects } from "@/components/Project/useRecentProjects";
import { SearchBox, ProjectV1Table } from "@/components/v2";
import { Drawer } from "@/components/v2";
-import { ProjectNameCell } from "@/components/v2/Model/DatabaseV1Table/cells";
import { PROJECT_V1_ROUTE_DETAIL } from "@/router/dashboard/projectV1";
-import { WORKSPACE_ROUTE_MY_ISSUES } from "@/router/dashboard/workspaceRoutes";
+import { WORKSPACE_ROUTE_LANDING } from "@/router/dashboard/workspaceRoutes";
import { useRecentVisit } from "@/router/useRecentVisit";
import { useProjectV1List } from "@/store";
import { getProjectName } from "@/store/modules/v1/common";
@@ -118,8 +90,6 @@ import {
filterProjectV1ListByKeyword,
hasWorkspacePermissionV2,
} from "@/utils";
-import ProjectCreatePanel from "./ProjectCreatePanel.vue";
-import { useCurrentProject } from "./useCurrentProject";
interface LocalState {
showPopover: boolean;
@@ -217,7 +187,7 @@ const onProjectSelect = (project: ComposedProject) => {
const gotoWorkspace = () => {
const route = router.resolve({
- name: WORKSPACE_ROUTE_MY_ISSUES,
+ name: WORKSPACE_ROUTE_LANDING,
});
record(route.fullPath);
router.push(route.fullPath);
diff --git a/frontend/src/components/Project/ProjectSwitch/ProjectSwitchModal.vue b/frontend/src/components/Project/ProjectSwitch/ProjectSwitchModal.vue
new file mode 100644
index 0000000000..0cafaac27b
--- /dev/null
+++ b/frontend/src/components/Project/ProjectSwitch/ProjectSwitchModal.vue
@@ -0,0 +1,26 @@
+<template>
+ <BBModal
+ :close-on-esc="true"
+ :mask-closable="true"
+ :trap-focus="false"
+ :show="show"
+ :title="$t('project.select')"
+ class="w-[48rem] max-w-full h-auto max-h-full"
+ @close="$emit('dismiss')"
+ >
+ <ProjectSwitchContent />
+ </BBModal>
+</template>
+
+<script lang="ts" setup>
+import { BBModal } from "@/bbkit";
+import ProjectSwitchContent from "./ProjectSwitchContent.vue";
+
+defineProps<{
+ show: boolean;
+}>();
+
+defineEmits<{
+ (event: "dismiss"): void;
+}>();
+</script>
diff --git a/frontend/src/components/Project/ProjectSwitch/ProjectSwitchPopover.vue b/frontend/src/components/Project/ProjectSwitch/ProjectSwitchPopover.vue
new file mode 100644
index 0000000000..c445c00bce
--- /dev/null
+++ b/frontend/src/components/Project/ProjectSwitch/ProjectSwitchPopover.vue
@@ -0,0 +1,73 @@
+<template>
+ <NPopover
+ v-model:show="state.showPopover"
+ class="max-h-[80vh] w-[24rem] max-w-full"
+ placement="bottom-start"
+ scrollable
+ trigger="click"
+ :show-arrow="false"
+ >
+ <template #trigger>
+ <NButton
+ class="hidden sm:inline"
+ size="small"
+ @click="state.showPopover = !state.showPopover"
+ >
+ <div class="min-w-[8rem] text-left">
+ <ProjectNameCell
+ v-if="isValidProjectName(project.name)"
+ mode="ALL_SHORT"
+ :project="project"
+ />
+ <span v-else class="text-control-placeholder text-sm">
+ {{ $t("project.select") }}
+ </span>
+ </div>
+ <ChevronDownIcon class="w-5 h-auto text-gray-400" />
+ </NButton>
+ </template>
+
+ <ProjectSwitchContent />
+ </NPopover>
+</template>
+
+<script lang="ts" setup>
+import { ChevronDownIcon } from "lucide-vue-next";
+import { NButton, NPopover } from "naive-ui";
+import { computed, reactive, watch } from "vue";
+import { useRouter } from "vue-router";
+import { ProjectNameCell } from "@/components/v2/Model/DatabaseV1Table/cells";
+import { isValidProjectName } from "@/types";
+import { useCurrentProject } from "../useCurrentProject";
+import ProjectSwitchContent from "./ProjectSwitchContent.vue";
+
+interface LocalState {
+ showPopover: boolean;
+}
+
+const state = reactive<LocalState>({
+ showPopover: false,
+});
+const router = useRouter();
+
+const params = computed(() => {
+ const route = router.currentRoute.value;
+ return {
+ projectId: route.params.projectId as string | undefined,
+ issueSlug: route.params.issueSlug as string | undefined,
+ instanceId: route.params.instanceId as string | undefined,
+ databaseName: route.params.databaseName as string | undefined,
+ changeHistoryId: route.params.changeHistoryId as string | undefined,
+ };
+});
+
+const { project } = useCurrentProject(params);
+
+// Close popover when current project changed.
+watch(
+ () => project.value.name,
+ () => {
+ state.showPopover = false;
+ }
+);
+</script>
diff --git a/frontend/src/layouts/BodyLayout.vue b/frontend/src/layouts/BodyLayout.vue
index 901020a06b..67d6415fb3 100644
--- a/frontend/src/layouts/BodyLayout.vue
+++ b/frontend/src/layouts/BodyLayout.vue
@@ -82,7 +82,7 @@
data-label="bb-dashboard-header"
>
<div class="max-w-full mx-auto">
- <DashboardHeader />
+ <DashboardHeader :show-logo="false" />
</div>
</nav>
diff --git a/frontend/src/layouts/IssueLayout.vue b/frontend/src/layouts/IssueLayout.vue
new file mode 100644
index 0000000000..294976212e
--- /dev/null
+++ b/frontend/src/layouts/IssueLayout.vue
@@ -0,0 +1,52 @@
+<template>
+ <div class="h-full flex flex-col overflow-hidden">
+ <div class="flex-1 flex overflow-hidden">
+ <div
+ class="flex flex-col min-w-0 flex-1"
+ :class="!hideHeader && 'border-x border-block-border'"
+ data-label="bb-main-body-wrapper"
+ >
+ <nav
+ v-if="!hideHeader"
+ class="bg-white border-b border-block-border"
+ data-label="bb-dashboard-header"
+ >
+ <div class="max-w-full mx-auto">
+ <DashboardHeader :show-logo="true" />
+ </div>
+ </nav>
+
+ <!-- This area may scroll -->
+ <div
+ id="bb-layout-main"
+ ref="mainContainerRef"
+ class="md:min-w-0 flex-1 overflow-y-auto py-4"
+ :class="mainContainerClasses"
+ >
+ <!-- Start main area-->
+ <router-view name="content" />
+ <!-- End main area -->
+ </div>
+ </div>
+ </div>
+
+ <Quickstart v-if="!hideQuickStart" />
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { ref } from "vue";
+import { useAppFeature } from "@/store";
+import DashboardHeader from "@/views/DashboardHeader.vue";
+import Quickstart from "../components/Quickstart.vue";
+import { provideBodyLayoutContext } from "./common";
+
+const mainContainerRef = ref<HTMLDivElement>();
+
+const hideHeader = useAppFeature("bb.feature.console.hide-header");
+const hideQuickStart = useAppFeature("bb.feature.hide-quick-start");
+
+const { mainContainerClasses } = provideBodyLayoutContext({
+ mainContainerRef,
+});
+</script>
diff --git a/frontend/src/layouts/ProjectV1Layout.vue b/frontend/src/layouts/ProjectV1Layout.vue
index 423b37f225..5796478f56 100644
--- a/frontend/src/layouts/ProjectV1Layout.vue
+++ b/frontend/src/layouts/ProjectV1Layout.vue
@@ -69,7 +69,7 @@ import {
PROJECT_V1_ROUTE_DETAIL,
PROJECT_V1_ROUTE_DATABASES,
} from "@/router/dashboard/projectV1";
-import { WORKSPACE_ROUTE_MY_ISSUES } from "@/router/dashboard/workspaceRoutes";
+import { WORKSPACE_ROUTE_LANDING } from "@/router/dashboard/workspaceRoutes";
import { useRecentVisit } from "@/router/useRecentVisit";
import {
hasFeature,
@@ -139,7 +139,7 @@ watchEffect(async () => {
});
removeVisit(projectRoute.fullPath);
router.replace({
- name: WORKSPACE_ROUTE_MY_ISSUES,
+ name: WORKSPACE_ROUTE_LANDING,
});
}
});
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index cfacac37af..8fd852cc72 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -966,6 +966,7 @@
},
"release": {
"new-version-available": "New version is available",
+ "new-version-available-with-tag": "New version {tag} is available",
"new-version-content": "The new version {tag} is available now! Please check our docs for installation.",
"not-show-till-next-release": "Don't show this till next version"
},
@@ -3519,9 +3520,6 @@
"search": "Search classification"
}
},
- "principal": {
- "select": "Select user"
- },
"role": {
"self": "Role",
"setting": {
@@ -3869,5 +3867,15 @@
},
"setup": {
"self": "Setup"
+ },
+ "landing": {
+ "quick-link": {
+ "self": "Quick Link",
+ "manage": "Manage quick link",
+ "visit-prjects": "Visit Projects",
+ "visit-issues": "Visit Issues"
+ },
+ "last-visit": "Last visit",
+ "changelog-for-version": "Changelog for {version}"
}
}
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index ee6b4f2536..35d81ce56a 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -966,6 +966,7 @@
},
"release": {
"new-version-available": "Nueva versión disponible",
+ "new-version-available-with-tag": "La nueva versión {tag} está disponible",
"new-version-content": "¡La nueva versión {tag} está disponible ahora! Consulte nuestra documentación para la instalación.",
"not-show-till-next-release": "No mostrar esto hasta la próxima versión"
},
@@ -3519,9 +3520,6 @@
"search": "Clasificación de búsqueda"
}
},
- "principal": {
- "select": "Seleccionar usuario"
- },
"role": {
"self": "Rol",
"setting": {
@@ -3869,5 +3867,15 @@
},
"setup": {
"self": "Configuración"
+ },
+ "landing": {
+ "quick-link": {
+ "self": "Enlace rápido",
+ "manage": "Administrar enlace rápido",
+ "visit-prjects": "Visitar Proyectos",
+ "visit-issues": "Problemas de visita"
+ },
+ "last-visit": "Última visita",
+ "changelog-for-version": "Registro de cambios para {version}"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 4757e02c61..dd5c0dcb4b 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -966,6 +966,7 @@
},
"release": {
"new-version-available": "更新する新しいバージョンがあります",
+ "new-version-available-with-tag": "新しいバージョン {tag} が利用可能です",
"new-version-content": "新しいバージョン {tag} が正式にリリースされました。新しいバージョンを入手するには、ドキュメントに従ってください。",
"not-show-till-next-release": "次の更新までは通知しないでください"
},
@@ -3519,9 +3520,6 @@
"search": "カテゴリを検索する"
}
},
- "principal": {
- "select": "ユーザーの選択"
- },
"role": {
"self": "役割",
"setting": {
@@ -3869,5 +3867,15 @@
},
"setup": {
"self": "設定"
+ },
+ "landing": {
+ "quick-link": {
+ "self": "クイックリンク",
+ "manage": "クイックリンクを管理する",
+ "visit-prjects": "プロジェクトを訪問",
+ "visit-issues": "訪問に関する問題"
+ },
+ "last-visit": "最終訪問",
+ "changelog-for-version": "{version} の変更履歴"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/subscription/zh-CN.json b/frontend/src/locales/subscription/zh-CN.json
index d4a6a4f7e7..466502a0ff 100644
--- a/frontend/src/locales/subscription/zh-CN.json
+++ b/frontend/src/locales/subscription/zh-CN.json
@@ -196,4 +196,4 @@
"2fa": "双重认证 (2FA)",
"custom-approval": "自定义审批"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index fc565ec196..354057b376 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -966,6 +966,7 @@
},
"release": {
"new-version-available": "有新版本可更新",
+ "new-version-available-with-tag": "新版本 {tag} 已推出",
"new-version-content": "新版本 {tag} 正式发布!请根据我们的文档来获取新版本。",
"not-show-till-next-release": "在下次更新前不要提醒我"
},
@@ -3519,9 +3520,6 @@
"search": "搜索分类"
}
},
- "principal": {
- "select": "选择用户"
- },
"role": {
"self": "角色",
"setting": {
@@ -3869,5 +3867,15 @@
},
"setup": {
"self": "设置"
+ },
+ "landing": {
+ "quick-link": {
+ "self": "快捷访问",
+ "manage": "管理快捷访问",
+ "visit-prjects": "访问项目",
+ "visit-issues": "访问工单"
+ },
+ "last-visit": "上次访问",
+ "changelog-for-version": "{version} 的更新日志"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/router/dashboard/index.ts b/frontend/src/router/dashboard/index.ts
index 877fd11e96..24e6167abc 100644
--- a/frontend/src/router/dashboard/index.ts
+++ b/frontend/src/router/dashboard/index.ts
@@ -1,10 +1,13 @@
import type { RouteRecordRaw } from "vue-router";
import BodyLayout from "@/layouts/BodyLayout.vue";
import DashboardLayout from "@/layouts/DashboardLayout.vue";
+import IssueLayout from "@/layouts/IssueLayout.vue";
+import MyIssues from "@/views/MyIssues.vue";
import environmentV1Routes from "./environmentV1";
import instanceRoutes from "./instance";
import projectV1Routes from "./projectV1";
import workspaceRoutes from "./workspace";
+import { WORKSPACE_ROUTE_MY_ISSUES } from "./workspaceRoutes";
import workspaceSettingRoutes from "./workspaceSetting";
const dashboardRoutes: RouteRecordRaw[] = [
@@ -23,6 +26,22 @@ const dashboardRoutes: RouteRecordRaw[] = [
...projectV1Routes,
],
},
+ {
+ path: "issues",
+ components: {
+ body: IssueLayout,
+ },
+ props: true,
+ children: [
+ {
+ path: "",
+ name: WORKSPACE_ROUTE_MY_ISSUES,
+ components: {
+ content: MyIssues,
+ },
+ },
+ ],
+ },
],
},
];
diff --git a/frontend/src/router/dashboard/workspace.ts b/frontend/src/router/dashboard/workspace.ts
index 68352fe0db..8086c16a61 100644
--- a/frontend/src/router/dashboard/workspace.ts
+++ b/frontend/src/router/dashboard/workspace.ts
@@ -2,13 +2,12 @@ import { startCase } from "lodash-es";
import type { RouteRecordRaw } from "vue-router";
import DummyRootView from "@/DummyRootView";
import { t } from "@/plugins/i18n";
-import MyIssues from "@/views/MyIssues.vue";
import {
PROJECT_V1_ROUTE_DASHBOARD,
INSTANCE_ROUTE_DASHBOARD,
ENVIRONMENT_V1_ROUTE_DASHBOARD,
WORKSPACE_ROOT_MODULE,
- WORKSPACE_ROUTE_MY_ISSUES,
+ WORKSPACE_ROUTE_LANDING,
WORKSPACE_ROUTE_USER_PROFILE,
WORKSPACE_ROUTE_SQL_REVIEW,
WORKSPACE_ROUTE_SQL_REVIEW_CREATE,
@@ -44,16 +43,12 @@ const rootRoute: RouteRecordRaw = {
const workspaceRoutes: RouteRecordRaw[] = [
rootRoute,
{
- path: "issues",
- name: WORKSPACE_ROUTE_MY_ISSUES,
+ path: "landing",
+ name: WORKSPACE_ROUTE_LANDING,
components: {
- content: MyIssues,
+ content: () => import("@/views/DashboardLanding.vue"),
leftSidebar: () => import("@/views/DashboardSidebar.vue"),
},
- props: {
- content: true,
- leftSidebar: true,
- },
},
{
path: "projects",
diff --git a/frontend/src/router/dashboard/workspaceRoutes.ts b/frontend/src/router/dashboard/workspaceRoutes.ts
index fd9e4d9248..f7c3d4e257 100644
--- a/frontend/src/router/dashboard/workspaceRoutes.ts
+++ b/frontend/src/router/dashboard/workspaceRoutes.ts
@@ -1,4 +1,5 @@
export const WORKSPACE_ROOT_MODULE = "workspace.root";
+export const WORKSPACE_ROUTE_LANDING = "workspace.landing";
export const WORKSPACE_ROUTE_MY_ISSUES = "workspace.my-issues";
export const WORKSPACE_ROUTE_EXPORT_CENTER = "workspace.export-center";
export const WORKSPACE_ROUTE_USER_PROFILE = "workspace.user-profile";
diff --git a/frontend/src/router/useRecentVisit.ts b/frontend/src/router/useRecentVisit.ts
index ec347583e1..358e6eeecb 100644
--- a/frontend/src/router/useRecentVisit.ts
+++ b/frontend/src/router/useRecentVisit.ts
@@ -1,9 +1,10 @@
import { computed } from "vue";
import { useCurrentUserV1 } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
import { useDynamicLocalStorage } from "@/utils";
const STORAGE_KEY = "bb.space.recently_visited";
-const MAX_HISTORY = 3;
+const MAX_HISTORY = 10;
export function useRecentVisit() {
const currentUser = useCurrentUserV1();
@@ -20,6 +21,15 @@ export function useRecentVisit() {
return recentVisit.value[0];
});
+ const lastVisitProjectPath = computed(() => {
+ for (const visit of recentVisit.value) {
+ if (visit.startsWith(`/${projectNamePrefix}`)) {
+ return visit;
+ }
+ }
+ return "";
+ });
+
const remove = (path: string) => {
const index = recentVisit.value.findIndex((item) => {
// We treat the two URLs "the same" when their urls'
@@ -54,6 +64,7 @@ export function useRecentVisit() {
remove,
record,
lastVisit,
+ lastVisitProjectPath,
};
}
diff --git a/frontend/src/store/modules/index.ts b/frontend/src/store/modules/index.ts
index 0268cb5423..aaf74d253e 100644
--- a/frontend/src/store/modules/index.ts
+++ b/frontend/src/store/modules/index.ts
@@ -20,5 +20,6 @@ export * from "./branch";
export * from "./release";
export * from "./revision";
export * from "./rollout";
+export * from "./quickLink";
export * from "./v1";
diff --git a/frontend/src/store/modules/quickLink.ts b/frontend/src/store/modules/quickLink.ts
new file mode 100644
index 0000000000..67b80108de
--- /dev/null
+++ b/frontend/src/store/modules/quickLink.ts
@@ -0,0 +1,110 @@
+import { flatten } from "lodash-es";
+import {
+ GalleryHorizontalEndIcon,
+ SettingsIcon,
+ CircleDotIcon,
+} from "lucide-vue-next";
+import { computed, h, type VNode } from "vue";
+import { t } from "@/plugins/i18n";
+import {
+ WORKSPACE_ROUTE_LANDING,
+ WORKSPACE_ROUTE_USERS,
+ WORKSPACE_ROUTE_SQL_REVIEW,
+} from "@/router/dashboard/workspaceRoutes";
+import { useCurrentUserV1 } from "@/store";
+import {
+ useDynamicLocalStorage,
+ useDashboardSidebar,
+ type DashboardSidebarItem,
+} from "@/utils";
+
+export interface QuickLink {
+ id: string;
+ title: string;
+ route?: string;
+ icon: () => VNode;
+}
+
+export function useQuickLink() {
+ const currentUser = useCurrentUserV1();
+ const { dashboardSidebarItemList } = useDashboardSidebar();
+
+ const getAccessListBySidebar = (
+ sidebarItem: DashboardSidebarItem,
+ icon: () => VNode = () => h(SettingsIcon)
+ ): QuickLink[] => {
+ if (sidebarItem.type === "route" && sidebarItem.title && sidebarItem.name) {
+ if (sidebarItem.name === WORKSPACE_ROUTE_LANDING) {
+ return [];
+ }
+ return [
+ {
+ id: sidebarItem.name,
+ title: sidebarItem.title,
+ route: sidebarItem.name,
+ icon: sidebarItem.icon || icon,
+ },
+ ];
+ }
+
+ if (sidebarItem.children) {
+ return flatten(
+ sidebarItem.children.map((child) =>
+ getAccessListBySidebar(child, sidebarItem.icon)
+ )
+ ).filter((item) => item) as QuickLink[];
+ }
+
+ return [];
+ };
+
+ const fullQuickLinkList = computed((): QuickLink[] => {
+ const accessList = flatten(
+ dashboardSidebarItemList.value.map((item) => getAccessListBySidebar(item))
+ ).filter((item) => item) as QuickLink[];
+
+ accessList.unshift(
+ {
+ id: "visit-projects",
+ title: t("landing.quick-link.visit-prjects"),
+ icon: () => h(GalleryHorizontalEndIcon),
+ },
+ {
+ id: "visit-issues",
+ title: t("landing.quick-link.visit-issues"),
+ icon: () => h(CircleDotIcon),
+ }
+ );
+
+ return accessList;
+ });
+
+ const quickAccessConfig = useDynamicLocalStorage<string[]>(
+ computed(() => `bb.quick-access.${currentUser.value.name}`),
+ [
+ "visit-issues",
+ "visit-projects",
+ WORKSPACE_ROUTE_USERS,
+ WORKSPACE_ROUTE_SQL_REVIEW,
+ ]
+ );
+
+ const quickLinkList = computed({
+ get() {
+ return quickAccessConfig.value
+ .map((id) => {
+ return fullQuickLinkList.value.find((item) => item.id === id);
+ })
+ .filter((item) => item) as QuickLink[];
+ },
+ set(list) {
+ quickAccessConfig.value = list.map((item) => item.id);
+ },
+ });
+
+ return {
+ quickLinkList,
+ quickAccessConfig,
+ fullQuickLinkList,
+ };
+}
diff --git a/frontend/src/store/modules/v1/actuator.ts b/frontend/src/store/modules/v1/actuator.ts
index c79fb584dd..6c09e6d98d 100644
--- a/frontend/src/store/modules/v1/actuator.ts
+++ b/frontend/src/store/modules/v1/actuator.ts
@@ -2,6 +2,7 @@ import type { RemovableRef } from "@vueuse/core";
import { useLocalStorage } from "@vueuse/core";
import axios from "axios";
import { defineStore } from "pinia";
+import semver from "semver";
import { computed } from "vue";
import { actuatorServiceClient } from "@/grpcweb";
import { useSilentRequest } from "@/plugins/silent-request";
@@ -45,6 +46,14 @@ export const useActuatorV1Store = defineStore("actuator_v1", {
appProfile: defaultAppProfile(),
}),
getters: {
+ changelogURL: (state) => {
+ // valid version should following semantic version like 3.1.0
+ const version = semver.valid(state.serverInfo?.version);
+ if (!version) {
+ return "";
+ }
+ return `https://bytebase.com/changelog/bytebase-${version.split(".").join("-")}/`;
+ },
info: (state) => {
return state.serverInfo;
},
diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts
index 1731f8eb47..6c27e76c9c 100644
--- a/frontend/src/utils/index.ts
+++ b/frontend/src/utils/index.ts
@@ -23,6 +23,7 @@ export * from "./resource-composer";
export * from "./TinyTimer";
export * from "./sheet";
export * from "./naive-ui";
+export * from "./useDashboardSidebar";
export * from "./v1";
export * from "./iam";
diff --git a/frontend/src/utils/useDashboardSidebar.ts b/frontend/src/utils/useDashboardSidebar.ts
new file mode 100644
index 0000000000..f014d21ff2
--- /dev/null
+++ b/frontend/src/utils/useDashboardSidebar.ts
@@ -0,0 +1,328 @@
+import {
+ LinkIcon,
+ HomeIcon,
+ DatabaseIcon,
+ WorkflowIcon,
+ GalleryHorizontalEndIcon,
+ LayersIcon,
+ SquareStackIcon,
+ ShieldCheck,
+ UsersIcon,
+ SettingsIcon,
+} from "lucide-vue-next";
+import { computed, h } from "vue";
+import type { RouteRecordRaw } from "vue-router";
+import { useRoute } from "vue-router";
+import type { SidebarItem } from "@/components/CommonSidebar.vue";
+import { t } from "@/plugins/i18n";
+import workspaceRoutes from "@/router/dashboard/workspace";
+import {
+ DATABASE_ROUTE_DASHBOARD,
+ ENVIRONMENT_V1_ROUTE_DASHBOARD,
+ INSTANCE_ROUTE_DASHBOARD,
+ PROJECT_V1_ROUTE_DASHBOARD,
+ WORKSPACE_ROUTE_LANDING,
+ WORKSPACE_ROUTE_SQL_REVIEW,
+ WORKSPACE_ROUTE_SCHEMA_TEMPLATE,
+ WORKSPACE_ROUTE_CUSTOM_APPROVAL,
+ WORKSPACE_ROUTE_RISK_CENTER,
+ WORKSPACE_ROUTE_DATA_MASKING,
+ WORKSPACE_ROUTE_DATA_CLASSIFICATION,
+ WORKSPACE_ROUTE_AUDIT_LOG,
+ WORKSPACE_ROUTE_GITOPS,
+ WORKSPACE_ROUTE_SSO,
+ WORKSPACE_ROUTE_MAIL_DELIVERY,
+ WORKSPACE_ROUTE_USERS,
+ WORKSPACE_ROUTE_MEMBERS,
+ WORKSPACE_ROUTE_ROLES,
+ WORKSPACE_ROUTE_USER_PROFILE,
+ WORKSPACE_ROUTE_IM,
+} from "@/router/dashboard/workspaceRoutes";
+import {
+ SETTING_ROUTE_WORKSPACE_GENERAL,
+ SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,
+ SETTING_ROUTE_WORKSPACE_ARCHIVE,
+} from "@/router/dashboard/workspaceSetting";
+import { useAppFeature, usePermissionStore } from "@/store";
+import type { Permission } from "@/types";
+import { DatabaseChangeMode } from "@/types/proto/v1/setting_service";
+import { hasWorkspacePermissionV2 } from "@/utils";
+
+export interface DashboardSidebarItem extends SidebarItem {
+ navigationId?: string;
+ shortcuts?: string[];
+ hide?: boolean;
+ children?: DashboardSidebarItem[];
+}
+
+export const useDashboardSidebar = () => {
+ const route = useRoute();
+ const permissionStore = usePermissionStore();
+ const databaseChangeMode = useAppFeature("bb.feature.database-change-mode");
+
+ 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");
+ return classes;
+ }
+ if (
+ item.name === WORKSPACE_ROUTE_USERS &&
+ current?.toString() === WORKSPACE_ROUTE_USER_PROFILE
+ ) {
+ classes.push("router-link-active", "bg-link-hover");
+ return classes;
+ }
+ return classes;
+ };
+
+ const filterSidebarByPermissions = (
+ sidebarList: DashboardSidebarItem[]
+ ): DashboardSidebarItem[] => {
+ return sidebarList
+ .filter((item) => {
+ const routeConfig = flattenRoutes.value.find(
+ (workspaceRoute) => workspaceRoute.name === item.name
+ );
+ return (routeConfig?.permissions ?? []).every((permission) =>
+ hasWorkspacePermissionV2(permission)
+ );
+ })
+ .map((item) => ({
+ ...item,
+ expand:
+ item.expand ||
+ (item.children ?? [])
+ .reduce((classList, child) => {
+ classList.push(...getItemClass(child));
+ return classList;
+ }, [] as string[])
+ .includes("router-link-active"),
+ children: filterSidebarByPermissions(item.children ?? []),
+ }));
+ };
+
+ const getFlattenRoutes = (
+ routes: RouteRecordRaw[],
+ permissions: Permission[] = []
+ ): {
+ name: string;
+ permissions: Permission[];
+ }[] => {
+ return routes.reduce(
+ (list, workspaceRoute) => {
+ const requiredWorkspacePermissionListFunc =
+ workspaceRoute.meta?.requiredWorkspacePermissionList;
+ let requiredPermissionList = requiredWorkspacePermissionListFunc
+ ? requiredWorkspacePermissionListFunc()
+ : [];
+ if (requiredPermissionList.length === 0) {
+ requiredPermissionList = permissions;
+ }
+
+ if (workspaceRoute.name && workspaceRoute.name.toString() !== "") {
+ list.push({
+ name: workspaceRoute.name.toString(),
+ permissions: requiredPermissionList,
+ });
+ }
+ if (workspaceRoute.children) {
+ list.push(
+ ...getFlattenRoutes(workspaceRoute.children, requiredPermissionList)
+ );
+ }
+ return list;
+ },
+ [] as { name: string; permissions: Permission[] }[]
+ );
+ };
+
+ const flattenRoutes = computed(() => {
+ return getFlattenRoutes(workspaceRoutes);
+ });
+
+ const dashboardSidebarItemList = computed((): DashboardSidebarItem[] => {
+ const sidebarList: DashboardSidebarItem[] = [
+ {
+ navigationId: "bb.navigation.home",
+ title: t("common.home"),
+ icon: () => h(HomeIcon),
+ name: WORKSPACE_ROUTE_LANDING,
+ type: "route",
+ shortcuts: ["g", "h"],
+ },
+ {
+ navigationId: "bb.navigation.projects",
+ title: t("common.projects"),
+ icon: () => h(GalleryHorizontalEndIcon),
+ name: PROJECT_V1_ROUTE_DASHBOARD,
+ type: "route",
+ shortcuts: ["g", "p"],
+ },
+ {
+ navigationId: "bb.navigation.instances",
+ title: t("common.instances"),
+ icon: () => h(LayersIcon),
+ name: INSTANCE_ROUTE_DASHBOARD,
+ type: "route",
+ shortcuts: ["g", "i"],
+ },
+ {
+ navigationId: "bb.navigation.databases",
+ title: t("common.databases"),
+ icon: () => h(DatabaseIcon),
+ name: DATABASE_ROUTE_DASHBOARD,
+ type: "route",
+ shortcuts: ["g", "d"],
+ },
+ {
+ navigationId: "bb.navigation.environments",
+ title: t("common.environments"),
+ icon: () => h(SquareStackIcon),
+ name: ENVIRONMENT_V1_ROUTE_DASHBOARD,
+ type: "route",
+ shortcuts: ["g", "e"],
+ },
+ {
+ type: "divider",
+ name: "",
+ },
+ {
+ title: t("settings.sidebar.iam-and-admin"),
+ icon: () => h(UsersIcon),
+ type: "div",
+ children: [
+ {
+ title: t("settings.sidebar.users-and-groups"),
+ name: WORKSPACE_ROUTE_USERS,
+ type: "route",
+ },
+ {
+ title: t("settings.sidebar.members"),
+ name: WORKSPACE_ROUTE_MEMBERS,
+ type: "route",
+ hide: permissionStore.onlyWorkspaceMember,
+ },
+ {
+ title: t("settings.sidebar.custom-roles"),
+ name: WORKSPACE_ROUTE_ROLES,
+ type: "route",
+ },
+ {
+ title: t("settings.sidebar.sso"),
+ name: WORKSPACE_ROUTE_SSO,
+ type: "route",
+ },
+ {
+ title: t("settings.sidebar.audit-log"),
+ name: WORKSPACE_ROUTE_AUDIT_LOG,
+ type: "route",
+ },
+ ],
+ },
+ {
+ title: "CI/CD",
+ icon: () => h(WorkflowIcon),
+ type: "div",
+ hide: databaseChangeMode.value === DatabaseChangeMode.EDITOR,
+ children: [
+ {
+ title: t("sql-review.title"),
+ name: WORKSPACE_ROUTE_SQL_REVIEW,
+ type: "route",
+ },
+ {
+ title: t("custom-approval.risk.risk-center"),
+ name: WORKSPACE_ROUTE_RISK_CENTER,
+ type: "route",
+ },
+ {
+ title: t("custom-approval.self"),
+ name: WORKSPACE_ROUTE_CUSTOM_APPROVAL,
+ type: "route",
+ },
+ {
+ title: t("schema-template.self"),
+ name: WORKSPACE_ROUTE_SCHEMA_TEMPLATE,
+ type: "route",
+ },
+ {
+ title: t("settings.sidebar.gitops"),
+ name: WORKSPACE_ROUTE_GITOPS,
+ type: "route",
+ hide: databaseChangeMode.value === DatabaseChangeMode.EDITOR,
+ },
+ ],
+ },
+ {
+ title: t("settings.sidebar.data-access"),
+ icon: () => h(ShieldCheck),
+ type: "div",
+ children: [
+ {
+ title: t("settings.sidebar.data-classification"),
+ name: WORKSPACE_ROUTE_DATA_CLASSIFICATION,
+ type: "route",
+ },
+ {
+ title: t("settings.sidebar.data-masking"),
+ name: WORKSPACE_ROUTE_DATA_MASKING,
+ type: "route",
+ },
+ ],
+ },
+ {
+ title: t("settings.sidebar.integration"),
+ icon: () => h(LinkIcon),
+ type: "div",
+ hide: databaseChangeMode.value === DatabaseChangeMode.EDITOR,
+ children: [
+ {
+ title: t("settings.sidebar.mail-delivery"),
+ name: WORKSPACE_ROUTE_MAIL_DELIVERY,
+ type: "route",
+ },
+ {
+ title: t("settings.sidebar.im-integration"),
+ name: WORKSPACE_ROUTE_IM,
+ type: "route",
+ },
+ ],
+ },
+ {
+ title: t("common.settings"),
+ icon: () => h(SettingsIcon),
+ type: "div",
+ hide: !hasWorkspacePermissionV2("bb.settings.get"),
+ children: [
+ {
+ title: t("settings.sidebar.general"),
+ name: SETTING_ROUTE_WORKSPACE_GENERAL,
+ type: "route",
+ },
+ {
+ title: t("settings.sidebar.subscription"),
+ name: SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,
+ type: "route",
+ },
+ {
+ title: t("common.archived"),
+ name: SETTING_ROUTE_WORKSPACE_ARCHIVE,
+ type: "route",
+ },
+ ],
+ },
+ ];
+
+ return filterSidebarByPermissions(sidebarList);
+ });
+
+ return {
+ getItemClass,
+ dashboardSidebarItemList,
+ };
+};
diff --git a/frontend/src/views/DashboardHeader.vue b/frontend/src/views/DashboardHeader.vue
index 8b886c0a4b..df4530f513 100644
--- a/frontend/src/views/DashboardHeader.vue
+++ b/frontend/src/views/DashboardHeader.vue
@@ -1,14 +1,29 @@
<template>
<div class="flex items-center justify-between h-10 px-4 my-1 space-x-3">
- <div class="flex items-center">
- <BytebaseLogo
- class="block md:hidden"
- :redirect="WORKSPACE_ROUTE_MY_ISSUES"
- />
- <ProjectSwitchPopover />
- </div>
+ <BytebaseLogo
+ v-if="showLogo"
+ class="shrink-0"
+ :redirect="WORKSPACE_ROUTE_LANDING"
+ />
+ <ProjectSwitchPopover />
+ <router-link
+ :to="sqlEditorLink"
+ class="flex flex-row justify-center items-center"
+ exact-active-class=""
+ target="_blank"
+ >
+ <NButton size="small">
+ <SquareTerminalIcon class="w-4 h-auto mr-1" />
+ <span class="whitespace-nowrap">{{ $t("sql-editor.self") }}</span>
+ </NButton>
+ </router-link>
+
<div class="flex-1 flex justify-end items-center space-x-3">
- <NButton class="hidden md:flex" size="small" @click="onClickSearchButton">
+ <NButton
+ class="!hidden md:!flex"
+ size="small"
+ @click="onClickSearchButton"
+ >
<SearchIcon class="w-4 h-auto mr-1" />
<span class="text-control-placeholder text-sm mr-4">
{{ $t("common.search") }}
@@ -34,35 +49,27 @@
type="success"
@click="handleWantHelp"
>
- <span class="hidden lg:block mr-2">{{ $t("common.want-help") }}</span>
- <heroicons-outline:chat-bubble-left-right class="w-4 h-4" />
+ <MessagesSquareIcon class="w-4 h-4" />
+ <span class="hidden lg:block ml-2">{{ $t("common.want-help") }}</span>
</NButton>
- <router-link
- :to="sqlEditorLink"
- class="flex flex-row justify-center items-center"
- exact-active-class=""
- target="_blank"
- >
- <NButton size="small">
- <SquareTerminalIcon class="w-4 h-auto mr-1" />
- <span class="whitespace-nowrap">{{ $t("sql-editor.self") }}</span>
- </NButton>
- </router-link>
- <NTooltip>
+
+ <NTooltip :disabled="windowWidth >= 640">
<template #trigger>
- <router-link :to="myIssueLink" exact-active-class="">
+ <router-link :to="myIssueLink" class="flex">
<NButton size="small" @click="goToMyIssues">
- <CircleDotIcon class="w-4 h-auto" />
+ <CircleDotIcon class="w-4" />
+ <span class="hidden sm:block ml-2">{{
+ $t("issue.my-issues")
+ }}</span>
</NButton>
</router-link>
</template>
{{ $t("issue.my-issues") }}
</NTooltip>
- <div class="ml-2">
- <ProfileBrandingLogo>
- <ProfileDropdown :link="true" />
- </ProfileBrandingLogo>
- </div>
+
+ <ProfileBrandingLogo>
+ <ProfileDropdown :link="true" />
+ </ProfileBrandingLogo>
</div>
</div>
@@ -76,24 +83,33 @@
<script lang="ts" setup>
import { defineAction, useRegisterActions } from "@bytebase/vue-kbar";
import { useKBarHandler } from "@bytebase/vue-kbar";
-import { useLocalStorage } from "@vueuse/core";
-import { CircleDotIcon, SearchIcon, SquareTerminalIcon } from "lucide-vue-next";
+import { useLocalStorage, useWindowSize } from "@vueuse/core";
+import {
+ CircleDotIcon,
+ SearchIcon,
+ SquareTerminalIcon,
+ MessagesSquareIcon,
+} from "lucide-vue-next";
import { NButton, NTooltip } from "naive-ui";
import { storeToRefs } from "pinia";
import { v4 as uuidv4 } from "uuid";
import { computed, reactive } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
-import ProjectSwitchPopover from "@/components/Project/ProjectSwitchPopover.vue";
+import ProjectSwitchPopover from "@/components/Project/ProjectSwitch/ProjectSwitchPopover.vue";
import { useCurrentProject } from "@/components/Project/useCurrentProject";
import WeChatQRModal from "@/components/WeChatQRModal.vue";
-import { WORKSPACE_ROUTE_MY_ISSUES } from "@/router/dashboard/workspaceRoutes";
+import {
+ WORKSPACE_ROUTE_MY_ISSUES,
+ WORKSPACE_ROUTE_LANDING,
+} from "@/router/dashboard/workspaceRoutes";
import { SETTING_ROUTE_WORKSPACE_GENERAL } from "@/router/dashboard/workspaceSetting";
import {
SQL_EDITOR_DATABASE_MODULE,
SQL_EDITOR_HOME_MODULE,
SQL_EDITOR_PROJECT_MODULE,
} from "@/router/sqlEditor";
+import { useRecentVisit } from "@/router/useRecentVisit";
import { useSubscriptionV1Store } from "@/store";
import { PlanType } from "@/types/proto/v1/subscription_service";
import {
@@ -108,6 +124,10 @@ import ProfileDropdown from "../components/ProfileDropdown.vue";
import { useLanguage } from "../composables/useLanguage";
import { isValidDatabaseName, isValidProjectName } from "../types";
+defineProps<{
+ showLogo: boolean;
+}>();
+
interface LocalState {
showQRCodeModal: boolean;
showProjectModal: boolean;
@@ -117,6 +137,8 @@ const { t } = useI18n();
const subscriptionStore = useSubscriptionV1Store();
const router = useRouter();
const { locale } = useLanguage();
+const { record } = useRecentVisit();
+const { width: windowWidth } = useWindowSize();
const state = reactive<LocalState>({
showQRCodeModal: false,
@@ -176,13 +198,13 @@ const sqlEditorLink = computed(() => {
});
const myIssueLink = computed(() => {
- // Always redirect to my issues page in workspace level.
return router.resolve({
name: WORKSPACE_ROUTE_MY_ISSUES,
});
});
const goToMyIssues = () => {
+ record(myIssueLink.value.fullPath);
// Trigger page reload manually.
useLocalStorage<string>(
getComponentIdLocalStorageKey(WORKSPACE_ROUTE_MY_ISSUES),
diff --git a/frontend/src/views/DashboardLanding.vue b/frontend/src/views/DashboardLanding.vue
new file mode 100644
index 0000000000..ce92d785fa
--- /dev/null
+++ b/frontend/src/views/DashboardLanding.vue
@@ -0,0 +1,217 @@
+<template>
+ <div class="px-4 flex flex-col h-full items-center relative">
+ <div class="flex-1" />
+ <div class="flex-[60%] space-y-6">
+ <div class="flex items-baseline gap-x-4">
+ <div class="flex items-start gap-x-1">
+ <div class="font-semibold text-2xl">
+ {{ $t("landing.quick-link.self") }}
+ </div>
+ <NButton
+ quaternary
+ size="small"
+ @click="state.showConfigDrawer = true"
+ >
+ <template #icon>
+ <SettingsIcon class="w-4" />
+ </template>
+ </NButton>
+ </div>
+ <router-link
+ v-if="lastProject"
+ class="underline normal-link"
+ :to="{ path: lastVisitProjectPath }"
+ >
+ {{ $t("landing.last-visit") }}:
+ {{ lastProject.title }}
+ </router-link>
+ </div>
+ <div
+ class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4"
+ >
+ <component
+ :is="access.route ? 'router-link' : 'div'"
+ v-for="(access, i) in quickLinkList"
+ :key="i"
+ :to="{
+ name: access.route,
+ }"
+ class="flex justify-center items-center gap-x-2 cursor-pointer border rounded px-4 py-5 bg-white hover:bg-gray-100"
+ @click="handleClick(access)"
+ >
+ <component :is="access.icon" class="w-5 h-5 text-gray-500" />
+ {{ access.title }}
+ </component>
+ </div>
+ <div class="space-y-2">
+ <a
+ v-if="actuatorStore.changelogURL"
+ class="underline normal-link"
+ target="_blank"
+ :href="actuatorStore.changelogURL"
+ >
+ {{
+ $t("landing.changelog-for-version", {
+ version: actuatorStore.version,
+ })
+ }}
+ </a>
+ <a
+ v-if="actuatorStore.hasNewRelease"
+ class="underline normal-link flex items-center gap-x-1"
+ target="_blank"
+ :href="actuatorStore.releaseInfo.latest?.html_url"
+ >
+ <Volume2Icon class="h-4 w-4" />
+ {{
+ $t("settings.release.new-version-available-with-tag", {
+ tag: actuatorStore.releaseInfo.latest?.tag_name,
+ })
+ }}
+ </a>
+ </div>
+ </div>
+ </div>
+
+ <ProjectSwitchModal
+ :show="state.showProjectModal"
+ @dismiss="state.showProjectModal = false"
+ />
+
+ <Drawer
+ :show="state.showConfigDrawer"
+ :close-on-esc="true"
+ @close="state.showConfigDrawer = false"
+ >
+ <DrawerContent
+ :title="$t('landing.quick-link.manage')"
+ class="!w-96 max-w-full"
+ style="max-width: calc(100vw - 8rem)"
+ >
+ <div>
+ <Draggable v-model="quickLinkList" item-key="id" animation="300">
+ <template #item="{ element }: { element: QuickLink }">
+ <div
+ class="flex items-center justify-between p-2 hover:bg-gray-100 rounded-sm cursor-grab"
+ >
+ <div :key="element.id" class="flex items-center gap-x-2">
+ <NCheckbox
+ :disabled="quickLinkList.length <= 1"
+ :checked="true"
+ @update:checked="() => uncheckAccessItem(element)"
+ />
+ <component :is="element.icon" class="w-5 h-5 text-gray-500" />
+ {{ element.title }}
+ </div>
+ <ArrowDownUpIcon class="w-5 h-5 text-gray-500" />
+ </div>
+ </template>
+ </Draggable>
+ <NDivider />
+
+ <div
+ v-for="access in unSelectedAccessList"
+ :key="access.id"
+ class="flex items-center gap-x-2 p-2 hover:bg-gray-100 rounded-sm cursor-pointer"
+ @click.prevent.stop="() => checkAccessItem(access)"
+ >
+ <NCheckbox
+ :checked="false"
+ @update:checked="() => checkAccessItem(access)"
+ />
+ <component :is="access.icon" class="w-5 h-5 text-gray-500" />
+ {{ access.title }}
+ </div>
+ </div>
+ </DrawerContent>
+ </Drawer>
+</template>
+
+<script lang="tsx" setup>
+import { Volume2Icon } from "lucide-vue-next";
+import { SettingsIcon, ArrowDownUpIcon } from "lucide-vue-next";
+import { NButton, NCheckbox, NDivider } from "naive-ui";
+import { computed, reactive } from "vue";
+import { useRouter } from "vue-router";
+import Draggable from "vuedraggable";
+import ProjectSwitchModal from "@/components/Project/ProjectSwitch/ProjectSwitchModal.vue";
+import { Drawer, DrawerContent } from "@/components/v2";
+import { WORKSPACE_ROUTE_MY_ISSUES } from "@/router/dashboard/workspaceRoutes";
+import { useRecentVisit } from "@/router/useRecentVisit";
+import {
+ useProjectV1Store,
+ useActuatorV1Store,
+ useQuickLink,
+ type QuickLink,
+} from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+import { UNKNOWN_PROJECT_NAME } from "@/types";
+import { extractProjectResourceName } from "@/utils";
+
+interface LocalState {
+ showProjectModal: boolean;
+ showConfigDrawer: boolean;
+}
+
+const state = reactive<LocalState>({
+ showProjectModal: false,
+ showConfigDrawer: false,
+});
+const projectStore = useProjectV1Store();
+const actuatorStore = useActuatorV1Store();
+const { lastVisitProjectPath } = useRecentVisit();
+const router = useRouter();
+
+const lastProject = computed(() => {
+ if (!lastVisitProjectPath.value) {
+ return;
+ }
+ const projectName = `${projectNamePrefix}${extractProjectResourceName(lastVisitProjectPath.value)}`;
+ const project = projectStore.getProjectByName(projectName);
+ if (project.name === UNKNOWN_PROJECT_NAME) {
+ return;
+ }
+ return project;
+});
+
+const { quickLinkList, quickAccessConfig, fullQuickLinkList } = useQuickLink();
+
+const handleClick = (access: QuickLink) => {
+ if (access.route) {
+ return;
+ }
+
+ switch (access.id) {
+ case "visit-projects":
+ state.showProjectModal = true;
+ break;
+ case "visit-issues":
+ router.push({
+ name: WORKSPACE_ROUTE_MY_ISSUES,
+ });
+ return;
+ default:
+ return;
+ }
+};
+
+const unSelectedAccessList = computed(() =>
+ fullQuickLinkList.value.filter(
+ (item) => !quickAccessConfig.value.includes(item.id)
+ )
+);
+
+const checkAccessItem = (access: QuickLink) => {
+ const index = quickAccessConfig.value.findIndex((id) => id === access.id);
+ if (index < 0) {
+ quickAccessConfig.value.push(access.id);
+ }
+};
+
+const uncheckAccessItem = (access: QuickLink) => {
+ const index = quickAccessConfig.value.findIndex((id) => id === access.id);
+ if (index >= 0) {
+ quickAccessConfig.value.splice(index, 1);
+ }
+};
+</script>
diff --git a/frontend/src/views/DashboardSidebar.vue b/frontend/src/views/DashboardSidebar.vue
index 5bfce1aa38..3e117309c0 100644
--- a/frontend/src/views/DashboardSidebar.vue
+++ b/frontend/src/views/DashboardSidebar.vue
@@ -11,340 +11,28 @@
<script lang="ts" setup>
import type { Action } from "@bytebase/vue-kbar";
import { defineAction, useRegisterActions } from "@bytebase/vue-kbar";
-import {
- LinkIcon,
- HomeIcon,
- DatabaseIcon,
- WorkflowIcon,
- GalleryHorizontalEndIcon,
- LayersIcon,
- SquareStackIcon,
- ShieldCheck,
- UsersIcon,
- SettingsIcon,
-} from "lucide-vue-next";
-import { computed, h } from "vue";
+import { computed } from "vue";
import { useI18n } from "vue-i18n";
-import type { RouteRecordRaw } from "vue-router";
-import { useRouter, useRoute } from "vue-router";
-import type { SidebarItem } from "@/components/CommonSidebar.vue";
+import { useRouter } from "vue-router";
import CommonSidebar from "@/components/CommonSidebar.vue";
import { useGlobalDatabaseActions } from "@/components/KBar/useDatabaseActions";
import { useProjectActions } from "@/components/KBar/useProjectActions";
-import workspaceRoutes from "@/router/dashboard/workspace";
-import {
- DATABASE_ROUTE_DASHBOARD,
- ENVIRONMENT_V1_ROUTE_DASHBOARD,
- INSTANCE_ROUTE_DASHBOARD,
- PROJECT_V1_ROUTE_DASHBOARD,
- WORKSPACE_ROUTE_MY_ISSUES,
- WORKSPACE_ROUTE_SQL_REVIEW,
- WORKSPACE_ROUTE_SCHEMA_TEMPLATE,
- WORKSPACE_ROUTE_CUSTOM_APPROVAL,
- WORKSPACE_ROUTE_RISK_CENTER,
- WORKSPACE_ROUTE_DATA_MASKING,
- WORKSPACE_ROUTE_DATA_CLASSIFICATION,
- WORKSPACE_ROUTE_AUDIT_LOG,
- WORKSPACE_ROUTE_GITOPS,
- WORKSPACE_ROUTE_SSO,
- WORKSPACE_ROUTE_MAIL_DELIVERY,
- WORKSPACE_ROUTE_USERS,
- WORKSPACE_ROUTE_MEMBERS,
- WORKSPACE_ROUTE_ROLES,
- WORKSPACE_ROUTE_USER_PROFILE,
- WORKSPACE_ROUTE_IM,
-} from "@/router/dashboard/workspaceRoutes";
-import {
- SETTING_ROUTE_WORKSPACE_GENERAL,
- SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,
- SETTING_ROUTE_WORKSPACE_ARCHIVE,
-} from "@/router/dashboard/workspaceSetting";
+import { WORKSPACE_ROUTE_LANDING } from "@/router/dashboard/workspaceRoutes";
import { SQL_EDITOR_HOME_MODULE } from "@/router/sqlEditor";
-import { useAppFeature, usePermissionStore } from "@/store";
-import type { Permission } from "@/types";
+import { useAppFeature } from "@/store";
import { DatabaseChangeMode } from "@/types/proto/v1/setting_service";
-import { hasWorkspacePermissionV2 } from "@/utils";
-
-interface DashboardSidebarItem extends SidebarItem {
- navigationId?: string;
- shortcuts?: string[];
- hide?: boolean;
- children?: DashboardSidebarItem[];
-}
+import { useDashboardSidebar, type DashboardSidebarItem } from "@/utils";
const { t } = useI18n();
-const route = useRoute();
const router = useRouter();
-const permissionStore = usePermissionStore();
const databaseChangeMode = useAppFeature("bb.feature.database-change-mode");
-
-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");
- return classes;
- }
- if (
- item.name === WORKSPACE_ROUTE_USERS &&
- current?.toString() === WORKSPACE_ROUTE_USER_PROFILE
- ) {
- classes.push("router-link-active", "bg-link-hover");
- return classes;
- }
- return classes;
-};
-
-const getFlattenRoutes = (
- routes: RouteRecordRaw[],
- permissions: Permission[] = []
-): {
- name: string;
- permissions: Permission[];
-}[] => {
- return routes.reduce(
- (list, workspaceRoute) => {
- const requiredWorkspacePermissionListFunc =
- workspaceRoute.meta?.requiredWorkspacePermissionList;
- let requiredPermissionList = requiredWorkspacePermissionListFunc
- ? requiredWorkspacePermissionListFunc()
- : [];
- if (requiredPermissionList.length === 0) {
- requiredPermissionList = permissions;
- }
-
- if (workspaceRoute.name && workspaceRoute.name.toString() !== "") {
- list.push({
- name: workspaceRoute.name.toString(),
- permissions: requiredPermissionList,
- });
- }
- if (workspaceRoute.children) {
- list.push(
- ...getFlattenRoutes(workspaceRoute.children, requiredPermissionList)
- );
- }
- return list;
- },
- [] as { name: string; permissions: Permission[] }[]
- );
-};
-
-const flattenRoutes = computed(() => {
- return getFlattenRoutes(workspaceRoutes);
-});
-
-const filterSidebarByPermissions = (
- sidebarList: DashboardSidebarItem[]
-): DashboardSidebarItem[] => {
- return sidebarList
- .filter((item) => {
- const routeConfig = flattenRoutes.value.find(
- (workspaceRoute) => workspaceRoute.name === item.name
- );
- return (routeConfig?.permissions ?? []).every((permission) =>
- hasWorkspacePermissionV2(permission)
- );
- })
- .map((item) => ({
- ...item,
- expand:
- item.expand ||
- (item.children ?? [])
- .reduce((classList, child) => {
- classList.push(...getItemClass(child));
- return classList;
- }, [] as string[])
- .includes("router-link-active"),
- children: filterSidebarByPermissions(item.children ?? []),
- }));
-};
-
-const dashboardSidebarItemList = computed((): DashboardSidebarItem[] => {
- const sidebarList: DashboardSidebarItem[] = [
- {
- navigationId: "bb.navigation.my-issues",
- title: t("issue.my-issues"),
- icon: () => h(HomeIcon),
- name: WORKSPACE_ROUTE_MY_ISSUES,
- hide: databaseChangeMode.value === DatabaseChangeMode.EDITOR,
- type: "route",
- shortcuts: ["g", "m", "i"],
- },
- {
- navigationId: "bb.navigation.projects",
- title: t("common.projects"),
- icon: () => h(GalleryHorizontalEndIcon),
- name: PROJECT_V1_ROUTE_DASHBOARD,
- type: "route",
- shortcuts: ["g", "p"],
- },
- {
- navigationId: "bb.navigation.instances",
- title: t("common.instances"),
- icon: () => h(LayersIcon),
- name: INSTANCE_ROUTE_DASHBOARD,
- type: "route",
- shortcuts: ["g", "i"],
- },
- {
- navigationId: "bb.navigation.databases",
- title: t("common.databases"),
- icon: () => h(DatabaseIcon),
- name: DATABASE_ROUTE_DASHBOARD,
- type: "route",
- shortcuts: ["g", "d"],
- },
- {
- navigationId: "bb.navigation.environments",
- title: t("common.environments"),
- icon: () => h(SquareStackIcon),
- name: ENVIRONMENT_V1_ROUTE_DASHBOARD,
- type: "route",
- shortcuts: ["g", "e"],
- },
- {
- type: "divider",
- name: "",
- },
- {
- title: t("settings.sidebar.iam-and-admin"),
- icon: () => h(UsersIcon),
- type: "div",
- children: [
- {
- title: t("settings.sidebar.users-and-groups"),
- name: WORKSPACE_ROUTE_USERS,
- type: "route",
- },
- {
- title: t("settings.sidebar.members"),
- name: WORKSPACE_ROUTE_MEMBERS,
- type: "route",
- hide: permissionStore.onlyWorkspaceMember,
- },
- {
- title: t("settings.sidebar.custom-roles"),
- name: WORKSPACE_ROUTE_ROLES,
- type: "route",
- },
- {
- title: t("settings.sidebar.sso"),
- name: WORKSPACE_ROUTE_SSO,
- type: "route",
- },
- {
- title: t("settings.sidebar.audit-log"),
- name: WORKSPACE_ROUTE_AUDIT_LOG,
- type: "route",
- },
- ],
- },
- {
- title: "CI/CD",
- icon: () => h(WorkflowIcon),
- type: "div",
- hide: databaseChangeMode.value === DatabaseChangeMode.EDITOR,
- children: [
- {
- title: t("sql-review.title"),
- name: WORKSPACE_ROUTE_SQL_REVIEW,
- type: "route",
- },
- {
- title: t("custom-approval.risk.risk-center"),
- name: WORKSPACE_ROUTE_RISK_CENTER,
- type: "route",
- },
- {
- title: t("custom-approval.self"),
- name: WORKSPACE_ROUTE_CUSTOM_APPROVAL,
- type: "route",
- },
- {
- title: t("schema-template.self"),
- name: WORKSPACE_ROUTE_SCHEMA_TEMPLATE,
- type: "route",
- },
- {
- title: t("settings.sidebar.gitops"),
- name: WORKSPACE_ROUTE_GITOPS,
- type: "route",
- hide: databaseChangeMode.value === DatabaseChangeMode.EDITOR,
- },
- ],
- },
- {
- title: t("settings.sidebar.data-access"),
- icon: () => h(ShieldCheck),
- type: "div",
- children: [
- {
- title: t("settings.sidebar.data-classification"),
- name: WORKSPACE_ROUTE_DATA_CLASSIFICATION,
- type: "route",
- },
- {
- title: t("settings.sidebar.data-masking"),
- name: WORKSPACE_ROUTE_DATA_MASKING,
- type: "route",
- },
- ],
- },
- {
- title: t("settings.sidebar.integration"),
- icon: () => h(LinkIcon),
- type: "div",
- hide: databaseChangeMode.value === DatabaseChangeMode.EDITOR,
- children: [
- {
- title: t("settings.sidebar.mail-delivery"),
- name: WORKSPACE_ROUTE_MAIL_DELIVERY,
- type: "route",
- },
- {
- title: t("settings.sidebar.im-integration"),
- name: WORKSPACE_ROUTE_IM,
- type: "route",
- },
- ],
- },
- {
- title: t("common.settings"),
- icon: () => h(SettingsIcon),
- type: "div",
- hide: !hasWorkspacePermissionV2("bb.settings.get"),
- children: [
- {
- title: t("settings.sidebar.general"),
- name: SETTING_ROUTE_WORKSPACE_GENERAL,
- type: "route",
- },
- {
- title: t("settings.sidebar.subscription"),
- name: SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,
- type: "route",
- },
- {
- title: t("common.archived"),
- name: SETTING_ROUTE_WORKSPACE_ARCHIVE,
- type: "route",
- },
- ],
- },
- ];
-
- return filterSidebarByPermissions(sidebarList);
-});
+const { getItemClass, dashboardSidebarItemList } = useDashboardSidebar();
const logoRedirect = computed(() => {
if (databaseChangeMode.value === DatabaseChangeMode.EDITOR) {
return SQL_EDITOR_HOME_MODULE;
}
- return WORKSPACE_ROUTE_MY_ISSUES;
+ return WORKSPACE_ROUTE_LANDING;
});
const navigationKbarActions = computed((): Action[] => {
diff --git a/frontend/src/views/SettingSidebar.vue b/frontend/src/views/SettingSidebar.vue
deleted file mode 100644
index ccb18868f3..0000000000
--- a/frontend/src/views/SettingSidebar.vue
+++ /dev/null
@@ -1,168 +0,0 @@
-<template>
- <CommonSidebar
- :key="'setting'"
- :item-list="settingSidebarItemList"
- :get-item-class="getItemClass"
- :logo-redirect="WORKSPACE_ROUTE_MY_ISSUES"
- @select="onSelect"
- >
- <template #prefix>
- <div class="px-2.5 mb-2">
- <router-link
- class="group flex items-center gap-2 px-2 py-1.5 leading-normal font-medium rounded-md text-main outline-item !text-base"
- :to="{ name: WORKSPACE_ROUTE_MY_ISSUES }"
- >
- <ChevronLeftIcon class="w-5 h-5" />
- <span>{{ $t("common.setting") }}</span>
- </router-link>
- </div>
- </template>
- </CommonSidebar>
-</template>
-
-<script lang="ts" setup>
-import {
- UserCircle,
- Building,
- Archive,
- ChevronLeftIcon,
-} from "lucide-vue-next";
-import { computed, h } from "vue";
-import { useI18n } from "vue-i18n";
-import type { RouteRecordRaw } from "vue-router";
-import { useRoute, useRouter } from "vue-router";
-import type { SidebarItem } from "@/components/CommonSidebar.vue";
-import CommonSidebar from "@/components/CommonSidebar.vue";
-import { WORKSPACE_ROUTE_MY_ISSUES } from "@/router/dashboard/workspaceRoutes";
-import workspaceSettingRoutes, {
- SETTING_ROUTE_PROFILE,
- SETTING_ROUTE_PROFILE_TWO_FACTOR,
- SETTING_ROUTE_WORKSPACE_GENERAL,
- SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,
- SETTING_ROUTE_WORKSPACE_ARCHIVE,
- SETTING_ROUTE_WORKSPACE,
-} from "@/router/dashboard/workspaceSetting";
-import {
- hasWorkspaceLevelProjectPermissionInAnyProject,
- hasWorkspacePermissionV2,
-} from "@/utils";
-
-const { t } = useI18n();
-const route = useRoute();
-const router = useRouter();
-
-const getItemClass = (item: SidebarItem) => {
- const list = [];
- if (route.name === item.name) {
- list.push("router-link-active", "bg-link-hover");
- return list;
- }
-
- switch (route.name) {
- case SETTING_ROUTE_PROFILE_TWO_FACTOR:
- if (item.name === SETTING_ROUTE_PROFILE) {
- list.push("router-link-active", "bg-link-hover");
- }
- break;
- }
- return list;
-};
-
-const onSelect = (item: SidebarItem, e: MouseEvent | undefined) => {
- if (!item.name) {
- return;
- }
- const route = router.resolve({
- name: item.name,
- });
-
- if (e?.ctrlKey || e?.metaKey) {
- window.open(route.fullPath, "_blank");
- } else {
- router.replace(route);
- }
-};
-
-const settingSidebarItemList = computed((): SidebarItem[] => {
- const list: SidebarItem[] = [
- {
- title: t("settings.sidebar.workspace"),
- icon: () => h(Building),
- type: "div",
- expand: true,
- children: [
- {
- title: t("settings.sidebar.general"),
- name: SETTING_ROUTE_WORKSPACE_GENERAL,
- type: "route",
- },
- {
- title: t("settings.sidebar.subscription"),
- name: SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,
- type: "route",
- },
- ],
- },
- {
- title: t("settings.sidebar.account"),
- icon: () => h(UserCircle),
- type: "div",
- expand: true,
- children: [
- {
- title: t("settings.sidebar.profile"),
- name: SETTING_ROUTE_PROFILE,
- type: "route",
- },
- ],
- },
- {
- title: t("common.archived"),
- icon: () => h(Archive),
- name: SETTING_ROUTE_WORKSPACE_ARCHIVE,
- type: "route",
- },
- ];
-
- const checkSidebarItemPermission = (item: SidebarItem) => {
- if (item.name) {
- item.hide = !hasRoutePermission(item.name);
- }
- if (item.children) {
- item.children.forEach((child) => {
- checkSidebarItemPermission(child);
- });
- }
- };
- list.forEach((item) => {
- checkSidebarItemPermission(item);
- });
-
- return list;
-});
-
-const routes = workspaceSettingRoutes.find(
- (route) => route.name === SETTING_ROUTE_WORKSPACE
-)?.children as RouteRecordRaw[];
-
-const hasRoutePermission = (routeName: string) => {
- const route = routes.find((route) => route.name === routeName);
- if (!route) {
- return false;
- }
-
- if (route.meta?.requiredWorkspacePermissionList) {
- const requiredPermissions = route.meta.requiredWorkspacePermissionList();
- return requiredPermissions.every((permission) =>
- hasWorkspacePermissionV2(permission)
- );
- } else if (route.meta?.requiredProjectPermissionList) {
- const requiredPermissions = route.meta.requiredProjectPermissionList();
- return requiredPermissions.every((permission) =>
- hasWorkspaceLevelProjectPermissionInAnyProject(permission)
- );
- }
-
- return true;
-};
-</script>