Skip to content

feat(sidebar): drag-and-drop connection reordering (#748) - #817

Open
Asgabani wants to merge 1 commit into
libredb:mainfrom
Asgabani:feat/connection-reorder
Open

feat(sidebar): drag-and-drop connection reordering (#748)#817
Asgabani wants to merge 1 commit into
libredb:mainfrom
Asgabani:feat/connection-reorder

Conversation

@Asgabani

Copy link
Copy Markdown

Closes #748.

What changed

  • StorageData.connection_order (new collection): a flat list of connection ids in the user's preferred order, mirroring the existing dismissed_seeds-style separate-list pattern rather than a field on DatabaseConnection — a managed:true connection is replaced wholesale on every load (see mergeManagedConnections), so a field on the connection object itself would be silently discarded on reload.
  • storage.getConnectionOrder() / storage.setConnectionOrder() on the storage facade, wired into useStorageSync's migrate/pull paths like every other collection.
  • applyConnectionOrder() (src/lib/connection-order.ts): sorts a connections array by the persisted order; a connection absent from the order (never dragged, or created after the user last reordered) sorts after every connection the order does know about, in its original relative position (Array.prototype.sort is spec-stable, so that fallback needs no code of its own).
  • useConnectionOrder() hook: useSyncExternalStore over the facade, same shape as the repo's other storage-backed hooks.
  • ConnectionsList / ConnectionItem: native HTML5 drag-and-drop (no new dependency) — a drag handle appears on hover once onReorderConnections is passed and the list has more than one connection; dropping persists the new order via the facade.

Note on #694

#748's "Done when" mentions #694 (favorites): if that lands first, a favorited group should keep its own drag order rather than the two features competing for one order field. Since #694 hasn't merged yet, this PR reorders the flat connections list only. connectionOrder/onReorderConnections are threaded through as plain optional props (not baked into any favorites-aware grouping), so whichever PR lands second can partition the already-ordered list into favorite/non-favorite groups without this one needing to change.

Testing

Ran locally (bun run format && bun run lint && bun run typecheck && bun run knip && bun run chart:check && bun run channels:showcase:check && bun run readme:check && bun run security:check && bun run test && bun run build, plus bun run build:lib && bun run attw):

  • format / lint / typecheck / knip: clean. Lint warning count unchanged from a clean checkout (189, compared via git stash).
  • All four drift guards (chart, channels showcase, readme, security): pass.
  • bun run test:components: 39/39 groups pass.
  • bun run test: same 13 pre-existing failures as a clean checkout (Helm binary not installed, missing built standalone zip) — verified identical via git stash before/after. No live Postgres/MySQL in this sandbox, so DB-integration tests weren't exercised beyond what's already mocked.
  • bun run test:coverage && bun run coverage:check: 100.00% line coverage on the merged lcov.
  • bun run build, bun run build:lib, bun run attw: all succeed (ConnectionsList/Sidebar are reachable from the embeddable workspace export surface).

If CI surfaces something this sandbox couldn't (Helm chart tests, live DB integration tests), happy to fix it up.

Connections render in a persisted custom order rather than storage's
natural array order. A new connection_order collection (flat id list)
is stored via the existing write-through storage facade, and
ConnectionsList gains native HTML5 drag-and-drop to reorder its rows,
persisting the new order on drop.
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.

No way to reorder saved connections

1 participant