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: use iam permission check for environment section (#10178)
boojackb114d9362d2f
diff --git a/frontend/src/components/EnvironmentForm.vue b/frontend/src/components/EnvironmentForm.vueindex 89bc2968d1..ae09b301b4 100644--- a/frontend/src/components/EnvironmentForm.vue+++ b/frontend/src/components/EnvironmentForm.vue@@ -274,6 +274,7 @@ import {import {extractEnvironmentResourceName,hasWorkspacePermissionV1,+ hasWorkspacePermissionV2,sqlReviewPolicySlug,} from "@/utils";import { getErrorCode } from "@/utils/grpcweb";@@ -325,16 +326,17 @@ const emit = defineEmits([]);const { t } = useI18n();+const router = useRouter();+const currentUserV1 = useCurrentUserV1();+const environmentV1Store = useEnvironmentV1Store();+const environmentList = useEnvironmentV1List();+const sqlReviewStore = useSQLReviewStore();const state = reactive<LocalState>({environment: cloneDeep(props.environment),rolloutPolicy: cloneDeep(props.rolloutPolicy),backupPolicy: cloneDeep(props.backupPolicy),environmentTier: props.environmentTier,});--const router = useRouter();-const environmentV1Store = useEnvironmentV1Store();-const sqlReviewStore = useSQLReviewStore();const resourceIdField = ref<InstanceType<typeof ResourceIdField>>();const bindings = computed(() => {@@ -416,14 +418,10 @@ watch(});-const currentUserV1 = useCurrentUserV1();--const environmentList = useEnvironmentV1List();-const hasPermission = computed(() => {- return hasWorkspacePermissionV1(- "bb.permission.workspace.manage-environment",- currentUserV1.value.userRole+ return hasWorkspacePermissionV2(+ currentUserV1.value,+ "bb.environments.update");});diff --git a/frontend/src/components/Quickstart.vue b/frontend/src/components/Quickstart.vueindex 6dd91e5432..7d5586c9e4 100644--- a/frontend/src/components/Quickstart.vue+++ b/frontend/src/components/Quickstart.vue@@ -113,7 +113,7 @@ import { useKBarHandler, useKBarEventOnce } from "@bytebase/vue-kbar";import { computed, unref, Ref } from "vue";import { useI18n } from "vue-i18n";import { pushNotification, useCurrentUserV1, useUIStateStore } from "@/store";-import { hasWorkspacePermissionV1 } from "@/utils";+import { hasWorkspacePermissionV1, hasWorkspacePermissionV2 } from "@/utils";type IntroItem = {name: string | Ref<string>;@@ -163,12 +163,7 @@ const introList = computed(() => {},];- if (- hasWorkspacePermissionV1(- "bb.permission.workspace.manage-environment",- currentUserV1.value.userRole- )- ) {+ if (hasWorkspacePermissionV2(currentUserV1.value, "bb.environments.create")) {introList.push({name: computed(() => t("quick-start.visit-environment")),link: "/environment",diff --git a/frontend/src/utils/role.ts b/frontend/src/utils/role.tsindex c1e5d366c0..054c7e1531 100644--- a/frontend/src/utils/role.ts+++ b/frontend/src/utils/role.ts@@ -7,7 +7,6 @@ import { UserRole } from "@/types/proto/v1/auth_service";export type WorkspacePermissionType =| "bb.permission.workspace.debug"- | "bb.permission.workspace.manage-environment"| "bb.permission.workspace.manage-instance"// Visible to and manage databases even if not in the project the database// belongs to, and unassigned databases@@ -43,7 +42,6 @@ export const WORKSPACE_PERMISSION_MATRIX: Map<boolean[]> = new Map([["bb.permission.workspace.debug", [false, true, true]],- ["bb.permission.workspace.manage-environment", [false, true, true]],["bb.permission.workspace.manage-instance", [false, true, true]],["bb.permission.workspace.manage-database", [false, true, true]],["bb.permission.workspace.manage-issue", [false, true, true]],diff --git a/frontend/src/views/Archive.vue b/frontend/src/views/Archive.vueindex 5a374f0d60..ca2ce85bfe 100644--- a/frontend/src/views/Archive.vue+++ b/frontend/src/views/Archive.vue@@ -53,6 +53,7 @@ import { IdentityProvider } from "@/types/proto/v1/idp_service";import {filterProjectV1ListByKeyword,hasWorkspacePermissionV1,+ hasWorkspacePermissionV2,} from "@/utils";interface LocalState {@@ -116,10 +117,7 @@ const tabItemList = computed(() => {}if (- hasWorkspacePermissionV1(- "bb.permission.workspace.manage-environment",- currentUserV1.value.userRole- )+ hasWorkspacePermissionV2(currentUserV1.value, "bb.environments.undelete")) {list.push({ value: "ENVIRONMENT", label: t("common.environment") });}