Repository navigation
feat(variables): [QOV-2445] create an override from a conflict and show which scope wins - #3141
Conversation
|
Qovery can create a Preview Environment for this PR.
This comment has been generated from Qovery AI 🤖.
|
|
View your CI Pipeline Execution ↗ for commit ba8bb48
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
All reported issues were addressed across 10 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## staging #3141 +/- ##
============================================
- Coverage 88.10% 53.85% -34.26%
============================================
Files 15 1435 +1420
Lines 328 32361 +32033
Branches 84 9663 +9579
============================================
+ Hits 289 17427 +17138
- Misses 28 12224 +12196
- Partials 11 2710 +2699
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ec45943 to
7ba6299
Compare
When POST /variable returns 409 and the existing variable sits at a strictly higher scope, is a value, file or override, and has the same secret kind, the conflict toast offers "Create an override". It opens the override modal with the existing variable as parent and the value and scope the user typed. Other conflicts keep the link to the existing variable.
A variable overridden at a lower scope is muted and labelled "Overridden in <scope>"; the override is labelled "Overrides <scope>". Both labels scroll to the other row.
A 409 can also come from a mount path clash with a variable of another key; that case now keeps the link to the existing variable instead of offering an override of an unrelated variable. The override modal replaced the creation modal at the same tree position, so it reused the creation form state (file format, mount path, interpolation toggle). A distinct key now forces a remount so the override form starts from the parent variable.
…e variable kind - Detect the 409 with isHttpStatus instead of the code the interceptor copies from the body. - Only offer an override when the request and the existing variable are the same kind (file or value). An existing override only carries its kind through the variable it overrides, which the 409 body does not include, so it keeps the link. - Clear the unsaved-changes guard armed by the creation form before swapping in the override form.
7ba6299 to
c102433
Compare
Use VariableConflictResponse and ExistingVariableResponse from qovery-typescript-axios instead of the local ConflictingVariableResponse type. variable_type and is_secret are now always sent, so the checks for an older API go away. An existing override still falls back to the link: the body doesn't include the variable it overrides.
Jira: QOV-2445
Related changes:
Two changes that make variable inheritance easier to follow. We keep the explicit OVERRIDE type and fix the UX around it.
"Create an override" on a creation conflict
When
POST /variablereturns a 409 status, the toast now offers Create an override if the existing variable:VALUEorFILEvariable of the same kind as the request (a file when the request has a mount path, a value otherwise),is_secretas the request.Clicking it swaps the creation modal for the existing override modal, with the existing variable as parent and the value and scope the user had typed. Every other conflict keeps the "Go to the conflicting variable" link. That includes an existing
OVERRIDE: q-core stores overrides without a mount path and the 409 body doesn't include the overridden variable, so the Console can't tell a file override from a value override. The toast description is the API'sdetail, which says which scope holds the existing variable.The rules mirror q-core's override validation and live in
@qovery/domains/variables/util(canOverrideConflictingVariable). The 409 body is typed with the generatedVariableConflictResponseandExistingVariableResponse; there is no hand-written type left.useCreateVariable()takes an optionalonCreateOverride; the other callers (service and job creation flows, external secrets tab) don't pass it and keep today's behavior.Dependencies, all merged: q-core!4207 sends
variable_type,is_secretandmount_pathin the 409 body and is deployed to production (v1.772.0). qovery-openapi-spec#1237 addsoverride_if_existsand #1248 describes the 409 body.qovery-typescript-axiosis bumped to 1.1.1030.Provenance in the service variable list
The service list already returned rows from every visible scope, with an OVERRIDE badge and the parent key under the override. Nothing marked the parent row, so you couldn't tell which value applied. Now:
Both labels scroll to the other row.
Testing
yarn nx test domains-variables-util --maxWorkers=2: 18 passed.yarn nx test domains-variables-feature --maxWorkers=2: 80 passed. New hook spec covers the eligible conflict, same scope, another key (mount path clash), an existing override, different secret kind, a body without location ids, no handler, noexisting_variable, and non-409 errors. Modal and list specs cover the prefill, the modal swap (fresh form, guard cleared), and both labels.nx run-many -t linton both variables libs: clean. Prettier on the changed files: clean.Summary by cubic
Makes variable inheritance easier to follow by converting eligible creation conflicts into override creation and by labeling which scope wins in the variable list.
is_secret, and is the same kind (VALUE/FILE, or anOVERRIDEwhose overridden variable reveals the kind) as the request. Other conflicts—including a mount path clash with another key—keep the link to the existing variable.onCreateOverridehandler is passed, so otheruseCreateVariable()callers keep today's behavior.VariableConflictResponse/ExistingVariableResponse), wherevariable_typeandis_secretare always sent; the older-API fallbacks are gone. Bumpsqovery-typescript-axiosto 1.1.1030.Written for commit ba8bb48. Summary will update on new commits.