Skip to content

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

chore: add navigation from tasks to related spec changes (#17136)

boojackf174c8cb1fb1
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionGroup.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionGroup.vue
index 3af6b79ed9..8c39aa7b20 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionGroup.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionGroup.vue
@@ -20,9 +20,9 @@
@select="handleDropdownSelect"
>
<NButton
- :quaternary="true"
+ class="!px-1"
+ quaternary
size="medium"
- style="--n-padding: 0 4px"
:disabled="disabled"
:title="disabled ? disabledTooltip : undefined"
>
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskStatusActions.vue b/frontend/src/components/Plan/components/RolloutView/TaskStatusActions.vue
index e87f019c0d..396a011496 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskStatusActions.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskStatusActions.vue
@@ -4,12 +4,7 @@
v-if="!props.readonly && (primaryAction || dropdownOptions.length > 0)"
class="flex flex-row justify-end items-center gap-x-2"
>
- <NButton
- v-if="primaryAction"
- type="primary"
- size="small"
- @click="handlePrimaryAction"
- >
+ <NButton v-if="primaryAction" size="small" @click="handlePrimaryAction">
{{ actionDisplayTitle(primaryAction) }}
</NButton>
<NDropdown
@@ -18,7 +13,7 @@
:options="dropdownOptions"
@select="handleDropdownSelect"
>
- <NButton size="small">
+ <NButton size="small" class="!px-1" quaternary>
<template #icon>
<EllipsisVerticalIcon class="w-4 h-4" />
</template>
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskView.vue b/frontend/src/components/Plan/components/RolloutView/TaskView.vue
index 11e50bf01c..3d7d75a2ce 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskView.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskView.vue
@@ -9,13 +9,30 @@
<DatabaseDisplay :database="database.name" :size="'large'" />
</div>
<div class="flex flex-row gap-x-2">
- <NTag round>{{ semanticTaskType(task.type) }}</NTag>
<NTooltip v-if="schemaVersion">
<template #trigger>
<NTag round>{{ schemaVersion }}</NTag>
</template>
{{ $t("common.version") }}
</NTooltip>
+ <RouterLink
+ v-if="relatedSpec"
+ :to="{
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
+ params: {
+ projectId: extractProjectResourceName(plan.name),
+ planId: extractPlanUID(plan.name),
+ specId: relatedSpec.id,
+ },
+ }"
+ >
+ <NTag round class="cursor-pointer hover:opacity-80">
+ <span class="text-control-light"
+ >{{ $t("plan.spec.change") }}:</span
+ >
+ {{ getSpecTitle(relatedSpec) }}
+ </NTag>
+ </RouterLink>
<NTooltip v-if="task.runTime">
<template #trigger>
<NTag round>
@@ -108,11 +125,12 @@ import { last } from "lodash-es";
import { CalendarClockIcon } from "lucide-vue-next";
import { NTag, NTooltip } from "naive-ui";
import { computed, watchEffect } from "vue";
-import { semanticTaskType } from "@/components/IssueV1";
+import { RouterLink } from "vue-router";
import TaskRunDetail from "@/components/IssueV1/components/TaskRunSection/TaskRunDetail.vue";
import { MonacoEditor } from "@/components/MonacoEditor";
import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
import { CopyButton } from "@/components/v2";
+import { PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL } from "@/router/dashboard/projectV1";
import {
taskRunNamePrefix,
useCurrentProjectV1,
@@ -120,13 +138,14 @@ import {
} from "@/store";
import { getTimeForPbTimestampProtoEs, unknownTask } from "@/types";
import { TaskRun_Status } from "@/types/proto-es/v1/rollout_service_pb";
-import { databaseForTask } from "@/utils";
+import { databaseForTask, extractPlanUID } from "@/utils";
import {
extractSchemaVersionFromTask,
getSheetStatement,
sheetNameOfTaskV1,
+ extractProjectResourceName,
} from "@/utils";
-import { usePlanContextWithRollout } from "../../logic";
+import { usePlanContextWithRollout, getSpecTitle } from "../../logic";
import DatabaseDisplay from "../common/DatabaseDisplay.vue";
import TaskRollbackButton from "./TaskRollbackButton.vue";
import TaskRunTable from "./TaskRunTable.vue";
@@ -144,6 +163,7 @@ const {
taskRuns: allTaskRuns,
readonly,
events,
+ plan,
} = usePlanContextWithRollout();
const sheetStore = useSheetV1Store();
@@ -178,6 +198,12 @@ const rollbackableTaskRun = computed(() => {
const database = computed(() => databaseForTask(project.value, task.value));
const schemaVersion = computed(() => extractSchemaVersionFromTask(task.value));
+// Related spec
+const relatedSpec = computed(() => {
+ if (!plan.value || !task.value.specId) return undefined;
+ return plan.value.specs.find((spec) => spec.id === task.value.specId);
+});
+
const formatFullDateTime = (timestamp: any) => {
const timestampInMilliseconds = getTimeForPbTimestampProtoEs(timestamp, 0);
return dayjs(timestampInMilliseconds).local().format();
diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
index 01151f9042..ef96cd2c0d 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
@@ -16,7 +16,7 @@
<span
v-if="isSpecEmpty(spec)"
class="text-error ml-0.5"
- :title="t('plan.navigator.statement-empty')"
+ :title="$t('plan.navigator.statement-empty')"
>
*
</span>
@@ -50,17 +50,15 @@
import { PlusIcon } from "lucide-vue-next";
import { NTabs, NTab, NButton } from "naive-ui";
import { ref } from "vue";
-import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL } from "@/router/dashboard/projectV1";
import type { Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
-import { Plan_ChangeDatabaseConfig_Type } from "@/types/proto-es/v1/plan_service_pb";
import { usePlanContext } from "../../logic/context";
+import { getSpecTitle } from "../../logic/utils";
import AddSpecDrawer from "../AddSpecDrawer.vue";
import { useSpecsValidation } from "../common";
import { useSelectedSpec } from "./context";
-const { t } = useI18n();
const router = useRouter();
const { plan, isCreating } = usePlanContext();
const selectedSpec = useSelectedSpec();
@@ -68,33 +66,6 @@ const { isSpecEmpty } = useSpecsValidation(plan.value.specs);
const showAddSpecDrawer = ref(false);
-const getSpecTitle = (spec: Plan_Spec) => {
- let title = "";
- if (spec.config?.case === "createDatabaseConfig") {
- title = t("plan.spec.type.create-database");
- } else if (spec.config?.case === "changeDatabaseConfig") {
- const changeType = spec.config.value.type;
- switch (changeType) {
- case Plan_ChangeDatabaseConfig_Type.MIGRATE:
- title = t("plan.spec.type.schema-change");
- break;
- case Plan_ChangeDatabaseConfig_Type.DATA:
- title = t("plan.spec.type.data-change");
- break;
- case Plan_ChangeDatabaseConfig_Type.MIGRATE_GHOST:
- title = t("plan.spec.type.ghost-migration");
- break;
- default:
- title = t("plan.spec.type.database-change");
- }
- } else if (spec.config?.case === "exportDataConfig") {
- title = t("plan.spec.type.export-data");
- } else {
- title = t("plan.spec.type.unknown");
- }
- return title;
-};
-
const handleTabChange = (specId: string) => {
if (selectedSpec.value.id !== specId) {
gotoSpec(specId);
diff --git a/frontend/src/components/Plan/logic/utils.ts b/frontend/src/components/Plan/logic/utils.ts
index 0e149d0378..0ac407c778 100644
--- a/frontend/src/components/Plan/logic/utils.ts
+++ b/frontend/src/components/Plan/logic/utils.ts
@@ -1,9 +1,41 @@
+import { t } from "@/plugins/i18n";
import { useProjectV1Store } from "@/store";
import type { ComposedProject } from "@/types";
-import type { Plan } from "@/types/proto-es/v1/plan_service_pb";
+import type { Plan, Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
+import { Plan_ChangeDatabaseConfig_Type } from "@/types/proto-es/v1/plan_service_pb";
import { extractProjectResourceName } from "@/utils";
export const projectOfPlan = (plan: Plan): ComposedProject => {
const project = `projects/${extractProjectResourceName(plan.name)}`;
return useProjectV1Store().getProjectByName(project);
};
+
+export const getSpecTitle = (spec: Plan_Spec): string => {
+ let title = "";
+ if (spec.config?.case === "createDatabaseConfig") {
+ title = t("plan.spec.type.create-database");
+ } else if (spec.config?.case === "changeDatabaseConfig") {
+ const changeType = spec.config.value.type;
+ switch (changeType) {
+ case Plan_ChangeDatabaseConfig_Type.MIGRATE:
+ title = t("plan.spec.type.schema-change");
+ break;
+ case Plan_ChangeDatabaseConfig_Type.MIGRATE_SDL:
+ title = "SDL";
+ break;
+ case Plan_ChangeDatabaseConfig_Type.MIGRATE_GHOST:
+ title = t("plan.spec.type.ghost-migration");
+ break;
+ case Plan_ChangeDatabaseConfig_Type.DATA:
+ title = t("plan.spec.type.data-change");
+ break;
+ default:
+ title = t("plan.spec.type.database-change");
+ }
+ } else if (spec.config?.case === "exportDataConfig") {
+ title = t("plan.spec.type.export-data");
+ } else {
+ title = t("plan.spec.type.unknown");
+ }
+ return title;
+};
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 6613eaea9a..16c11e265b 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1102,6 +1102,7 @@
"statement-empty": "Statement is empty"
},
"spec": {
+ "change": "Change",
"type": {
"create-database": "Create Database",
"schema-change": "Schema Change",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index a3f49d4e04..e62a02f240 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1102,6 +1102,7 @@
"statement-empty": "La declaración está vacía"
},
"spec": {
+ "change": "Cambiar",
"type": {
"create-database": "Crear base de datos",
"schema-change": "Cambio de esquema",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 93cb3b6eff..4d1f0cc25a 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1102,6 +1102,7 @@
"statement-empty": "ステートメントが空です"
},
"spec": {
+ "change": "変化",
"type": {
"create-database": "データベースの作成",
"schema-change": "スキーマの変更",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 455b1d0f28..ca56d819a2 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1102,6 +1102,7 @@
"statement-empty": "Câu lệnh trống rỗng"
},
"spec": {
+ "change": "Thay đổi",
"type": {
"create-database": "Tạo cơ sở dữ liệu",
"schema-change": "Thay đổi sơ đồ",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 88cc3ffa73..7e6a7e379c 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1102,6 +1102,7 @@
"statement-empty": "变更语句为空"
},
"spec": {
+ "change": "变更项",
"type": {
"create-database": "创建数据库",
"schema-change": "Schema 变更",
diff --git a/frontend/src/utils/v1/issue/plan.ts b/frontend/src/utils/v1/issue/plan.ts
index cbea4b60ec..9cc464a74f 100644
--- a/frontend/src/utils/v1/issue/plan.ts
+++ b/frontend/src/utils/v1/issue/plan.ts
@@ -1,6 +1,5 @@
-import slug from "slug";
import { EMPTY_ID, UNKNOWN_ID } from "@/types";
-import type { Plan, Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
+import type { Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
export const sheetNameOfSpec = (spec: Plan_Spec): string => {
if (spec.config?.case === "changeDatabaseConfig") {
@@ -12,10 +11,6 @@ export const sheetNameOfSpec = (spec: Plan_Spec): string => {
return "";
};
-export function planV1Slug(plan: Plan): string {
- return [slug(plan.title), extractPlanUID(plan.name)].join("-");
-}
-
export const extractPlanUID = (name: string) => {
const pattern = /(?:^|\/)plans\/(\d+)(?:$|\/)/;
const matches = name.match(pattern);