Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: database group permission (#10390)
ecmadao612f6fb31fa3
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vueindex 516df68939..34a7f7ec90 100644--- a/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue@@ -18,11 +18,9 @@/><template #footer><div class="w-full flex justify-between items-center">- <div>- <NButton v-if="showDeleteButton" type="error" @click="doDelete">{{- $t("common.delete")- }}</NButton>- </div>+ <NButton v-if="showDeleteButton" type="error" @click="doDelete">+ {{ $t("common.delete") }}+ </NButton><div class="flex flex-row justify-end items-center gap-x-2"><NButton @click="$emit('close')">{{ $t("common.cancel") }}</NButton><NButton@@ -57,7 +55,10 @@ import {useDBGroupStore,useEnvironmentV1Store,} from "@/store";-import { getProjectNameAndDatabaseGroupNameAndSchemaGroupName } from "@/store/modules/v1/common";+import {+ getProjectNameAndDatabaseGroupName,+ getProjectNameAndDatabaseGroupNameAndSchemaGroupName,+} from "@/store/modules/v1/common";import {ComposedDatabaseGroup,ComposedProject,@@ -184,12 +185,16 @@ const doDelete = () => {router.currentRoute.value.name ===PROJECT_V1_ROUTE_DATABASE_GROUP_TABLE_GROUP_DETAIL) {- const [_, databaseGroupName] =+ const [, databaseGroupName] =getProjectNameAndDatabaseGroupNameAndSchemaGroupName(schemaGroupName);- // TODO(steven): prevent `Cannot use 'in' operator to search for 'path' in undefined` error in vue-router.- window.location.href = `/${props.project.name}/database-groups/${databaseGroupName}`;+ router.replace({+ name: PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,+ params: {+ databaseGroupName,+ },+ });}}emit("close");@@ -231,6 +236,12 @@ const doConfirm = async () => {},databaseGroupId: resourceId,});+ router.push({+ name: PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,+ params: {+ databaseGroupName: resourceId,+ },+ });} else {const environment = environmentStore.getEnvironmentByUID(formState.environmentId || ""@@ -281,14 +292,16 @@ const doConfirm = async () => {},schemaGroupId: resourceId,});- const dbGroup = dbGroupStore.getDBGroupByName(+ const [, databaseGroupName] = getProjectNameAndDatabaseGroupName(formState.selectedDatabaseGroupId);- if (dbGroup) {- router.push(- `/${dbGroup.project.name}/database-groups/${dbGroup.databaseGroupName}`- );- }+ router.push({+ name: PROJECT_V1_ROUTE_DATABASE_GROUP_TABLE_GROUP_DETAIL,+ params: {+ databaseGroupName,+ schemaGroupName: resourceId,+ },+ });} else {const celStrings = await batchConvertParsedExprToCELString([ParsedExpr.fromJSON({diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vueindex 60562f0461..0911ec3a71 100644--- a/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue@@ -14,9 +14,9 @@</div><div class="bb-grid-cell">{{ item.environment.title }}</div><div v-if="props.showEdit" class="bb-grid-cell gap-x-2 justify-end">- <NButton size="small" @click.stop="$emit('edit', item)">{{- $t("common.configure")- }}</NButton>+ <NButton size="small" @click.stop="$emit('edit', item)">+ {{ $t("common.configure") }}+ </NButton></div></template></BBGrid>@@ -27,6 +27,7 @@ import { computed } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import { BBGridColumn } from "@/bbkit";+import { PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL } from "@/router/dashboard/projectV1";import { ComposedDatabaseGroup } from "@/types";import { DatabaseGroup } from "@/types/proto/v1/project_service";@@ -66,8 +67,11 @@ const clickDatabaseGroup = (databaseGroup: ComposedDatabaseGroup) => {return;}- router.push(- `/${databaseGroup.project.name}/database-groups/${databaseGroup.databaseGroupName}`- );+ router.push({+ name: PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,+ params: {+ databaseGroupName: databaseGroup.databaseGroupName,+ },+ });};</script>diff --git a/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue b/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vueindex 04edc5c7d3..2ca96ac9bf 100644--- a/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue+++ b/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue@@ -2,7 +2,7 @@<div class="w-full"><DatabaseGroupTable:database-group-list="databaseGroupList"- :show-edit="true"+ :show-edit="allowEdit"@edit="handleConfigureDatabaseGroup"/></div>@@ -32,6 +32,7 @@ interface LocalState {const props = defineProps<{project: ComposedProject;+ allowEdit: boolean;}>();const dbGroupStore = useDBGroupStore();diff --git a/frontend/src/components/DatabaseGroup/SchemaGroupTable.vue b/frontend/src/components/DatabaseGroup/SchemaGroupTable.vueindex d1b0e48154..6ab9694fae 100644--- a/frontend/src/components/DatabaseGroup/SchemaGroupTable.vue+++ b/frontend/src/components/DatabaseGroup/SchemaGroupTable.vue@@ -25,6 +25,7 @@ import { computed } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import { BBGridColumn } from "@/bbkit";+import { PROJECT_V1_ROUTE_DATABASE_GROUP_TABLE_GROUP_DETAIL } from "@/router/dashboard/projectV1";import { getProjectNameAndDatabaseGroupNameAndSchemaGroupName } from "@/store/modules/v1/common";import { ComposedSchemaGroup } from "@/types";import { SchemaGroup } from "@/types/proto/v1/project_service";@@ -53,10 +54,14 @@ const COLUMN_LIST = computed(() => {});const clickSchemaGroup = (schemaGroup: ComposedSchemaGroup) => {- const [_, databaseGroupName, schemaGroupName] =+ const [, , schemaGroupName] =getProjectNameAndDatabaseGroupNameAndSchemaGroupName(schemaGroup.name);- router.push(- `/${schemaGroup.databaseGroup.project.name}/database-groups/${databaseGroupName}/table-groups/${schemaGroupName}`- );++ router.push({+ name: PROJECT_V1_ROUTE_DATABASE_GROUP_TABLE_GROUP_DETAIL,+ params: {+ schemaGroupName: schemaGroupName,+ },+ });};</script>diff --git a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vueindex f51f213c32..fc563ecf7b 100644--- a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue+++ b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue@@ -1,5 +1,5 @@<template>- <div class="space-y-5 divide-y pb-5">+ <div class="space-y-5 divide-y pb-5 px-2"><divv-for="(row, i) in tableRows":key="i"diff --git a/frontend/src/components/SQLCheck/SQLCheckDetail.vue b/frontend/src/components/SQLCheck/SQLCheckDetail.vueindex cb0b5440a9..81bf901a7d 100644--- a/frontend/src/components/SQLCheck/SQLCheckDetail.vue+++ b/frontend/src/components/SQLCheck/SQLCheckDetail.vue@@ -1,5 +1,5 @@<template>- <div class="space-y-5 divide-y pb-5">+ <div class="space-y-5 divide-y pb-5 px-2"><divv-for="(row, i) in tableRows":key="i"diff --git a/frontend/src/components/v2/Model/DatabaseGroupName.vue b/frontend/src/components/v2/Model/DatabaseGroupName.vueindex 9db68a311c..3f325b8ff8 100644--- a/frontend/src/components/v2/Model/DatabaseGroupName.vue+++ b/frontend/src/components/v2/Model/DatabaseGroupName.vue@@ -11,6 +11,8 @@<script lang="ts" setup>import { computed } from "vue";+import { PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL } from "@/router/dashboard/projectV1";+import { getProjectNameAndDatabaseGroupName } from "@/store/modules/v1/common";import type { ComposedDatabaseGroup } from "@/types";const props = withDefaults(@@ -32,10 +34,18 @@ const bindings = computed(() => {return {};}- const route = `/${props.databaseGroup.project.name}/database-groups/${props.databaseGroup.databaseGroupName}`;+ const [projectId, databaseGroupName] = getProjectNameAndDatabaseGroupName(+ props.databaseGroup.name+ );if (props.link) {return {- to: route,+ to: {+ name: PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,+ params: {+ projectId,+ databaseGroupName,+ },+ },activeClass: "",exactActiveClass: "",onClick: (e: MouseEvent) => {diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vueindex 4c10cc73f6..a184e2e8d6 100644--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue@@ -146,6 +146,7 @@ import {import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import { BBGridColumn } from "@/bbkit/types";+import { PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL } from "@/router/dashboard/projectV1";import { usePolicyV1Store, usePageMode, useCurrentUserV1 } from "@/store";import { getProjectNameAndDatabaseGroupName } from "@/store/modules/v1/common";import { ComposedDatabase, ComposedDatabaseGroup } from "@/types";@@ -487,14 +488,16 @@ const clickDatabase = (router.push(url);}} else {- const [_, databaseGroupName] = getProjectNameAndDatabaseGroupName(+ const [projectId, databaseGroupName] = getProjectNameAndDatabaseGroupName(database.name);- router.push(- `/${- (database as ComposedDatabaseGroup).project.name- }/database-groups/${databaseGroupName}`- );+ router.push({+ name: PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,+ params: {+ projectId,+ databaseGroupName,+ },+ });}}};diff --git a/frontend/src/layouts/ProjectV1Layout.vue b/frontend/src/layouts/ProjectV1Layout.vueindex 3ce861f9e1..0fe3b0ea03 100644--- a/frontend/src/layouts/ProjectV1Layout.vue+++ b/frontend/src/layouts/ProjectV1Layout.vue@@ -103,17 +103,11 @@ const allowEdit = computed(() => {return false;}- if (- hasProjectPermissionV2(- project.value,- currentUserV1.value,- "bb.projects.update"- )- ) {- return true;- }-- return false;+ return hasProjectPermissionV2(+ project.value,+ currentUserV1.value,+ "bb.projects.update"+ );});const cachedNotifiedActivities = useLocalStorage<string[]>(@@ -129,16 +123,7 @@ onMounted(async () => {);if (- !hasProjectPermissionV2(- project.value,- currentUserV1.value,- "bb.issues.get"- ) &&- !hasProjectPermissionV2(- project.value,- currentUserV1.value,- "bb.databases.update"- )+ !hasProjectPermissionV2(project.value, currentUserV1.value, "bb.issues.get")) {return;}diff --git a/frontend/src/views/DatabaseGroupDetail.vue b/frontend/src/views/DatabaseGroupDetail.vueindex 123ca2324a..ac98928f5b 100644--- a/frontend/src/views/DatabaseGroupDetail.vue+++ b/frontend/src/views/DatabaseGroupDetail.vue@@ -52,16 +52,21 @@<divclass="flex flex-row justify-end items-center flex-wrap shrink gap-x-2 gap-y-2">- <NButton @click="handleEditDatabaseGroup">{{- $t("common.configure")- }}</NButton>+ <NButton v-if="allowEdit" @click="handleEditDatabaseGroup">+ {{ $t("common.configure") }}+ </NButton><NButton+ v-if="hasPermissionToCreateIssue"@click="createMigration('bb.issue.database.schema.update')"- >{{ $t("database.edit-schema") }}</NButton>- <NButton @click="createMigration('bb.issue.database.data.update')">{{- $t("database.change-data")- }}</NButton>+ {{ $t("database.edit-schema") }}+ </NButton>+ <NButton+ v-if="hasPermissionToCreateIssue"+ @click="createMigration('bb.issue.database.data.update')"+ >+ {{ $t("database.change-data") }}+ </NButton></div></div>@@ -97,11 +102,9 @@<div class="w-full max-w-5xl"><div class="w-full flex flex-row justify-between items-center"><p class="my-4">{{ $t("database-group.table-group.self") }}</p>- <div>- <NButton @click.prevent="handleCreateSchemaGroup">- {{ $t("database-group.table-group.create") }}- </NButton>- </div>+ <NButton v-if="allowEdit" @click.prevent="handleCreateSchemaGroup">+ {{ $t("database-group.table-group.create") }}+ </NButton></div><SchemaGroupTable:schema-group-list="schemaGroupList"@@ -140,6 +143,7 @@ import ExprEditor from "@/components/DatabaseGroup/common/ExprEditor";import { ResourceType } from "@/components/DatabaseGroup/common/ExprEditor/context";import { ConditionGroupExpr } from "@/plugins/cel";import {+ useCurrentUserV1,useDBGroupStore,useProjectV1Store,useSubscriptionV1Store,@@ -148,6 +152,7 @@ import { databaseGroupNamePrefix } from "@/store/modules/v1/common";import { projectNamePrefix } from "@/store/modules/v1/common";import { ComposedDatabase, ComposedDatabaseGroup } from "@/types";import { DatabaseGroup, SchemaGroup } from "@/types/proto/v1/project_service";+import { hasProjectPermissionV2 } from "@/utils";interface LocalState {isLoaded: boolean;@@ -164,6 +169,7 @@ interface EditDatabaseGroupState {const props = defineProps<{projectId: string;databaseGroupName: string;+ allowEdit: boolean;}>();const projectStore = useProjectV1Store();@@ -201,6 +207,13 @@ const schemaGroupList = computed(() => {);});const environment = computed(() => databaseGroup.value?.environment);+const hasPermissionToCreateIssue = computed(() =>+ hasProjectPermissionV2(+ project.value,+ useCurrentUserV1().value,+ "bb.issues.create"+ )+);onMounted(async () => {await dbGroupStore.getOrFetchDBGroupByName(databaseGroupResourceName.value);diff --git a/frontend/src/views/SchemaGroupDetail.vue b/frontend/src/views/SchemaGroupDetail.vueindex 04d93184ef..a918e182e0 100644--- a/frontend/src/views/SchemaGroupDetail.vue+++ b/frontend/src/views/SchemaGroupDetail.vue@@ -49,7 +49,10 @@<divclass="flex flex-row justify-end items-center flex-wrap shrink gap-x-2 gap-y-2">- <NButton @click.prevent="state.showConfigurePanel = true">+ <NButton+ v-if="allowEdit"+ @click.prevent="state.showConfigurePanel = true"+ >{{ $t("common.configure") }}</NButton></div>@@ -125,6 +128,7 @@ const props = defineProps<{projectId: string;databaseGroupName: string;schemaGroupName: string;+ allowEdit: boolean;}>();const projectStore = useProjectV1Store();diff --git a/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue b/frontend/src/views/project/ProjectDatabaseGroupDashboard.vueindex d532818669..3425201a80 100644--- a/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue+++ b/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue@@ -1,5 +1,5 @@<template>- <ProjectDatabaseGroupPanel :project="project" />+ <ProjectDatabaseGroupPanel :project="project" :allow-edit="allowEdit" /></template><script setup lang="ts">@@ -10,6 +10,7 @@ import { projectNamePrefix } from "@/store/modules/v1/common";const props = defineProps<{projectId: string;+ allowEdit: boolean;}>();const projectV1Store = useProjectV1Store();