Skip to content

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

fix: database group page should nested in the project page (#8985)

ecmadao11a7b8b51c9c
diff --git a/frontend/src/components/Breadcrumb.vue b/frontend/src/components/Breadcrumb.vue
index fedffe9dd2..41715dd9fe 100644
--- a/frontend/src/components/Breadcrumb.vue
+++ b/frontend/src/components/Breadcrumb.vue
@@ -33,7 +33,7 @@
{{ item.name }}
</div>
<span
- v-if="isTenantProject && index == breadcrumbList.length - 1"
+ v-if="isTenantProject && index == 1"
class="flex-shrink-0 h-4 w-4"
>
<TenantIcon class="ml-1 text-control" />
@@ -153,7 +153,7 @@ export default defineComponent({
const sqlReviewPolicySlug = routeSlug.sqlReviewPolicySlug;
const ssoName = routeSlug.ssoName;
- const projectName = routeSlug.projectName;
+ const changelistName = routeSlug.changelistName;
const databaseGroupName = routeSlug.databaseGroupName;
const schemaGroupName = routeSlug.schemaGroupName;
@@ -169,14 +169,53 @@ export default defineComponent({
path: "/project",
});
+ const project = projectV1Store.getProjectByUID(
+ String(idFromSlug(projectSlug))
+ );
+
if (projectWebhookSlug) {
- const project = projectV1Store.getProjectByUID(
- String(idFromSlug(projectSlug))
- );
list.push({
name: `${project.title}`,
path: `/project/${projectSlug}`,
});
+ } else if (databaseGroupName) {
+ list.push(
+ {
+ name: project.title,
+ path: `/project/${projectV1Slug(project)}`,
+ },
+ {
+ name: t("common.database-groups"),
+ path: `/project/${projectSlug}#database-groups`,
+ }
+ );
+
+ if (schemaGroupName) {
+ list.push(
+ {
+ name: databaseGroupName,
+ path: `/project/${projectSlug}/database-groups/${databaseGroupName}`,
+ },
+ {
+ name: `Tables - ${schemaGroupName}`,
+ }
+ );
+ } else {
+ list.push({
+ name: databaseGroupName,
+ });
+ }
+ } else if (changelistName) {
+ list.push(
+ {
+ name: project.title,
+ path: `/project/${projectV1Slug(project)}`,
+ },
+ {
+ name: t("changelist.self"),
+ path: `/project/${projectSlug}#changelists`,
+ }
+ );
}
} else if (instanceSlug) {
list.push({
@@ -215,21 +254,6 @@ export default defineComponent({
path: "/setting/sso",
});
}
- } else if (schemaGroupName) {
- if (projectName && databaseGroupName) {
- list.push(
- {
- name: "Databases",
- },
- {
- name: databaseGroupName,
- path: `/projects/${projectName}/database-groups/${databaseGroupName}`,
- },
- {
- name: `Tables - ${schemaGroupName}`,
- }
- );
- }
}
if (route.name === "workspace.database.history.detail") {
const parent = `instances/${route.params.instance}/databases/${route.params.database}`;
@@ -243,19 +267,7 @@ export default defineComponent({
path: `/db/${databaseV1Slug(database)}#change-history`,
});
}
- if (route.name === "workspace.changelist.detail") {
- const project = useProjectV1Store().getProjectByUID(
- String(idFromSlug(route.params.projectSlug as string))
- );
- list.push({
- name: project.title,
- path: `/project/${projectV1Slug(project)}`,
- });
- list.push({
- name: t("changelist.self"),
- path: `/project/${projectSlug}#changelists`,
- });
- }
+
if (route.name === "workspace.branch.detail") {
if (route.params.branchName !== "new") {
const project = projectV1Store.getProjectByName(
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
index a7e145ddb5..c924ca2652 100644
--- a/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
@@ -181,12 +181,14 @@ const doDelete = () => {
router.currentRoute.value.name ===
"workspace.database-group.table-group.detail"
) {
- const [projectName, databaseGroupName] =
+ const [_, databaseGroupName] =
getProjectNameAndDatabaseGroupNameAndSchemaGroupName(
schemaGroupName
);
// TODO(steven): prevent `Cannot use 'in' operator to search for 'path' in undefined` error in vue-router.
- window.location.href = `/projects/${projectName}/database-groups/${databaseGroupName}`;
+ window.location.href = `/project/${projectV1Slug(
+ props.project
+ )}/database-groups/${databaseGroupName}`;
}
}
emit("close");
@@ -256,6 +258,10 @@ const doConfirm = async () => {
return;
}
+ if (!buildCELExpr(formState.expr)) {
+ return;
+ }
+
const celStrings = await batchConvertParsedExprToCELString([
ParsedExpr.fromJSON({
expr: buildCELExpr(formState.expr),
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue
index a3016aa37b..4efcd1357d 100644
--- a/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue
+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue
@@ -28,6 +28,7 @@ import { useRouter } from "vue-router";
import { BBGridColumn } from "@/bbkit";
import { ComposedDatabaseGroup } from "@/types";
import { DatabaseGroup } from "@/types/proto/v1/project_service";
+import { projectV1Slug } from "@/utils";
const props = defineProps<{
databaseGroupList: ComposedDatabaseGroup[];
@@ -66,7 +67,9 @@ const clickDatabaseGroup = (databaseGroup: ComposedDatabaseGroup) => {
}
router.push(
- `/${databaseGroup.project.name}/database-groups/${databaseGroup.databaseGroupName}`
+ `/project/${projectV1Slug(databaseGroup.project)}/database-groups/${
+ databaseGroup.databaseGroupName
+ }`
);
};
</script>
diff --git a/frontend/src/components/DatabaseGroup/SchemaGroupTable.vue b/frontend/src/components/DatabaseGroup/SchemaGroupTable.vue
index 6f2212b661..7cb0eeee34 100644
--- a/frontend/src/components/DatabaseGroup/SchemaGroupTable.vue
+++ b/frontend/src/components/DatabaseGroup/SchemaGroupTable.vue
@@ -28,6 +28,7 @@ import { BBGridColumn } from "@/bbkit";
import { getProjectNameAndDatabaseGroupNameAndSchemaGroupName } from "@/store/modules/v1/common";
import { ComposedSchemaGroup } from "@/types";
import { SchemaGroup } from "@/types/proto/v1/project_service";
+import { projectV1Slug } from "@/utils";
defineProps<{
schemaGroupList: SchemaGroup[];
@@ -53,10 +54,12 @@ const COLUMN_LIST = computed(() => {
});
const clickSchemaGroup = (schemaGroup: ComposedSchemaGroup) => {
- const [projectName, databaseGroupName, schemaGroupName] =
+ const [_, databaseGroupName, schemaGroupName] =
getProjectNameAndDatabaseGroupNameAndSchemaGroupName(schemaGroup.name);
router.push(
- `/projects/${projectName}/database-groups/${databaseGroupName}/table-groups/${schemaGroupName}`
+ `/project/${projectV1Slug(
+ schemaGroup.databaseGroup.project
+ )}/database-groups/${databaseGroupName}/table-groups/${schemaGroupName}`
);
};
</script>
diff --git a/frontend/src/components/DatabaseListSidePanel.vue b/frontend/src/components/DatabaseListSidePanel.vue
index cb87dc7578..8054df7a5b 100644
--- a/frontend/src/components/DatabaseListSidePanel.vue
+++ b/frontend/src/components/DatabaseListSidePanel.vue
@@ -40,7 +40,6 @@ import {
environmentV1Name,
projectV1Slug,
isDatabaseV1Accessible,
- extractProjectResourceName,
uidFromSlug,
keyBy,
extractUserUID,
@@ -272,9 +271,9 @@ const tenantDatabaseListByProject = computed((): BBOutlineItem[] => {
...databaseGroupList.map<BBOutlineItem>((dbGroup) => ({
id: `bb.project.${project.uid}.databaseGroup.${dbGroup.name}`,
name: dbGroup.databaseGroupName,
- link: `/projects/${extractProjectResourceName(
- project.name
- )}/database-groups/${dbGroup.databaseGroupName}`,
+ link: `/project/${projectV1Slug(project)}/database-groups/${
+ dbGroup.databaseGroupName
+ }`,
prefix: h(DatabaseGroupIcon, {
class: "w-4 h-auto",
}),
diff --git a/frontend/src/components/v2/Model/DatabaseGroupName.vue b/frontend/src/components/v2/Model/DatabaseGroupName.vue
index 9db68a311c..37c610809c 100644
--- a/frontend/src/components/v2/Model/DatabaseGroupName.vue
+++ b/frontend/src/components/v2/Model/DatabaseGroupName.vue
@@ -12,6 +12,7 @@
<script lang="ts" setup>
import { computed } from "vue";
import type { ComposedDatabaseGroup } from "@/types";
+import { projectV1Slug } from "@/utils";
const props = withDefaults(
defineProps<{
@@ -32,7 +33,9 @@ const bindings = computed(() => {
return {};
}
- const route = `/${props.databaseGroup.project.name}/database-groups/${props.databaseGroup.databaseGroupName}`;
+ const route = `/project/${projectV1Slug(
+ props.databaseGroup.project
+ )}/database-groups/${props.databaseGroup.databaseGroupName}`;
if (props.link) {
return {
to: route,
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
index 461a3a12be..f2061df783 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
@@ -164,6 +164,7 @@ import {
import { getScrollParent } from "@/utils";
import {
databaseV1Slug,
+ projectV1Slug,
isDatabaseV1Queryable,
isPITRDatabaseV1,
VueClass,
@@ -487,10 +488,13 @@ const clickDatabase = (
router.push(url);
}
} else {
- const [projectName, databaseGroupName] =
- getProjectNameAndDatabaseGroupName(database.name);
+ const [_, databaseGroupName] = getProjectNameAndDatabaseGroupName(
+ database.name
+ );
router.push(
- `/projects/${projectName}/database-groups/${databaseGroupName}`
+ `/project/${projectV1Slug(
+ (database as ComposedDatabaseGroup).project
+ )}/database-groups/${databaseGroupName}`
);
}
}
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 873b3474b3..fa68b82eff 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -1000,14 +1000,14 @@ const routes: Array<RouteRecordRaw> = [
},
// Resource name related routes.
{
- path: "projects/:projectName",
+ path: "project/:projectSlug",
children: [
{
path: "database-groups/:databaseGroupName",
name: "workspace.database-group.detail",
components: {
content: () => import("../views/DatabaseGroupDetail.vue"),
- leftSidebar: DashboardSidebar,
+ leftSidebar: ProjectSidebar,
},
props: true,
},
@@ -1016,7 +1016,7 @@ const routes: Array<RouteRecordRaw> = [
name: "workspace.database-group.table-group.detail",
components: {
content: () => import("../views/SchemaGroupDetail.vue"),
- leftSidebar: DashboardSidebar,
+ leftSidebar: ProjectSidebar,
},
props: true,
},
diff --git a/frontend/src/store/modules/dbGroup.ts b/frontend/src/store/modules/dbGroup.ts
index 6a2d50dc6d..833b01930a 100644
--- a/frontend/src/store/modules/dbGroup.ts
+++ b/frontend/src/store/modules/dbGroup.ts
@@ -408,6 +408,12 @@ export const useDBGroupStore = defineStore("db-group", () => {
databaseGroupName: string;
expr: ConditionGroupExpr;
}) => {
+ if (!buildCELExpr(expr)) {
+ return {
+ matchedTableList: [],
+ unmatchedTableList: [],
+ };
+ }
const celStrings = await batchConvertParsedExprToCELString([
ParsedExpr.fromJSON({
expr: buildCELExpr(expr),
diff --git a/frontend/src/store/modules/router.ts b/frontend/src/store/modules/router.ts
index 00546190e8..c06059a42e 100644
--- a/frontend/src/store/modules/router.ts
+++ b/frontend/src/store/modules/router.ts
@@ -61,14 +61,15 @@ export const useRouterStore = defineStore("router", {
}
{
- // /project/:projectSlug
- // Total 2 elements, 2nd element is the project slug
+ // /project/:projectSlug/changelists/:changelistName
+ // 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_-]+)"
+ "/project/([0-9a-zA-Z_-]+)/changelists/([0-9a-zA-Z_-]+)"
) || ["/", undefined];
- if (projectComponents[1]) {
+ if (projectComponents.length === 3) {
return {
projectSlug: projectComponents[1],
+ changelistName: projectComponents[2],
};
}
}
@@ -208,20 +209,47 @@ export const useRouterStore = defineStore("router", {
}
{
- // /projects/proj-nt-iq3z/database-groups/test/table-groups/asd123
+ // /project/proj-nt-iq3z/database-groups/test/table-groups/asd123
const schemaGroupDetailComponents = currentRoute.path.match(
- "/projects/([0-9a-zA-Z_-]+)/database-groups/([0-9a-zA-Z_-]+)/table-groups/([0-9a-zA-Z_-]+)"
+ "/project/([0-9a-zA-Z_-]+)/database-groups/([0-9a-zA-Z_-]+)/table-groups/([0-9a-zA-Z_-]+)"
) || ["/", undefined];
if (schemaGroupDetailComponents.length === 4) {
return {
- projectName: schemaGroupDetailComponents[1],
+ projectSlug: schemaGroupDetailComponents[1],
databaseGroupName: schemaGroupDetailComponents[2],
schemaGroupName: schemaGroupDetailComponents[3],
};
}
}
+ {
+ // /project/proj-nt-iq3z/database-groups/test
+ const schemaGroupDetailComponents = currentRoute.path.match(
+ "/project/([0-9a-zA-Z_-]+)/database-groups/([0-9a-zA-Z_-]+)"
+ ) || ["/", undefined];
+
+ if (schemaGroupDetailComponents.length === 3) {
+ return {
+ projectSlug: schemaGroupDetailComponents[1],
+ databaseGroupName: schemaGroupDetailComponents[2],
+ };
+ }
+ }
+
+ {
+ // /project/:projectSlug
+ // Total 2 elements, 2nd element is the project slug
+ const projectComponents = currentRoute.path.match(
+ "/project/([0-9a-zA-Z_-]+)"
+ ) || ["/", undefined];
+ if (projectComponents[1]) {
+ return {
+ projectSlug: projectComponents[1],
+ };
+ }
+ }
+
return {};
},
},
diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.ts
index f3126d3510..dbd8b64cad 100644
--- a/frontend/src/types/common.ts
+++ b/frontend/src/types/common.ts
@@ -64,6 +64,7 @@ export type RouterSlug = {
projectName?: string;
databaseGroupName?: string;
schemaGroupName?: string;
+ changelistName?: string;
};
// Quick Action Type
diff --git a/frontend/src/views/DatabaseGroupDetail.vue b/frontend/src/views/DatabaseGroupDetail.vue
index de9c8047ab..9cebf17127 100644
--- a/frontend/src/views/DatabaseGroupDetail.vue
+++ b/frontend/src/views/DatabaseGroupDetail.vue
@@ -145,12 +145,10 @@ import {
useProjectV1Store,
useSubscriptionV1Store,
} from "@/store";
-import {
- databaseGroupNamePrefix,
- projectNamePrefix,
-} from "@/store/modules/v1/common";
+import { databaseGroupNamePrefix } from "@/store/modules/v1/common";
import { ComposedDatabase, ComposedDatabaseGroup } from "@/types";
import { DatabaseGroup, SchemaGroup } from "@/types/proto/v1/project_service";
+import { idFromSlug } from "@/utils";
interface LocalState {
isLoaded: boolean;
@@ -165,7 +163,7 @@ interface EditDatabaseGroupState {
}
const props = defineProps({
- projectName: {
+ projectSlug: {
required: true,
type: String,
},
@@ -191,8 +189,11 @@ const issueType = ref<
| "bb.issue.database.data.update"
| undefined
>();
+const project = computed(() => {
+ return projectStore.getProjectByUID(String(idFromSlug(props.projectSlug)));
+});
const databaseGroupResourceName = computed(() => {
- return `${projectNamePrefix}${props.projectName}/${databaseGroupNamePrefix}${props.databaseGroupName}`;
+ return `${project.value.name}/${databaseGroupNamePrefix}${props.databaseGroupName}`;
});
const databaseGroup = computed(() => {
return dbGroupStore.getDBGroupByName(
@@ -205,11 +206,6 @@ const schemaGroupList = computed(() => {
);
});
const environment = computed(() => databaseGroup.value?.environment);
-const project = computed(() => {
- return projectStore.getProjectByName(
- `${projectNamePrefix}${props.projectName}`
- );
-});
onMounted(async () => {
await dbGroupStore.getOrFetchDBGroupByName(databaseGroupResourceName.value);
diff --git a/frontend/src/views/SchemaGroupDetail.vue b/frontend/src/views/SchemaGroupDetail.vue
index 6d73a754d4..9fac4e0fac 100644
--- a/frontend/src/views/SchemaGroupDetail.vue
+++ b/frontend/src/views/SchemaGroupDetail.vue
@@ -114,10 +114,10 @@ import {
} from "@/store";
import {
databaseGroupNamePrefix,
- projectNamePrefix,
schemaGroupNamePrefix,
} from "@/store/modules/v1/common";
import { ComposedSchemaGroupTable } from "@/types";
+import { idFromSlug } from "@/utils";
import { convertCELStringToExpr } from "@/utils/databaseGroup/cel";
interface LocalState {
@@ -127,7 +127,7 @@ interface LocalState {
}
const props = defineProps({
- projectName: {
+ projectSlug: {
required: true,
type: String,
},
@@ -150,13 +150,11 @@ const state = reactive<LocalState>({
showConfigurePanel: false,
});
const project = computed(() => {
- return projectStore.getProjectByName(
- `${projectNamePrefix}${props.projectName}`
- );
+ return projectStore.getProjectByUID(String(idFromSlug(props.projectSlug)));
});
const schemaGroup = computed(() => {
return dbGroupStore.getSchemaGroupByName(
- `${projectNamePrefix}${props.projectName}/${databaseGroupNamePrefix}${props.databaseGroupName}/${schemaGroupNamePrefix}${props.schemaGroupName}`
+ `${project.value.name}/${databaseGroupNamePrefix}${props.databaseGroupName}/${schemaGroupNamePrefix}${props.schemaGroupName}`
);
});
@@ -164,7 +162,7 @@ watch(
() => [props, schemaGroup.value],
async () => {
const schemaGroup = await dbGroupStore.getOrFetchSchemaGroupByName(
- `${projectNamePrefix}${props.projectName}/${databaseGroupNamePrefix}${props.databaseGroupName}/${schemaGroupNamePrefix}${props.schemaGroupName}`
+ `${project.value.name}/${databaseGroupNamePrefix}${props.databaseGroupName}/${schemaGroupNamePrefix}${props.schemaGroupName}`
);
const expression = schemaGroup.tableExpr?.expression ?? "";