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: branch detail page nested in the project detail page (#8998)
ecmadaob0efa3167092
diff --git a/frontend/src/components/Branch/BranchCreateView.vue b/frontend/src/components/Branch/BranchCreateView.vueindex abf8e410cc..3efe193758 100644--- a/frontend/src/components/Branch/BranchCreateView.vue+++ b/frontend/src/components/Branch/BranchCreateView.vue@@ -81,7 +81,7 @@ import { cloneDeep, uniqueId } from "lodash-es";import { NButton, NDivider, NInput } from "naive-ui";import { computed, onMounted, reactive, ref, watch } from "vue";import { useI18n } from "vue-i18n";-import { useRoute, useRouter } from "vue-router";+import { useRouter } from "vue-router";import SchemaEditorV1 from "@/components/SchemaEditorV1/index.vue";import { mergeSchemaEditToMetadata } from "@/components/SchemaEditorV1/utils";import { ProjectSelect } from "@/components/v2";@@ -97,7 +97,6 @@ import { useSchemaDesignStore } from "@/store/modules/schemaDesign";import {databaseNamePrefix,getProjectAndSchemaDesignSheetId,- projectNamePrefix,} from "@/store/modules/v1/common";import { UNKNOWN_ID } from "@/types";import {@@ -114,7 +113,7 @@ import {Sheet_Type,Sheet_Visibility,} from "@/types/proto/v1/sheet_service";-import { extractChangeHistoryUID } from "@/utils";+import { extractChangeHistoryUID, projectV1Slug } from "@/utils";import BaselineSchemaSelector from "./BaselineSchemaSelector.vue";import { validateBranchName } from "./utils";@@ -142,7 +141,6 @@ const props = defineProps({const { t } = useI18n();const router = useRouter();-const route = useRoute();const projectStore = useProjectV1Store();const databaseStore = useDatabaseV1Store();const schemaDesignStore = useSchemaDesignStore();@@ -170,12 +168,8 @@ const disallowToChangeBaseline = computed(() => {});onMounted(async () => {- const projectName = route.params.projectName;- if (projectName !== "-") {- const project = await projectStore.getOrFetchProjectByName(- `${projectNamePrefix}${projectName}`- );- state.projectId = project.uid;+ if (props.projectId) {+ state.projectId = props.projectId;// When we are creating a branch from a project page, we don't show the project selector.showProjectSelector.value = false;}@@ -389,13 +383,13 @@ const handleConfirm = async () => {});// Go to branch detail page after created.- const [projectName, sheetId] = getProjectAndSchemaDesignSheetId(+ const [_, sheetId] = getProjectAndSchemaDesignSheetId(createdSchemaDesign.name);router.replace({name: "workspace.branch.detail",params: {- projectName,+ projectSlug: projectV1Slug(project.value),branchName: sheetId,},});diff --git a/frontend/src/components/Branch/BranchDataTable.vue b/frontend/src/components/Branch/BranchDataTable.vueindex ec63ebae7f..bac64b8b30 100644--- a/frontend/src/components/Branch/BranchDataTable.vue+++ b/frontend/src/components/Branch/BranchDataTable.vue@@ -22,7 +22,10 @@ import {useProjectV1Store,useUserStore,} from "@/store";-import { getProjectAndSchemaDesignSheetId } from "@/store/modules/v1/common";+import {+ getProjectAndSchemaDesignSheetId,+ projectNamePrefix,+} from "@/store/modules/v1/common";import { UNKNOWN_ID } from "@/types";import {SchemaDesign,@@ -92,7 +95,9 @@ const dataTableRows = computed(() => {});const parentRows: BranchRowData[] = parentBranches.map((branch) => {const [projectName] = getProjectAndSchemaDesignSheetId(branch.name);- const project = projectV1Store.getProjectByName(`projects/${projectName}`);+ const project = projectV1Store.getProjectByName(+ `${projectNamePrefix}${projectName}`+ );const database = databaseStore.getDatabaseByName(branch.baselineDatabase);const changeHistory =branch.baselineChangeHistoryId &&diff --git a/frontend/src/components/Branch/BranchDetailView.vue b/frontend/src/components/Branch/BranchDetailView.vueindex 33d030d8c2..c4148bc2cd 100644--- a/frontend/src/components/Branch/BranchDetailView.vue+++ b/frontend/src/components/Branch/BranchDetailView.vue@@ -144,6 +144,7 @@ import {SchemaDesign,SchemaDesign_Type,} from "@/types/proto/v1/schema_design_service";+import { projectV1Slug } from "@/utils";import { provideSQLCheckContext } from "../SQLCheck";import { fetchBaselineMetadataOfBranch } from "../SchemaEditorV1/utils/branch";import MergeBranchPanel from "./MergeBranchPanel.vue";@@ -437,14 +438,14 @@ const handleSaveBranch = async () => {closeOnEsc: true,onNegativeClick: () => {// Go to draft branch detail page after merge failed.- const [projectName, sheetId] = getProjectAndSchemaDesignSheetId(+ const [_, sheetId] = getProjectAndSchemaDesignSheetId(newBranch.name);state.isEditing = false;router.replace({name: "workspace.branch.detail",params: {- projectName,+ projectSlug: projectV1Slug(project.value),branchName: sheetId,},});@@ -503,11 +504,11 @@ const handleSaveBranch = async () => {const handleMergeAfterConflictResolved = (branchName: string) => {state.showDiffEditor = false;state.isEditing = false;- const [projectName, sheetId] = getProjectAndSchemaDesignSheetId(branchName);+ const [_, sheetId] = getProjectAndSchemaDesignSheetId(branchName);router.replace({name: "workspace.branch.detail",params: {- projectName,+ projectSlug: projectV1Slug(project.value),branchName: sheetId,},});diff --git a/frontend/src/components/Branch/BranchTable.vue b/frontend/src/components/Branch/BranchTable.vueindex 75ea36525c..8a1ef1244d 100644--- a/frontend/src/components/Branch/BranchTable.vue+++ b/frontend/src/components/Branch/BranchTable.vue@@ -40,7 +40,10 @@ import { useI18n } from "vue-i18n";import { BBGridColumn } from "@/bbkit";import DatabaseInfo from "@/components/DatabaseInfo.vue";import { useDatabaseV1Store, useProjectV1Store, useUserStore } from "@/store";-import { getProjectAndSchemaDesignSheetId } from "@/store/modules/v1/common";+import {+ getProjectAndSchemaDesignSheetId,+ projectNamePrefix,+} from "@/store/modules/v1/common";import {SchemaDesign,SchemaDesign_Type,@@ -81,7 +84,9 @@ const COLUMN_LIST = computed(() => {const getFormattedValue = (branch: SchemaDesign) => {const [projectName] = getProjectAndSchemaDesignSheetId(branch.name);- const project = projectV1Store.getProjectByName(`projects/${projectName}`);+ const project = projectV1Store.getProjectByName(+ `${projectNamePrefix}${projectName}`+ );let parentBranch = "";if (branch.type === SchemaDesign_Type.PERSONAL_DRAFT) {const parentSchemaDesign = props.branches.find(diff --git a/frontend/src/components/Branch/MergeBranchPanel.vue b/frontend/src/components/Branch/MergeBranchPanel.vueindex b7ea839230..7a42e4f0af 100644--- a/frontend/src/components/Branch/MergeBranchPanel.vue+++ b/frontend/src/components/Branch/MergeBranchPanel.vue@@ -96,7 +96,10 @@ import { useI18n } from "vue-i18n";import DiffEditor from "@/components/MonacoEditor/DiffEditor.vue";import { pushNotification, useSheetV1Store } from "@/store";import { useSchemaDesignStore } from "@/store/modules/schemaDesign";-import { getProjectAndSchemaDesignSheetId } from "@/store/modules/v1/common";+import {+ getProjectAndSchemaDesignSheetId,+ projectNamePrefix,+} from "@/store/modules/v1/common";import { SchemaDesign } from "@/types/proto/v1/schema_design_service";import {Sheet_Source,@@ -186,7 +189,7 @@ const handleSaveDraft = async (ignoreNotify?: boolean) => {);// Create a baseline sheet for the schema design.const baselineSheet = await sheetStore.createSheet(- `projects/${projectName}`,+ `${projectNamePrefix}${projectName}`,{title: `baseline schema of ${targetBranch.value.title}`,database: targetBranch.value.baselineDatabase,diff --git a/frontend/src/components/Breadcrumb.vue b/frontend/src/components/Breadcrumb.vueindex 41715dd9fe..59067697da 100644--- a/frontend/src/components/Breadcrumb.vue+++ b/frontend/src/components/Breadcrumb.vue@@ -79,8 +79,7 @@ import {useProjectV1Store,useDatabaseV1Store,} from "@/store";-import { projectNamePrefix } from "@/store/modules/v1/common";-import { RouteMapList } from "@/types";+import { RouteMapList, UNKNOWN_ID } from "@/types";import { Bookmark } from "@/types/proto/v1/bookmark_service";import { TenantMode } from "@/types/proto/v1/project_service";import { databaseV1Slug, idFromSlug, projectV1Slug } from "../utils";@@ -216,6 +215,23 @@ export default defineComponent({path: `/project/${projectSlug}#changelists`,});+ } else if (route.name === "workspace.branch.detail") {+ list.push(+ {+ name: project.uid === String(UNKNOWN_ID) ? "-" : project.title,+ path:+ project.uid === String(UNKNOWN_ID)+ ? undefined+ : `/project/${projectV1Slug(project)}`,+ },+ {+ name: t("common.branches"),+ path:+ project.uid === String(UNKNOWN_ID)+ ? "/branches"+ : `/project/${projectV1Slug(project)}#branches`,+ }+ );}} else if (instanceSlug) {list.push({@@ -268,24 +284,6 @@ export default defineComponent({});}- if (route.name === "workspace.branch.detail") {- if (route.params.branchName !== "new") {- const project = projectV1Store.getProjectByName(- `${projectNamePrefix}${route.params.projectName}`- );- if (project) {- list.push({- name: project.title,- path: `/project/${projectV1Slug(project)}#branches`,- });- }- }- list.push({- name: t("common.branches"),- path: `/branches`,- });- }-const {title: routeTitle,overrideTitle,diff --git a/frontend/src/components/Project/ProjectSidebar.vue b/frontend/src/components/Project/ProjectSidebar.vueindex f45f0fa0a1..eeae30ff4d 100644--- a/frontend/src/components/Project/ProjectSidebar.vue+++ b/frontend/src/components/Project/ProjectSidebar.vue@@ -218,7 +218,11 @@ const getItemClass = (hash: string | undefined) => {return [];}const list = ["outline-item"];- if (state.selectedHash === hash) {+ if (!isProjectHash(hash)) {+ return list;+ }+ const projectHash = hash as ProjectHash;+ if (state.selectedHash === projectHash) {list.push("bg-link-hover");}return list;@@ -250,6 +254,13 @@ const selectProjectTabOnHash = () => {state.selectedHash = "webhook";} else if (name == "workspace.changelist.detail") {state.selectedHash = "changelists";+ } else if (name === "workspace.branch.detail") {+ state.selectedHash = "branches";+ } else if (+ name === "workspace.database-group.detail" ||+ name === "workspace.database-group.table-group.detail"+ ) {+ state.selectedHash = "database-groups";}};diff --git a/frontend/src/components/ProjectBranchesPanel.vue b/frontend/src/components/ProjectBranchesPanel.vueindex 0e3d31ddb7..c4c9120a18 100644--- a/frontend/src/components/ProjectBranchesPanel.vue+++ b/frontend/src/components/ProjectBranchesPanel.vue@@ -34,11 +34,9 @@ import { useRouter } from "vue-router";import BranchDataTable from "@/components/Branch/BranchDataTable.vue";import { useProjectV1Store } from "@/store";import { useSchemaDesignList } from "@/store/modules/schemaDesign";-import {- getProjectAndSchemaDesignSheetId,- getProjectName,-} from "@/store/modules/v1/common";+import { getProjectAndSchemaDesignSheetId } from "@/store/modules/v1/common";import { SchemaDesign } from "@/types/proto/v1/schema_design_service";+import { projectV1Slug } from "@/utils";const props = defineProps<{projectId: string;@@ -74,24 +72,21 @@ const filteredBranches = computed(() => {});const handleCreateBranch = () => {- const projectName = getProjectName(project.value.name);router.push({name: "workspace.branch.detail",params: {- projectName: projectName,+ projectSlug: projectV1Slug(project.value),branchName: "new",},});};const handleBranchClick = async (schemaDesign: SchemaDesign) => {- const [projectName, sheetId] = getProjectAndSchemaDesignSheetId(- schemaDesign.name- );+ const [_, sheetId] = getProjectAndSchemaDesignSheetId(schemaDesign.name);router.push({name: "workspace.branch.detail",params: {- projectName: projectName,+ projectSlug: projectV1Slug(project.value),branchName: `${sheetId}`,},});diff --git a/frontend/src/components/SyncDatabaseSchema/SchemaDesignSelector.vue b/frontend/src/components/SyncDatabaseSchema/SchemaDesignSelector.vueindex c22914ff92..ab6fdd8c5c 100644--- a/frontend/src/components/SyncDatabaseSchema/SchemaDesignSelector.vue+++ b/frontend/src/components/SyncDatabaseSchema/SchemaDesignSelector.vue@@ -73,7 +73,7 @@ import {SchemaDesign,SchemaDesign_Type,} from "@/types/proto/v1/schema_design_service";-import { projectV1Name } from "@/utils";+import { projectV1Name, projectV1Slug } from "@/utils";const emit = defineEmits<{(event: "select", schemaDesign: SchemaDesign): void;@@ -154,7 +154,7 @@ const handleCreateBranch = () => {const route = router.resolve({name: "workspace.branch.detail",params: {- projectName: "-",+ projectSlug: "-",branchName: "new",},});@@ -162,13 +162,14 @@ const handleCreateBranch = () => {};const handleViewSchemaDesign = (schemaDesign: SchemaDesign) => {- const [projectName, sheetId] = getProjectAndSchemaDesignSheetId(- schemaDesign.name+ const [_, sheetId] = getProjectAndSchemaDesignSheetId(schemaDesign.name);+ const baselineDatabase = databaseV1Store.getDatabaseByName(+ schemaDesign.baselineDatabase);const route = router.resolve({name: "workspace.branch.detail",params: {- projectName,+ projectSlug: projectV1Slug(baselineDatabase.projectEntity),branchName: sheetId,},});diff --git a/frontend/src/components/SyncDatabaseSchema/SelectTargetDatabasesView.vue b/frontend/src/components/SyncDatabaseSchema/SelectTargetDatabasesView.vueindex 0b8014f3a8..5c1650859c 100644--- a/frontend/src/components/SyncDatabaseSchema/SelectTargetDatabasesView.vue+++ b/frontend/src/components/SyncDatabaseSchema/SelectTargetDatabasesView.vue@@ -450,13 +450,13 @@ const handleViewBranch = () => {return;}- const [projectName, sheetId] = getProjectAndSchemaDesignSheetId(+ const [_, sheetId] = getProjectAndSchemaDesignSheetId(selectedSchemaDesign.value.name);const route = router.resolve({name: "workspace.branch.detail",params: {- projectName,+ projectSlug: projectV1Slug(project.value),branchName: sheetId,},});diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.tsindex fa68b82eff..a8b6b97c18 100644--- a/frontend/src/router/index.ts+++ b/frontend/src/router/index.ts@@ -286,7 +286,7 @@ const routes: Array<RouteRecordRaw> = [props: { content: true, leftSidebar: true },},{- path: "/projects/:projectName/branches/:branchName",+ path: "/project/:projectSlug/branches/:branchName",name: "workspace.branch.detail",meta: {allowBookmark: true,@@ -294,9 +294,9 @@ const routes: Array<RouteRecordRaw> = [},components: {content: () => import("../views/branch/BranchDetail.vue"),- leftSidebar: DashboardSidebar,+ leftSidebar: ProjectSidebar,},- props: { content: false },+ props: { content: true },},{path: "sync-schema",@@ -1306,7 +1306,6 @@ router.beforeEach((to, from, next) => {to.name === "workspace.branch.dashboard" ||to.name === "workspace.environment" ||to.name === "sql-editor.home" ||- to.name?.toString().startsWith("workspace.database-group") ||to.name?.toString().startsWith("sheets") ||(to.name?.toString().startsWith("setting") &&to.name?.toString() != "setting.workspace.gitops.detail" &&@@ -1399,7 +1398,7 @@ router.beforeEach((to, from, next) => {return;}- if (projectSlug) {+ if (projectSlug && projectSlug !== "-") {projectV1Store.fetchProjectByUID(String(idFromSlug(projectSlug))).then((project) => {@@ -1440,6 +1439,31 @@ router.beforeEach((to, from, next) => {});throw error;});+ } else if (+ to.name === "workspace.branch.detail" &&+ to.params.branchName !== "new"+ ) {+ const name = `${project.name}/schemaDesigns/${to.params.branchName}`;+ useSchemaDesignStore()+ .fetchSchemaDesignByName(name, false /* !useCache */)+ .then((branch) => {+ if (branch) {+ next();+ } else {+ next({+ name: "error.404",+ replace: false,+ });+ throw new Error("not found");+ }+ })+ .catch((error) => {+ next({+ name: "error.404",+ replace: false,+ });+ throw error;+ });} else {next();}@@ -1466,30 +1490,6 @@ router.beforeEach((to, from, next) => {next();return;}-- // Prepare the data for the branch detail page.- const name = `projects/${to.params.projectName}/schemaDesigns/${to.params.branchName}`;- useSchemaDesignStore()- .fetchSchemaDesignByName(name, false /* !useCache */)- .then((branch) => {- if (branch) {- next();- } else {- next({- name: "error.404",- replace: false,- });- throw new Error("not found");- }- })- .catch((error) => {- next({- name: "error.404",- replace: false,- });- throw error;- });- return;}if (databaseSlug) {diff --git a/frontend/src/store/modules/router.ts b/frontend/src/store/modules/router.tsindex c06059a42e..fdbf0855e0 100644--- a/frontend/src/store/modules/router.ts+++ b/frontend/src/store/modules/router.ts@@ -74,6 +74,20 @@ export const useRouterStore = defineStore("router", {}}+ {+ // /project/:projectSlug/branches/:branchName+ // Total 3 elements, 2nd element is the project slug, 3rd element is the project changelist name.+ const projectComponents = currentRoute.path.match(+ "/project/([0-9a-zA-Z_-]+)/branches/([0-9a-zA-Z_-]+)"+ ) || ["/", undefined];+ if (projectComponents.length === 3) {+ return {+ projectSlug: projectComponents[1],+ branchName: projectComponents[2],+ };+ }+ }+{// /issue/:issueSlug// Total 2 elements, 2nd element is the issue slugdiff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex dbd8b64cad..855a1e945f 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -65,6 +65,7 @@ export type RouterSlug = {databaseGroupName?: string;schemaGroupName?: string;changelistName?: string;+ branchName?: string;};// Quick Action Typediff --git a/frontend/src/views/branch/BranchDashboard.vue b/frontend/src/views/branch/BranchDashboard.vueindex 3b3d3e497b..15410c6685 100644--- a/frontend/src/views/branch/BranchDashboard.vue+++ b/frontend/src/views/branch/BranchDashboard.vue@@ -36,11 +36,12 @@ import { computed, reactive } from "vue";import { useRouter } from "vue-router";import BranchDataTable from "@/components/Branch/BranchDataTable.vue";import { ProjectSelect } from "@/components/v2";-import { useProjectV1Store } from "@/store";+import { useProjectV1Store, useDatabaseV1Store } from "@/store";import { useSchemaDesignList } from "@/store/modules/schemaDesign";import { getProjectAndSchemaDesignSheetId } from "@/store/modules/v1/common";import { UNKNOWN_ID } from "@/types";import { SchemaDesign } from "@/types/proto/v1/schema_design_service";+import { projectV1Slug } from "@/utils";interface LocalState {searchKeyword: string;@@ -50,6 +51,7 @@ interface LocalState {const router = useRouter();const { schemaDesignList, ready } = useSchemaDesignList();const projectStore = useProjectV1Store();+const databaseStore = useDatabaseV1Store();const state = reactive<LocalState>({searchKeyword: "",projectFilter: String(UNKNOWN_ID),@@ -77,20 +79,22 @@ const handleCreateBranch = () => {router.push({name: "workspace.branch.detail",params: {- projectName: "-",+ projectSlug: "-",branchName: "new",},});};const handleBranchClick = async (schemaDesign: SchemaDesign) => {- const [projectName, sheetId] = getProjectAndSchemaDesignSheetId(- schemaDesign.name+ const [_, sheetId] = getProjectAndSchemaDesignSheetId(schemaDesign.name);+ const baselineDatabase = databaseStore.getDatabaseByName(+ schemaDesign.baselineDatabase);+ console.log("handleBranchClick");router.push({name: "workspace.branch.detail",params: {- projectName,+ projectSlug: projectV1Slug(baselineDatabase.projectEntity),branchName: sheetId,},});diff --git a/frontend/src/views/branch/BranchDetail.vue b/frontend/src/views/branch/BranchDetail.vueindex edd793f1bb..9ad1ce1dab 100644--- a/frontend/src/views/branch/BranchDetail.vue+++ b/frontend/src/views/branch/BranchDetail.vue@@ -1,7 +1,7 @@<template><template v-if="ready"><template v-if="isCreating">- <BranchCreateView />+ <BranchCreateView :project-id="project?.uid" /></template><template v-else-if="branch"><BranchDetailView :branch="branch" />@@ -19,18 +19,36 @@ import BranchDetailView from "@/components/Branch/BranchDetailView.vue";import { useProjectV1Store, useSheetV1Store } from "@/store";import { useSchemaDesignStore } from "@/store/modules/schemaDesign";import { getProjectAndSheetId } from "@/store/modules/v1/common";+import { idFromSlug } from "@/utils";++const props = defineProps({+ projectSlug: {+ required: true,+ type: String,+ },+ branchName: {+ required: true,+ type: String,+ },+});const { t } = useI18n();const route = useRoute();const sheetStore = useSheetV1Store();const projectStore = useProjectV1Store();const schemaDesignStore = useSchemaDesignStore();-const branchName = ref<string>("");+const branchFullName = ref<string>("");const ready = ref<boolean>(false);-const isCreating = computed(() => route.params.branchName === "new");+const isCreating = computed(() => props.branchName === "new");const branch = computed(() => {- return schemaDesignStore.getSchemaDesignByName(branchName.value);+ return schemaDesignStore.getSchemaDesignByName(branchFullName.value);+});+const project = computed(() => {+ if (props.projectSlug === "-") {+ return;+ }+ return projectStore.getProjectByUID(String(idFromSlug(props.projectSlug)));});watch(@@ -41,7 +59,7 @@ watch(}// Prepare branch name from route params.- const sheetId = (route.params.branchName as string) || "";+ const sheetId = (props.branchName as string) || "";if (!sheetId) {return;}@@ -49,7 +67,7 @@ watch(if (sheet) {const [projectName] = getProjectAndSheetId(sheet.name);await projectStore.getOrFetchProjectByName(`projects/${projectName}`);- branchName.value = `projects/${projectName}/schemaDesigns/${sheetId}`;+ branchFullName.value = `projects/${projectName}/schemaDesigns/${sheetId}`;}},{@@ -59,16 +77,16 @@ watch();watch(- () => branchName.value,+ () => branchFullName.value,async () => {ready.value = false;- if (isCreating.value || !branchName.value) {+ if (isCreating.value || !branchFullName.value) {ready.value = true;return;}await schemaDesignStore.fetchSchemaDesignByName(- branchName.value,+ branchFullName.value,false /* useCache */);ready.value = true;