Repository navigation
feat(cloud-registry): add form change events - #506
Conversation
Fire `ecc-service-form-changed` with `{ dirty }` whenever the values of
the create form change, and add the read-only property `dirty`: whether
the values differ from the empty form, `false` again after Reset or a
successful create. Apps can warn about unsaved input without depending
on the inner inputs and buttons.
Closes #462.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reset the form before `ecc-service-created`, and fire `ecc-service-form-changed` right away on resets, so that the form is not dirty while apps handle the event. Compute `dirty` from the current values, and document the property. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideAdds a read-only form dirtiness state and typed Sequence diagram for form dirtiness events and successful createsequenceDiagram
participant User
participant Form as ServiceCreate
participant App
User->>Form: formData changes
Form->>Form: updated
Form->>Form: notifyChange
Form-->>App: dispatchEvent ecc-service-form-changed { dirty: true }
User->>Form: submit form
alt successful create
Form->>Form: resetForm
Form->>Form: notifyChange
Form-->>App: dispatchEvent ecc-service-form-changed { dirty: false }
Form-->>App: dispatchEvent ecc-service-created
else failed create
Form-->>App: dispatchEvent ecc-service-create-failed
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Documentation build overview
|
Resolve the conflicts in service-create.ts: keep the form change events and dirty state, on dev's provider handling (#502). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #506 +/- ##
==========================================
+ Coverage 70.68% 70.89% +0.20%
==========================================
Files 23 23
Lines 5598 5638 +40
Branches 188 190 +2
==========================================
+ Hits 3957 3997 +40
Misses 1636 1636
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
anuragxxd
left a comment
There was a problem hiding this comment.
@uniqueg Thanks! We merged dev (with #501, #503, #505 and #530) into this branch. On a successful create, the reset still comes before ecc-service-created, and #503's reload of the type list now follows the event. Tested locally on the merged form: typing, clearing by hand, Reset, a failed and a successful create, and an environment the registry stops allowing. We will merge once CI passes. Small follow-up, as you suggested: one helper for the empty form data, now that the form PRs are in.
Summary
Closes #462.
ecc-client-elixir-cloud-registry-service-createnow tells apps whether its form has unsaved input. Apps (e.g. the Cloud Registry UI's "unsaved changes" guard) no longer have to listen to the inner inputs or find the "Reset" button by its text.ecc-service-form-changedwith{ dirty: boolean }. It is composed and bubbles, like the other events, and the React wrapper getsonEccServiceFormChanged.dirtysays whether they differ from the empty form. It isfalseagain after "Reset" and after a successful create, and when the user clears the fields by hand.dirty. It always holds the current value.ecc-service-created. On a successful create, the form now resets before it firesecc-service-created. Sodirtyis alreadyfalsewhile apps handle that event (e.g. a redirect isn't blocked by a guard). The event'sserviceDatais unchanged.dirtyis in the properties table, and the event is in the events table, with its own section.The other form PRs (#501, #503, #505, and #453's) change the same file. Each one is branched from
dev(#453's stacks on #505), so they can be reviewed in any order; I'll resolve the merge conflicts after each merge. When #503 (type picker) merges, its type choice will be part of thedirtysnapshot too.Verification
npm run lint(pre-commit hook, all packages) and the build of@elixir-cloud/cloud-registrypass. The ESLint warnings are the ones already ondev.cc-forms-checks/check-462-change-events.mjs(withharness.mjs, outside the repo). All checks pass. They cover:dirty: true, once per change;dirty: false;dirty: false, and fires nothing on an empty form;dirty: false, already inside theecc-service-createdhandler, with no duplicate event afterwards;dirtyis current right away (synchronously).Declined review findings
resetForm()duplicate it ondev, and the other open form PRs change both. A comment now documents the snapshot's dependency on it; I'd unify it once the form PRs are in.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Expose unsaved form state changes from the cloud registry service creation component.
New Features:
dirtyproperty and a bubblingecc-service-form-changedevent with React support.Bug Fixes:
ecc-service-createdso consumers observe a clean form during success handling.Documentation: