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: main branch permission (#13203)
Danny Xua5d46a45225e
diff --git a/frontend/src/components/Branch/BranchCreateView.vue b/frontend/src/components/Branch/BranchCreateView.vueindex 53f71b394f..8e282ea3e6 100644--- a/frontend/src/components/Branch/BranchCreateView.vue+++ b/frontend/src/components/Branch/BranchCreateView.vue@@ -113,7 +113,7 @@ import type { ComposedProject } from "@/types";import { UNKNOWN_ID } from "@/types";import { Branch } from "@/types/proto/v1/branch_service";import { DatabaseMetadataView } from "@/types/proto/v1/database_service";-import { hasProjectPermissionV2, isOwnerOfProjectV1 } from "@/utils";+import { hasProjectPermissionV2 } from "@/utils";import BaselineSchemaSelector from "./BaselineSchemaSelector.vue";import BranchSelector from "./BranchSelector.vue";import { validateBranchName } from "./utils";@@ -135,7 +135,6 @@ const router = useRouter();const databaseStore = useDatabaseV1Store();const branchStore = useBranchStore();const dbSchemaStore = useDBSchemaV1Store();-const me = useCurrentUserV1();const source = ref<Source>("PARENT");const databaseId = ref<string>();const parentBranchName = ref<string>();@@ -146,7 +145,11 @@ const isPreparingBranch = ref(false);const EMPTY_BRANCH = Branch.fromPartial({});const allowCreateBranchFromDatabase = computed(() => {- return isOwnerOfProjectV1(props.project, me.value);+ return hasProjectPermissionV2(+ props.project,+ useCurrentUserV1().value,+ "bb.branches.admin"+ )});const debouncedDatabaseId = useDebounce(databaseId, DEBOUNCE_RATE);diff --git a/frontend/src/components/Branch/BranchDetailView.vue b/frontend/src/components/Branch/BranchDetailView.vueindex 94efbd4d52..82487ce8b7 100644--- a/frontend/src/components/Branch/BranchDetailView.vue+++ b/frontend/src/components/Branch/BranchDetailView.vue@@ -61,7 +61,6 @@{{ $t("branch.merge-rebase.rebase-branch") }}</NButton><NButton- v-if="showApplyBranchButton"type="primary"@click="handleApplyBranchToDatabase">{{ $t("schema-designer.apply-to-database") }}</NButton@@ -176,7 +175,6 @@ import {defer,extractProjectResourceName,hasProjectPermissionV2,- isOwnerOfProjectV1,} from "@/utils";import { getErrorCode } from "@/utils/grpcweb";import { provideSQLCheckContext } from "../SQLCheck";@@ -277,20 +275,17 @@ const showMergeBranchButton = computed(() => {const showRebaseBranchButton = computed(() => {// For main branches: only project owners are allowedif (!parentBranch.value) {- return isOwnerOfProjectV1(props.project, currentUser.value);+ return hasProjectPermissionV2(+ props.project,+ useCurrentUserV1().value,+ "bb.branches.admin"+ )}// For feature branches: project owners and branch creatorreturn allowEdit.value;});-// Only show apply to database button when the branch is main branch.-const showApplyBranchButton = computed(() => {- return (- !parentBranch.value && isOwnerOfProjectV1(props.project, currentUser.value)- );-});-const rebuildMetadataEdit = () => {const rebuild = schemaDesignerRef.value?.schemaEditor?.rebuildMetadataEdit;if (typeof rebuild !== "function") {diff --git a/frontend/src/components/Branch/BranchRebaseView/BranchRebaseView.vue b/frontend/src/components/Branch/BranchRebaseView/BranchRebaseView.vueindex 8b4f31322e..414b6ac488 100644--- a/frontend/src/components/Branch/BranchRebaseView/BranchRebaseView.vue+++ b/frontend/src/components/Branch/BranchRebaseView/BranchRebaseView.vue@@ -77,13 +77,12 @@ import { branchServiceClient } from "@/grpcweb";import {pushNotification,useBranchStore,- useCurrentUserV1,useDatabaseV1Store,} from "@/store";import type { ComposedProject } from "@/types";import { isValidDatabaseName } from "@/types";import type { Branch } from "@/types/proto/v1/branch_service";-import { defer, isOwnerOfProjectV1 } from "@/utils";+import { defer } from "@/utils";import BranchComparison from "../common/BranchComparison.vue";import RebaseBranchSelect from "./RebaseBranchSelect.vue";import RebaseBranchValidationStateView from "./RebaseBranchValidationStateView.vue";@@ -120,7 +119,6 @@ const route = useRoute();const $dialog = useDialog();const resolveConflictRef = ref<InstanceType<typeof ResolveConflict>>();const branchStore = useBranchStore();-const me = useCurrentUserV1();const isLoadingHeadBranch = ref(false);const isLoadingSourceBranch = ref(false);const isValidating = ref(false);@@ -184,9 +182,6 @@ const parentBranchOnly = computed(() => {if (!head.parentBranch) {return false; // parent-less (main) branches}- if (isOwnerOfProjectV1(props.project, me.value)) {- return false; // project owners are not limited- }return true;});