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: fix parent branch name (#10849)
Liu Ji57b424252cc7
diff --git a/frontend/src/components/Branch/BranchDataTable/cells/AsyncBranchNameCell.vue b/frontend/src/components/Branch/BranchDataTable/cells/AsyncBranchNameCell.vuenew file mode 100644index 0000000000..18701fa983--- /dev/null+++ b/frontend/src/components/Branch/BranchDataTable/cells/AsyncBranchNameCell.vue@@ -0,0 +1,74 @@+<template>+ <div class="flex flex-row justify-start items-center gap-1">+ <span+ class="cursor-pointer hover:underline hover:text-blue-600"+ @click.stop="handleBranchClick"+ >{{ branchName }}</span+ >+ <span v-if="isProtected">+ <NTooltip trigger="hover">+ <template #trigger>+ <ShieldAlertIcon class="w-4 h-auto text-gray-500" />+ </template>+ {{ $t("branch.branch-is-protected") }}+ </NTooltip>+ </span>+ </div>+</template>++<script lang="ts" setup>+import { computedAsync } from "@vueuse/core";+import { ShieldAlertIcon } from "lucide-vue-next";+import { NTooltip } from "naive-ui";+import { computed } from "vue";+import { useRouter } from "vue-router";+import { PROJECT_V1_ROUTE_BRANCH_DETAIL } from "@/router/dashboard/projectV1";+import { useBranchStore, useProjectV1Store } from "@/store";+import {+ getProjectAndBranchId,+ projectNamePrefix,+} from "@/store/modules/v1/common";+import { useProjectBranchProtectionRules } from "@/store/modules/v1/projectProtectionRoles";+import { wildcardToRegex } from "../../utils";++const props = defineProps<{+ name: string;+}>();++const router = useRouter();+const projectStore = useProjectV1Store();+const branchStore = useBranchStore();++const branch = computedAsync(async () => {+ return branchStore.getBranchByName(props.name);+}, undefined);++const project = computed(() => {+ const [projectId] = getProjectAndBranchId(props.name);+ return projectStore.getProjectByName(`${projectNamePrefix}${projectId}`);+});++const branchProtectionRules = useProjectBranchProtectionRules(+ project.value.name+);++const branchName = computed(() => {+ return branch.value?.branchId ?? getProjectAndBranchId(props.name)[1];+});++const isProtected = computed(() => {+ return branchProtectionRules.value.some((rule) => {+ return wildcardToRegex(rule.nameFilter).test(props.name);+ });+});++const handleBranchClick = async () => {+ const [_, branchId] = getProjectAndBranchId(props.name);+ router.push({+ name: PROJECT_V1_ROUTE_BRANCH_DETAIL,+ params: {+ branchName: `${branchId}`,+ },+ });+};+</script>diff --git a/frontend/src/components/Branch/BranchDataTable/index.vue b/frontend/src/components/Branch/BranchDataTable/index.vueindex 7c174623aa..8ac17b3bae 100644--- a/frontend/src/components/Branch/BranchDataTable/index.vue+++ b/frontend/src/components/Branch/BranchDataTable/index.vue@@ -15,11 +15,15 @@ import { NDataTable, DataTableColumn, PaginationProps } from "naive-ui";import { computed, h, ref } from "vue";import { useI18n } from "vue-i18n";import BranchBaseline from "@/components/Branch/BranchBaseline.vue";-import { useBranchStore } from "@/store";import { Branch } from "@/types/proto/v1/branch_service";+import AsyncBranchNameCell from "./cells/AsyncBranchNameCell.vue";import BranchNameCell from "./cells/BranchNameCell.vue";import BranchUpdatedCell from "./cells/BranchUpdatedCell.vue";+defineOptions({+ name: "BranchDataTable",+});+const props = defineProps<{branches: Branch[];ready?: boolean;@@ -27,7 +31,6 @@ const props = defineProps<{}>();const { t } = useI18n();-const branchStore = useBranchStore();const pagination = ref<PaginationProps>({pageSize: 5,@@ -50,12 +53,9 @@ const columns = computed(() => {width: 256,hide: !props.showParentBranchColumn,render: (row: Branch) => {- const parentBranch = branchStore.getBranchByName(row.parentBranch);- if (!parentBranch) {- return "";- }- return h(BranchNameCell, {- branch: parentBranch,+ if (!row.parentBranch) return null;+ return h(AsyncBranchNameCell, {+ name: row.parentBranch,});},},