settingsSearch.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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';
  24. export interface SettingsSearchEntry {
  25. /** i18n key for the label. Resolved with t() at render time. */
  26. labelKey: string;
  27. /** Fallback label if the i18n key is missing. */
  28. labelFallback?: string;
  29. tab: SettingsSearchTab;
  30. subTab?: SettingsSearchSubTab;
  31. /** Space-separated extra search terms (lowercase). */
  32. keywords: string;
  33. /** DOM id attached to the target card — used for scrollIntoView. */
  34. anchor: string;
  35. }
  36. const entries = new Map<string, SettingsSearchEntry>();
  37. export function registerSettingsSearch(entry: SettingsSearchEntry): void {
  38. entries.set(entry.anchor, entry);
  39. }
  40. export function getSettingsSearchEntries(): SettingsSearchEntry[] {
  41. return Array.from(entries.values());
  42. }