settingsSearch.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Settings search registry.
  2. //
  3. // Each settings card/section registers itself at module-import time by calling
  4. // `registerSettingsSearch(...)` at module scope (NOT inside a component).
  5. // SettingsPage reads the accumulated registry to power its cross-tab search.
  6. //
  7. // Convention: co-locate the registration call with the component/section that
  8. // owns the `anchor` id. When you add a new settings card, add one call here
  9. // next to it — no central index to forget to update.
  10. export type SettingsSearchTab =
  11. | 'general'
  12. | 'plugs'
  13. | 'notifications'
  14. | 'queue'
  15. | 'filament'
  16. | 'network'
  17. | 'apikeys'
  18. | 'virtual-printer'
  19. | 'spoolbuddy'
  20. | 'users'
  21. | 'backup'
  22. | 'failure-detection';
  23. export type SettingsSearchSubTab = 'users' | 'email' | 'ldap' | 'oidc' | 'twofa' | 'security';
  24. export type UsersSubTab = SettingsSearchSubTab;
  25. export interface SettingsSearchEntry {
  26. /** i18n key for the label. Resolved with t() at render time. */
  27. labelKey: string;
  28. /** Fallback label if the i18n key is missing. */
  29. labelFallback?: string;
  30. tab: SettingsSearchTab;
  31. subTab?: SettingsSearchSubTab;
  32. /** Space-separated extra search terms (lowercase). */
  33. keywords: string;
  34. /** DOM id attached to the target card — used for scrollIntoView. */
  35. anchor: string;
  36. }
  37. const entries = new Map<string, SettingsSearchEntry>();
  38. export function registerSettingsSearch(entry: SettingsSearchEntry): void {
  39. entries.set(entry.anchor, entry);
  40. }
  41. export function getSettingsSearchEntries(): SettingsSearchEntry[] {
  42. return Array.from(entries.values());
  43. }