Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: unify plan check run status count display across components (#17083)
boojack2572f9c27e83
diff --git a/frontend/src/components/Plan/components/ChecksView/ChecksView.vue b/frontend/src/components/Plan/components/ChecksView/ChecksView.vueindex ae594c7fa7..d06aff591f 100644--- a/frontend/src/components/Plan/components/ChecksView/ChecksView.vue+++ b/frontend/src/components/Plan/components/ChecksView/ChecksView.vue@@ -3,66 +3,15 @@<!-- Header with filters --><div class="flex items-center justify-between px-4"><div class="flex items-center gap-4">- <!-- Check result summary with icons -->- <div class="flex items-center gap-3">- <div- v-if="getChecksCount(PlanCheckRun_Result_Status.ERROR) > 0"- class="flex items-center gap-1 px-2 py-1 cursor-pointer"- :class="[- selectedStatus &&- selectedStatus === PlanCheckRun_Result_Status.ERROR &&- 'bg-gray-100 rounded-lg',- 'text-lg text-error',- ]"- @click="toggleSelectedStatus(PlanCheckRun_Result_Status.ERROR)"- >- <XCircleIcon class="w-6 h-6" />- <span>- {{ $t("common.error") }}- </span>- <span class="font-semibold">- {{ getChecksCount(PlanCheckRun_Result_Status.ERROR) }}- </span>- </div>- <div- v-if="getChecksCount(PlanCheckRun_Result_Status.WARNING) > 0"- class="flex items-center gap-1 px-2 py-1 cursor-pointer"- :class="[- selectedStatus &&- selectedStatus === PlanCheckRun_Result_Status.WARNING &&- 'bg-gray-100 rounded-lg',- 'text-lg text-warning',- ]"- @click="toggleSelectedStatus(PlanCheckRun_Result_Status.WARNING)"- >- <AlertCircleIcon class="w-6 h-6" />- <span>- {{ $t("common.warning") }}- </span>- <span class="font-semibold">- {{ getChecksCount(PlanCheckRun_Result_Status.WARNING) }}- </span>- </div>- <div- v-if="getChecksCount(PlanCheckRun_Result_Status.SUCCESS) > 0"- class="flex items-center gap-1 px-2 py-1 cursor-pointer"- :class="[- selectedStatus &&- selectedStatus === PlanCheckRun_Result_Status.SUCCESS &&- 'bg-gray-100 rounded-lg',- 'text-lg text-success',- ]"- @click="toggleSelectedStatus(PlanCheckRun_Result_Status.SUCCESS)"- >- <CheckCircleIcon class="w-6 h-6" />- <span>- {{ $t("common.success") }}- </span>- <span class="font-semibold">- {{ getChecksCount(PlanCheckRun_Result_Status.SUCCESS) }}- </span>- </div>- </div>+ <PlanCheckStatusCount+ :plan="plan"+ :show-label="true"+ :clickable="true"+ :selected-status="selectedStatus"+ size="normal"+ class="text-lg"+ @click="toggleSelectedStatus($event)"+ /></div></div>@@ -148,8 +97,6 @@import type { Timestamp } from "@bufbuild/protobuf/wkt";import {CheckCircleIcon,- AlertCircleIcon,- XCircleIcon,FileCodeIcon,DatabaseIcon,ShieldIcon,@@ -164,8 +111,9 @@ import {type PlanCheckRun,} from "@/types/proto-es/v1/plan_service_pb";import { humanizeTs } from "@/utils";-import { usePlanContext } from "../../logic/context";+import { usePlanContext } from "../../logic";import { useResourcePoller } from "../../logic/poller";+import PlanCheckStatusCount from "../PlanCheckStatusCount.vue";import CheckResultItem from "../common/CheckResultItem.vue";import DatabaseDisplay from "../common/DatabaseDisplay.vue";@@ -212,12 +160,6 @@ watch({ immediate: true });-const getChecksCount = (status: PlanCheckRun_Result_Status) => {- return (- plan.value.planCheckRunStatusCount[PlanCheckRun_Result_Status[status]] || 0- );-};-const toggleSelectedStatus = (status: PlanCheckRun_Result_Status) => {if (selectedStatus.value === status) {selectedStatus.value = undefined; // Deselect if already selecteddiff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vueindex 2f3ed9defb..017a485b28 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue@@ -12,35 +12,7 @@<span class="text-control shrink-0">{{$t("plan.navigator.checks")}}</span>- <div class="flex items-center gap-3">- <div- v-if="planCheckStatus.error > 0"- class="flex items-center gap-1"- >- <XCircleIcon class="w-5 h-5 text-error" />- <span class="text-base font-semibold text-error">{{- planCheckStatus.error- }}</span>- </div>- <div- v-if="planCheckStatus.warning > 0"- class="flex items-center gap-1"- >- <AlertCircleIcon class="w-5 h-5 text-warning" />- <span class="text-base font-semibold text-warning">{{- planCheckStatus.warning- }}</span>- </div>- <div- v-if="planCheckStatus.success > 0"- class="flex items-center gap-1"- >- <CheckCircleIcon class="w-5 h-5 text-success" />- <span class="text-base font-semibold text-success">{{- planCheckStatus.success- }}</span>- </div>- </div>+ <PlanCheckStatusCount :plan="plan" /></div><div class="flex flex-col gap-y-1">@@ -110,15 +82,15 @@<script setup lang="ts">import { create } from "@bufbuild/protobuf";-import { CheckCircleIcon, XCircleIcon, AlertCircleIcon } from "lucide-vue-next";import { NButton, NInput, NTooltip } from "naive-ui";import { computed, nextTick, ref, watchEffect } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import IssueLabelSelector from "@/components/IssueV1/components/IssueLabelSelector.vue";import CommonDrawer from "@/components/IssueV1/components/Panel/CommonDrawer.vue";+import PlanCheckStatusCount from "@/components/Plan/components/PlanCheckStatusCount.vue";import { ErrorList } from "@/components/Plan/components/common";-import { usePlanContext } from "@/components/Plan/logic";+import { usePlanContext, usePlanCheckStatus } from "@/components/Plan/logic";import {issueServiceClientConnect,planServiceClientConnect,@@ -170,40 +142,10 @@ const title = computed(() => {return t("plan.ready-for-review");});-const planCheckStatus = computed(() => {- const statusCount = plan.value.planCheckRunStatusCount || {};- const success =- statusCount[- PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.SUCCESS]- ] || 0;- const warning =- statusCount[- PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.WARNING]- ] || 0;- const error =- statusCount[PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.ERROR]] ||- 0;-- return {- total: success + warning + error,- success,- warning,- error,- };-});--const planCheckSummaryStatus = computed((): PlanCheckRun_Result_Status => {- if (planCheckStatus.value.error > 0) {- return PlanCheckRun_Result_Status.ERROR;- }- if (planCheckStatus.value.warning > 0) {- return PlanCheckRun_Result_Status.WARNING;- }- if (planCheckStatus.value.success > 0) {- return PlanCheckRun_Result_Status.SUCCESS;- }- return PlanCheckRun_Result_Status.STATUS_UNSPECIFIED;-});+const {+ statusSummary: planCheckStatus,+ getOverallStatus: planCheckSummaryStatus,+} = usePlanCheckStatus(plan);const tips = computed(() => {const tipsList: string[] = [];diff --git a/frontend/src/components/Plan/components/IssueReviewView/OverviewSection.vue b/frontend/src/components/Plan/components/IssueReviewView/OverviewSection.vueindex a804003784..151e7d53cc 100644--- a/frontend/src/components/Plan/components/IssueReviewView/OverviewSection.vue+++ b/frontend/src/components/Plan/components/IssueReviewView/OverviewSection.vue@@ -6,54 +6,12 @@{{ $t("plan.navigator.checks") }}</h3><div class="flex items-center gap-4">- <div- v-if="getChecksCount(PlanCheckRun_Result_Status.ERROR) > 0"- class="flex items-center gap-1 cursor-pointer text-error"- @click="selectedResultStatus = PlanCheckRun_Result_Status.ERROR"- >- <XCircleIcon class="w-5 h-5" />- <span>- {{ $t("common.error") }}- </span>- <span class="font-semibold">- {{ getChecksCount(PlanCheckRun_Result_Status.ERROR) }}- </span>- </div>- <div- v-if="getChecksCount(PlanCheckRun_Result_Status.WARNING) > 0"- class="flex items-center gap-1 cursor-pointer text-warning"- @click="selectedResultStatus = PlanCheckRun_Result_Status.WARNING"- >- <AlertCircleIcon class="w-5 h-5" />- <span>- {{ $t("common.warning") }}- </span>- <span class="font-semibold">- {{ getChecksCount(PlanCheckRun_Result_Status.WARNING) }}- </span>- </div>- <div- v-if="getChecksCount(PlanCheckRun_Result_Status.SUCCESS) > 0"- class="flex items-center gap-1 cursor-pointer text-success"- @click="selectedResultStatus = PlanCheckRun_Result_Status.SUCCESS"- >- <CheckCircleIcon class="w-5 h-5" />- <span>- {{ $t("common.success") }}- </span>- <span class="font-semibold">- {{ getChecksCount(PlanCheckRun_Result_Status.SUCCESS) }}- </span>- </div>- <span- v-if="- getChecksCount(PlanCheckRun_Result_Status.ERROR) +- getChecksCount(PlanCheckRun_Result_Status.WARNING) +- getChecksCount(PlanCheckRun_Result_Status.SUCCESS) ===- 0- "- class="text-sm text-control"- >+ <PlanCheckStatusCount+ :plan="plan"+ clickable+ @click="selectedResultStatus = $event"+ />+ <span v-if="!hasAnyChecks" class="text-sm text-control">{{ $t("plan.overview.no-checks") }}</span></div>@@ -107,7 +65,6 @@</template><script setup lang="ts">-import { CheckCircleIcon, AlertCircleIcon, XCircleIcon } from "lucide-vue-next";import { ref } from "vue";import { useRouter } from "vue-router";import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";@@ -115,24 +72,20 @@ import { PROJECT_V1_ROUTE_ROLLOUT_DETAIL_STAGE_DETAIL } from "@/router/dashboardimport { useCurrentProjectV1, useEnvironmentV1Store } from "@/store";import { PlanCheckRun_Result_Status } from "@/types/proto-es/v1/plan_service_pb";import { extractProjectResourceName, getStageStatus } from "@/utils";-import { usePlanContext } from "../../logic";+import { usePlanContext, usePlanCheckStatus } from "../../logic";import ChecksDrawer from "../ChecksView/ChecksDrawer.vue";+import PlanCheckStatusCount from "../PlanCheckStatusCount.vue";const { plan, rollout } = usePlanContext();const environmentStore = useEnvironmentV1Store();const router = useRouter();const { project } = useCurrentProjectV1();+const { hasAnyStatus: hasAnyChecks } = usePlanCheckStatus(plan);const selectedResultStatus = ref<PlanCheckRun_Result_Status | undefined>(undefined);-const getChecksCount = (status: PlanCheckRun_Result_Status) => {- return (- plan.value.planCheckRunStatusCount[PlanCheckRun_Result_Status[status]] || 0- );-};-const getEnvironmentTitle = (environmentName: string) => {const environment = environmentStore.getEnvironmentByName(environmentName);return environment.title || environmentName;diff --git a/frontend/src/components/Plan/components/PlanCheckRunStatusIcon.vue b/frontend/src/components/Plan/components/PlanCheckRunStatusIcon.vueindex 5878bd4feb..137255df04 100644--- a/frontend/src/components/Plan/components/PlanCheckRunStatusIcon.vue+++ b/frontend/src/components/Plan/components/PlanCheckRunStatusIcon.vue@@ -37,6 +37,7 @@ import {PlanCheckRun_Result_Status,type Plan,} from "@/types/proto-es/v1/plan_service_pb";+import { usePlanCheckStatus } from "../logic";export type SizeType = "small" | "normal";@@ -51,17 +52,9 @@ const props = defineProps({},});-const planCheckRunStatus = computed(() => {- const { planCheckRunStatusCount } = props.plan;- if (planCheckRunStatusCount["ERROR"] > 0) {- return PlanCheckRun_Result_Status.ERROR;- } else if (planCheckRunStatusCount["WARNING"] > 0) {- return PlanCheckRun_Result_Status.WARNING;- } else if (planCheckRunStatusCount["SUCCESS"] > 0) {- return PlanCheckRun_Result_Status.SUCCESS;- }- return PlanCheckRun_Result_Status.STATUS_UNSPECIFIED;-});+const { getOverallStatus: planCheckRunStatus } = usePlanCheckStatus(+ computed(() => props.plan)+);const iconClass = () => {const iconClass = props.size === "normal" ? "w-5 h-5" : "w-4 h-4";diff --git a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vueindex 8f4f8e2b05..87fed8628f 100644--- a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue+++ b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue@@ -24,68 +24,11 @@<div class="flex items-center gap-2"><!-- Status Summary -->- <div class="flex items-center gap-2 text-sm">- <div- v-if="- getChecksCount(PlanCheckRun_Status[PlanCheckRun_Status.RUNNING]) >- 0- "- class="flex items-center gap-1"- >- <LoaderIcon class="w-5 h-5 text-control animate-spin" />- <span class="text-control">{{- getChecksCount(PlanCheckRun_Status[PlanCheckRun_Status.RUNNING])- }}</span>- </div>- <button- v-if="- getChecksCount(- PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.ERROR]- ) > 0- "- class="flex items-center gap-1 hover:opacity-80"- @click="openChecksDrawer(PlanCheckRun_Result_Status.ERROR)"- >- <XCircleIcon class="w-5 h-5 text-error" />- <span class="text-error">{{- getChecksCount(- PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.ERROR]- )- }}</span>- </button>- <button- v-if="- getChecksCount(- PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.WARNING]- ) > 0- "- class="flex items-center gap-1 hover:opacity-80"- @click="openChecksDrawer(PlanCheckRun_Result_Status.WARNING)"- >- <AlertCircleIcon class="w-5 h-5 text-warning" />- <span class="text-warning">{{- getChecksCount(- PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.WARNING]- )- }}</span>- </button>- <button- v-if="- getChecksCount(- PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.SUCCESS]- ) > 0- "- class="flex items-center gap-1 hover:opacity-80"- @click="openChecksDrawer(PlanCheckRun_Result_Status.SUCCESS)"- >- <CheckCircleIcon class="w-5 h-5 text-success" />- <span class="text-success">{{- getChecksCount(- PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.SUCCESS]- )- }}</span>- </button>- </div>+ <PlanCheckStatusCount+ :plan="plan"+ clickable+ @click="openChecksDrawer($event)"+ /><!-- Run Checks Button --><NButton@@ -112,13 +55,7 @@<script setup lang="ts">import { create } from "@bufbuild/protobuf";import type { ConnectError } from "@connectrpc/connect";-import {- CheckCircleIcon,- AlertCircleIcon,- XCircleIcon,- PlayIcon,- LoaderIcon,-} from "lucide-vue-next";+import { PlayIcon } from "lucide-vue-next";import { NButton, NTooltip, NTag } from "naive-ui";import { computed, ref, watch } from "vue";import { planServiceClientConnect } from "@/grpcweb";@@ -130,14 +67,18 @@ import {} from "@/store";import {PlanCheckRun_Result_Status,- PlanCheckRun_Status,RunPlanChecksRequestSchema,} from "@/types/proto-es/v1/plan_service_pb";import { hasProjectPermissionV2 } from "@/utils";-import { planCheckRunListForSpec, planSpecHasPlanChecks } from "../../logic";-import { usePlanContext } from "../../logic/context";+import {+ planCheckRunListForSpec,+ planSpecHasPlanChecks,+ usePlanContext,+ usePlanCheckStatus,+} from "../../logic";import { useResourcePoller } from "../../logic/poller";import ChecksDrawer from "../ChecksView/ChecksDrawer.vue";+import PlanCheckStatusCount from "../PlanCheckStatusCount.vue";import { useSelectedSpec } from "../SpecDetailView/context";const currentUser = useCurrentUserV1();@@ -145,6 +86,7 @@ const { project } = useCurrentProjectV1();const { plan, planCheckRuns } = usePlanContext();const selectedSpec = useSelectedSpec();const { refreshResources } = useResourcePoller();+const { statusCountString } = usePlanCheckStatus(plan);const isRunningChecks = ref(false);const showChecksDrawer = ref(false);@@ -187,10 +129,6 @@ const affectedRows = computed(() => {}, 0);});-const getChecksCount = (status: string) => {- return plan.value.planCheckRunStatusCount[status] || 0;-};-const runChecks = async () => {if (!plan.value.name || !selectedSpec.value) return;@@ -228,7 +166,7 @@ const openChecksDrawer = (status: PlanCheckRun_Result_Status) => {// Prepare plan check runs.watch(- [selectedSpec.value.id, JSON.stringify(plan.value.planCheckRunStatusCount)],+ [selectedSpec.value.id, statusCountString],async () => {if (planSpecHasPlanChecks(selectedSpec.value)) {await refreshResources(["planCheckRuns"], true /** force */);diff --git a/frontend/src/components/Plan/components/PlanCheckStatusCount.vue b/frontend/src/components/Plan/components/PlanCheckStatusCount.vuenew file mode 100644index 0000000000..7bb7a97960--- /dev/null+++ b/frontend/src/components/Plan/components/PlanCheckStatusCount.vue@@ -0,0 +1,137 @@+<template>+ <div class="flex items-center gap-2" v-if="hasAnyStatus">+ <template v-if="displayMode === 'icon'">+ <PlanCheckRunStatusIcon :plan="plan" :size="size" />+ </template>+ <!-- Default display mode: show all status counts with icons -->+ <template v-else>+ <div class="flex items-center gap-3">+ <div+ v-if="statusSummary.running > 0"+ class="flex items-center gap-1 text-control"+ >+ <LoaderIcon :class="iconSizeClass" class="animate-spin" />+ <span v-if="showLabel">{{ $t("task.status.running") }}</span>+ <span>{{ statusSummary.running }}</span>+ </div>+ <div+ v-if="statusSummary.error > 0"+ class="flex items-center gap-1 text-error"+ :class="getItemClass(PlanCheckRun_Result_Status.ERROR)"+ @click="handleClick('error')"+ >+ <XCircleIcon :class="iconSizeClass" />+ <span v-if="showLabel">{{ $t("common.error") }}</span>+ <span>{{ statusSummary.error }}</span>+ </div>+ <div+ v-if="statusSummary.warning > 0"+ class="flex items-center gap-1 text-warning"+ :class="getItemClass(PlanCheckRun_Result_Status.WARNING)"+ @click="handleClick('warning')"+ >+ <AlertCircleIcon :class="iconSizeClass" />+ <span v-if="showLabel">{{ $t("common.warning") }}</span>+ <span>{{ statusSummary.warning }}</span>+ </div>+ <div+ v-if="statusSummary.success > 0"+ class="flex items-center gap-1 text-success"+ :class="getItemClass(PlanCheckRun_Result_Status.SUCCESS)"+ @click="handleClick('success')"+ >+ <CheckCircleIcon :class="iconSizeClass" />+ <span v-if="showLabel">{{ $t("common.success") }}</span>+ <span>{{ statusSummary.success }}</span>+ </div>+ </div>+ </template>+ </div>+</template>++<script setup lang="ts">+import {+ CheckCircleIcon,+ AlertCircleIcon,+ XCircleIcon,+ LoaderIcon,+} from "lucide-vue-next";+import { computed, type PropType } from "vue";+import {+ PlanCheckRun_Result_Status,+ type Plan,+} from "@/types/proto-es/v1/plan_service_pb";+import { usePlanCheckStatus } from "../logic";+import PlanCheckRunStatusIcon from "./PlanCheckRunStatusIcon.vue";++type DisplayMode = "icon" | "default";+type SizeType = "small" | "normal";++const props = defineProps({+ plan: {+ required: true,+ type: Object as PropType<Plan>,+ },+ displayMode: {+ type: String as PropType<DisplayMode>,+ default: "default",+ },+ size: {+ type: String as PropType<SizeType>,+ default: "normal",+ },+ showLabel: {+ type: Boolean,+ default: false,+ },+ clickable: {+ type: Boolean,+ default: false,+ },+ selectedStatus: {+ type: Number as PropType<PlanCheckRun_Result_Status | undefined>,+ default: undefined,+ },+});++const emit = defineEmits<{+ click: [status: PlanCheckRun_Result_Status];+}>();++const { statusSummary, hasAnyStatus } = usePlanCheckStatus(+ computed(() => props.plan)+);++const iconSizeClass = computed(() => {+ return props.size === "normal" ? "w-5 h-5" : "w-4 h-4";+});++const handleClick = (statusType: "error" | "warning" | "success") => {+ if (!props.clickable) return;++ const statusMap = {+ error: PlanCheckRun_Result_Status.ERROR,+ warning: PlanCheckRun_Result_Status.WARNING,+ success: PlanCheckRun_Result_Status.SUCCESS,+ };++ emit("click", statusMap[statusType]);+};++const getItemClass = (status: PlanCheckRun_Result_Status) => {+ const classes: string[] = [];++ if (props.clickable) {+ classes.push("cursor-pointer");+ }++ if (props.selectedStatus === status) {+ classes.push("bg-gray-100 rounded-lg px-2 py-1");+ } else if (props.selectedStatus !== undefined) {+ // Add some padding to align with selected items+ classes.push("px-2 py-1");+ }++ return classes;+};+</script>diff --git a/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue b/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vueindex 58776505b6..3181d4c311 100644--- a/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue+++ b/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue@@ -43,35 +43,7 @@<span class="font-medium text-control shrink-0">{{$t("plan.navigator.checks")}}</span>- <div class="flex items-center gap-3">- <div- v-if="planCheckStatus.error > 0"- class="flex items-center gap-1"- >- <XCircleIcon class="w-5 h-5 text-error" />- <span class="text-base font-semibold text-error">{{- planCheckStatus.error- }}</span>- </div>- <div- v-if="planCheckStatus.warning > 0"- class="flex items-center gap-1"- >- <AlertCircleIcon class="w-5 h-5 text-warning" />- <span class="text-base font-semibold text-warning">{{- planCheckStatus.warning- }}</span>- </div>- <div- v-if="planCheckStatus.success > 0"- class="flex items-center gap-1"- >- <CheckCircleIcon class="w-5 h-5 text-success" />- <span class="text-base font-semibold text-success">{{- planCheckStatus.success- }}</span>- </div>- </div>+ <PlanCheckStatusCount :plan="plan" /></div><div@@ -274,7 +246,6 @@ import { create } from "@bufbuild/protobuf";import { TimestampSchema } from "@bufbuild/protobuf/wkt";import dayjs from "dayjs";import { head } from "lodash-es";-import { CheckCircleIcon, XCircleIcon, AlertCircleIcon } from "lucide-vue-next";import {NAlert,NButton,@@ -300,7 +271,6 @@ import {useEnvironmentV1Store,} from "@/store";import { Issue_Approver_Status } from "@/types/proto-es/v1/issue_service_pb";-import { PlanCheckRun_Result_Status } from "@/types/proto-es/v1/plan_service_pb";import {BatchRunTasksRequestSchema,BatchSkipTasksRequestSchema,@@ -315,8 +285,9 @@ import {hasWorkspacePermissionV2,isNullOrUndefined,} from "@/utils";-import { usePlanContextWithRollout } from "../../logic";+import { usePlanContextWithRollout, usePlanCheckStatus } from "../../logic";import { useIssueReviewContext } from "../../logic/issue-review";+import PlanCheckStatusCount from "../PlanCheckStatusCount.vue";import TaskDatabaseName from "./TaskDatabaseName.vue";import { useTaskActionPermissions } from "./taskPermissions";@@ -353,29 +324,7 @@ const { canPerformTaskAction } = useTaskActionPermissions();const comment = ref("");const runTimeInMS = ref<number | undefined>(undefined);const forceRollout = ref(false);--// Plan check status computed property-const planCheckStatus = computed(() => {- const statusCount = plan.value.planCheckRunStatusCount || {};- const success =- statusCount[- PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.SUCCESS]- ] || 0;- const warning =- statusCount[- PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.WARNING]- ] || 0;- const error =- statusCount[PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.ERROR]] ||- 0;-- return {- total: success + warning + error,- success,- warning,- error,- };-});+const { statusSummary: planCheckStatus } = usePlanCheckStatus(plan);// Check issue approval status using the review contextconst issueApprovalStatus = computed(() => {diff --git a/frontend/src/components/Plan/logic/index.ts b/frontend/src/components/Plan/logic/index.tsindex ab4b5b8ad2..a16bd0992a 100644--- a/frontend/src/components/Plan/logic/index.ts+++ b/frontend/src/components/Plan/logic/index.ts@@ -7,3 +7,4 @@ export * from "./plan-check";export * from "./utils";export * from "./sidebar";export * from "./issue-review";+export * from "./usePlanCheckStatus";diff --git a/frontend/src/components/Plan/logic/usePlanCheckStatus.ts b/frontend/src/components/Plan/logic/usePlanCheckStatus.tsnew file mode 100644index 0000000000..94edeea041--- /dev/null+++ b/frontend/src/components/Plan/logic/usePlanCheckStatus.ts@@ -0,0 +1,97 @@+import { computed, type ComputedRef, type Ref } from "vue";+import {+ PlanCheckRun_Result_Status,+ PlanCheckRun_Status,+ type Plan,+} from "@/types/proto-es/v1/plan_service_pb";++export interface PlanCheckStatusSummary {+ running: number;+ success: number;+ warning: number;+ error: number;+ total: number;+}++export const usePlanCheckStatus = (+ plan: ComputedRef<Plan | undefined> | Ref<Plan | undefined>+) => {+ const getCheckCount = (status: PlanCheckRun_Result_Status): number => {+ if (!plan.value) return 0;+ const statusKey = PlanCheckRun_Result_Status[status];+ return plan.value.planCheckRunStatusCount?.[statusKey] || 0;+ };++ const getOverallStatus = computed(() => {+ if (!plan.value) return PlanCheckRun_Result_Status.STATUS_UNSPECIFIED;++ const statusCount = plan.value.planCheckRunStatusCount || {};++ if (statusCount["ERROR"] > 0) {+ return PlanCheckRun_Result_Status.ERROR;+ } else if (statusCount["WARNING"] > 0) {+ return PlanCheckRun_Result_Status.WARNING;+ } else if (statusCount["SUCCESS"] > 0) {+ return PlanCheckRun_Result_Status.SUCCESS;+ }++ return PlanCheckRun_Result_Status.STATUS_UNSPECIFIED;+ });++ const statusSummary = computed<PlanCheckStatusSummary>(() => {+ if (!plan.value) {+ return { running: 0, success: 0, warning: 0, error: 0, total: 0 };+ }++ const statusCount = plan.value.planCheckRunStatusCount || {};+ const running =+ statusCount[PlanCheckRun_Status[PlanCheckRun_Status.RUNNING]] || 0;+ const success =+ statusCount[+ PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.SUCCESS]+ ] || 0;+ const warning =+ statusCount[+ PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.WARNING]+ ] || 0;+ const error =+ statusCount[+ PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.ERROR]+ ] || 0;+ const total = running + success + warning + error;++ return { running, success, warning, error, total };+ });++ const hasAnyStatus = computed(() => {+ const summary = statusSummary.value;+ return summary.total > 0;+ });++ const hasRunning = computed(() => {+ return statusSummary.value.running > 0;+ });++ const hasErrors = computed(() => {+ return statusSummary.value.error > 0;+ });++ const hasWarnings = computed(() => {+ return statusSummary.value.warning > 0;+ });++ const statusCountString = computed(() => {+ return JSON.stringify(plan.value?.planCheckRunStatusCount || {});+ });++ return {+ getCheckCount,+ getOverallStatus,+ statusSummary,+ hasAnyStatus,+ hasRunning,+ hasErrors,+ hasWarnings,+ statusCountString,+ };+};