Repository navigation
fix(settings): keep propagated default coverage on save and reject an empty field - #538
Conversation
… empty field Saving the Settings page PUT every service row with the coverage loaded before the save, overwriting the value the backend had just propagated from a changed default_coverage. Send the new default unless the user edited that SP card, refresh the cached rows after a save, and reject an empty global coverage field instead of saving 0. Refs #522
|
@coderabbitai full review |
|
|
Warning Review limit reached
This review includes 2 billable files and costs up to $0.50.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 2 minutes for your next included review. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Your 54 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (2)
Comment |
What
Fixes the Settings save reverting backend coverage propagation (#500), and an empty global coverage field saving as 0.
Why
saveGlobalSettingsPUT each service row with the coverage cached at load time (or the SP card's DOM value).updateServiceConfigoverlays that coverage unconditionally, so it overwrote the value the backend had just copied from a changeddefault_coverage.Number('')is 0, so a cleared field passed validation.How
frontend/src/settings.ts: decide "global coverage changed" and "SP card edited" from the existingsavedSnapshotdirty tracking instead of a separate loaded-default variable. When the global default changed, send the new default for every service row; an SP card value overrides it only when the user edited it on the card. Once the global PUT succeeds, the snapshot entry and the cached rows are refreshed (the backend has propagated the default), and each SP card's snapshot entry is refreshed as its row PUT succeeds, so a retry after a partial failure keeps saved SP edits and does not resend stale values. Reject an empty global coverage field with the existing error toast.propagateChangedDefaults, which overwrites coverage on allservice_configsrows.frontend/src/__tests__/settings.test.ts: global 50 -> 0 propagates to ec2 and SP compute; an SP card edit in the same save wins; second save does not revert; a saved SP edit survives a further save and does not shield the card from a later global change; partial failure then retry keeps the SP card at its saved value; a further global change after a partial failure reaches the SP card; empty field is rejected. The tests mock all PUTs to succeed except the partial-failure tests.Verified
The new tests fail on the pre-fix source, and each snapshot/cache refresh removed in turn fails at least one test. Full frontend jest: 92 suites, 3048 passed, 1 skipped. tsc clean, eslint 0 errors.
Not in this PR
The same
Number('')pattern infrontend/src/plans.ts:1345(plan coverage field) andwireInlineRangeValidationshowing no inline error for an empty value. #522 stays open for those.Refs #522