Skip to content

feat(api-manager): collapsible and searchable connection groups with select-all - #13952

Merged
diegosouzapw merged 5 commits into
diegosouzapw:release/v3.8.51from
fouadSalkini:feat/api-key-connection-groups
Sep 24, 2026
Merged

diegosouzapw merged 5 commits into
diegosouzapw:release/v3.8.51from
fouadSalkini:feat/api-key-connection-groups

Conversation

@fouadSalkini

@fouadSalkini fouadSalkini commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Redesign the allowed connections list in API Manager's key permissions modal (/dashboard/api-manager) to match the pattern of ProviderModelPermissionList.
  • Introduce ProviderConnectionPermissionList.tsx:
    • Groups connections by provider with collapsible accordion sections.
    • Adds a provider-level select-all checkbox (with full, empty, and indeterminate states).
    • Includes real-time search filtering across connection name, connection ID, and provider name.
    • Automatically expands matching provider accordions during search.
    • Displays total and selected connection counts per provider.
    • Defensive null guards for safe array operations and proper useEffect import for indeterminate checkbox synchronization.
  • Add unit tests in tests/unit/api-key-connection-groups.test.ts covering grouping, search filtering, provider-level select/deselect calculations, and graceful handling of empty/null inputs.

Verification

  • npm run typecheck:core passed cleanly (0 errors).
  • node --import tsx/esm --test tests/unit/api-key-connection-groups.test.ts passed (5/5).
  • Pre-commit hooks (lint, prettier, docs-sync, any-budget, tracked-artifacts) passed.
  • Built on VPS with 6d7e44a and verified live modal rendering.

@diegosouzapw

Copy link
Copy Markdown
Owner

A UI está segura; o teste não prova nada.

A premissa é consistente com o repo: a lista antiga era flat com max-h-40, e o padrão de acordeão já existe em components/ProviderModelPermissionList.tsx. O guard allowAllConnections foi preservado corretamente.

Bloqueador — tests/unit/api-key-connection-groups.test.ts é tautologia pura. Ele importa apenas o type ProviderConnection do componente e re-implementa agrupamento, filtro e seleção dentro do próprio arquivo de teste. Ele passa com o componente deletado. Zero cobertura real.

Isso acontece por uma escolha de runner: o componente é .tsx, então um teste de verdade teria que ser vitest (vitest.config.ts:15-19); escrevendo .test.ts sem render, o teste deixa de tocar o componente. O caminho certo é um teste vitest de render cobrindo expandir/colapsar, o select-all indeterminado e a busca.

Bug real de comportamento: ProviderConnectionPermissionList.tsx usa useState(() => …) para calcular expandedProviders uma única vez. Se connections chegar depois do mount, nenhum provider com seleção abre. Mover para useEffect sobre connections resolve.

Menores: aria-label={${provider} connection access} é string em inglês hardcoded (e o chevron usa aria-label={provider}, o id cru em vez do display name); a interface ProviderConnection está duplicada entre o componente e ApiManagerPageClient.tsx:150. Também vale notar a mudança de default: antes tudo visível, agora tudo colapsado salvo grupos com seleção — um clique a mais no fluxo comum.

diegosouzapw and others added 2 commits September 18, 2026 01:35
… + add render coverage

expandedProviders was computed once via a lazy useState initializer keyed on
the first render's connections/selectedConnections. When the permissions
modal opens before its fetch resolves (a common pattern), those props arrive
empty at mount and real data lands on a later re-render, so a provider group
with a pre-existing selection never auto-expanded.

- Adjust expandedProviders during render (React's documented pattern for
  reacting to data becoming available) instead of only at the first-render
  lazy initializer, guarded to run once so it never fights a later manual
  collapse.
- Add a Vitest render test (api-key-connection-groups-render.test.tsx) that
  actually mounts ProviderConnectionPermissionList and exercises the delayed-
  data auto-expand, manual collapse persistence, search filtering, and the
  indeterminate/select-all checkbox state. The existing
  api-key-connection-groups.test.ts only imports the ProviderConnection TYPE
  and re-implements the grouping/filter logic inline, so it would still pass
  even if the component file were deleted.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@fouadSalkini

Copy link
Copy Markdown
Contributor Author

Fixes applied and verified:

  • Async data load synchronization: expandedProviders now auto-expands provider groups that have active selections when connections loads asynchronously after mount, guarded so it never interferes with subsequent manual collapses.
  • Component render tests: Added tests/unit/api-key-connection-groups-render.test.tsx using Vitest + React Testing Library to mount and verify delayed-data auto-expand, manual collapse persistence, query filtering, and select-all/indeterminate behavior.
  • Cleaned up minor items: De-duplicated ProviderConnection by using the shared export in ApiManagerPageClient.tsx, and updated chevron accessibility labels to use provider display names instead of raw IDs.

fouadSalkini added a commit to fouadSalkini/OmniRoute that referenced this pull request Sep 18, 2026
@diegosouzapw
diegosouzapw merged commit 72cb483 into diegosouzapw:release/v3.8.51 Sep 24, 2026
11 of 16 checks passed
fouadSalkini added a commit to fouadSalkini/OmniRoute that referenced this pull request Sep 26, 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.

2 participants