Skip to content

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

feat: add branch page and entry (#8295)

boojack637058843d08
diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vue
index ffae3e8474..7457fde564 100644
--- a/frontend/src/components/QuickActionPanel.vue
+++ b/frontend/src/components/QuickActionPanel.vue
@@ -65,20 +65,6 @@
{{ $t("database.change-data") }}
</h3>
</div>
-
- <div
- v-if="quickAction === 'quickaction.bb.database.branching'"
- class="flex flex-col items-center w-24"
- >
- <button class="btn-icon-primary p-3" @click.prevent="designSchema">
- <GitBranch class="w-4 h-4" />
- </button>
- <h3
- class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"
- >
- {{ $t("database.branching") }}
- </h3>
- </div>
</template>
<div
@@ -249,11 +235,6 @@
:type="'bb.issue.database.data.update'"
@dismiss="state.quickActionType = undefined"
/>
- <DesignSchemaPrepForm
- v-if="state.quickActionType === 'quickaction.bb.database.branching'"
- :project-id="projectId"
- @dismiss="state.quickActionType = undefined"
- />
<TransferDatabaseForm
v-if="
projectId &&
@@ -299,7 +280,6 @@
<script lang="ts" setup>
import { Action, defineAction, useRegisterActions } from "@bytebase/vue-kbar";
-import { GitBranch } from "lucide-vue-next";
import { reactive, PropType, computed, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRoute, useRouter } from "vue-router";
@@ -309,7 +289,6 @@ import InstanceForm from "@/components/InstanceForm/";
import RequestExportPanel from "@/components/Issue/panel/RequestExportPanel/index.vue";
import RequestQueryPanel from "@/components/Issue/panel/RequestQueryPanel/index.vue";
import ProjectCreatePanel from "@/components/Project/ProjectCreatePanel.vue";
-import DesignSchemaPrepForm from "@/components/SchemaDesigner/PrepForm/index.vue";
import TransferDatabaseForm from "@/components/TransferDatabaseForm.vue";
import TransferOutDatabaseForm from "@/components/TransferOutDatabaseForm";
import { Drawer } from "@/components/v2";
@@ -404,10 +383,6 @@ const alterSchema = () => {
state.quickActionType = "quickaction.bb.database.schema.update";
};
-const designSchema = () => {
- state.quickActionType = "quickaction.bb.database.branching";
-};
-
const changeData = () => {
state.quickActionType = "quickaction.bb.database.data.update";
};
diff --git a/frontend/src/components/SchemaDesigner/BranchTable.vue b/frontend/src/components/SchemaDesigner/BranchTable.vue
index 7003e87174..43e2503165 100644
--- a/frontend/src/components/SchemaDesigner/BranchTable.vue
+++ b/frontend/src/components/SchemaDesigner/BranchTable.vue
@@ -1,35 +1,34 @@
<template>
- <div ref="wrapper" rule="database-table" v-bind="$attrs">
- <BBGrid
- class="border"
- :show-placeholder="true"
- :column-list="COLUMN_LIST"
- :data-source="branches"
- @click-row="clickBranch"
- >
- <template #item="{ item: branch }: { item: SchemaDesign }">
- <div v-if="!hideProjectColumn" class="bb-grid-cell">
- {{ projectV1Name(getFormatedValue(branch).project) }}
- </div>
- <div class="bb-grid-cell">
- <NEllipsis :line-clamp="1">{{ branch.title }}</NEllipsis>
- </div>
- <div class="bb-grid-cell">
- <NEllipsis :line-clamp="1">{{
- getFormatedValue(branch).parentBranch
- }}</NEllipsis>
- </div>
- <div class="bb-grid-cell">
- <DatabaseInfo :database="getFormatedValue(branch).database" />
- </div>
- <div class="bb-grid-cell">
- <span class="text-gray-400">{{
- getFormatedValue(branch).updatedTimeStr
- }}</span>
- </div>
- </template>
- </BBGrid>
- </div>
+ <BBGrid
+ class="border"
+ :show-placeholder="true"
+ :column-list="COLUMN_LIST"
+ :data-source="branches"
+ v-bind="$attrs"
+ @click-row="clickBranch"
+ >
+ <template #item="{ item: branch }: { item: SchemaDesign }">
+ <div v-if="!hideProjectColumn" class="bb-grid-cell">
+ {{ projectV1Name(getFormatedValue(branch).project) }}
+ </div>
+ <div class="bb-grid-cell">
+ <NEllipsis :line-clamp="1">{{ branch.title }}</NEllipsis>
+ </div>
+ <div class="bb-grid-cell">
+ <NEllipsis :line-clamp="1">{{
+ getFormatedValue(branch).parentBranch
+ }}</NEllipsis>
+ </div>
+ <div class="bb-grid-cell">
+ <DatabaseInfo :database="getFormatedValue(branch).database" />
+ </div>
+ <div class="bb-grid-cell">
+ <span class="text-gray-400">{{
+ getFormatedValue(branch).updatedTimeStr
+ }}</span>
+ </div>
+ </template>
+ </BBGrid>
</template>
<script lang="ts" setup>
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 209f54209a..210bcde830 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -159,14 +159,12 @@ const routes: Array<RouteRecordRaw> = [
const DBA_AND_OWNER_QUICK_ACTION_LIST: QuickActionType[] = [
"quickaction.bb.database.schema.update",
"quickaction.bb.database.data.update",
- "quickaction.bb.database.branching",
"quickaction.bb.database.create",
"quickaction.bb.instance.create",
];
const DEVELOPER_QUICK_ACTION_LIST: QuickActionType[] = [
"quickaction.bb.database.schema.update",
"quickaction.bb.database.data.update",
- "quickaction.bb.database.branching",
"quickaction.bb.issue.grant.request.querier",
"quickaction.bb.issue.grant.request.exporter",
];
@@ -671,7 +669,6 @@ const routes: Array<RouteRecordRaw> = [
const DBA_AND_OWNER_QUICK_ACTION_LIST: QuickActionType[] = [
"quickaction.bb.database.schema.update",
"quickaction.bb.database.data.update",
- "quickaction.bb.database.branching",
"quickaction.bb.database.create",
"quickaction.bb.project.database.transfer",
"quickaction.bb.project.database.transfer-out",
@@ -692,7 +689,6 @@ const routes: Array<RouteRecordRaw> = [
DEVELOPER_QUICK_ACTION_LIST.push(
"quickaction.bb.database.schema.update",
"quickaction.bb.database.data.update",
- "quickaction.bb.database.branching",
"quickaction.bb.database.create"
);
}
@@ -833,13 +829,11 @@ const routes: Array<RouteRecordRaw> = [
const DBA_AND_OWNER_QUICK_ACTION_LIST: QuickActionType[] = [
"quickaction.bb.database.schema.update",
"quickaction.bb.database.data.update",
- "quickaction.bb.database.branching",
"quickaction.bb.database.create",
];
const DEVELOPER_QUICK_ACTION_LIST: QuickActionType[] = [
"quickaction.bb.database.schema.update",
"quickaction.bb.database.data.update",
- "quickaction.bb.database.branching",
"quickaction.bb.database.create",
"quickaction.bb.issue.grant.request.querier",
"quickaction.bb.issue.grant.request.exporter",
@@ -979,6 +973,31 @@ const routes: Array<RouteRecordRaw> = [
},
],
},
+ {
+ path: "branch",
+ name: "workspace.branch",
+ meta: {
+ title: () => t("common.branches"),
+ },
+ components: {
+ content: () => import("../views/branch/BranchDashboard.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: { content: true, leftSidebar: true },
+ },
+ {
+ path: "branch/:branchSlug",
+ name: "workspace.branch.detail",
+ meta: {
+ allowBookmark: true,
+ overrideTitle: true,
+ },
+ components: {
+ content: () => import("../views/branch/BranchDetail.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: { content: true },
+ },
],
},
],
@@ -1305,6 +1324,7 @@ router.beforeEach((to, from, next) => {
to.name === "workspace.database" ||
to.name === "workspace.archive" ||
to.name === "workspace.issue" ||
+ to.name === "workspace.branch" ||
to.name === "workspace.environment" ||
to.name === "sql-editor.home" ||
to.name?.toString().startsWith("workspace.database-group") ||
diff --git a/frontend/src/types/quickAction.ts b/frontend/src/types/quickAction.ts
index 1906fb58c6..e036b2fa38 100644
--- a/frontend/src/types/quickAction.ts
+++ b/frontend/src/types/quickAction.ts
@@ -10,9 +10,7 @@ export type DatabaseQuickActionType =
| "quickaction.bb.database.create" // Used by DBA and Owner
| "quickaction.bb.database.request" // Used by Developer (not yet)
| "quickaction.bb.database.schema.update"
- | "quickaction.bb.database.data.update"
- // Schema designer quick action. (Maybe will be removed after changelist is implemented)
- | "quickaction.bb.database.branching";
+ | "quickaction.bb.database.data.update";
export type IssueQuickActionType =
| "quickaction.bb.issue.grant.request.querier"
| "quickaction.bb.issue.grant.request.exporter";
diff --git a/frontend/src/views/DashboardHeader.vue b/frontend/src/views/DashboardHeader.vue
index dc9a5acc50..b831b98461 100644
--- a/frontend/src/views/DashboardHeader.vue
+++ b/frontend/src/views/DashboardHeader.vue
@@ -12,6 +12,13 @@
>{{ $t("common.issues") }}</router-link
>
+ <router-link
+ to="/branch"
+ class="bar-link px-2 py-1 rounded-md"
+ :class="getRouteLinkClass('/branch')"
+ >{{ $t("common.branches") }}</router-link
+ >
+
<router-link
to="/project"
class="bar-link px-2 py-1 rounded-md"
diff --git a/frontend/src/views/branch/BranchDashboard.vue b/frontend/src/views/branch/BranchDashboard.vue
new file mode 100644
index 0000000000..0fc57dd1dc
--- /dev/null
+++ b/frontend/src/views/branch/BranchDashboard.vue
@@ -0,0 +1,103 @@
+<template>
+ <div class="space-y-3 pt-2 w-full overflow-x-auto">
+ <div class="w-full px-4 flex flex-row justify-between items-center">
+ <div class="flex flex-row justify-start items-center space-x-2">
+ <NButton type="primary" @click="state.showCreatePanel = true">
+ <heroicons-solid:plus class="w-4 h-auto mr-0.5" />
+ <span>{{ $t("database.new-branch") }}</span>
+ </NButton>
+ </div>
+ <div class="flex flex-row justify-end items-center gap-x-2">
+ <NInput
+ v-model:value="state.searchKeyword"
+ class="!w-36"
+ clearable
+ :placeholder="$t('schema-designer.action.filter-by-name')"
+ />
+ </div>
+ </div>
+
+ <BranchTable
+ v-if="ready"
+ :branches="filteredBranches"
+ :hide-project-column="hideProjectColumn"
+ class="border-x-0"
+ @click="handleBranchClick"
+ />
+ <div v-else class="w-full h-[20rem] flex items-center justify-center">
+ <BBSpin />
+ </div>
+ </div>
+
+ <CreateSchemaDesignPanel
+ v-if="state.showCreatePanel"
+ :project-id="projectId"
+ @dismiss="state.showCreatePanel = false"
+ @created="
+ (schemaDesign: SchemaDesign) => {
+ state.showCreatePanel = false;
+ handleBranchClick(schemaDesign);
+ }
+ "
+ />
+
+ <EditSchemaDesignPanel
+ v-if="state.selectedSchemaDesignName"
+ :schema-design-name="state.selectedSchemaDesignName"
+ @dismiss="state.selectedSchemaDesignName = undefined"
+ />
+</template>
+
+<script lang="ts" setup>
+import { orderBy } from "lodash-es";
+import { NButton, NInput } from "naive-ui";
+import { computed, reactive } from "vue";
+import BranchTable from "@/components/SchemaDesigner/BranchTable.vue";
+import CreateSchemaDesignPanel from "@/components/SchemaDesigner/CreateSchemaDesignPanel.vue";
+import EditSchemaDesignPanel from "@/components/SchemaDesigner/EditSchemaDesignPanel.vue";
+import { useProjectV1Store } from "@/store";
+import { useSchemaDesignList } from "@/store/modules/schemaDesign";
+import { SchemaDesign } from "@/types/proto/v1/schema_design_service";
+
+const props = defineProps<{
+ projectId?: string;
+ hideProjectColumn?: boolean;
+}>();
+
+interface LocalState {
+ searchKeyword: string;
+ showCreatePanel: boolean;
+ selectedSchemaDesignName?: string;
+}
+
+const projectV1Store = useProjectV1Store();
+const { schemaDesignList, ready } = useSchemaDesignList();
+const state = reactive<LocalState>({
+ searchKeyword: "",
+ showCreatePanel: false,
+});
+
+const project = computed(() =>
+ projectV1Store.getProjectByUID(props.projectId || "")
+);
+
+const filteredBranches = computed(() => {
+ return orderBy(
+ props.projectId
+ ? schemaDesignList.value.filter((schemaDesign) =>
+ schemaDesign.name.startsWith(project.value.name)
+ )
+ : schemaDesignList.value,
+ "updateTime",
+ "desc"
+ ).filter((branch) => {
+ return state.searchKeyword
+ ? branch.title.includes(state.searchKeyword)
+ : true;
+ });
+});
+
+const handleBranchClick = async (schemaDesign: SchemaDesign) => {
+ state.selectedSchemaDesignName = schemaDesign.name;
+};
+</script>
diff --git a/frontend/src/views/branch/BranchDetail.vue b/frontend/src/views/branch/BranchDetail.vue
new file mode 100644
index 0000000000..6f90a1d71b
--- /dev/null
+++ b/frontend/src/views/branch/BranchDetail.vue
@@ -0,0 +1,4 @@
+<template>
+ <!-- TBC -->
+ <p>Detail page placeholder</p>
+</template>