Skip to content

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

fix(frontend): fix webhook detail page broken by UUID resource_id migration (#19719)

Vincent Huangf69a9d6fbaf6
diff --git a/frontend/src/components/ProjectWebhookForm.vue b/frontend/src/components/ProjectWebhookForm.vue
index f64927ca69..6bf97114c6 100644
--- a/frontend/src/components/ProjectWebhookForm.vue
+++ b/frontend/src/components/ProjectWebhookForm.vue
@@ -283,7 +283,7 @@ import {
type Webhook,
} from "@/types/proto-es/v1/project_service_pb";
import { Setting_SettingName } from "@/types/proto-es/v1/setting_service_pb";
-import { projectWebhookV1Slug } from "../utils";
+import { extractProjectWebhookID } from "../utils";
import WebhookTypeIcon from "./Project/WebhookTypeIcon.vue";
interface LocalState {
@@ -484,7 +484,7 @@ const createWebhook = () => {
router.push({
name: PROJECT_V1_ROUTE_WEBHOOK_DETAIL,
params: {
- projectWebhookSlug: projectWebhookV1Slug(createdWebhook),
+ webhookResourceId: extractProjectWebhookID(createdWebhook.name),
},
});
}
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
index 993b0c6acc..85ef3fad18 100644
--- a/frontend/src/router/dashboard/projectV1.ts
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -326,7 +326,7 @@ const projectV1Routes: RouteRecordRaw[] = [
props: true,
},
{
- path: ":projectWebhookSlug",
+ path: ":webhookResourceId",
name: PROJECT_V1_ROUTE_WEBHOOK_DETAIL,
component: () => import("@/views/project/ProjectWebhookDetail.vue"),
props: true,
diff --git a/frontend/src/store/modules/v1/projectWebhook.ts b/frontend/src/store/modules/v1/projectWebhook.ts
index cb937ad7a7..137c23d2c9 100644
--- a/frontend/src/store/modules/v1/projectWebhook.ts
+++ b/frontend/src/store/modules/v1/projectWebhook.ts
@@ -1,7 +1,7 @@
import { create } from "@bufbuild/protobuf";
import { defineStore } from "pinia";
import { projectServiceClientConnect } from "@/connect";
-import type { IdType } from "@/types";
+
import {
AddWebhookRequestSchema,
type Project,
@@ -15,13 +15,10 @@ import { extractProjectWebhookID } from "@/utils";
export const useProjectWebhookV1Store = defineStore("projectWebhook_v1", () => {
const getProjectWebhookFromProjectById = (
project: Project,
- webhookId: IdType
+ webhookId: string
) => {
- if (typeof webhookId === "string") {
- webhookId = parseInt(webhookId, 10);
- }
return project.webhooks.find((webhook) => {
- return parseInt(extractProjectWebhookID(webhook.name), 10) === webhookId;
+ return extractProjectWebhookID(webhook.name) === webhookId;
});
};
const createProjectWebhook = async (project: string, webhook: Webhook) => {
diff --git a/frontend/src/utils/slug.ts b/frontend/src/utils/slug.ts
index cfbb796752..848da37313 100644
--- a/frontend/src/utils/slug.ts
+++ b/frontend/src/utils/slug.ts
@@ -4,11 +4,6 @@ import {
} from "@/store/modules/v1/common";
import type { SQLReviewPolicy } from "../types";
-export const idFromSlug = (slug: string): string => {
- const parts = slug.split("-");
- return parts[parts.length - 1];
-};
-
export function sqlReviewPolicySlug(reviewPolicy: SQLReviewPolicy): string {
return getReviewConfigId(reviewPolicy.id);
}
diff --git a/frontend/src/utils/v1/projectWebhook.ts b/frontend/src/utils/v1/projectWebhook.ts
index 99f48f3389..5ac7283db8 100644
--- a/frontend/src/utils/v1/projectWebhook.ts
+++ b/frontend/src/utils/v1/projectWebhook.ts
@@ -1,13 +1,5 @@
-import slug from "slug";
-import type { Webhook } from "@/types/proto-es/v1/project_service_pb";
-
export const extractProjectWebhookID = (name: string) => {
const pattern = /(?:^|\/)webhooks\/([^/]+)(?:$|\/)/;
const matches = name.match(pattern);
return matches?.[1] ?? "";
};
-
-export function projectWebhookV1Slug(webhook: Webhook): string {
- const id = extractProjectWebhookID(webhook.name);
- return [slug(webhook.title), id].join("-");
-}
diff --git a/frontend/src/views/project/ProjectWebhookDashboard.vue b/frontend/src/views/project/ProjectWebhookDashboard.vue
index 41d295ef53..8ecaf872ba 100644
--- a/frontend/src/views/project/ProjectWebhookDashboard.vue
+++ b/frontend/src/views/project/ProjectWebhookDashboard.vue
@@ -53,7 +53,7 @@ import { projectNamePrefix } from "@/store/modules/v1/common";
import { projectWebhookV1ActivityItemList } from "@/types";
import type { Webhook } from "@/types/proto-es/v1/project_service_pb";
import { Activity_Type } from "@/types/proto-es/v1/project_service_pb";
-import { projectWebhookV1Slug } from "@/utils";
+import { extractProjectWebhookID } from "@/utils";
const props = defineProps<{
projectId: string;
@@ -84,7 +84,7 @@ const rowProps = (webhook: Webhook) => {
router.push({
name: PROJECT_V1_ROUTE_WEBHOOK_DETAIL,
params: {
- projectWebhookSlug: projectWebhookV1Slug(webhook),
+ webhookResourceId: extractProjectWebhookID(webhook.name),
},
});
},
diff --git a/frontend/src/views/project/ProjectWebhookDetail.vue b/frontend/src/views/project/ProjectWebhookDetail.vue
index 44188d77a6..a3b8b3f033 100644
--- a/frontend/src/views/project/ProjectWebhookDetail.vue
+++ b/frontend/src/views/project/ProjectWebhookDetail.vue
@@ -14,11 +14,10 @@ import ProjectWebhookForm from "@/components/ProjectWebhookForm.vue";
import { useProjectByName, useProjectWebhookV1Store } from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
import { unknownProjectWebhook } from "@/types/v1/projectWebhook";
-import { idFromSlug } from "@/utils";
const props = defineProps<{
projectId: string;
- projectWebhookSlug: string;
+ webhookResourceId: string;
allowEdit: boolean;
}>();
@@ -28,10 +27,11 @@ const { project } = useProjectByName(
);
const projectWebhook = computed(() => {
- const id = idFromSlug(props.projectWebhookSlug);
return (
- projectWebhookV1Store.getProjectWebhookFromProjectById(project.value, id) ??
- unknownProjectWebhook()
+ projectWebhookV1Store.getProjectWebhookFromProjectById(
+ project.value,
+ props.webhookResourceId
+ ) ?? unknownProjectWebhook()
);
});
</script>