refactor(web): consolidate StatusBadge import path + flatten color ternary (BEN-56)#58
Open
benSepanski wants to merge 1 commit intomainfrom
Open
refactor(web): consolidate StatusBadge import path + flatten color ternary (BEN-56)#58benSepanski wants to merge 1 commit intomainfrom
benSepanski wants to merge 1 commit intomainfrom
Conversation
…rnary (BEN-56) `Dashboard.tsx` re-exported `StatusBadge` from `./shared.js` solely to support RunDetail.tsx + Search.tsx importing it from there. Two import paths for one helper is a DRY hazard. Make every consumer import from `./shared.js` and drop the re-export. While in `shared.tsx`, replace the 7-deep nested ternary in StatusBadge with a `STATUS_BADGE_COLORS` lookup map + default — same behaviour, easier to extend with a new run status.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
BEN-56 ("Code quality") asks for DRY / style cleanups. While reviewing
src/web/, theStatusBadgehelper had two consumer paths: most filesimported from
./shared.js, butRunDetail.tsxandSearch.tsximported itfrom
./Dashboard.js, which existed only becauseDashboard.tsxre-exportedit. Two paths for one helper is a DRY hazard.
TL;DR
Drop the
StatusBadgere-export fromDashboard.tsx, point all consumers at./shared.js, and replace its 7-deep nested ternary with a lookup map.Summary
src/web/Dashboard.tsx: removeexport { StatusBadge } from "./shared.js"re-export.src/web/RunDetail.tsx+src/web/Search.tsx: importStatusBadgefrom./shared.jsdirectly (matchesMetricsPanel.tsx,Dashboard.tsx).src/web/shared.tsx: replace the nested ternary inStatusBadgewith aSTATUS_BADGE_COLORS: Record<string, string>lookup + named default — same rendering, easier to extend with new run statuses.runningpulse indicator are unchanged.Demo
n/a — internal refactor, no user-visible surface.
Alternatives
that bans re-exporting from feature files. Rejected: the rule would have
exactly one trigger today; a one-line refactor is cheaper.
mapping, which is data, and the ternary form makes adding
cancelledvs.
rate_limitednon-obvious — see howcancelledand the unknownfallback shared the same arm.
StatusBadgecolor tokens into a Tailwind plugin / theme file.Deferred: the codebase doesn't have one and this PR isn't the place to
add framework infrastructure for one helper.
Test Plan
pnpm all— typecheck + fmt:check + lint + test (151) + eval (5)pnpm build:web— not run; touched no bundling, no new depsgrep -rn "from \"./Dashboard" src/web/— onlyApp.tsx(which importsDashboarditself) remains.Generated by Claude Code