Skip to content

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

chore(branching): hide project selector under project view (#8819)

boojack67aa4b45284d
diff --git a/frontend/src/components/Branch/BranchCreateView.vue b/frontend/src/components/Branch/BranchCreateView.vue
index 2145753672..f3202ef458 100644
--- a/frontend/src/components/Branch/BranchCreateView.vue
+++ b/frontend/src/components/Branch/BranchCreateView.vue
@@ -1,6 +1,9 @@
<template>
- <div class="space-y-3 w-full overflow-x-auto px-4 pb-8">
- <div class="w-full flex flex-row justify-start items-center pt-1">
+ <div class="space-y-3 w-full overflow-x-auto px-4 pb-8 pt-4">
+ <div
+ v-if="showProjectSelector"
+ class="w-full flex flex-row justify-start items-center"
+ >
<span class="flex w-40 items-center shrink-0 text-sm">
{{ $t("common.project") }}
</span>
@@ -27,6 +30,7 @@
<BranchSelector
class="!w-60"
:branch="state.parentBranchName"
+ :project="state.projectId"
@update:branch="(branch) => (state.parentBranchName = branch)"
/>
</div>
@@ -148,6 +152,7 @@ const state = reactive<LocalState>({
type: SchemaDesign_Type.MAIN_BRANCH,
}),
});
+const showProjectSelector = ref<boolean>(true);
const refreshId = ref<string>("");
const project = computed(() => {
@@ -166,6 +171,8 @@ onMounted(async () => {
`${projectNamePrefix}${projectName}`
);
state.projectId = project.uid;
+ // When we are creating a branch from a project page, we don't show the project selector.
+ showProjectSelector.value = false;
}
});
diff --git a/frontend/src/components/Branch/BranchSelector.vue b/frontend/src/components/Branch/BranchSelector.vue
index 9bb7507275..133eaf7df3 100644
--- a/frontend/src/components/Branch/BranchSelector.vue
+++ b/frontend/src/components/Branch/BranchSelector.vue
@@ -8,42 +8,58 @@
:clearable="clearable"
:filter="filterByName"
class="bb-branch-select"
+ :render-label="renderLabel"
@update:value="$emit('update:branch', $event)"
/>
</template>
<script lang="ts" setup>
-import { NSelect, SelectOption } from "naive-ui";
-import { computed } from "vue";
-import { useSchemaDesignList } from "@/store";
+import { NSelect, SelectOption, SelectRenderLabel } from "naive-ui";
+import { computed, h } from "vue";
+import {
+ useDatabaseV1Store,
+ useProjectV1Store,
+ useSchemaDesignList,
+} from "@/store";
+import {
+ getProjectAndSchemaDesignSheetId,
+ projectNamePrefix,
+} from "@/store/modules/v1/common";
+import { UNKNOWN_ID } from "@/types";
import { SchemaDesign } from "@/types/proto/v1/schema_design_service";
+import { InstanceV1EngineIcon } from "../v2";
interface BranchSelectOption extends SelectOption {
value: string;
branch: SchemaDesign;
}
-const props = withDefaults(
- defineProps<{
- branch?: string | undefined;
- filter?: (branch: SchemaDesign, index: number) => boolean;
- clearable?: boolean;
- }>(),
- {
- branch: undefined,
- clearable: true,
- filter: () => true,
- }
-);
+const props = defineProps<{
+ project?: string;
+ branch?: string;
+ clearable?: boolean;
+ filter?: (branch: SchemaDesign, index: number) => boolean;
+}>();
defineEmits<{
(event: "update:branch", name: string | undefined): void;
}>();
const { schemaDesignList: branchList } = useSchemaDesignList();
+const projectStore = useProjectV1Store();
+const databaseStore = useDatabaseV1Store();
const combinedBranchList = computed(() => {
let list = branchList.value;
+ if (props.project) {
+ const project = projectStore.getProjectByUID(props.project);
+ if (project) {
+ list = list.filter((branch) => {
+ const [projectName] = getProjectAndSchemaDesignSheetId(branch.name);
+ return project.name === `${projectNamePrefix}${projectName}`;
+ });
+ }
+ }
if (props.filter) {
list = list.filter(props.filter);
}
@@ -68,6 +84,32 @@ const filterByName = (pattern: string, option: SelectOption) => {
branch.title.toLowerCase().includes(pattern)
);
};
+
+const renderLabel: SelectRenderLabel = (option) => {
+ const { branch } = option as BranchSelectOption;
+ if (!branch) {
+ return;
+ }
+
+ const children = [h("div", {}, [branch.title])];
+ const database = databaseStore.getDatabaseByName(branch.baselineDatabase);
+ if (database.uid !== String(UNKNOWN_ID)) {
+ // prefix engine icon
+ children.unshift(
+ h(InstanceV1EngineIcon, {
+ class: "mr-1",
+ instance: database.instanceEntity,
+ })
+ );
+ }
+ return h(
+ "div",
+ {
+ class: "w-full flex flex-row justify-start items-center truncate",
+ },
+ children
+ );
+};
</script>
<style lang="postcss" scoped>