Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: permission in quick start (#10424)
ecmadao6a764cb3d848
diff --git a/frontend/src/components/Quickstart.vue b/frontend/src/components/Quickstart.vueindex b61bc12bb6..4a23bbd72d 100644--- a/frontend/src/components/Quickstart.vue+++ b/frontend/src/components/Quickstart.vue@@ -110,7 +110,7 @@<script setup lang="ts">import { useKBarHandler, useKBarEventOnce } from "@bytebase/vue-kbar";-import { computed, unref, Ref } from "vue";+import { computed, unref, Ref, watchEffect } from "vue";import { useI18n } from "vue-i18n";import { RouteLocationRaw } from "vue-router";import { ISSUE_ROUTE_DETAIL } from "@/router/dashboard/issue";@@ -122,16 +122,25 @@ import {} from "@/router/dashboard/workspaceRoutes";import { SETTING_ROUTE_WORKSPACE_MEMBER } from "@/router/dashboard/workspaceSetting";import { SQL_EDITOR_SHARE_MODULE } from "@/router/sqlEditor";-import { pushNotification, useCurrentUserV1, useUIStateStore } from "@/store";-import { hasWorkspacePermissionV2 } from "@/utils";+import {+ pushNotification,+ useCurrentUserV1,+ useUIStateStore,+ useProjectV1Store,+} from "@/store";+import { WorkspacePermission, UNKNOWN_ID } from "@/types";+import { hasWorkspacePermissionV2, hasProjectPermissionV2 } from "@/utils";type IntroItem = {name: string | Ref<string>;link?: RouteLocationRaw;done: Ref<boolean>;click?: () => void;+ hide?: boolean;+ requiredPermissions?: WorkspacePermission[];};+const projectStore = useProjectV1Store();const uiStateStore = useUIStateStore();const { t } = useI18n();const kbarHandler = useKBarHandler();@@ -142,6 +151,18 @@ const show = computed(() => {return !uiStateStore.getIntroStateByKey("hidden");});+const sampleProject = computed(() => {+ const project = projectStore.getProjectByUID("101");+ if (project.uid === `${UNKNOWN_ID}`) {+ return;+ }+ return project;+});++watchEffect(async () => {+ await projectStore.getOrFetchProjectByUID("101", true /* silent */);+});+const introList = computed(() => {const introList: IntroItem[] = [{@@ -164,6 +185,13 @@ const introList = computed(() => {},},done: computed(() => uiStateStore.getIntroStateByKey("issue.visit")),+ hide:+ !sampleProject.value ||+ !hasProjectPermissionV2(+ sampleProject.value,+ currentUserV1.value,+ "bb.issues.get"+ ),},{name: computed(() => t("quick-start.query-data")),@@ -174,19 +202,23 @@ const introList = computed(() => {},},done: computed(() => uiStateStore.getIntroStateByKey("data.query")),+ hide:+ !sampleProject.value ||+ !hasProjectPermissionV2(+ sampleProject.value,+ currentUserV1.value,+ "bb.databases.query"+ ),},{name: computed(() => t("quick-start.visit-project")),-link: {name: PROJECT_V1_ROUTE_DASHBOARD,},done: computed(() => uiStateStore.getIntroStateByKey("project.visit")),+ requiredPermissions: ["bb.projects.list"],},- ];-- if (hasWorkspacePermissionV2(currentUserV1.value, "bb.environments.create")) {- introList.push({+ {name: computed(() => t("quick-start.visit-environment")),link: {name: ENVIRONMENT_V1_ROUTE_DASHBOARD,@@ -194,36 +226,40 @@ const introList = computed(() => {done: computed(() =>uiStateStore.getIntroStateByKey("environment.visit")),- });- }-- if (hasWorkspacePermissionV2(currentUserV1.value, "bb.instances.list")) {- introList.push({+ requiredPermissions: ["bb.environments.list"],+ },+ {name: computed(() => t("quick-start.visit-instance")),link: {name: INSTANCE_ROUTE_DASHBOARD,},done: computed(() => uiStateStore.getIntroStateByKey("instance.visit")),- });- }-- introList.push({- name: computed(() => t("quick-start.visit-database")),- link: {- name: DATABASE_ROUTE_DASHBOARD,+ requiredPermissions: ["bb.instances.list"],},- done: computed(() => uiStateStore.getIntroStateByKey("database.visit")),- });-- introList.push({- name: computed(() => t("quick-start.visit-member")),- link: {- name: SETTING_ROUTE_WORKSPACE_MEMBER,+ {+ name: computed(() => t("quick-start.visit-database")),+ link: {+ name: DATABASE_ROUTE_DASHBOARD,+ },+ done: computed(() => uiStateStore.getIntroStateByKey("database.visit")),},- done: computed(() => uiStateStore.getIntroStateByKey("member.visit")),- });+ {+ name: computed(() => t("quick-start.visit-member")),+ link: {+ name: SETTING_ROUTE_WORKSPACE_MEMBER,+ },+ done: computed(() => uiStateStore.getIntroStateByKey("member.visit")),+ requiredPermissions: ["bb.policies.get"],+ },+ ];- return introList;+ return introList.filter(+ (item) =>+ !item.hide &&+ (item.requiredPermissions ?? []).every((permission) =>+ hasWorkspacePermissionV2(currentUserV1.value, permission)+ )+ );});const showQuickstart = computed(() => {diff --git a/frontend/src/layouts/BodyLayout.vue b/frontend/src/layouts/BodyLayout.vueindex 255af19d2a..980f6cb975 100644--- a/frontend/src/layouts/BodyLayout.vue+++ b/frontend/src/layouts/BodyLayout.vue@@ -201,7 +201,7 @@</div></HideInStandaloneMode><!-- This area may scroll -->- <div id="bb-layout-main" class="md:min-w-0 flex-1 overflow-y-auto pt-4">+ <div id="bb-layout-main" class="md:min-w-0 flex-1 overflow-y-auto py-4"><!-- Start main area--><router-view name="content" /><!-- End main area -->diff --git a/frontend/src/store/modules/v1/project.ts b/frontend/src/store/modules/v1/project.tsindex 019e9a6e1a..a4764e135c 100644--- a/frontend/src/store/modules/v1/project.ts+++ b/frontend/src/store/modules/v1/project.ts@@ -96,8 +96,8 @@ export const useProjectV1Store = defineStore("project_v1", () => {await upsertProjectMap([project]);return project as ComposedProject;};- const fetchProjectByUID = async (uid: string) => {- return fetchProjectByName(`${projectNamePrefix}${uid}`);+ const fetchProjectByUID = async (uid: string, silent = false) => {+ return fetchProjectByName(`${projectNamePrefix}${uid}`, silent);};const getOrFetchProjectByName = async (name: string, silent = false) => {const cachedData = projectMapByName.get(name);@@ -106,7 +106,7 @@ export const useProjectV1Store = defineStore("project_v1", () => {}return fetchProjectByName(name, silent);};- const getOrFetchProjectByUID = async (uid: string) => {+ const getOrFetchProjectByUID = async (uid: string, silent = false) => {if (uid === String(EMPTY_ID)) return emptyProject();if (uid === String(UNKNOWN_ID)) return unknownProject();@@ -114,7 +114,7 @@ export const useProjectV1Store = defineStore("project_v1", () => {if (cachedData) {return cachedData;}- await fetchProjectByUID(uid);+ await fetchProjectByUID(uid, silent);return getProjectByUID(uid);};const createProject = async (project: Project, resourceId: string) => {diff --git a/frontend/src/views/AnomalyCenterDashboard.vue b/frontend/src/views/AnomalyCenterDashboard.vueindex 3b979fbfb2..0441d0660b 100644--- a/frontend/src/views/AnomalyCenterDashboard.vue+++ b/frontend/src/views/AnomalyCenterDashboard.vue@@ -1,5 +1,5 @@<template>- <div class="px-4 py-6">+ <div class="px-4"><AnomalyCenterDashboard :selected-tab="selectedTab" /></div></template>diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vueindex f6867c995f..ada3f5efad 100644--- a/frontend/src/views/EnvironmentDashboard.vue+++ b/frontend/src/views/EnvironmentDashboard.vue@@ -1,5 +1,5 @@<template>- <div class="h-full flex flex-col pt-4">+ <div class="h-full flex flex-col"><NTabstype="line":bar-width="200"diff --git a/frontend/src/views/ExportCenter/index.vue b/frontend/src/views/ExportCenter/index.vueindex 4e46aa8102..3afad50e77 100644--- a/frontend/src/views/ExportCenter/index.vue+++ b/frontend/src/views/ExportCenter/index.vue@@ -1,5 +1,5 @@<template>- <div class="w-full px-4 py-6">+ <div class="w-full px-4"><divclass="w-full flex flex-col lg:flex-row items-start lg:items-center justify-between gap-2">diff --git a/frontend/src/views/SlowQuery/SlowQueryDashboard.vue b/frontend/src/views/SlowQuery/SlowQueryDashboard.vueindex 75b32fea68..f3b391f041 100644--- a/frontend/src/views/SlowQuery/SlowQueryDashboard.vue+++ b/frontend/src/views/SlowQuery/SlowQueryDashboard.vue@@ -1,5 +1,5 @@<template>- <div class="px-4 py-6">+ <div class="px-4"><SlowQueryPanel /></div></template>