Badges.tsx 1.6 KB

123456789101112131415161718192021222324252627282930
  1. import type { SourceNotice } from "@/lib/types";
  2. const statusLabels: Record<string, string> = {
  3. merged: "已采用", parked: "暂存", discarded: "未采用", open: "尚未处置",
  4. running: "运行中", success: "已完成", completed: "已完成", partial: "部分完成",
  5. failed: "失败", stopped: "已停止", cancel: "已取消", cancle: "已取消", cancelled: "已取消", done: "已结束", passed: "通过",
  6. interrupted: "构建中断",
  7. hit: "查询命中", empty: "查询成功 · 无匹配", failure: "查询失败",
  8. "partially-passed": "部分通过", "needs-retry": "需要继续", "not-evaluated": "未整体评审", unknown: "尚无结论",
  9. legacy: "旧结构",
  10. };
  11. export function statusLabel(status?: string) {
  12. const value = (status || "unknown").toLowerCase();
  13. return statusLabels[value] || status || "尚无结论";
  14. }
  15. export function StatusBadge({ status }: { status?: string }) {
  16. const value = (status || "unknown").toLowerCase();
  17. return <span className={`statusBadge status-${value}`}>{statusLabel(status)}</span>;
  18. }
  19. export function SourceNoticeBadge({ notice }: { notice?: SourceNotice }) {
  20. // Runtime association is provenance, not a business status. Keep it in the
  21. // Inspector's technical record; only surface notices that change how a
  22. // business user should interpret the visible step.
  23. if (!notice || notice === "runtime-associated") return null;
  24. const label = notice === "process-incomplete" ? "流程未完成" : notice === "legacy-record" ? "旧版本记录" : "记录缺失";
  25. return <span className={`sourceBadge source-${notice}`}>{label}</span>;
  26. }