Skip to content

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

chore(branch): add project link to breadcrumb (#8464)

boojack527858b37e56
diff --git a/frontend/src/components/Branch/BranchDetailView.vue b/frontend/src/components/Branch/BranchDetailView.vue
index 3d4ef72d63..b660349412 100644
--- a/frontend/src/components/Branch/BranchDetailView.vue
+++ b/frontend/src/components/Branch/BranchDetailView.vue
@@ -2,12 +2,6 @@
<div class="space-y-3 w-full overflow-x-auto px-4 pt-1">
<div class="w-full flex flex-row justify-between items-center">
<div class="w-full flex flex-row justify-start items-center gap-x-2">
- <router-link
- class="normal-link inline-flex items-center"
- :to="`/project/${projectV1Slug(project)}`"
- >{{ project.title }}</router-link
- >
- <span class="ml-1 -mr-1">/</span>
<NInput
v-model:value="state.schemaDesignTitle"
class="!w-auto"
@@ -140,7 +134,6 @@ import {
SchemaDesign,
SchemaDesign_Type,
} from "@/types/proto/v1/schema_design_service";
-import { projectV1Slug } from "@/utils";
import { provideSQLCheckContext } from "../SQLCheck";
import { getBaselineMetadataOfBranch } from "../SchemaEditorV1/utils/branch";
import MergeBranchPanel from "./MergeBranchPanel.vue";
diff --git a/frontend/src/components/Breadcrumb.vue b/frontend/src/components/Breadcrumb.vue
index bf8543f0c0..1866b3a079 100644
--- a/frontend/src/components/Breadcrumb.vue
+++ b/frontend/src/components/Breadcrumb.vue
@@ -71,10 +71,15 @@ import {
useBookmarkV1Store,
useProjectV1Store,
useDatabaseV1Store,
+ useSheetV1Store,
} from "@/store";
+import {
+ getProjectAndSheetId,
+ projectNamePrefix,
+} from "@/store/modules/v1/common";
import { Bookmark } from "@/types/proto/v1/bookmark_service";
import { RouteMapList } from "../types";
-import { databaseV1Slug, idFromSlug } from "../utils";
+import { databaseV1Slug, idFromSlug, projectV1Slug } from "../utils";
interface BreadcrumbItem {
name: string;
@@ -92,8 +97,8 @@ export default defineComponent({
const currentRoute = useRouter().currentRoute;
const { t } = useI18n();
const bookmarkV1Store = useBookmarkV1Store();
-
const projectV1Store = useProjectV1Store();
+ const sheetStore = useSheetV1Store();
const documentTitle = useTitle(null, { observe: true });
@@ -126,6 +131,7 @@ export default defineComponent({
const projectWebhookSlug = routeSlug.projectWebhookSlug;
const instanceSlug = routeSlug.instanceSlug;
const databaseSlug = routeSlug.databaseSlug;
+ const branchSlug = routeSlug.branchSlug;
const tableName = routeSlug.tableName;
const dataSourceSlug = routeSlug.dataSourceSlug;
const vcsSlug = routeSlug.vcsSlug;
@@ -177,6 +183,21 @@ export default defineComponent({
path: `/db/${databaseSlug}`,
});
}
+ } else if (branchSlug) {
+ const sheetId = idFromSlug(branchSlug);
+ const sheet = sheetStore.getSheetByUID(`${sheetId}`);
+ if (sheet) {
+ const [projectName] = getProjectAndSheetId(sheet.name);
+ const project = projectV1Store.getProjectByName(
+ `${projectNamePrefix}${projectName}`
+ );
+ if (project) {
+ list.push({
+ name: project.title,
+ path: `/project/${projectV1Slug(project)}`,
+ });
+ }
+ }
} else if (vcsSlug) {
list.push({
name: t("common.gitops"),
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 0dc770a105..418a81dcaf 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -1462,9 +1462,32 @@ router.beforeEach((to, from, next) => {
}
if (branchSlug) {
- // We've moved the preparation data fetch jobs into BranchDetail page
- // so just next() here.
- next();
+ if (branchSlug === "new") {
+ next();
+ return;
+ }
+
+ // Prepare the data for the branch detail page.
+ useSheetV1Store()
+ .getOrFetchSheetByUID(String(idFromSlug(branchSlug)))
+ .then((sheet) => {
+ if (sheet) {
+ next();
+ } else {
+ next({
+ name: "error.404",
+ replace: false,
+ });
+ throw new Error("not found");
+ }
+ })
+ .catch((error) => {
+ next({
+ name: "error.404",
+ replace: false,
+ });
+ throw error;
+ });
return;
}
diff --git a/frontend/src/store/modules/router.ts b/frontend/src/store/modules/router.ts
index 40ef37b6ba..8af6ec16ba 100644
--- a/frontend/src/store/modules/router.ts
+++ b/frontend/src/store/modules/router.ts
@@ -89,9 +89,10 @@ export const useRouterStore = defineStore("router", {
{
// /branch/:branchSlug
// Total 2 elements, 2nd element is the branch slug
- const branchComponents = currentRoute.path.match(
- "/branch/([0-9a-zA-Z_-]+)"
- ) || ["/", undefined];
+ const branchComponents = currentRoute.path.match("/branch/(.+)") || [
+ "/",
+ undefined,
+ ];
if (branchComponents[1]) {
return {
branchSlug: branchComponents[1],
diff --git a/frontend/src/views/branch/BranchDetail.vue b/frontend/src/views/branch/BranchDetail.vue
index fe8df0e4f0..6293edd32a 100644
--- a/frontend/src/views/branch/BranchDetail.vue
+++ b/frontend/src/views/branch/BranchDetail.vue
@@ -69,7 +69,7 @@ const documentTitle = computed(() => {
const schemaDesign = schemaDesignStore.getSchemaDesignByName(
branchName.value
);
- return `${schemaDesign.title} - ${t("common.branch")}`;
+ return `${schemaDesign.title}`;
}
}
return t("common.loading");