Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(plan-list): show "Bypassed" review status (BYT-9551) (#20372)
zchpeter6cf58f5ab087
diff --git a/frontend/scripts/check-react-i18n.mjs b/frontend/scripts/check-react-i18n.mjsindex 5291a10600..2b4892f2c8 100644--- a/frontend/scripts/check-react-i18n.mjs+++ b/frontend/scripts/check-react-i18n.mjs@@ -11,7 +11,11 @@ import { readFileSync, readdirSync } from "fs";import { resolve, dirname } from "path";import { fileURLToPath } from "url";-// Keys constructed at runtime via template literals — exempt from unused check.+// Keys whose usage the checker cannot trace statically — exempt from the+// unused-key check. Matched with String.startsWith, so an entry ending in+// "." is a prefix family (matches any key under it) and an entry without a+// trailing "." matches itself (and, technically, anything that starts with+// it — see `instance.selected-n-instances` for that convention).const DYNAMIC_PREFIXES = ["dynamic.subscription.features.","dynamic.subscription.purchase.features.",@@ -25,6 +29,14 @@ const DYNAMIC_PREFIXES = ["settings.sensitive-data.algorithms.","instance.selected-n-instances","settings.sidebar.",+ // Returned from getReviewBadge as labelKey string literals, not invoked+ // via t("…") in source. See frontend/src/react/pages/project/utils/reviewBadge.ts.+ "common.bypassed",+ "common.closed",+ "common.rejected",+ "common.skipped",+ "common.under-review",+ "issue.table.approved",];const __dirname = dirname(fileURLToPath(import.meta.url));@@ -172,7 +184,7 @@ if (unused.length > 0) {error(` - ${key}`);}console.error(- "\nRemove from frontend/src/react/locales/ or add to DYNAMIC_PREFIXES if constructed at runtime.\n"+ "\nRemove from frontend/src/react/locales/ or add to DYNAMIC_PREFIXES if referenced indirectly (helper return, template literal).\n");}diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex e05fd29ee1..300cc66010 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -2685,7 +2685,6 @@"self": "SQL review"}},- "checking": "Checking...","created": "Created","data-export-creator-only": "Only the issue creator can execute data export tasks","error": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex d8e97c311b..7c3378cee7 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -2685,7 +2685,6 @@"self": "Revisión de SQL"}},- "checking": "Comprobando...","created": "Creado","data-export-creator-only": "Sólo el creador del problema puede ejecutar tareas de exportación de datos","error": {diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 3ad3c4eb7f..f3096cb34e 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -2685,7 +2685,6 @@"self": "SQL レビュー"}},- "checking": "検査中…","created": "内蔵","data-export-creator-only": "イシュー作成者のみがデータエクスポートタスクを実行できます","error": {diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 72cae6deae..6e404d63fb 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -2685,7 +2685,6 @@"self": "Đánh giá SQL"}},- "checking": "Đang kiểm tra...","created": "Đã tạo","data-export-creator-only": "Chỉ người tạo sự cố mới có thể thực hiện tác vụ xuất dữ liệu","error": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex f76f33d16d..ac917b0c81 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -2685,7 +2685,6 @@"self": "SQL 审核"}},- "checking": "检查中…","created": "创建于","data-export-creator-only": "只有工单创建者可以执行数据导出任务","error": {diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.jsonindex 3690943ace..bf2ae5b468 100644--- a/frontend/src/react/locales/en-US.json+++ b/frontend/src/react/locales/en-US.json@@ -3742,7 +3742,6 @@"task": {"cancel-task": "Cancel task | Cancel tasks","cancel-task-description": "Pending and available task runs are canceled immediately. Running task runs receive a best-effort cancel request and may keep running; retry if needed.",- "checking": "Checking...","created": "Created","data-export-creator-only": "Only the issue creator can execute data export tasks","error": {diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.jsonindex 8ff276a5a2..998b3766e2 100644--- a/frontend/src/react/locales/es-ES.json+++ b/frontend/src/react/locales/es-ES.json@@ -3730,7 +3730,6 @@"task": {"cancel-task": "Cancelar tarea | Cancelar tareas","cancel-task-description": "Las ejecuciones de tareas pendientes y disponibles se cancelan inmediatamente. Las ejecuciones en curso reciben una solicitud de cancelación de mejor esfuerzo y pueden seguir ejecutándose; vuelva a intentarlo si es necesario.",- "checking": "Comprobando...","created": "Creado","data-export-creator-only": "Sólo el creador del problema puede ejecutar tareas de exportación de datos","error": {diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.jsonindex c62e298b9b..49727c81df 100644--- a/frontend/src/react/locales/ja-JP.json+++ b/frontend/src/react/locales/ja-JP.json@@ -3730,7 +3730,6 @@"task": {"cancel-task": "タスクをキャンセルする","cancel-task-description": "保留中および利用可能なタスク実行はすぐにキャンセルされます。実行中のタスク実行にはベストエフォートのキャンセル要求が送信されますが、実行が続く場合があります。必要に応じて再試行してください。",- "checking": "検査中…","created": "作成日時","data-export-creator-only": "イシュー作成者のみがデータエクスポートタスクを実行できます","error": {diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.jsonindex 721b2db9ac..e9180b9ed5 100644--- a/frontend/src/react/locales/vi-VN.json+++ b/frontend/src/react/locales/vi-VN.json@@ -3730,7 +3730,6 @@"task": {"cancel-task": "Hủy tác vụ | Hủy các tác vụ","cancel-task-description": "Các lần chạy tác vụ đang chờ và sẵn sàng sẽ được hủy ngay. Các lần chạy đang chạy sẽ nhận yêu cầu hủy theo cách cố gắng tối đa và có thể tiếp tục chạy; hãy thử lại nếu cần.",- "checking": "Đang kiểm tra...","created": "Đã tạo","data-export-creator-only": "Chỉ người tạo sự cố mới có thể thực hiện tác vụ xuất dữ liệu","error": {diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.jsonindex abb9bdd907..69b6b3202c 100644--- a/frontend/src/react/locales/zh-CN.json+++ b/frontend/src/react/locales/zh-CN.json@@ -3730,7 +3730,6 @@"task": {"cancel-task": "取消任务","cancel-task-description": "待运行和就绪的任务运行会立即取消。运行中的任务运行会收到尽力而为的取消请求,可能会继续运行;如有需要请重试。",- "checking": "检查中…","created": "创建时间","data-export-creator-only": "只有工单创建者可以执行数据导出任务","error": {diff --git a/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx b/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsxindex ae1216c511..eeb216dcf5 100644--- a/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx+++ b/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx@@ -24,6 +24,7 @@ import {usePermissionCheck,} from "@/react/components/PermissionGuard";import { Alert } from "@/react/components/ui/alert";+import { Badge } from "@/react/components/ui/badge";import { Button } from "@/react/components/ui/button";import { Checkbox } from "@/react/components/ui/checkbox";import { SearchInput } from "@/react/components/ui/search-input";@@ -76,7 +77,7 @@ import {isValidDatabaseGroupName,unknownUser,} from "@/types";-import { ApprovalStatus, State } from "@/types/proto-es/v1/common_pb";+import { State } from "@/types/proto-es/v1/common_pb";import type { DatabaseGroup } from "@/types/proto-es/v1/database_group_service_pb";import { DatabaseGroupView } from "@/types/proto-es/v1/database_group_service_pb";import {@@ -106,6 +107,7 @@ import {type SearchParams as VueSearchParams,} from "@/utils";import { extractStageUID } from "@/utils/v1/issue/rollout";+import { getReviewBadge } from "./utils/reviewBadge";// Task status priority order for determining rollout stage statusconst TASK_STATUS_FILTERS: Task_Status[] = [@@ -442,26 +444,25 @@ function PlanRow({ plan, projectId }: { plan: Plan; projectId: string }) {);// Approval status+ // Plan List passes issueStatus=undefined because the Plan proto does not+ // expose issue_status. Two divergence categories vs Plan Detail remain by+ // design (see the spec's "Residual divergences" table):+ // Category A — CANCELED issues render the approval-derived badge here+ // instead of "Closed".+ // Category C₂ — issue manually marked DONE with no rollout while approval+ // is still PENDING renders "Under Review" here instead of "Bypassed".+ // To close those gaps, expose issue_status on the Plan proto and pass it+ // through here. Bug history: BYT-9551.const approvalTag = useMemo(() => {- if (plan.issue === "") return undefined;- switch (plan.approvalStatus) {- case ApprovalStatus.CHECKING:- return { label: t("task.checking"), variant: "default" as const };- case ApprovalStatus.APPROVED:- return {- label: t("issue.table.approved"),- variant: "success" as const,- };- case ApprovalStatus.SKIPPED:- return { label: t("common.skipped"), variant: "default" as const };- case ApprovalStatus.REJECTED:- return { label: t("common.rejected"), variant: "warning" as const };- case ApprovalStatus.PENDING:- return { label: t("common.under-review"), variant: "info" as const };- default:- return undefined;- }- }, [plan.approvalStatus, plan.issue, t]);+ const badge = getReviewBadge({+ hasIssue: plan.issue !== "",+ issueStatus: undefined,+ hasRollout: plan.hasRollout,+ approvalStatus: plan.approvalStatus,+ });+ if (!badge) return undefined;+ return { label: t(badge.labelKey), variant: badge.variant };+ }, [plan.approvalStatus, plan.hasRollout, plan.issue, t]);// Plan check status summaryconst checkSummary = useMemo(() => {@@ -558,7 +559,9 @@ function PlanRow({ plan, projectId }: { plan: Plan; projectId: string }) {{/* Approval */}<TableCell>{approvalTag ? (- <StatusTag label={approvalTag.label} variant={approvalTag.variant} />+ <Badge variant={approvalTag.variant} className="whitespace-nowrap">+ {approvalTag.label}+ </Badge>) : (<span className="text-control-light">-</span>)}@@ -614,35 +617,6 @@ function PlanRow({ plan, projectId }: { plan: Plan; projectId: string }) {);}-// ----------------------------------------------------------------------------// StatusTag-// -----------------------------------------------------------------------------function StatusTag({- label,- variant = "default",-}: {- label: string;- variant?: "default" | "success" | "warning" | "info";-}) {- const variantClasses: Record<string, string> = {- default: "bg-control-bg text-control-light",- success: "bg-success/10 text-success",- warning: "bg-warning/10 text-warning",- info: "bg-accent/10 text-accent",- };- return (- <span- className={cn(- "inline-flex items-center whitespace-nowrap rounded-full px-2 py-0.5 text-xs",- variantClasses[variant]- )}- >- {label}- </span>- );-}-// ---------------------------------------------------------------------------// TaskStatusIcon// ---------------------------------------------------------------------------diff --git a/frontend/src/react/pages/project/plan-detail/ProjectPlanDetailPage.tsx b/frontend/src/react/pages/project/plan-detail/ProjectPlanDetailPage.tsxindex 97f1c8ae4b..3c82583cce 100644--- a/frontend/src/react/pages/project/plan-detail/ProjectPlanDetailPage.tsx+++ b/frontend/src/react/pages/project/plan-detail/ProjectPlanDetailPage.tsx@@ -18,9 +18,9 @@ import {SheetTitle,} from "@/react/components/ui/sheet";import { cn } from "@/react/lib/utils";-import { ApprovalStatus } from "@/types/proto-es/v1/common_pb";import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";+import { getReviewBadge } from "../utils/reviewBadge";import { DeployBranch } from "./components/deploy/DeployBranch";import { DeployTaskDetailPanel } from "./components/deploy/DeployTaskDetailPanel";import { PlanDetailReviewApprovalFlow } from "./components/PlanDetailApprovalFlow";@@ -174,37 +174,18 @@ function ProjectPlanDetailPageInner({changesStatus === "active" && !page.isCreating? { label: t("common.draft"), variant: "default" as const }: undefined;- const reviewBadge = (() => {- if (!page.issue) return undefined;- if (page.issue.status === IssueStatus.CANCELED) {- return { label: t("common.closed"), variant: "default" as const };- }- if (review === "future") return undefined;- if (- review === "completed" &&- page.issue.approvalStatus === ApprovalStatus.PENDING- ) {- return { label: t("common.bypassed"), variant: "default" as const };- }- switch (page.issue.approvalStatus) {- case ApprovalStatus.APPROVED:- return {- label: t("issue.table.approved"),- variant: "success" as const,- };- case ApprovalStatus.SKIPPED:- return { label: t("common.skipped"), variant: "default" as const };- case ApprovalStatus.REJECTED:- return { label: t("common.rejected"), variant: "warning" as const };- case ApprovalStatus.PENDING:- return {- label: t("common.under-review"),- variant: "secondary" as const,- };- default:- return undefined;- }- })();+ const rawReviewBadge = getReviewBadge({+ hasIssue,+ issueStatus: page.issue?.status,+ hasRollout,+ approvalStatus: page.issue?.approvalStatus,+ });+ const reviewBadge = rawReviewBadge+ ? {+ label: t(rawReviewBadge.labelKey),+ variant: rawReviewBadge.variant,+ }+ : undefined;const deployBadge = (() => {if (deployStatus !== "active" || !page.rollout) return undefined;const hasCompletedTasks = allTasks.some(diff --git a/frontend/src/react/pages/project/utils/reviewBadge.test.ts b/frontend/src/react/pages/project/utils/reviewBadge.test.tsnew file mode 100644index 0000000000..178d5ea235--- /dev/null+++ b/frontend/src/react/pages/project/utils/reviewBadge.test.ts@@ -0,0 +1,264 @@+import { describe, expect, it } from "vitest";+import { ApprovalStatus } from "@/types/proto-es/v1/common_pb";+import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";+import { getReviewBadge } from "./reviewBadge";++describe("getReviewBadge", () => {+ it("returns undefined when there is no issue", () => {+ expect(+ getReviewBadge({+ hasIssue: false,+ issueStatus: undefined,+ hasRollout: false,+ approvalStatus: ApprovalStatus.PENDING,+ })+ ).toBeUndefined();+ });++ it("returns undefined when approval status is undefined and not in a known special case", () => {+ expect(+ getReviewBadge({+ hasIssue: true,+ issueStatus: IssueStatus.OPEN,+ hasRollout: false,+ approvalStatus: undefined,+ })+ ).toBeUndefined();+ });++ describe("with full issue context (Plan Detail caller)", () => {+ describe("canceled issue renders 'closed' regardless of rollout/approval", () => {+ it.each<ApprovalStatus | undefined>([+ ApprovalStatus.APPROVAL_STATUS_UNSPECIFIED,+ ApprovalStatus.CHECKING,+ ApprovalStatus.SKIPPED,+ ApprovalStatus.PENDING,+ ApprovalStatus.APPROVED,+ ApprovalStatus.REJECTED,+ undefined,+ ])("approval=%s without rollout", (approvalStatus) => {+ expect(+ getReviewBadge({+ hasIssue: true,+ issueStatus: IssueStatus.CANCELED,+ hasRollout: false,+ approvalStatus,+ })+ ).toEqual({ labelKey: "common.closed", variant: "default" });+ });++ it.each<ApprovalStatus | undefined>([+ ApprovalStatus.APPROVAL_STATUS_UNSPECIFIED,+ ApprovalStatus.CHECKING,+ ApprovalStatus.SKIPPED,+ ApprovalStatus.PENDING,+ ApprovalStatus.APPROVED,+ ApprovalStatus.REJECTED,+ undefined,+ ])("approval=%s with rollout", (approvalStatus) => {+ expect(+ getReviewBadge({+ hasIssue: true,+ issueStatus: IssueStatus.CANCELED,+ hasRollout: true,+ approvalStatus,+ })+ ).toEqual({ labelKey: "common.closed", variant: "default" });+ });+ });++ describe("bypassed: rollout exists OR issue done, while approval still pending", () => {+ it.each<[string, IssueStatus, boolean]>([+ ["DONE issue with rollout", IssueStatus.DONE, true],+ ["DONE issue without rollout", IssueStatus.DONE, false],+ ["OPEN issue with rollout", IssueStatus.OPEN, true],+ [+ "UNSPECIFIED issue status with rollout",+ IssueStatus.ISSUE_STATUS_UNSPECIFIED,+ true,+ ],+ ])("%s → 'bypassed'", (_label, issueStatus, hasRollout) => {+ expect(+ getReviewBadge({+ hasIssue: true,+ issueStatus,+ hasRollout,+ approvalStatus: ApprovalStatus.PENDING,+ })+ ).toEqual({ labelKey: "common.bypassed", variant: "default" });+ });+ });++ describe("non-canceled approval mapping over the full matrix", () => {+ // For each (issueStatus, hasRollout) pair, every approval value resolves+ // to a known badge. PENDING resolves to "bypassed" iff the input is in+ // a "completed" state (hasRollout || issueStatus === DONE), otherwise+ // "under-review". Other approval values pass through the switch.+ const pending = (completed: boolean) =>+ completed+ ? { labelKey: "common.bypassed", variant: "default" as const }+ : { labelKey: "common.under-review", variant: "secondary" as const };+ const approvalCases = (completed: boolean) =>+ [+ [+ ApprovalStatus.APPROVED,+ { labelKey: "issue.table.approved", variant: "success" },+ ],+ [+ ApprovalStatus.SKIPPED,+ { labelKey: "common.skipped", variant: "default" },+ ],+ [+ ApprovalStatus.REJECTED,+ { labelKey: "common.rejected", variant: "warning" },+ ],+ [ApprovalStatus.PENDING, pending(completed)],+ [ApprovalStatus.CHECKING, undefined],+ [ApprovalStatus.APPROVAL_STATUS_UNSPECIFIED, undefined],+ [undefined, undefined],+ ] as const;++ describe.each<[IssueStatus, boolean, boolean]>([+ [IssueStatus.OPEN, false, false],+ [IssueStatus.OPEN, true, true],+ [IssueStatus.DONE, false, true],+ [IssueStatus.DONE, true, true],+ [IssueStatus.ISSUE_STATUS_UNSPECIFIED, false, false],+ [IssueStatus.ISSUE_STATUS_UNSPECIFIED, true, true],+ ])("issueStatus=%s, hasRollout=%s (completed=%s)", (issueStatus, hasRollout, completed) => {+ it.each(+ approvalCases(completed)+ )("approval=%s → %j", (approvalStatus, expected) => {+ expect(+ getReviewBadge({+ hasIssue: true,+ issueStatus,+ hasRollout,+ approvalStatus,+ })+ ).toEqual(expected);+ });+ });+ });+ });++ describe("without issue status (Plan List caller)", () => {+ it("hasRollout=true + PENDING → 'bypassed' (closes BYT-9551 plan 201)", () => {+ expect(+ getReviewBadge({+ hasIssue: true,+ issueStatus: undefined,+ hasRollout: true,+ approvalStatus: ApprovalStatus.PENDING,+ })+ ).toEqual({ labelKey: "common.bypassed", variant: "default" });+ });++ describe("residual divergence vs Plan Detail — Category A (canceled issue)", () => {+ // List cannot detect CANCELED without issue_status; renders the+ // approval-derived badge instead of "closed". Documented in spec.+ it.each<+ [ApprovalStatus, { labelKey: string; variant: string } | undefined]+ >([+ [+ ApprovalStatus.APPROVED,+ { labelKey: "issue.table.approved", variant: "success" },+ ],+ [+ ApprovalStatus.SKIPPED,+ { labelKey: "common.skipped", variant: "default" },+ ],+ [+ ApprovalStatus.REJECTED,+ { labelKey: "common.rejected", variant: "warning" },+ ],+ [+ ApprovalStatus.PENDING,+ { labelKey: "common.under-review", variant: "secondary" },+ ],+ ])("would-be-canceled, approval=%s → approval badge (not 'closed')", (approvalStatus, expected) => {+ expect(+ getReviewBadge({+ hasIssue: true,+ issueStatus: undefined,+ hasRollout: false,+ approvalStatus,+ })+ ).toEqual(expected);+ });+ });++ it("residual divergence — Category C₂ (would-be-bypassed without rollout) renders 'under-review'", () => {+ // List cannot detect "DONE && !hasRollout && PENDING" without+ // issue_status; renders "under-review" instead of "bypassed".+ expect(+ getReviewBadge({+ hasIssue: true,+ issueStatus: undefined,+ hasRollout: false,+ approvalStatus: ApprovalStatus.PENDING,+ })+ ).toEqual({ labelKey: "common.under-review", variant: "secondary" });+ });++ describe("approval status mapping without rollout", () => {+ it.each<+ [ApprovalStatus, { labelKey: string; variant: string } | undefined]+ >([+ [+ ApprovalStatus.APPROVED,+ { labelKey: "issue.table.approved", variant: "success" },+ ],+ [+ ApprovalStatus.SKIPPED,+ { labelKey: "common.skipped", variant: "default" },+ ],+ [+ ApprovalStatus.REJECTED,+ { labelKey: "common.rejected", variant: "warning" },+ ],+ [ApprovalStatus.CHECKING, undefined],+ [ApprovalStatus.APPROVAL_STATUS_UNSPECIFIED, undefined],+ ])("approval=%s", (approvalStatus, expected) => {+ expect(+ getReviewBadge({+ hasIssue: true,+ issueStatus: undefined,+ hasRollout: false,+ approvalStatus,+ })+ ).toEqual(expected);+ });+ });++ describe("approval status mapping with rollout (PENDING handled separately as 'bypassed')", () => {+ it.each<+ [ApprovalStatus, { labelKey: string; variant: string } | undefined]+ >([+ [+ ApprovalStatus.APPROVED,+ { labelKey: "issue.table.approved", variant: "success" },+ ],+ [+ ApprovalStatus.SKIPPED,+ { labelKey: "common.skipped", variant: "default" },+ ],+ [+ ApprovalStatus.REJECTED,+ { labelKey: "common.rejected", variant: "warning" },+ ],+ [ApprovalStatus.CHECKING, undefined],+ [ApprovalStatus.APPROVAL_STATUS_UNSPECIFIED, undefined],+ ])("approval=%s, hasRollout=true", (approvalStatus, expected) => {+ expect(+ getReviewBadge({+ hasIssue: true,+ issueStatus: undefined,+ hasRollout: true,+ approvalStatus,+ })+ ).toEqual(expected);+ });+ });+ });+});diff --git a/frontend/src/react/pages/project/utils/reviewBadge.ts b/frontend/src/react/pages/project/utils/reviewBadge.tsnew file mode 100644index 0000000000..f9be2c2553--- /dev/null+++ b/frontend/src/react/pages/project/utils/reviewBadge.ts@@ -0,0 +1,45 @@+import { ApprovalStatus } from "@/types/proto-es/v1/common_pb";+import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";++export interface ReviewBadgeInput {+ hasIssue: boolean;+ // Pass undefined when the caller cannot observe issue status (e.g. Plan+ // List, which reads from the Plan proto and does not have issue_status).+ issueStatus: IssueStatus | undefined;+ hasRollout: boolean;+ approvalStatus: ApprovalStatus | undefined;+}++export interface ReviewBadge {+ labelKey: string;+ variant: "default" | "secondary" | "destructive" | "warning" | "success";+}++export function getReviewBadge(+ input: ReviewBadgeInput+): ReviewBadge | undefined {+ const { hasIssue, issueStatus, hasRollout, approvalStatus } = input;+ if (!hasIssue) return undefined;+ if (issueStatus === IssueStatus.CANCELED) {+ return { labelKey: "common.closed", variant: "default" };+ }+ const completed = hasRollout || issueStatus === IssueStatus.DONE;+ if (completed && approvalStatus === ApprovalStatus.PENDING) {+ return { labelKey: "common.bypassed", variant: "default" };+ }+ switch (approvalStatus) {+ case ApprovalStatus.APPROVED:+ return { labelKey: "issue.table.approved", variant: "success" };+ case ApprovalStatus.SKIPPED:+ return { labelKey: "common.skipped", variant: "default" };+ case ApprovalStatus.REJECTED:+ return { labelKey: "common.rejected", variant: "warning" };+ case ApprovalStatus.PENDING:+ return { labelKey: "common.under-review", variant: "secondary" };+ default:+ // CHECKING and APPROVAL_STATUS_UNSPECIFIED render no badge. This+ // aligns Plan Detail (current behavior) and Plan List (which+ // previously showed a transient "Checking" pill during plan checks).+ return undefined;+ }+}