settingsSearch.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. | 'sensors'
  14. | 'notifications'
  15. | 'queue'
  16. | 'filament'
  17. | 'network'
  18. | 'apikeys'
  19. | 'virtual-printer'
  20. | 'spoolbuddy'
  21. | 'users'
  22. | 'backup'
  23. | 'failure-detection';
  24. export type SettingsSearchSubTab = 'users' | 'email' | 'ldap' | 'oidc' | 'twofa' | 'security';
  25. export type UsersSubTab = SettingsSearchSubTab;
  26. export interface SettingsSearchEntry {
  27. /** i18n key for the label. Resolved with t() at render time. */
  28. labelKey: string;
  29. /** Fallback label if the i18n key is missing. */
  30. labelFallback?: string;
  31. tab: SettingsSearchTab;
  32. subTab?: SettingsSearchSubTab;
  33. /** Space-separated extra search terms (lowercase). */
  34. keywords: string;
  35. /** DOM id attached to the target card — used for scrollIntoView. */
  36. anchor: string;
  37. }
  38. const entries = new Map<string, SettingsSearchEntry>();
  39. export function registerSettingsSearch(entry: SettingsSearchEntry): void {
  40. entries.set(entry.anchor, entry);
  41. }
  42. export function getSettingsSearchEntries(): SettingsSearchEntry[] {
  43. return Array.from(entries.values());
  44. }