Skip to content

[web-console] Sort pipelines by name on the home page by default, persist order#6507

Open
Karakatiza666 wants to merge 1 commit into
mainfrom
issue6384
Open

[web-console] Sort pipelines by name on the home page by default, persist order#6507
Karakatiza666 wants to merge 1 commit into
mainfrom
issue6384

Conversation

@Karakatiza666

Copy link
Copy Markdown
Contributor

The implementation leverages existing sorting functionality in '@vincjo/datatables' package. ThSort.svelte re-implements a similar component shipped with that package (with extra additions) because that one lacks certain functionality.

Fix #6384

Testing: manual, added unit test

@Karakatiza666 Karakatiza666 requested a review from mihaibudiu June 19, 2026 18:37
} = $props()
const sort = table.createSort(field)

// Mirror @vincjo/datatables' own ThSort: create the sort and apply the initial

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.

this comment is overly long (there are many lately)
who cares about vincjo?

@mythical-fred mythical-fred left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

APPROVE.

Clean implementation. Persistence flows through the existing useLayoutSettings localStorage scaffold; ThSort keeps the upstream @vincjo/datatables ergonomics (createSort(field).init(direction)) while exposing onSort for the parent to record the column identity. Default of { column: 'name', direction: 'asc' } matches the issue.

Non-blocking nits:

  • pipelinesTableSort stores column: string rather than a union of the actual sortable field names. If a future rename of e.g. lastStatusSince ships without a migration, persisted state silently sorts nothing (no match on any column, so all five ThSorts mount with direction: undefined). A union type + a .filter(...) on read would fail loudly. Small; only matters once.
  • The browser test mounts the full Table.svelte, which is great for regression coverage, but ties row-order assertions to the data-testid="box-row-…" convention in a sibling row component. Worth a one-line comment in the spec calling out that contract so a future testid rename doesn't make this test pass for the wrong reason.
  • ThSort now has two static-over-lifetime props (direction, onSort) flowing in via $props(). Svelte 5 won't complain, but documenting "must be stable for the component lifetime" matches the inline comment style you already use.

Test coverage is thoughtful (rotation of date order vs name order makes the "did it actually re-sort?" assertion meaningful, and persistence is checked through the real localStorage key). Good PR.

@Karakatiza666 Karakatiza666 enabled auto-merge June 19, 2026 20:42
@Karakatiza666 Karakatiza666 added this pull request to the merge queue Jun 19, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 19, 2026

@mythical-fred mythical-fred left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Re-APPROVE on the force-pushed revision (b25062b897a6af). The rewrite is materially better than what I approved the first time round: instead of building a parallel sort state on the parent, ThSort now accepts optional direction/onSort props and the parent wires each sortable column through a tiny sortColumn(name) helper that reads/writes a single pipelinesTableSort entry through the existing useLayoutSettings + useLocalStorage scaffold. The default { column: 'name', direction: 'asc' } is right where it belongs.

The new Table.svelte.spec.ts is the highlight: name order and lastStatusSince order are deliberately rotated against each other so every assertion can only pass if the click actually re-sorted the rows, the persistence test reads back through the layout/pipelines/table/sort localStorage key, and the "restores on mount" test covers the warm path. beforeEach resets both the cached useLayoutSettings singleton and the backing store, which is the right cleanup discipline.

One non-blocking nit (still): pipelinesTableSort.value.column: string is structurally typed, so a future rename of e.g. lastStatusSince won't fail loudly — the stored value just silently won't match any header and the default-named column will appear active. Tightening this to column: NamesInUnion<…> | ((p: PipelineThumb) => unknown)['name'] (or a hand-rolled union of the five sortable field names) buys you a real compile error on rename, and the only cost is updating the useLocalStorage initializer's narrowing.

(Re mihaibudiu's "who cares about vincjo" — fair, but the comment is genuinely useful: it tells the next maintainer why ThSort.svelte exists at all instead of being imported from @vincjo/datatables. I'd keep it.)

…sist order

Signed-off-by: Karakatiza666 <bulakh.96@gmail.com>
@Karakatiza666 Karakatiza666 enabled auto-merge June 20, 2026 09:02
@Karakatiza666 Karakatiza666 added this pull request to the merge queue Jun 20, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 20, 2026
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.

Web console should have default sort order for pipelines, and sort order should be sticky

3 participants