Skip to content

refactor: add JobStatus value object replacing raw string comparisons#3046

Open
eloycoto wants to merge 1 commit intoredhat-developer:mainfrom
eloycoto:CleanupPR2
Open

refactor: add JobStatus value object replacing raw string comparisons#3046
eloycoto wants to merge 1 commit intoredhat-developer:mainfrom
eloycoto:CleanupPR2

Conversation

@eloycoto
Copy link
Copy Markdown
Contributor

@eloycoto eloycoto commented May 5, 2026

Replace a few raw string status checks across x2a-common, x2a-node, x2a-backend, and x2a frontend with a flyweight JobStatus class following the Phase pattern from PR #3002.

  • Add JobStatus class with predicates: isActive(), isFinished(), isPending(), isRunning(), isSuccess(), isError(), isCancelled()
  • Replace ['pending','running'].includes() with isActive()
  • Replace 3-way || chains with isFinished()
  • Keep raw strings for DB writes and API responses (data, not logic)

@rhdh-gh-app
Copy link
Copy Markdown

rhdh-gh-app Bot commented May 5, 2026

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @red-hat-developer-hub/backstage-plugin-x2a-backend
  • @red-hat-developer-hub/backstage-plugin-x2a-common
  • @red-hat-developer-hub/backstage-plugin-x2a-node
  • @red-hat-developer-hub/backstage-plugin-x2a

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-x2a-backend workspaces/x2a/plugins/x2a-backend none v1.4.2
@red-hat-developer-hub/backstage-plugin-x2a-common workspaces/x2a/plugins/x2a-common none v1.2.1
@red-hat-developer-hub/backstage-plugin-x2a-node workspaces/x2a/plugins/x2a-node none v0.2.2
@red-hat-developer-hub/backstage-plugin-x2a workspaces/x2a/plugins/x2a none v1.2.2

Replace a few raw string status checks across x2a-common, x2a-node, x2a-backend, and x2a frontend with a flyweight JobStatus class following the Phase pattern from PR redhat-developer#3002.

- Add JobStatus class with predicates: isActive(), isFinished(), isPending(), isRunning(), isSuccess(), isError(), isCancelled()
- Replace ['pending','running'].includes() with isActive()
- Replace 3-way || chains with isFinished()
- Keep raw strings for DB writes and API responses (data, not logic)

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
@eloycoto eloycoto requested a review from a team as a code owner May 5, 2026 15:29
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 5, 2026

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

❌ Patch coverage is 97.75281% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.78%. Comparing base (15f78e7) to head (c79feaf).
⚠️ Report is 45 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3046      +/-   ##
==========================================
+ Coverage   60.75%   60.78%   +0.02%     
==========================================
  Files        2067     2068       +1     
  Lines       63769    63817      +48     
  Branches    16613    16619       +6     
==========================================
+ Hits        38742    38790      +48     
  Misses      23783    23783              
  Partials     1244     1244              
Flag Coverage Δ *Carryforward flag
adoption-insights 83.58% <ø> (ø) Carriedforward from 15f78e7
ai-integrations 70.03% <ø> (ø) Carriedforward from 15f78e7
app-defaults 69.60% <ø> (ø) Carriedforward from 15f78e7
augment 69.36% <ø> (ø) Carriedforward from 15f78e7
bulk-import 72.43% <ø> (ø) Carriedforward from 15f78e7
cost-management 16.49% <ø> (ø) Carriedforward from 15f78e7
dcm 32.85% <ø> (ø) Carriedforward from 15f78e7
extensions 61.42% <ø> (ø) Carriedforward from 15f78e7
global-floating-action-button 73.75% <ø> (ø) Carriedforward from 15f78e7
global-header 61.62% <ø> (ø) Carriedforward from 15f78e7
homepage 50.84% <ø> (ø) Carriedforward from 15f78e7
konflux 91.01% <ø> (ø) Carriedforward from 15f78e7
lightspeed 69.64% <ø> (ø) Carriedforward from 15f78e7
mcp-integrations 81.59% <ø> (ø) Carriedforward from 15f78e7
orchestrator 33.07% <ø> (ø) Carriedforward from 15f78e7
quickstart 62.64% <ø> (ø) Carriedforward from 15f78e7
sandbox 79.56% <ø> (ø) Carriedforward from 15f78e7
scorecard 83.61% <ø> (ø) Carriedforward from 15f78e7
theme 64.54% <ø> (ø) Carriedforward from 15f78e7
translations 8.49% <ø> (ø) Carriedforward from 15f78e7
x2a 82.31% <97.75%> (+0.21%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 15f78e7...c79feaf. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant