outcome.tsx
This file
Path
apps/web/src/features/shared/outcome.tsx
203 lines · 5.2 KiB · TypeScript
Last changed by
Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571
History of this fileTake it
The walk stopped after 200 commits: lines older than 678c8b8 point at it.
Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 1why, one step back1import { Outcome, StageName } from "@repo/protocol/domain/outcome";Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 2why, one step back2import type { Handle, ProjectName } from "@repo/protocol/ids";Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 3why, one step back3Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 4–5why, one step back4import { StateMarkIcon } from "./marks.tsx";5import type { StateMark } from "./marks.tsx";Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 6why, one step back6import { RefusalView } from "./refusal.tsx";Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 7–8why, one step back7import { StatusLine, stageNames } from "./status-line.tsx";8import type { StatusSubject } from "./status-line.tsx";Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 9why, one step back9Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 10–31why, one step back10export const OutcomeView = ({11 claimant,12 outcome,13 project,14 size = "body",15 stage,16 stamp = false,17}: {18 readonly outcome: Outcome;19 readonly claimant?: Handle;20 readonly stage?: StageName;21 readonly project?: ProjectName;22 readonly size?: "body" | "title";23 readonly stamp?: boolean;24}) => {25 const subject: StatusSubject = {26 claimant,27 kind: "answer",28 outcome,29 project,30 stage,31 };Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 32–34why, one step back3233 if (Outcome.isAnyOf(["Refused"])(outcome)) {34 return (Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 35–40why, one step back35 <div36 className="flex flex-col gap-3"37 data-outcome={outcome._tag}38 data-state="final"39 >40 <StatusLine command={false} size={size} subject={subject} />Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 41–46why, one step back41 <RefusalView refusals={outcome.refusals} />42 </div>43 );44 }4546 return (Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 47why, one step back47 <divMerge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 48why, one step back48 data-outcome={outcome._tag}Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 49why, one step back49 data-state={Outcome.isAnyOf(["Landed"])(outcome) ? "final" : "waiting"}Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 50why, one step back50 >Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 51–54why, one step back51 <StatusLine52 size={size}53 stamp={stamp && Outcome.isAnyOf(["Landed"])(outcome)}54 subject={subject}Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 55why, one step back55 />Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 56why, one step back56 </div>Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 57–66why, one step back57 );58};5960export type StageState =61 | "passed"62 | "current"63 | "refused"64 | "pending"65 | "skipped";66Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 67–71why, one step back67export interface StageHolds {68 readonly decided: boolean;69 readonly heldBack: boolean;70}71Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 72why, one step back72/**Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571
lines 73–74why, one step back73 * A passing verdict reaches the maintainer stage whether or not a maintainer took74 * part, so with `holds` a held-back or maintainer stage it never needed reads notMerge build/comments-web-features into mainoscabrielbefore adoption74bfc72
line 75why, one step back75 * needed.Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 76–78why, one step back76 */77export const stageStates = (78 reached: StageName,Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 79–80why, one step back79 outcome: Outcome,80 holds?: StageHoldsMerge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 81–96why, one step back81): readonly (readonly [StageName, StageState])[] => {82 const at = StageName.literals.indexOf(reached);8384 const atReached = Outcome.match<StageState>(outcome, {85 AwaitingDecision: () => "current",86 AwaitingFinish: () => "current",87 Checking: () => "current",88 Landed: () => "passed",89 Refused: () => "refused",90 WaitingOnParent: () => "passed",91 });9293 const after: StageState = Outcome.isAnyOf(["Landed"])(outcome)94 ? "skipped"95 : "pending";96Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 97–103why, one step back97 const needed = (stage: StageName) =>98 holds === undefined ||99 (stage === "heldBack"100 ? holds.heldBack101 : stage !== "human" || holds.decided);102103 const reachedAs = (index: number): StageState => {Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 104why, one step back104 if (index < at) {Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 105why, one step back105 return "passed";Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 106–107why, one step back106 }107Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 108–117why, one step back108 return index === at ? atReached : after;109 };110111 return StageName.literals.map((stage, index) => {112 const state = reachedAs(index);113114 return [115 stage,116 state === "passed" && !needed(stage) ? "skipped" : state,117 ] as const;Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 118–120why, one step back118 });119};120Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 121–134why, one step back121const cellMarks = (outcome: Outcome) =>122 ({123 current: {124 mark: Outcome.isAnyOf(["Checking"])(outcome) ? "now" : "waiting",125 word: "now",126 },127 passed: { mark: "passed", word: "passed" },128 pending: { mark: "notYet", word: "not yet" },129 refused: { mark: "refused", word: "refused" },130 skipped: { mark: "notNeeded", word: "not needed" },131 }) as const satisfies Record<132 StageState,133 { readonly mark: StateMark; readonly word: string }134 >;Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 135why, one step back135Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 136–143why, one step back136const wordTones = {137 current: "",138 passed: "text-landed",139 pending: "text-muted-foreground",140 refused: "text-refused",141 skipped: "text-muted-foreground",142} as const satisfies Record<StageState, string>;143Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 144why, one step back144export const StageStrip = ({Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 145why, one step back145 holds,Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 146–148why, one step back146 outcome,147 stage,148}: {Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 149why, one step back149 readonly holds?: StageHolds;Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 150–152why, one step back150 readonly outcome: Outcome;151 readonly stage: StageName;152}) => {Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 153–154why, one step back153 const marks = cellMarks(outcome);154Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 155–161why, one step back155 const currentTone = Outcome.isAnyOf(["Checking"])(outcome)156 ? "text-checking"157 : "text-waiting";158159 return (160 <ol161 aria-label="Gate stages"Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 162why, one step back162 className="border-rule tablet:grid-cols-7 grid grid-cols-4 border-t border-l"Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 163why, one step back163 >Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 164–173why, one step back164 {stageStates(stage, outcome, holds).map(([name, state]) => (165 <li166 aria-current={state === "current" ? "step" : undefined}167 className={`border-rule flex min-w-0 flex-col gap-0.5 border-r border-b px-2 py-1.5 ${168 state === "current" ? "bg-surface" : ""169 }`}170 data-stage={name}171 data-state={state}172 key={name}173 >Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 174–180why, one step back174 <span className="text-label flex min-w-0 items-start gap-1.5">175 <StateMarkIcon176 className="mt-px"177 mark={marks[state].mark}178 size="sm"179 />180 {/* Four cells a row on a phone: a long label wraps rather than losing its end. */}Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 181why, one step back181 <spanMerge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 182why, one step back182 className={`min-w-0 break-words ${Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 183–186why, one step back183 state === "pending" || state === "skipped"184 ? "text-muted-foreground"185 : "text-foreground"186 }`}Finish the Control room: every page passes axe and a keyboard walk in both schemesoscabrielbefore adoption3fd50a5
line 187why, one step back187 data-term=""Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 188–189why, one step back188 >189 {stageNames(name).label}Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 190why, one step back190 </span>Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 191–200why, one step back191 </span>192 <span193 className={`text-label pl-5 font-normal ${194 state === "current" ? currentTone : wordTones[state]195 }`}196 >197 {marks[state].word}198 </span>199 </li>200 ))}Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 201–203why, one step back201 </ol>202 );203};