Skip to content

feat(cloud-registry): add form change events - #506

Merged
anuragxxd merged 5 commits into
devfrom
feat/create-form-change-events
Nov 1, 2026
Merged

anuragxxd merged 5 commits into
devfrom
feat/create-form-change-events

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #462.

ecc-client-elixir-cloud-registry-service-create now 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.

  • New event ecc-service-form-changed with { dirty: boolean }. It is composed and bubbles, like the other events, and the React wrapper gets onEccServiceFormChanged.
    • It fires whenever the form's values change.
    • dirty says whether they differ from the empty form. It is false again after "Reset" and after a successful create, and when the user clears the fields by hand.
  • New read-only property dirty. It always holds the current value.
  • Reset before ecc-service-created. On a successful create, the form now resets before it fires ecc-service-created. So dirty is already false while apps handle that event (e.g. a redirect isn't blocked by a guard). The event's serviceData is unchanged.
  • Docs: dirty is 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 the dirty snapshot too.

Verification

  • npm run lint (pre-commit hook, all packages) and the build of @elixir-cloud/cloud-registry pass. The ESLint warnings are the ones already on dev.
  • The package has no test setup yet; tests are blocked on test: set up unit, integration and e2e tests #484. I checked the behaviour in Chromium with a Playwright script against the built package and a mock provider: cc-forms-checks/check-462-change-events.mjs (with harness.mjs, outside the repo). All checks pass. They cover:
    • no event on load;
    • typing fires dirty: true, once per change;
    • clearing the fields by hand gives dirty: false;
    • Reset fires dirty: false, and fires nothing on an empty form;
    • a successful create gives dirty: false, already inside the ecc-service-created handler, with no duplicate event afterwards;
    • a failed create stays dirty;
    • dirty is current right away (synchronously).
  • CI: all checks pass (Conflict markers, Lint, Test on Node 22 and 24, PR title, Read the Docs).

Declined review findings

  • One helper for the empty form data (medium). The initialiser and resetForm() duplicate it on dev, 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.
  • Tests in the repo. Blocked on test: set up unit, integration and e2e tests #484.

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Expose unsaved form state changes from the cloud registry service creation component.

New Features:

  • Add form dirty-state tracking to the cloud registry service creation component through a read-only dirty property and a bubbling ecc-service-form-changed event with React support.

Bug Fixes:

  • Reset the form before emitting ecc-service-created so consumers observe a clean form during success handling.

Documentation:

  • Document the new dirty-state property and form-change event with React and JavaScript usage examples.

uniqueg and others added 2 commits October 28, 2026 23:21
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]>
@sourcery-ai

sourcery-ai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds a read-only form dirtiness state and typed ecc-service-form-changed event to the Cloud Registry service-create component, including deduplicated change detection, reset-before-success-event behavior, and React/API documentation.

Sequence diagram for form dirtiness events and successful create

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Track form dirtiness and emit a bubbling, composed change event when values transition.
  • Add a read-only dirty getter comparing current form data with the empty-form snapshot.
  • Deduplicate notifications using serialized form-value snapshots and emit { dirty } after updates and resets.
  • Define and export the typed global event handler mapping for ecc-service-form-changed.
  • Ensure reset and successful-create transitions report clean state without duplicate notifications.
packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts
packages/ecc-client-elixir-cloud-registry/src/events/ecc-service-form-changed.ts
packages/ecc-client-elixir-cloud-registry/src/events/index.ts
Update Cloud Registry service-create documentation with the new dirtiness API and event usage.
  • Document the read-only dirty property and ecc-service-form-changed event in API tables.
  • Add React and JavaScript examples for consuming the event and guarding navigation.
  • Document that successful creation resets dirtiness before ecc-service-created is dispatched.
apps/documentation/pages/docs/cloud-registry/components/service-create.mdx

Assessment against linked issues

Issue Objective Addressed Explanation
#462 Expose whether the service-create form differs from its empty state through a read-only dirty property and a composed, bubbling ecc-service-form-changed event carrying { dirty: boolean }. ✅
#462 Keep the dirty state and change notifications accurate when users edit or clear fields, reset the form, or successfully create a service. ✅
#462 Document the property and event so host applications can track unsaved form input without inspecting the component’s internals. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@read-the-docs-community

read-the-docs-community Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

@uniqueg
uniqueg marked this pull request as ready for review October 28, 2026 23:54
@uniqueg
uniqueg requested a review from anuragxxd as a code owner October 28, 2026 23:54

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

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

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.89%. Comparing base (b215404) to head (ad6ae9a).
⚠️ Report is 1 commits behind head on dev.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@anuragxxd anuragxxd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@anuragxxd
anuragxxd merged commit c735681 into dev Nov 1, 2026
18 of 19 checks passed
@anuragxxd
anuragxxd deleted the feat/create-form-change-events branch November 1, 2026 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cloud-registry): form change events

2 participants