Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: remove `ComposedPlan` type (#16452)
boojack013f14b5b120
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vueindex d91fe7c304..2dfe404ff1 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue@@ -47,7 +47,6 @@ import { PROJECT_V1_ROUTE_REVIEW_CENTER_DETAIL } from "@/router/dashboard/projecimport { useCurrentProjectV1, useSheetV1Store } from "@/store";import { type Plan_ChangeDatabaseConfig } from "@/types/proto/v1/plan_service";import type { Sheet } from "@/types/proto/v1/sheet_service";-import type { ComposedPlan } from "@/types/v1/issue/plan";import {extractProjectResourceName,extractSheetUID,@@ -85,27 +84,22 @@ const doCreatePlan = async () => {try {await createSheets();const createdPlan = await planServiceClient.createPlan({- parent: plan.value.project,+ parent: project.value.name,plan: plan.value,});if (!createdPlan) return;- const composedPlan: ComposedPlan = {- ...plan.value,- ...createdPlan,- };-nextTick(() => {router.push({name: PROJECT_V1_ROUTE_REVIEW_CENTER_DETAIL,params: {- projectId: extractProjectResourceName(composedPlan.project),- planSlug: planV1Slug(composedPlan),+ projectId: extractProjectResourceName(createdPlan.name),+ planSlug: planV1Slug(createdPlan),},});});- return composedPlan;+ return createdPlan;} catch {loading.value = false;}@@ -138,7 +132,7 @@ const createSheets = async () => {const sheet = pendingCreateSheetList[i];sheet.title = plan.value.title;const createdSheet = await sheetStore.createSheet(- plan.value.project,+ project.value.name,sheet);sheetNameMap.set(sheet.name, createdSheet.name);diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vueindex 1a04669dfa..c1b51ac4d1 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vue@@ -62,14 +62,14 @@ const router = useRouter();const dialog = useDialog();const { project } = useCurrentProjectV1();const policyV1Store = usePolicyV1Store();-const { plan } = usePlanContext();+const { plan, planCheckRunList } = usePlanContext();const loading = ref(false);const restrictIssueCreationForSqlReviewPolicy = ref(false);const planCheckStatus = computed((): PlanCheckRun_Result_Status => {const planCheckList = uniqBy(plan.value.specs.flatMap((spec) =>- planCheckRunListForSpec(plan.value, spec)+ planCheckRunListForSpec(planCheckRunList.value, spec)),(checkRun) => checkRun.name);@@ -117,7 +117,7 @@ watchEffect(async () => {const projectLevelPolicy =await policyV1Store.getOrFetchPolicyByParentAndType({- parentPath: plan.value.project,+ parentPath: project.value.name,policyType: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,});if (projectLevelPolicy?.restrictIssueCreationForSqlReviewPolicy?.disallow) {@@ -147,7 +147,7 @@ const doCreateIssue = async () => {try {const createdIssue = await issueServiceClient.createIssue({- parent: plan.value.project,+ parent: project.value.name,issue: {...Issue.fromPartial(buildIssue()),rollout: "",@@ -160,7 +160,7 @@ const doCreateIssue = async () => {planEntity: plan.value,};const createdRollout = await rolloutServiceClient.createRollout({- parent: plan.value.project,+ parent: project.value.name,rollout: {plan: plan.value.name,},@@ -173,7 +173,7 @@ const doCreateIssue = async () => {router.push({name: PROJECT_V1_ROUTE_ISSUE_DETAIL,params: {- projectId: extractProjectResourceName(plan.value.project),+ projectId: extractProjectResourceName(plan.value.name),issueSlug: issueV1Slug(composedIssue),},});diff --git a/frontend/src/components/Plan/components/Navigator.vue b/frontend/src/components/Plan/components/Navigator.vueindex 2eb95f4dfd..95cbcb0e4d 100644--- a/frontend/src/components/Plan/components/Navigator.vue+++ b/frontend/src/components/Plan/components/Navigator.vue@@ -156,6 +156,7 @@ import { useRouter, useRoute } from "vue-router";import {Plan_ChangeDatabaseConfig_Type,type Plan_Spec,+ type PlanCheckRun,} from "@/types/proto/v1/plan_service";import { usePlanContext } from "../logic/context";import { targetsForSpec } from "../logic/plan";@@ -166,7 +167,8 @@ import { useSpecsValidation } from "./common/validateSpec";const router = useRouter();const route = useRoute();const { t } = useI18n();-const { plan, selectedSpec, isCreating, events } = usePlanContext();+const { plan, selectedSpec, isCreating, events, planCheckRunList } =+ usePlanContext();const specs = computed(() => plan.value.specs);const showAddSpecDrawer = ref(false);@@ -207,7 +209,7 @@ const handleSpecCreated = (spec: Plan_Spec) => {const getSpecCheckStatus = (spec: Plan_Spec) => {// Get aggregated check status for the spec- const checkRuns = plan.value?.planCheckRunList || [];+ const checkRuns = planCheckRunList.value || [];const targets = targetsForSpec(spec);const sheet = getSheetFromSpec(spec);@@ -215,7 +217,7 @@ const getSpecCheckStatus = (spec: Plan_Spec) => {return "STATUS_UNSPECIFIED";}- const relevantCheckRuns = checkRuns.filter((check) => {+ const relevantCheckRuns = checkRuns.filter((check: PlanCheckRun) => {return targets.includes(check.target) && check.sheet === sheet;});diff --git a/frontend/src/components/Plan/components/Overview.vue b/frontend/src/components/Plan/components/Overview.vueindex 5f08ab9392..a2038de327 100644--- a/frontend/src/components/Plan/components/Overview.vue+++ b/frontend/src/components/Plan/components/Overview.vue@@ -4,7 +4,7 @@<!-- Plan Header --><div><h1 class="text-2xl font-semibold mb-2">- {{ $t("plan.overview.title") }}+ {{ $t("plan.navigator.overview") }}</h1><p class="text-control-light">{{ $t("plan.overview.description") }}diff --git a/frontend/src/components/Plan/components/PlanCheckRunStatusIcon.vue b/frontend/src/components/Plan/components/PlanCheckRunStatusIcon.vueindex 959b512909..411d68020a 100644--- a/frontend/src/components/Plan/components/PlanCheckRunStatusIcon.vue+++ b/frontend/src/components/Plan/components/PlanCheckRunStatusIcon.vue@@ -29,15 +29,17 @@<script lang="ts" setup>import type { PropType } from "vue";import { computed } from "vue";-import { PlanCheckRun_Result_Status } from "@/types/proto/v1/plan_service";-import type { ComposedPlan } from "@/types/v1/issue/plan";+import {+ PlanCheckRun_Result_Status,+ type Plan,+} from "@/types/proto/v1/plan_service";export type SizeType = "small" | "normal";const props = defineProps({plan: {required: true,- type: Object as PropType<ComposedPlan>,+ type: Object as PropType<Plan>,},size: {type: String as PropType<SizeType>,diff --git a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vueindex de2b00f38a..a9c957840c 100644--- a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue+++ b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue@@ -24,7 +24,11 @@ import { hasProjectPermissionV2 } from "@/utils";const currentUser = useCurrentUserV1();const { project } = useCurrentProjectV1();-const { plan, selectedSpec } = usePlanContext();+const {+ plan,+ selectedSpec,+ planCheckRunList: contextPlanCheckRunList,+} = usePlanContext();const show = computed(() => {if (!selectedSpec.value) {@@ -52,9 +56,12 @@ const allowRunChecks = computed(() => {const planCheckRunList = computed(() => {// If a spec is database change spec, show plan checks for the spec.if (selectedSpec.value && isDatabaseChangeSpec(selectedSpec.value)) {- return planCheckRunListForSpec(plan.value, selectedSpec.value);+ return planCheckRunListForSpec(+ contextPlanCheckRunList.value,+ selectedSpec.value+ );}// Otherwise, show all plan checks in the plan.- return plan.value.planCheckRunList;+ return contextPlanCheckRunList.value;});</script>diff --git a/frontend/src/components/Plan/components/PlanCheckSection/SpecBasedPlanCheckSection.vue b/frontend/src/components/Plan/components/PlanCheckSection/SpecBasedPlanCheckSection.vueindex 381d98d837..22bfc1091b 100644--- a/frontend/src/components/Plan/components/PlanCheckSection/SpecBasedPlanCheckSection.vue+++ b/frontend/src/components/Plan/components/PlanCheckSection/SpecBasedPlanCheckSection.vue@@ -246,7 +246,7 @@ import { usePlanContext } from "../../logic/context";const currentUser = useCurrentUserV1();const { project } = useCurrentProjectV1();-const { plan, selectedSpec } = usePlanContext();+const { plan, selectedSpec, planCheckRunList } = usePlanContext();const isLoading = ref(false);const isRunningChecks = ref(false);@@ -263,7 +263,7 @@ const show = computed(() => {const checkRunsForSpec = computed(() => {if (!selectedSpec.value) return [];- return planCheckRunListForSpec(plan.value, selectedSpec.value);+ return planCheckRunListForSpec(planCheckRunList.value, selectedSpec.value);});const totalCheckRuns = computed(() => checkRunsForSpec.value.length);diff --git a/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue b/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vueindex 7986157c33..00c9e9d123 100644--- a/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue+++ b/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue@@ -5,7 +5,7 @@:striped="true":bordered="true":loading="loading"- :row-key="(plan: ComposedPlan) => plan.name"+ :row-key="(plan: Plan) => plan.name":row-props="rowProps"/></template>@@ -22,7 +22,7 @@ import { ProjectNameCell } from "@/components/v2/Model/DatabaseV1Table/cells";import { PROJECT_V1_ROUTE_REVIEW_CENTER_DETAIL } from "@/router/dashboard/projectV1";import { useUserStore } from "@/store";import { getTimeForPbTimestamp, unknownUser } from "@/types";-import type { ComposedPlan } from "@/types/v1/issue/plan";+import type { Plan } from "@/types/proto/v1/plan_service";import {extractPlanUID,extractProjectResourceName,@@ -33,7 +33,7 @@ import PlanCheckRunStatusIcon from "../PlanCheckRunStatusIcon.vue";const props = withDefaults(defineProps<{- planList: ComposedPlan[];+ planList: Plan[];loading?: boolean;showProject: boolean;}>(),@@ -47,15 +47,13 @@ const { t } = useI18n();const router = useRouter();const userStore = useUserStore();-const columnList = computed((): DataTableColumn<ComposedPlan>[] => {- const columns: (DataTableColumn<ComposedPlan> & { hide?: boolean })[] = [+const columnList = computed((): DataTableColumn<Plan>[] => {+ const columns: (DataTableColumn<Plan> & { hide?: boolean })[] = [{key: "status",title: "",width: "36px",- render: (plan) => {- return <PlanCheckRunStatusIcon plan={plan} />;- },+ render: (plan) => <PlanCheckRunStatusIcon plan={plan} />,},{key: "title",@@ -117,14 +115,14 @@ const columnList = computed((): DataTableColumn<ComposedPlan>[] => {return columns.filter((column) => !column.hide);});-const rowProps = (plan: ComposedPlan) => {+const rowProps = (plan: Plan) => {return {style: "cursor: pointer;",onClick: (e: MouseEvent) => {const route = router.resolve({name: PROJECT_V1_ROUTE_REVIEW_CENTER_DETAIL,params: {- projectId: extractProjectResourceName(plan.project),+ projectId: extractProjectResourceName(plan.name),planSlug: planV1Slug(plan),},});diff --git a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vueindex 7fb0e0bae2..9d8f407413 100644--- a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue@@ -116,6 +116,7 @@ import {instanceV1Name,extractDatabaseResourceName,extractDatabaseGroupName,+ extractProjectResourceName,} from "@/utils";import { usePlanContext } from "../../logic/context";import { targetsForSpec } from "../../logic/plan";@@ -151,8 +152,9 @@ const isCreateDatabaseSpec = computed(() => {});const project = computed(() => {- if (!plan.value?.project) return undefined;- return projectStore.getProjectByName(plan.value.project);+ if (!plan.value?.name) return undefined;+ const projectName = `projects/${extractProjectResourceName(plan.value.name)}`;+ return projectStore.getProjectByName(projectName);});// Only allow editing in creation mode or if the plan is editablediff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vueindex 55c2833124..a928308c91 100644--- a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue+++ b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue@@ -425,7 +425,7 @@ const updateStatement = async (statement: string) => {});setSheetStatement(sheet, statement);const createdSheet = await useSheetV1Store().createSheet(- plan.value.project,+ project.value.name,sheet);diff --git a/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts b/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.tsindex 04fca6980b..ca49988c80 100644--- a/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts+++ b/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts@@ -35,9 +35,9 @@ export const useSQLAdviceMarkers = (};});} else {- const { plan, selectedSpec } = context;+ const { selectedSpec, planCheckRunList: contextPlanCheckRunList } = context;const planCheckRunList = planCheckRunListForSpec(- plan.value,+ contextPlanCheckRunList.value,selectedSpec.value as Plan_Spec);const types: PlanCheckRun_Type[] = [diff --git a/frontend/src/components/Plan/logic/context.ts b/frontend/src/components/Plan/logic/context.tsindex 517063e608..7148cbc12a 100644--- a/frontend/src/components/Plan/logic/context.ts+++ b/frontend/src/components/Plan/logic/context.ts@@ -2,8 +2,11 @@ import type Emittery from "emittery";import { v4 as uuidv4 } from "uuid";import type { InjectionKey, Ref } from "vue";import { inject, provide } from "vue";-import type { Plan_Spec } from "@/types/proto/v1/plan_service";-import type { ComposedPlan } from "@/types/v1/issue/plan";+import type {+ Plan,+ Plan_Spec,+ PlanCheckRun,+} from "@/types/proto/v1/plan_service";export type PlanEvents = Emittery<{"status-changed": { eager: boolean };@@ -15,7 +18,8 @@ export type PlanContext = {// Basic fieldsisCreating: Ref<boolean>;ready: Ref<boolean>;- plan: Ref<ComposedPlan>;+ plan: Ref<Plan>;+ planCheckRunList: Ref<PlanCheckRun[]>;// TODO(steven): save related issue/rollout for checking if the plan is changable.selectedSpec: Ref<Plan_Spec | undefined>;diff --git a/frontend/src/components/Plan/logic/initialize/create.ts b/frontend/src/components/Plan/logic/initialize/create.tsindex 8b15a84a25..a325bde6fa 100644--- a/frontend/src/components/Plan/logic/initialize/create.ts+++ b/frontend/src/components/Plan/logic/initialize/create.ts@@ -7,7 +7,6 @@ import {useSheetV1Store,} from "@/store";import { projectNamePrefix } from "@/store/modules/v1/common";-import { composePlan } from "@/store/modules/v1/plan";import type { ComposedProject, IssueType } from "@/types";import {Plan,@@ -119,7 +118,7 @@ export const buildPlan = async (params: CreatePlanParams) => {plan.specs = [spec];}}- return await composePlan(plan);+ return plan;};const buildSpecForTargetsV1 = async (diff --git a/frontend/src/components/Plan/logic/initialize/index.ts b/frontend/src/components/Plan/logic/initialize/index.tsindex 5be7a7b566..a0f6e39815 100644--- a/frontend/src/components/Plan/logic/initialize/index.ts+++ b/frontend/src/components/Plan/logic/initialize/index.ts@@ -4,7 +4,8 @@ import type { LocationQuery } from "vue-router";import { useRoute, useRouter } from "vue-router";import { usePlanStore } from "@/store/modules/v1/plan";import { EMPTY_ID, UNKNOWN_ID } from "@/types";-import { emptyPlan, type ComposedPlan } from "@/types/v1/issue/plan";+import type { Plan, PlanCheckRun } from "@/types/proto/v1/plan_service";+import { emptyPlan } from "@/types/v1/issue/plan";import { uidFromSlug } from "@/utils";import { createPlanSkeleton } from "./create";@@ -32,7 +33,8 @@ export function useInitializePlan(const planStore = usePlanStore();const isInitializing = ref(false);- const plan = ref<ComposedPlan>(emptyPlan());+ const plan = ref<Plan>(emptyPlan());+ const planCheckRunList = ref<PlanCheckRun[]>([]);const runner = async (uid: string, project: string, url: string) => {const plan =@@ -57,19 +59,24 @@ export function useInitializePlan(}const url = route.fullPath;isInitializing.value = true;- runner(uid, project, url).then((result) => {+ runner(uid, project, url).then(async (result) => {if (result.url !== route.fullPath) {// the url changed, drop the outdated resultreturn;}plan.value = result.plan;+ // Fetch plan check runs if not creating+ if (uid !== String(EMPTY_ID)) {+ const { fetchPlanCheckRuns } = usePlanStore();+ planCheckRunList.value = await fetchPlanCheckRuns(result.plan);+ }isInitializing.value = false;});},{ immediate: true });- return { isCreating, plan, isInitializing };+ return { isCreating, plan, planCheckRunList, isInitializing };}export const convertRouterQuery = (query: LocationQuery) => {diff --git a/frontend/src/components/Plan/logic/plan-check.ts b/frontend/src/components/Plan/logic/plan-check.tsindex 4fe475c28f..06b583da42 100644--- a/frontend/src/components/Plan/logic/plan-check.ts+++ b/frontend/src/components/Plan/logic/plan-check.ts@@ -1,5 +1,4 @@-import type { Plan_Spec } from "@/types/proto/v1/plan_service";-import type { ComposedPlan } from "@/types/v1/issue/plan";+import type { Plan_Spec, PlanCheckRun } from "@/types/proto/v1/plan_service";import { sheetNameForSpec, targetsForSpec } from "./plan";export const planSpecHasPlanChecks = (spec: Plan_Spec) => {@@ -10,12 +9,12 @@ export const planSpecHasPlanChecks = (spec: Plan_Spec) => {};export const planCheckRunListForSpec = (- plan: ComposedPlan,+ planCheckRunList: PlanCheckRun[],spec: Plan_Spec) => {const targets = targetsForSpec(spec);const sheet = spec ? sheetNameForSpec(spec) : "";- return plan.planCheckRunList.filter((check) => {+ return planCheckRunList.filter((check) => {if (!targets.includes(check.target)) {return false;}diff --git a/frontend/src/components/Plan/logic/utils.ts b/frontend/src/components/Plan/logic/utils.tsindex 4e2df0bf8c..26a223690c 100644--- a/frontend/src/components/Plan/logic/utils.ts+++ b/frontend/src/components/Plan/logic/utils.ts@@ -1,6 +1,9 @@import { useProjectV1Store } from "@/store";import type { ComposedProject } from "@/types";-import type { ComposedPlan } from "@/types/v1/issue/plan";+import type { Plan } from "@/types/proto/v1/plan_service";+import { extractProjectResourceName } from "@/utils";-export const projectOfPlan = (plan: ComposedPlan): ComposedProject =>- useProjectV1Store().getProjectByName(plan.project);+export const projectOfPlan = (plan: Plan): ComposedProject => {+ const project = `projects/${extractProjectResourceName(plan.name)}`;+ return useProjectV1Store().getProjectByName(project);+};diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 244605f540..c6b95b2470 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1003,7 +1003,6 @@"data-change-description": "Modify data (DML)","select-targets": "Select Targets","overview": {- "title": "Plan Overview","description": "View and manage all specifications in this plan","total-specs": "Total Specs","total-targets": "Total Targets",@@ -2641,7 +2640,7 @@"unspecified": "Unspecified"},"file-type": {- "versioned": "Version",+ "versioned": "Versioned","unspecified": "Unspecified"},"vcs-type": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 4d8b6de2cc..b5ca59d7a7 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1003,7 +1003,6 @@"data-change-description": "Modificar datos (DML)","select-targets": "Seleccionar objetivos","overview": {- "title": "Descripción general del plan","description": "Ver y administrar todas las especificaciones de este plan","total-specs": "Especificaciones totales","total-targets": "Objetivos totales",diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 70e408ee86..0a5f9831a5 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1003,7 +1003,6 @@"data-change-description": "データの変更 (DML)","select-targets": "ターゲットを選択","overview": {- "title": "プランの概要","description": "このプランのすべての仕様を表示および管理します","total-specs": "合計スペック","total-targets": "合計ターゲット",diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 9eb05c2134..a93bd25820 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -1003,7 +1003,6 @@"data-change-description": "Sửa đổi dữ liệu (DML)","select-targets": "Chọn mục tiêu","overview": {- "title": "Tổng quan về kế hoạch","description": "Xem và quản lý tất cả các thông số kỹ thuật trong kế hoạch này","total-specs": "Tổng số thông số kỹ thuật","total-targets": "Tổng số mục tiêu",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 333d853a75..f156e6a39b 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1003,7 +1003,6 @@"data-change-description": "修改数据(DML)","select-targets": "选择变更对象","overview": {- "title": "变更计划概述","description": "查看和管理此变更计划中的所有变更项","total-specs": "变更项","total-targets": "变更对象",diff --git a/frontend/src/store/modules/v1/plan.ts b/frontend/src/store/modules/v1/plan.tsindex 841277afdd..aaadeaa609 100644--- a/frontend/src/store/modules/v1/plan.ts+++ b/frontend/src/store/modules/v1/plan.ts@@ -3,11 +3,10 @@ import { orderBy, uniq } from "lodash-es";import { defineStore } from "pinia";import { planServiceClient } from "@/grpcweb";import { EMPTY_ID, UNKNOWN_ID } from "@/types";-import type { Plan } from "@/types/proto/v1/plan_service";+import type { Plan, PlanCheckRun } from "@/types/proto/v1/plan_service";import {emptyPlan,unknownPlan,- type ComposedPlan,} from "@/types/v1/issue/plan";import {extractProjectResourceName,@@ -71,24 +70,19 @@ export const buildPlanFindBySearchParams = (return filter;};-export const composePlan = async (rawPlan: Plan): Promise<ComposedPlan> => {- const project = `projects/${extractProjectResourceName(rawPlan.name)}`;+export const fetchPlanCheckRuns = async (plan: Plan): Promise<PlanCheckRun[]> => {+ const project = `projects/${extractProjectResourceName(plan.name)}`;const projectEntity =await useProjectV1Store().getOrFetchProjectByName(project);- const plan: ComposedPlan = {- ...rawPlan,- planCheckRunList: [],- project,- };if (hasProjectPermissionV2(projectEntity, "bb.planCheckRuns.list")) {const { planCheckRuns } = await planServiceClient.listPlanCheckRuns({- parent: rawPlan.name,+ parent: plan.name,latestOnly: true,});- plan.planCheckRunList = orderBy(planCheckRuns, "name", "desc");+ return orderBy(planCheckRuns, "name", "desc");}- return plan;+ return [];};export type ListPlanParams = {@@ -105,29 +99,26 @@ export const usePlanStore = defineStore("plan", () => {pageSize,pageToken,});- const composedPlans = await Promise.all(- resp.plans.map((plan) => composePlan(plan))- );- // Preprare creator for the plans.- const users = uniq(composedPlans.map((plan) => plan.creator));+ // Prepare creator for the plans.+ const users = uniq(resp.plans.map((plan) => plan.creator));await useUserStore().batchGetUsers(users);return {nextPageToken: resp.nextPageToken,- plans: composedPlans,+ plans: resp.plans,};};- const fetchPlanByName = async (name: string): Promise<ComposedPlan> => {- const rawPlan = await planServiceClient.getPlan({+ const fetchPlanByName = async (name: string): Promise<Plan> => {+ const plan = await planServiceClient.getPlan({name,});- return await composePlan(rawPlan);+ return plan;};const fetchPlanByUID = async (uid: string,project = "-"- ): Promise<ComposedPlan> => {+ ): Promise<Plan> => {if (uid === "undefined") {console.warn("undefined plan uid");return emptyPlan();@@ -143,5 +134,6 @@ export const usePlanStore = defineStore("plan", () => {searchPlans,fetchPlanByName,fetchPlanByUID,+ fetchPlanCheckRuns,};});diff --git a/frontend/src/types/v1/issue/plan.ts b/frontend/src/types/v1/issue/plan.tsindex 63bf7b5cf7..23e35bf01a 100644--- a/frontend/src/types/v1/issue/plan.ts+++ b/frontend/src/types/v1/issue/plan.ts@@ -1,35 +1,20 @@import { EMPTY_ID, UNKNOWN_ID } from "@/types/const";import {Plan,- PlanCheckRun,Plan_Spec,} from "@/types/proto/v1/plan_service";-import { EMPTY_PROJECT_NAME, UNKNOWN_PROJECT_NAME } from "../project";--export interface ComposedPlan extends Plan {- planCheckRunList: PlanCheckRun[];- project: string;-}export const EMPTY_PLAN_NAME = `projects/${EMPTY_ID}/plans/${EMPTY_ID}`;export const UNKNOWN_PLAN_NAME = `projects/${UNKNOWN_ID}/plans/${UNKNOWN_ID}`;-export const emptyPlan = (): ComposedPlan => {- return {- ...Plan.fromPartial({- name: EMPTY_PLAN_NAME,- }),- planCheckRunList: [],- project: EMPTY_PROJECT_NAME,- };+export const emptyPlan = (): Plan => {+ return Plan.fromPartial({+ name: EMPTY_PLAN_NAME,+ });};-export const unknownPlan = (): ComposedPlan => {- return {- ...Plan.fromPartial({- name: UNKNOWN_PLAN_NAME,- }),- planCheckRunList: [],- project: UNKNOWN_PROJECT_NAME,- };+export const unknownPlan = (): Plan => {+ return Plan.fromPartial({+ name: UNKNOWN_PLAN_NAME,+ });};export const emptyPlanSpec = () => {diff --git a/frontend/src/views/ReviewCenter/index.vue b/frontend/src/views/ReviewCenter/index.vueindex e8520377ef..8338261210 100644--- a/frontend/src/views/ReviewCenter/index.vue+++ b/frontend/src/views/ReviewCenter/index.vue@@ -72,7 +72,7 @@ import {import { projectNamePrefix } from "@/store/modules/v1/common";import { usePlanStore } from "@/store/modules/v1/plan";import { buildPlanFindBySearchParams } from "@/store/modules/v1/plan";-import type { ComposedPlan } from "@/types/v1/issue/plan";+import type { Plan } from "@/types/proto/v1/plan_service";import {extractProjectResourceName,hasPermissionToCreatePlanInProject,@@ -126,7 +126,7 @@ watch();const planStore = usePlanStore();-const planPagedTable = ref<ComponentExposed<typeof PagedTable<ComposedPlan>>>();+const planPagedTable = ref<ComponentExposed<typeof PagedTable<Plan>>>();const planCreationButtonOptions = computed((): DropdownOption[] => {return [diff --git a/frontend/src/views/project/ProjectPlanDetail.vue b/frontend/src/views/project/ProjectPlanDetail.vueindex 6025343709..273944bbaf 100644--- a/frontend/src/views/project/ProjectPlanDetail.vue+++ b/frontend/src/views/project/ProjectPlanDetail.vue@@ -39,10 +39,8 @@ const props = defineProps<{const { t } = useI18n();-const { isCreating, plan, isInitializing } = useInitializePlan(- toRef(props, "planSlug"),- toRef(props, "projectId")-);+const { isCreating, plan, planCheckRunList, isInitializing } =+ useInitializePlan(toRef(props, "planSlug"), toRef(props, "projectId"));const ready = computed(() => {return !isInitializing.value && !!plan.value;});@@ -56,6 +54,7 @@ providePlanContext({isCreating,plan,+ planCheckRunList,ready,...planBaseContext,},