Skip to content

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

chore: restrict to merge to parent (#13193)

Liu Ji898154d144ba
diff --git a/frontend/src/components/Branch/BranchMergeView/BranchMergeView.vue b/frontend/src/components/Branch/BranchMergeView/BranchMergeView.vue
index 917a4b2812..9c7eae9658 100644
--- a/frontend/src/components/Branch/BranchMergeView/BranchMergeView.vue
+++ b/frontend/src/components/Branch/BranchMergeView/BranchMergeView.vue
@@ -6,7 +6,7 @@
:project="project"
:head-branch="headBranch"
:target-branch="targetBranch"
- :parent-branch-only="parentBranchOnly"
+ :parent-branch-only="true"
@update:head-branch-name="handleUpdateHeadBranch"
@update:target-branch-name="state.targetBranchName = $event || null"
/>
@@ -63,10 +63,9 @@ import { computed, reactive, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import MaskSpinner from "@/components/misc/MaskSpinner.vue";
import { branchServiceClient } from "@/grpcweb";
-import { pushNotification, useBranchStore, useCurrentUserV1 } from "@/store";
+import { pushNotification, useBranchStore } from "@/store";
import type { ComposedProject } from "@/types";
import { Branch } from "@/types/proto/v1/branch_service";
-import { isOwnerOfProjectV1 } from "@/utils";
import { extractGrpcErrorMessage, getErrorCode } from "@/utils/grpcweb";
import BranchComparison from "../common/BranchComparison.vue";
import MergeBranchButton from "./MergeBranchButton.vue";
@@ -100,7 +99,6 @@ const state = reactive<LocalState>({
});
const { t } = useI18n();
const branchStore = useBranchStore();
-const me = useCurrentUserV1();
const isLoadingHeadBranch = ref(false);
const isLoadingTargetBranch = ref(false);
const isValidating = ref(false);
@@ -137,20 +135,6 @@ const targetBranch = computedAsync(
}
);
-const parentBranchOnly = computed(() => {
- const head = headBranch.value;
- if (!head) {
- return false; // not ready yet
- }
- if (!head.parentBranch) {
- return false; // parent-less (main) branches
- }
- if (isOwnerOfProjectV1(props.project, me.value)) {
- return false; // project owners are not limited
- }
- return true;
-});
-
const validationState = computedAsync(
async (): Promise<MergeBranchValidationState | undefined> => {
const head = headBranch.value;
diff --git a/frontend/src/components/Branch/BranchMergeView/MergeBranchSelect.vue b/frontend/src/components/Branch/BranchMergeView/MergeBranchSelect.vue
index 5f0295a728..4f3984e0bf 100644
--- a/frontend/src/components/Branch/BranchMergeView/MergeBranchSelect.vue
+++ b/frontend/src/components/Branch/BranchMergeView/MergeBranchSelect.vue
@@ -3,19 +3,28 @@
class="w-full grid grid-cols-3 items-end text-sm gap-x-2"
style="grid-template-columns: 1fr auto 1fr auto"
>
- <div class="flex flex-col">
+ <div class="flex flex-col overflow-x-hidden">
<div v-if="parentBranchOnly">
{{ $t("schema-designer.parent-branch") }}
</div>
- <BranchSelector
- class="!w-full text-center"
- :disabled="parentBranchOnly"
- :clearable="false"
- :project="project"
- :branch="targetBranch?.name"
- :filter="targetBranchFilter"
- @update:branch="$emit('update:target-branch-name', $event)"
- />
+ <NElement
+ tag="div"
+ class="flex overflow-x-hidden items-center gap-x-1"
+ style="
+ padding: 0 6px 0 12px;
+ border: 1px solid var(--border-color);
+ border-radius: var(--border-radius);
+ min-height: var(--height-medium);
+ "
+ >
+ <InstanceV1EngineIcon
+ v-if="parentDatabase"
+ :instance="parentDatabase.instanceResource"
+ />
+ <NPerformantEllipsis>
+ {{ targetBranch?.branchId }}
+ </NPerformantEllipsis>
+ </NElement>
</div>
<div class="flex flex-row justify-center px-2">
<MoveLeftIcon :size="40" stroke-width="1" />
@@ -33,7 +42,11 @@
<script setup lang="ts">
import { MoveLeftIcon } from "lucide-vue-next";
-import type { ComposedProject } from "@/types";
+import { NElement, NPerformantEllipsis } from "naive-ui";
+import { computed } from "vue";
+import { InstanceV1EngineIcon } from "@/components/v2";
+import { useDatabaseV1Store } from "@/store";
+import { isValidDatabaseName, type ComposedProject } from "@/types";
import type { Branch } from "@/types/proto/v1/branch_service";
import BranchSelector from "../BranchSelector.vue";
@@ -49,14 +62,12 @@ defineEmits<{
(event: "update:target-branch-name", branch: string | undefined): void;
}>();
-const targetBranchFilter = (branch: Branch) => {
- const { headBranch } = props;
- if (!headBranch) {
- return true;
- }
- // A feature branch is only allowed to be merged to its parent.
- return branch.name === headBranch.parentBranch;
-};
+const parentDatabase = computed(() => {
+ const name = props.targetBranch?.baselineDatabase;
+ if (!isValidDatabaseName(name)) return undefined;
+ return useDatabaseV1Store().getDatabaseByName(name);
+});
+
const headBranchFilter = (branch: Branch) => {
const { targetBranch } = props;
if (!targetBranch) {