Repository navigation
feat(service-registry): add list filters and pages - #575
Conversation
The services list now filters the loaded services by type, organization and environment, searches them locally (including the service URL) instead of fetching the list again, and pages them with a page-size property. A rowActions render hook lets apps add actions to each row without knowing the service IDs in advance, and clicking a row selects its service. Adds the package's first tests and its test script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A filter selected before it was hidden (filter turned off, or no service with an environment after a reload) kept narrowing the list with no way to clear it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Ignore the search query while the search field is hidden, and show the query that applies when it is shown again. - Ignore filter values that are no longer among the options (e.g. after a reload from another registry). - Derive the filter options once per change of the services, in willUpdate, with one place that decides which filters apply. - Open organization links only for http(s) URLs, with noopener. - Rename the marker for clicks that don't select a row to data-no-select. - Test the default page size, the page links and ellipses, the page clamp, null and replaced rowActions, the organization link and the load error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Organization names are rendered as links only for http(s) URLs, so no link does nothing on click. Tests the type filter's fallback to the services' types, and adds baseUrl to the documented properties. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewer's GuideAPIExpose the row-actions renderer and document the component’s public properties, slots, and selection event contract.
ImplementationAdd filter option and page-size helpers, apply visible filters and local search, and handle row selection and external URLs safely.
UIRender the filters, paginated service rows, row actions, organization links, and pagination controls.
ConfigurationAdd the service-registry package test command, reserve its test-runner port, and record the minor changeset.
DocumentationDocument the new filters, local search, pagination, row actions, slots, and selection behavior.
TestsAdd browser tests for search, filters, pagination, row actions, selection, organization links, and load errors.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Documentation build overview
|
Resolves the port note in web-test.runner-config.mjs: the TES tests now use 8003, so the service registry tests move to 8004. Adds the changeset for the service registry, as dev now uses changesets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #575 +/- ##
==========================================
+ Coverage 73.53% 75.31% +1.77%
==========================================
Files 33 37 +4
Lines 8123 9138 +1015
Branches 381 470 +89
==========================================
+ Hits 5973 6882 +909
- Misses 2141 2245 +104
- Partials 9 11 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Linked issuesChecked at commit 02caa7d #455 feat(service-registry): list filters and pagination · 7 of 8 met · 1 to check by hand
|
There was a problem hiding this comment.
Hey - I've found 12 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts" line_range="43-44" />
<code_context>
+type FilterOptions = Record<keyof ServiceFilters, FilterOption[]>;
+
+/** The value of a service type in the type filter. */
+const typeKey = (type: ServiceType): string =>
+ `${type.group}:${type.artifact}:${type.version}`;
+
+/** Whether a URL from the registry is a web URL (`http:` or `https:`). */
</code_context>
<issue_to_address>
**Distinct types share one filter**
When different service-type fields contain colons that produce the same joined key, `typeKey` returns the same key for both types, so `computeFilterOptions` deduplicates them and `filterServices` matches both; users see services from both types after selecting one.
Make `typeKey` collision-safe, and use that key consistently when deduplicating options and matching selected types.
</issue_to_address>
### Comment 2
<location path="packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts" line_range="223-224" />
<code_context>
+ * services), and the organizations and environments of the services.
+ */
+ private computeFilterOptions(): FilterOptions {
+ const types = this.serviceTypes.length
+ ? this.serviceTypes
+ : this.services.map((service) => service.type);
+ const uniqueTypes = [
</code_context>
<issue_to_address>
**Old types remain selectable**
When the component switches registries after loading types and the new registry's `getServiceTypes()` request fails, `loadServiceTypes` leaves the previous `serviceTypes` in place, so `computeFilterOptions` uses those instead of the loaded services' types; users can select types that return no services.
Clear `serviceTypes` when the request fails so `computeFilterOptions` falls back to the loaded services.
</issue_to_address>
### Comment 3
<location path="packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts" line_range="223" />
<code_context>
+ * services), and the organizations and environments of the services.
+ */
+ private computeFilterOptions(): FilterOptions {
+ const types = this.serviceTypes.length
+ ? this.serviceTypes
+ : this.services.map((service) => service.type);
</code_context>
<issue_to_address>
**Old registry types replace current options**
When the component switches from registry A to registry B while A’s type request is still pending, a late `getServiceTypes()` response from registry A overwrites `serviceTypes` after the component switches to registry B; `computeFilterOptions()` then prefers A’s non-empty types over B’s loaded services, so B’s types are missing from the filter and selecting them is impossible.
Associate each load with its provider or a request generation and ignore type responses that are no longer current.
</issue_to_address>
### Comment 4
<location path="packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts" line_range="275-276" />
<code_context>
+ service.description,
+ service.url,
+ service.organization.name,
+ service.type.group,
+ service.type.artifact,
+ ].some((field) => field?.toLowerCase().includes(query)))
+ );
</code_context>
<issue_to_address>
**Version searches omit matching services**
When a user searches for a value that occurs only in a service type's version, `filterServices` checks the type group and artifact but not its version, so services with that displayed version are omitted from the results.
Include `service.type.version` among the fields searched by `filterServices`.
Also at `packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts:277`.
</issue_to_address>
### Comment 5
<location path="packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts" line_range="237" />
<code_context>
+ label: `${type.artifact}@${type.version} (${type.group})`,
+ })),
+ organization: asOptions(
+ uniqueSorted(this.services.map((service) => service.organization.name))
+ ),
+ environment: asOptions(
</code_context>
<issue_to_address>
**Same-name organizations cannot be separated**
When the loaded services include distinct organizations with the same name, `computeFilterOptions` deduplicates organizations by name and `filterServices` matches only that name, so selecting the option returns services from both organizations.
Use organization identity, rather than name alone, for organization option values and filtering.
Also at `packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts:266`.
</issue_to_address>
### Comment 6
<location path="packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts" line_range="282" />
<code_context>
- this.loading = true;
- this.error = null;
+ private pageCount(total: number): number {
+ if (!(this.pageSize >= 1)) return 1;
+ return Math.max(1, Math.ceil(total / this.pageSize));
+ }
</code_context>
<issue_to_address>
**Invalid page sizes show wrong rows**
When `page-size` is malformed or is set to a positive fractional number, `pageCount` treats `NaN` as one page, and `render` then shows all services; for fractional sizes, `slice` truncates its boundaries and pages overlap or omit services.
Validate that `pageSize` is a finite positive integer before using it to calculate pages or slice services.
Also at `packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts:585-586`.
</issue_to_address>
### Comment 7
<location path="packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts" line_range="494-495" />
<code_context>
+ : html`<ecc-utils-design-button
+ size="sm"
+ @click=${() => this.handleViewDetails(service.id)}
+ >
+ View Details
+ </ecc-utils-design-button>`;
+ }
</code_context>
<issue_to_address>
**Default action still selects service**
When a user clicks the default “View Details” action, the default “View Details” action calls `handleViewDetails`, so clicking an action emits `ecc-service-selected` despite the documented exception for action clicks.
Either stop the default action from emitting `ecc-service-selected`, or document that this action is an exception because it intentionally selects the service.
</issue_to_address>
### Comment 8
<location path="packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts" line_range="24" />
<code_context>
+ * Renders the actions of a row from its service: a Lit template, a DOM node,
+ * a string, or nothing (`null` or `undefined`) for a row without actions.
+ */
+export type RowActionsRenderer = (service: ExternalService) => unknown;
+
+/** The selected values of the filters; empty for "All". */
</code_context>
<issue_to_address>
**Invalid actions crash list rendering**
When a TypeScript caller returns a non-renderable object from `rowActions`, `rowActions` accepts any return value at the type level, and `renderActions` inserts it directly into a Lit child part. If a caller returns a plain object, Lit throws while rendering the row and the services list fails to render.
Type the renderer result as the supported renderable-value union, or validate unsupported values and render a safe fallback.
Also at `packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts:490`.
</issue_to_address>
### Comment 9
<location path="packages/ecc-client-ga4gh-service-registry/src/components/services/tests/services.test.ts" line_range="185" />
<code_context>
+ });
+
+ it("matches the service URL", async () => {
+ const el = await renderLoaded();
+
+ await change(el, searchInput(el), "s3.example.org");
</code_context>
<issue_to_address>
**Registry type source goes untested**
When `getServiceTypes` is skipped or its non-empty result is ignored, `offers the types the registry lists` compares option values that are also present in the default loaded services; the fallback test likewise passes if `getServiceTypes` is never consulted. Ignoring registry-provided types therefore passes both tests.
Use registry types that differ from the loaded services in the registry-types test, and assert the provider method was called in both tests.
Also at `packages/ecc-client-ga4gh-service-registry/src/components/services/tests/services.test.ts:203`.
</issue_to_address>
### Comment 10
<location path="packages/ecc-client-ga4gh-service-registry/src/components/services/tests/services.test.ts" line_range="332-335" />
<code_context>
+ })
+ );
+ await el.updateComplete;
+ await change(el, searchInput(el), "Service s1");
+
+ // s1, s10, s11, s12
+ expect(shownIds(el)).to.deep.equal(["s1", "s10", "s11", "s12"]);
+ });
+
</code_context>
<issue_to_address>
**Page reset is not exercised**
When the page-3 search leaves four matches with a page size of five, `goes back to the first page when the filters change` gets only four matches for `Service s1`, fewer than the page size of five. The render-time page clamp shows those matches even if the search handler fails to reset the page, so the test passes without verifying the reset.
Search for a query that still matches more than five services, then assert that the first five are shown after the change.
</issue_to_address>
### Comment 11
<location path="packages/ecc-client-ga4gh-service-registry/src/components/services/tests/services.test.ts" line_range="462-464" />
<code_context>
+ const el = await renderLoaded();
+
+ setTimeout(() => rows(el)[1].click());
+ const event = (await oneEvent(el, "ecc-service-selected")) as CustomEvent;
+
+ expect(event.detail).to.deep.equal({ serviceId: "s2" });
+ });
+
</code_context>
<issue_to_address>
**Duplicate selection events go unnoticed**
When a row click emits `ecc-service-selected` more than once, `selects a service when its row is clicked` awaits only one `ecc-service-selected` event and checks its detail. If a single row click emits the event twice, `oneEvent` resolves on the first and the test passes without detecting the duplicate.
Spy on the event, click the row, and assert that exactly one event fired with the expected detail.
</issue_to_address>
### Comment 12
<location path="packages/ecc-client-ga4gh-service-registry/src/components/services/tests/services.test.ts" line_range="557-559" />
<code_context>
+ "error not shown"
+ );
+
+ expect(rows(el)).to.have.length(0);
+ expect(root(el).querySelector("ecc-utils-design-pagination")).to.equal(
+ null
+ );
+ });
</code_context>
<issue_to_address>
**Stuck loading state goes unnoticed**
When the load fails, the error is displayed, and the loading state is not cleared, `shows the error if the services can't be loaded` checks `rows(el)`, which selects only rows with `data-service-id`; loading skeleton rows have no such attribute. If an error is shown but `loading` stays true, the test still sees zero rows and no pagination while skeletons remain visible.
Also assert that the skeleton rows are absent after the error is shown, or otherwise wait for and verify that loading has ended.
</issue_to_address>Sourcery assessment
Approval pending. 12 findings to address first.
Blocking findings: packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts:44, packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts:224, packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts:223, packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts:276, packages/ecc-client-ga4gh-service-registry/src/components/services/services.ts:237, and 7 more
- Use a JSON key for service types in the type filter, so that types whose fields contain the separator stay apart. - Search also matches the type version. - Round a fractional page-size down; treat invalid ones as 0 (all). - Type rowActions results as the values Lit can render. - Document that the default "View Details" action selects the service. - Tighten tests: registry-only types, one selection event per click, page reset with more than a page of matches, no skeletons after a load error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anuragxxd
left a comment
There was a problem hiding this comment.
Looks good, thanks! A few optional nits:
handleRowClickchecksdata-no-selectall the way up towindow. Could it stop at the row?- A missing or
NaNpage-sizeshows all rows. Maybe fall back to 10? - Selecting text in a row, or Ctrl-clicking it, fires
ecc-service-selected.
- Check data-no-select only between the click target and the row, so an ancestor of the component can't suppress row selection. - Fall back to 10 services per page for a missing or invalid page-size; 0 or less still shows all services on one page. - Don't select a service for clicks with a modifier key or clicks that end a text selection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Suppress a row click only if the text selection changed since the mouse button went down on the row (a drag), so that a selection made before, e.g. elsewhere on the page, doesn't block clicks on buttons, which keep it. Treat an empty page-size attribute as missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clicks without a mousedown on the row, e.g. from code, can't end a drag, so a text selection doesn't suppress them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks a lot for the review, @anuragxxd! All three nits are addressed, with tests and docs:
With your approval in, we're merging now. |
When a load failed, the services, service, tools and objects components cleared their data without firing their ecc-*-changed event, so the app kept the data of the previous provider. They now fire it with empty data. The services list also starts on its first page after a provider switch, as the TRS and DRS lists do (the list has pages since #575). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Makes
ecc-client-ga4gh-service-registry-servicesusable for apps with role-based row actions (Cloud Registry UI, elixir-cloud-aai/cloud-registry-ui#9 and #10):/services/types, or else the types of the loaded services), organization and environment (shown only if a service has one), rendered whenfilteris on. Hidden filters don't apply, so none can get stuck.pageSizeproperty (attributepage-size, default 10;0or less shows all services). Shown only when there is more than one page; changing the search or a filter goes back to the first page.rowActionsrender hook,(service) => unknown, returns a Lit template, a DOM node, a string or nothing for each row, so apps don't need to know the service IDs in advance. Theactions-<id>slots stay, so existing apps keep working.ecc-service-selected, except clicks on its actions or the organization link (markeddata-no-select).http:/https:URLs and opens withnoopener,noreferrer(before, any URL was passed towindow.open); other URLs show the plain name.services.test.ts(36 tests) and atestscript on port 8004 (8003 went to the TES tests ondev), using the sharedweb-test.runner-config.mjslike the cloud-registry package. The component's lifecycle methods (firstUpdated,updated,loadData) are unchanged, to stay out of the way of the provider lifecycle work (fix: react to provider set after the first update #565).apps/documentation/pages/docs/service-registry/components/services.mdxcovers the new properties, the slot and the changed events.Changeset:
.changeset/service-registry-list-filters.md(minor).Verification
npm testinpackages/ecc-client-ga4gh-service-registry: 36 passed on Chromium and on Firefox. WebKit didn't run locally because its browser isn't installed on this machine; CI installs it.The new tests were written first and failed against the old component. The regression test for hidden filters failed before its fix.
npm run lintat the repo root (all packages, including the docs build): 19/19 tasks passed.tscon the package: no errors in the sources. Test files aren't type-checked, as in the other packages.CI on
ef154ce(before the Sourcery fixes): all checks passed (Lint, Test on Node 22 and 24 incl. WebKit, CI passed, codecov patch/project, CodeQL, Read the Docs).Maintainer review (anuragxxd)
Addressed in
0fc259a,50539e5and02caa7d, with tests and docs:data-no-selectcheck stops at the row, so ancestors of the component can't suppress row selection.page-sizefalls back to 10;0or less still shows all services on one page.ecc-service-selected; a selection made before the click (e.g. elsewhere on the page) doesn't block it.Verification of these commits:
npm testin the package, 46 passed on Chromium and Firefox (WebKit not installed locally; CI runs it);npx eslint .0 errors; the commit hook'sturbo run lint(all packages and the docs build) passed. The new tests failed before the fixes.Declined review findings
From the adversarial-reviewer and quality-reviewer subagents (two rounds; all high and medium findings and the cheap lows are fixed in the third and fourth commits):
ecc-client-ga4gh-trstools. Client-side paging is what the issue asks for (the Service Registry API has no paging), and a shared pagination helper would belong inecc-utils-design, which this PR doesn't touch.pageSizewithtools.ts(5). The packages already differ (TRS and TES 5, WES and DRS 10); 10 suits a registry list.updated,load*), which this PR leaves unchanged; fix: react to provider set after the first update #565 reworks it.firstUpdatedandupdatedmay load twice for an element initialised withbaseUrl. Not changed by this PR (it leaves the lifecycle alone); the provider lifecycle is fix: react to provider set after the first update #565.Open questions
None.
Closes #455
🤖 Generated with Claude Code