Skip to content

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

refactor: centralize issue routing logic for CICD layout (#17843)

boojack03be06ad75e9
diff --git a/frontend/src/components/IssueV1/components/IssueTableV1.vue b/frontend/src/components/IssueV1/components/IssueTableV1.vue
index 14e97bf4b1..6861c212fd 100644
--- a/frontend/src/components/IssueV1/components/IssueTableV1.vue
+++ b/frontend/src/components/IssueV1/components/IssueTableV1.vue
@@ -49,7 +49,7 @@ import { BBAvatar } from "@/bbkit";
import BatchIssueActionsV1 from "@/components/IssueV1/components/BatchIssueActionsV1.vue";
import CurrentApproverV1 from "@/components/IssueV1/components/CurrentApproverV1.vue";
import { useElementVisibilityInScrollParent } from "@/composables/useElementVisibilityInScrollParent";
-import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
+import { useIssueLayoutVersion } from "@/composables/useIssueLayoutVersion";
import { useUserStore } from "@/store";
import {
getTimeForPbTimestampProtoEs,
@@ -58,10 +58,9 @@ import {
} from "@/types";
import {
getHighlightHTMLByRegExp,
- extractProjectResourceName,
humanizeTs,
- issueV1Slug,
extractIssueUID,
+ getIssueRoute,
} from "@/utils";
import { projectOfIssue } from "../logic";
import IssueLabelSelector, {
@@ -95,6 +94,7 @@ const props = withDefaults(
const { t } = useI18n();
const router = useRouter();
const userStore = useUserStore();
+const { enabledNewLayout } = useIssueLayoutVersion();
const state = reactive<LocalState>({
selectedIssueNameList: new Set(),
});
@@ -248,12 +248,10 @@ const columnList = computed((): DataTableColumn<ComposedIssue>[] => {
});
const issueUrl = (issue: ComposedIssue) => {
+ const issueRoute = getIssueRoute(issue, undefined, enabledNewLayout.value);
const route = router.resolve({
- name: PROJECT_V1_ROUTE_ISSUE_DETAIL,
- params: {
- projectId: extractProjectResourceName(issue.name),
- issueSlug: issueV1Slug(issue.name, issue.title),
- },
+ name: issueRoute.name,
+ params: issueRoute.params,
});
return route.fullPath;
};
diff --git a/frontend/src/utils/v1/issue/issue.ts b/frontend/src/utils/v1/issue/issue.ts
index 5a9a51afe2..4e02d39ad6 100644
--- a/frontend/src/utils/v1/issue/issue.ts
+++ b/frontend/src/utils/v1/issue/issue.ts
@@ -1,10 +1,16 @@
import dayjs from "dayjs";
import slug from "slug";
import { t } from "@/plugins/i18n";
+import {
+ PROJECT_V1_ROUTE_ISSUE_DETAIL,
+ PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,
+} from "@/router/dashboard/projectV1";
import { EMPTY_ID, UNKNOWN_ID, type ComposedIssue } from "@/types";
import { Issue_Type } from "@/types/proto-es/v1/issue_service_pb";
+import type { Plan } from "@/types/proto-es/v1/plan_service_pb";
import type { Rollout } from "@/types/proto-es/v1/rollout_service_pb";
import { Task_Type } from "@/types/proto-es/v1/rollout_service_pb";
+import { extractProjectResourceName } from "../project";
export const issueV1Slug = (name: string, title: string = "issue") => {
return [slug(title), extractIssueUID(name)].join("-");
@@ -95,3 +101,85 @@ export const generateIssueTitle = (
return parts.join(" ");
};
+
+/**
+ * Determines whether an issue should use the new CICD layout route.
+ *
+ * Rules:
+ * - Grant request issues: ALWAYS use new layout
+ * - Create database issues: ALWAYS use new layout
+ * - Data export issues: ALWAYS use new layout
+ * - Database changing issues: Use new layout ONLY when enabledNewLayout is true
+ */
+export const shouldUseNewIssueLayout = (
+ issue: { type?: Issue_Type; name?: string },
+ plan?: Plan | { specs?: Array<{ config?: { case?: string } }> },
+ enabledNewLayout = true
+): boolean => {
+ // Grant request issues always use new layout
+ if (issue.type === Issue_Type.GRANT_REQUEST) {
+ return true;
+ }
+
+ // Check if it's a create database or export data plan
+ if (plan?.specs) {
+ const isCreatingDatabasePlan = plan.specs.every(
+ (spec) => spec.config?.case === "createDatabaseConfig"
+ );
+ const isExportDataPlan = plan.specs.every(
+ (spec) => spec.config?.case === "exportDataConfig"
+ );
+
+ if (isCreatingDatabasePlan || isExportDataPlan) {
+ return true;
+ }
+ }
+
+ // Database export issue type always uses new layout
+ if (issue.type === Issue_Type.DATABASE_EXPORT) {
+ return true;
+ }
+
+ // For database changing issues, respect the layout preference
+ return enabledNewLayout;
+};
+
+/**
+ * Gets the appropriate route name and params for an issue based on its type and layout settings.
+ *
+ * @param issue - The issue object (must have name, and optionally type)
+ * @param plan - Optional plan object to check for create database or export data specs
+ * @param enabledNewLayout - Whether the new layout is enabled (default: true)
+ * @returns Route configuration with name and params
+ */
+export const getIssueRoute = (
+ issue: { type?: Issue_Type; name: string; title?: string },
+ plan?: Plan | { specs?: Array<{ config?: { case?: string } }> },
+ enabledNewLayout = true
+): {
+ name: string;
+ params: { projectId: string; issueSlug?: string; issueId?: string };
+} => {
+ const projectId = extractProjectResourceName(issue.name);
+ const useNewLayout = shouldUseNewIssueLayout(issue, plan, enabledNewLayout);
+
+ if (useNewLayout) {
+ // Use new CICD layout route with numeric issueId
+ return {
+ name: PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,
+ params: {
+ projectId,
+ issueId: extractIssueUID(issue.name),
+ },
+ };
+ } else {
+ // Use legacy route with issueSlug
+ return {
+ name: PROJECT_V1_ROUTE_ISSUE_DETAIL,
+ params: {
+ projectId,
+ issueSlug: issueV1Slug(issue.name, issue.title || "issue"),
+ },
+ };
+ }
+};
diff --git a/frontend/src/utils/v1/issue/rollout.ts b/frontend/src/utils/v1/issue/rollout.ts
index e978b84f50..9dd9078eb5 100644
--- a/frontend/src/utils/v1/issue/rollout.ts
+++ b/frontend/src/utils/v1/issue/rollout.ts
@@ -1,10 +1,8 @@
import { last } from "lodash-es";
-import { stringify } from "qs";
import { useI18n } from "vue-i18n";
import { extractCoreDatabaseInfoFromDatabaseCreateTask } from "@/components/IssueV1";
import { mockDatabase } from "@/components/IssueV1/logic/utils";
import { useDatabaseV1Store } from "@/store";
-import type { ComposedIssue } from "@/types";
import {
EMPTY_TASK_NAME,
emptyStage,
@@ -25,8 +23,7 @@ import {
type Task,
} from "@/types/proto-es/v1/rollout_service_pb";
import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
-import { extractProjectResourceName } from "../project";
-import { extractIssueUID, flattenTaskV1List, issueV1Slug } from "./issue";
+import { flattenTaskV1List } from "./issue";
export const extractRolloutUID = (name: string) => {
const pattern = /(?:^|\/)rollouts\/([^/]+)(?:$|\/)/;
@@ -186,32 +183,6 @@ export const setSheetNameForTask = (task: Task, sheetName: string) => {
}
};
-export const buildIssueV1LinkWithTask = (
- issue: ComposedIssue,
- task: Task,
- simple = false
-) => {
- const stage = issue.rolloutEntity?.stages.find(
- (s) => s.tasks.findIndex((t) => t.name === task.name) >= 0
- );
-
- const projectId = extractProjectResourceName(issue.name);
- const issueSlug = simple
- ? extractIssueUID(issue.name)
- : issueV1Slug(issue.name, issue.title);
- const query: Record<string, string> = {};
- if (stage) {
- // Stage UID is now always the environment ID
- query.stage = extractStageUID(stage.name);
- }
- query.task = simple ? extractTaskUID(task.name) : taskV1Slug(task);
-
- const querystring = stringify(query);
- const url = `/projects/${projectId}/issues/${issueSlug}?${querystring}`;
-
- return url;
-};
-
export const stringifyTaskStatus = (
status: Task_Status | TaskRun_Status
): string => {
diff --git a/frontend/src/views/project/ProjectIssueDetail.vue b/frontend/src/views/project/ProjectIssueDetail.vue
index cfc04313f1..1b4fb70943 100644
--- a/frontend/src/views/project/ProjectIssueDetail.vue
+++ b/frontend/src/views/project/ProjectIssueDetail.vue
@@ -28,19 +28,19 @@ import {
providePlanCheckRunContext,
type PlanCheckRunEvents,
} from "@/components/PlanCheckRun/context";
+import { useIssueLayoutVersion } from "@/composables/useIssueLayoutVersion";
import { useBodyLayoutContext } from "@/layouts/common";
import {
PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,
PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
} from "@/router/dashboard/projectV1";
import { projectNamePrefix, useProjectByName, useUIStateStore } from "@/store";
-import { Issue_Type } from "@/types/proto-es/v1/issue_service_pb";
import {
extractIssueUID,
extractProjectResourceName,
- isDatabaseDataExportIssue,
isGrantRequestIssue,
isValidIssueName,
+ shouldUseNewIssueLayout,
} from "@/utils";
defineOptions({
@@ -55,6 +55,7 @@ const props = defineProps<{
const { t } = useI18n();
const router = useRouter();
const route = useRoute();
+const { enabledNewLayout } = useIssueLayoutVersion();
const { project, ready: projectReady } = useProjectByName(
computed(() => `${projectNamePrefix}${props.projectId}`)
@@ -115,19 +116,14 @@ watch(
(isReady) => {
if (!isReady) return;
- // Determine if this issue should use the new layout
- const shouldUseNewLayout =
- // Data export issues always use new layout
- isDatabaseDataExportIssue(issue.value) ||
- // Grant request issues always use new layout
- isGrantRequestIssue(issue.value) ||
- // Database creation issues always use new layout
- (issue.value.type === Issue_Type.DATABASE_CHANGE &&
- issue.value.planEntity?.specs.every(
- (spec) => spec.config.case === "createDatabaseConfig"
- ));
-
- if (shouldUseNewLayout) {
+ // Determine if this issue should use the new layout based on issue type and user preference
+ const shouldRedirect = shouldUseNewIssueLayout(
+ issue.value,
+ issue.value.planEntity,
+ enabledNewLayout.value
+ );
+
+ if (shouldRedirect) {
if (isCreating.value) {
// Redirect creation to plan creation page
router.replace({