Skip to content

feat(cloud-registry): pick service types from list - #503

Merged
anuragxxd merged 7 commits into
devfrom
feat/create-form-type-picker
Nov 1, 2026
Merged

anuragxxd merged 7 commits into
devfrom
feat/create-form-type-picker

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #456.

ecc-client-elixir-cloud-registry-service-create now asks for the service type as one choice from the registered types (GET /services/types), labelled group · artifact · version (e.g. org.ga4gh · tes · 1.1.0). Before, it had three free-text fields, and typos created new types.

  • New property allowNewType (attribute allow-new-type, default true, so new types stay possible as before):
    • When it's set, the list ends with "Add new service type", which shows the three fields "Type Group", "Type Artifact" and "Type Version" (all required; the group is pre-filled with org.ga4gh, as before).
    • Without it, only listed types can be chosen.
    • Apps set it from may_add_service_types of Cloud Registry's GET /me (false in deployments with custom.access_control.service_types: controlled, except for admins).
    • As an attribute, allow-new-type="false" turns it off (same converter as admin in feat(cloud-registry): add admin option to form #501).
  • No types registered: the new-type fields show right away, or, if adding is off, a hint that an admin has to add one (the form can't be submitted then).
  • Loading: while the types load, the list says so. If loading fails, the form shows a hint and still offers "Add new service type" (if allowed). It no longer pretends that no types exist.
  • After a create: the list reloads, so that a type added with the service shows up. A failed reload doesn't fire ecc-service-create-failed after the success event.
  • Robustness: outdated answers are ignored. A chosen type that is no longer listed is dropped. Turning allowNewType off discards a new type entered so far.
  • Docs: allowNewType in the properties table, plus a section on it.

The other form PRs (#501 admin fields, #461 environments, #453 validation, #462 change events) change the same file. Each one is branched from dev, so they can be reviewed in any order; I'll resolve the merge conflicts after each merge.

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-456-type-picker.mjs (with harness.mjs, outside the repo; I can add them or attach them). All checks pass. They cover:
    • labels and order;
    • sending a listed type or a new type;
    • the button disabled until a type is complete;
    • allowNewType off, also at runtime, and the attribute;
    • an empty registry, with and without adding;
    • a failed load;
    • re-choosing "Add new" (the input is kept);
    • a stale choice after a reload;
    • the reload after a create, with no failure event.
  • CI: all checks pass (Conflict markers, Lint, Test on Node 22 and 24, PR title, Read the Docs).

Declined review findings

  • Performance with many types (medium): ecc-utils-design-select polls every 100 ms per item, and the list has no search, so very long type lists get slow. That belongs to the design package (an event-driven select or a combobox) and is out of scope here. I can open an issue.
  • Lifecycle of baseUrl/provider (firstUpdated/updated): that's fix(cloud-registry): react to provider changes #448, in a separate PR.
  • A DEFAULT_TYPE constant and folding typeChoice into one "effective choice" getter (low): these would also touch the duplicated initial form data and resetForm, which predate this PR.
  • 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

Add registered service type selection to the Cloud Registry service creation form while preserving controlled support for creating new types.

New Features:

  • Replace free-text service type entry with a registered service type selector, while allowing users to add a new type when permitted.
  • Add the allowNewType property and corresponding allow-new-type attribute to control whether new service types may be entered.

Bug Fixes:

  • Handle service type loading failures, stale responses, unavailable selections, empty registries, and post-creation type list updates without misreporting successful creates.

Enhancements:

  • Improve service type selection validation and user feedback for loading, unavailable, and incomplete type choices.

Documentation:

  • Document the allowNewType property, supported behavior, and usage examples.

Tests:

  • Expand service creation tests to cover registered and new service type selection and reloading after creation.

uniqueg and others added 3 commits October 28, 2026 20:17
Replace the three free-text type fields of the create form with one
list of the registered types (`GET /services/types`), labelled
`group · artifact · version`. The new property `allowNewType`
(attribute `allow-new-type`, default `true`) adds "Add new service
type", which shows required fields for a new type; without it, only
listed types can be chosen. If no types are registered, the new-type
fields show right away (or a hint, if adding is off). The list reloads
after a service is created.

Closes #456.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Track whether the types are loading, loaded or failed: show the
new-type fields or the "none registered" hint only for a loaded, empty
list, and a hint if loading failed. Ignore outdated answers, drop a
chosen type that is no longer listed, keep the entered type when "Add
new service type" is chosen again, and fire no failure event when the
reload after a create fails. Accept `false` in any case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Clear an implicit new type when adding types is turned off, keep a new
type being entered when types show up, and drop the list of a previous
registry when loading fails.

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

The service creation form now loads registered Cloud Registry service types into a labeled picker, optionally permits adding a new type through validated fields, handles asynchronous loading and refresh edge cases, and documents the new allowNewType configuration.

Sequence diagram for service type loading and creation refresh

sequenceDiagram
    participant Form as ServiceCreateForm
    participant Provider as CloudRegistryProvider
    participant Registry as CloudRegistry

    Form->>Provider: loadServiceTypes()
    Provider->>Registry: getServiceTypes()
    Registry-->>Provider: service types
    Provider-->>Form: serviceTypes
    Form->>Form: selectType(choice)
    Form->>Provider: createService(formData)
    Provider->>Registry: createService(formData)
    Registry-->>Provider: service created
    Provider-->>Form: success
    Form->>Provider: loadServiceTypes(false)
    Provider->>Registry: getServiceTypes()
    Registry-->>Provider: refreshed service types
    Provider-->>Form: serviceTypes
Loading

State diagram for service type loading and selection

stateDiagram-v2
    [*] --> Loading
    Loading --> Loaded: getServiceTypes()
    Loading --> Failed: getServiceTypes() throws
    Loaded --> ListedChoice: selectType(listed type)
    Loaded --> NewType: selectType(NEW_TYPE)
    Loaded --> NewType: no registered types and allowNewType
    ListedChoice --> Loaded: serviceTypes reload drops stale choice
    NewType --> Empty: allowNewType disabled
    NewType --> Loaded: clearType()
    Failed --> NewType: allowNewType
    Failed --> Failed: allowNewType disabled
    ListedChoice --> Loading: loadServiceTypes()
    NewType --> Loading: loadServiceTypes()
    Loading --> Loaded: loadServiceTypes(false) succeeds
    Loading --> Failed: loadServiceTypes(false) fails
Loading

Flow diagram for service type selection

flowchart TD
    A[Load registered service types] --> B{Types available?}
    B -->|Yes| C[Choose listed type]
    B -->|No| D{allowNewType enabled?}
    C --> E[Populate group artifact version]
    D -->|Yes| F[Choose Add new service type]
    D -->|No| G[Show admin hint and disable submission]
    F --> H[Enter required group artifact version]
    E --> I{typeComplete}
    H --> I
    I -->|Yes| J[Create service]
    I -->|No| K[Keep Create Service disabled]
Loading

File-Level Changes

Change Details Files
Replace free-text service type entry with a registry-backed choice and optional new-type flow.
  • Fetch and display registered types using group · artifact · version labels.
  • Add an “Add new service type” option that reveals required group, artifact, and version fields.
  • Validate submissions based on either a selected registered type or a complete new type.
  • Handle empty, loading, failed, stale, and no-longer-listed type states.
packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts
Add configurable control over whether users may create new service types.
  • Introduce allowNewType, defaulting to true for compatibility.
  • Support case-insensitive allow-new-type="false" attribute conversion.
  • Discard in-progress new-type data when the option is disabled at runtime.
packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts
Refresh service types after successful creation without misreporting reload failures.
  • Reload the type list after creation so newly registered types become selectable.
  • Ignore outdated asynchronous responses.
  • Keep the existing list and avoid emitting a creation-failed event when a post-create reload fails.
packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts
Document the new service-type selection behavior and property.
  • Add allowNewType to the property reference with its default and purpose.
  • Document registered-type selection, permission integration, empty/error states, and HTML/React usage examples.
apps/documentation/pages/docs/cloud-registry/components/service-create.mdx

Assessment against linked issues

Issue Objective Addressed Explanation
#456 Replace the three always-visible free-text service-type fields with a single choice from registered types, labelled as group · artifact · version, and submit the selected complete type. ✅
#456 Allow entry of a new service type only when allow-new-type permits it (defaulting to true for compatibility), requiring group, artifact, and version; when adding is disabled, restrict users to registered types. ✅

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 21:43
@uniqueg
uniqueg requested a review from anuragxxd as a code owner October 28, 2026 21:43

@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 found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts" line_range="137" />
<code_context>
+    // a reload after a create keeps the list; other loads start over
+    if (reportErrors) this.typesStatus = "loading";
     try {
-      this.serviceTypes = await this._provider.getServiceTypes();
+      const types = await this._provider.getServiceTypes();
+      if (request !== this.typesRequest) return;
</code_context>
<issue_to_address>
**Stalled type request blocks selection**

When `GET /services/types` stalls without settling, `loadServiceTypes()` waits on `getServiceTypes()` without a deadline, so a request that never settles leaves `typesStatus` at `loading`; with `allowNewType` disabled, users have no listed type to select and cannot submit until the request completes or the page is refreshed.

Give the type-list request a finite timeout and handle timeout as a load failure so the UI can report the problem and recover.
</issue_to_address>

### Comment 2
<location path="packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts" line_range="181" />
<code_context>
+      changedProperties.has("serviceTypes") &&
+      this.allowNewType &&
+      this.typeChoice === "" &&
+      (this.formData.type.artifact || this.formData.type.version)
+    ) {
+      this.typeChoice = NEW_TYPE;
</code_context>
<issue_to_address>
**Group-only drafts disappear**

When the user edits only the group and the type list changes, `willUpdate` does not recognize the group-only edit as an in-progress new type, so `typeChoice` stays empty and `newType` becomes false when registered types are present; the new-type fields disappear, and choosing “Add new service type” resets the user's group.

Treat a changed group field as an in-progress new type when updating `typeChoice`.

Also at `packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:182`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 2 findings to address first, and if the form submits the wrong type, the registry will retain a service record with that type after this change is reverted. The mistake is limited to the services created and can be corrected by updating or removing those records.

Blocking findings: packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:137, packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts:181


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

Treat a changed group as a new type being entered, so that it stays
when types show up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the conflicts in service-create.ts: keep the type picker and
its type status and reloads, on dev's provider handling (#502) and
problem details (#504); drop the duplicate typesRequest field.

Adapt dev's new service-create tests to the type picker: fillForm
chooses "Add new service type", and the provider tests expect the
reload of the types after a create.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.35616% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.75%. Comparing base (ee4a4fc) to head (33434bb).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
...ry/src/components/service-create/service-create.ts 88.35% 32 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #503      +/-   ##
==========================================
+ Coverage   70.07%   70.75%   +0.68%     
==========================================
  Files          23       23              
  Lines        5240     5448     +208     
  Branches      134      164      +30     
==========================================
+ Hits         3672     3855     +183     
- Misses       1566     1589      +23     
- Partials        2        4       +2     

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

# Conflicts:
#	apps/documentation/pages/docs/cloud-registry/components/service-create.mdx
#	packages/ecc-client-elixir-cloud-registry/src/components/service-create/service-create.ts
"Add new service type" was the last entry of the type list and looked
like a registered type, so long lists hid it. It now comes first, with
a plus icon and a separator before the registered types.
@anuragxxd

Copy link
Copy Markdown
Member

@uniqueg We merged dev (with #501) into this branch and resolved the conflicts. admin and allowNewType now share one trueUnlessFalse converter. We also moved "Add new service type" to the top of the list, with a plus icon and a separator before the registered types, so long lists no longer hide it. Three new tests cover the order. We will merge once CI passes.

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

Linked issues

#456 feat(cloud-registry): pick service types from a list · 3 of 4 met

# Requirement Status Notes
1 Offer registered service types from GET /services/types as one choice labelled group · artifact · version. ✅ Met The component loads the types and renders each with the requested label.
2 Add allow-new-type, defaulting to true; when enabled, offer “Add new service type” with required fields. 🟡 Partly met The property defaults to true and the option reveals the required fields, but the option appears first rather than at the end of the list as requested.
3 Without allow-new-type, let users choose only listed types. ✅ Met When adding is disabled, the new-type option and fields are hidden; the docs show the property bound to may_add_service_types from GET /me.
4 Users can submit a complete service type and add a new one only when the app allows it. ✅ Met Submission requires a complete listed or new type, and new types are gated by allowNewType.

@anuragxxd
anuragxxd merged commit 188d7d3 into dev Nov 1, 2026
19 checks passed
@anuragxxd
anuragxxd deleted the feat/create-form-type-picker branch November 1, 2026 05:47
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): pick service types from a list

2 participants