Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

3.2 KB
Raw Blame
import { NavKey } from "@editor/components/shared/config/types";

/**
 * A whole settings section (nav tab), described as pure data so the global
 * super search can offer section-level results.
 *
 * This is the single source of truth for *which settings sections are
 * searchable* in a given build. It is intentionally **component-free**: the
 * always-mounted top bar imports it (via `@editor/data/settingsSectionRegistry`)
 * to feed the super search, and pulling the heavy settings component tree in
 * here would defeat the lazy-loaded settings page.
 *
 * Layering mirrors the nav builders (`configNavSections`): core lists the
 * always-present sections; higher layers shadow this module to add their own
 * (proprietary admin sections, saas cloud sections, …). A section only belongs
 * in a layer's registry if that layer's settings nav can actually render it -
 * otherwise search would deep-link to a tab that doesn't exist.
 *
 * Per-user visibility (admin / login) is expressed by the flags below and
 * applied by the super search at query time, mirroring the nav's own gating.
 */
export interface SettingsSectionEntry {
  /** Nav key; used for the `/settings/{key}` deep link. */
  key: NavKey;
  /** i18n key for the display label. */
  labelKey: string;
  /** English fallback / default for the label. */
  labelFallback: string;
  /**
   * The nav group this section sits under ("Preferences",
   * "Configuration", …) — shown as result context ("Group · match").
   * Same keys the nav builder uses.
   */
  groupLabelKey?: string;
  groupLabelFallback?: string;
  /** Extra English terms to match against (synonyms, related words). */
  keywords?: string[];
  /** Surface only when login mode is on (e.g. account, API keys). */
  requiresLogin?: boolean;
  /**
   * Admin-area section: the self-hosted nav surfaces it when the user is an
   * admin OR login mode is off (single-user self-host). Mirrors the proprietary
   * nav builder's `isAdmin || !loginEnabled` gate.
   */
  adminArea?: boolean;
  /**
   * Section only mounts for a signed-in (non-anonymous) account — mirrors the
   * SaaS nav builder's `!isAnonymous` gate. Distinct from `requiresLogin`,
   * which keys off the local backend's login mode rather than auth state.
   */
  requiresAccount?: boolean;
  /** Section is the processor's; only a session that can enter it sees it. */
  requiresPortalAccess?: boolean;
}

/** Core (OSS) sections — always present in every build. */
export const SETTINGS_SECTION_REGISTRY: SettingsSectionEntry[] = [
  {
    key: "general",
    labelKey: "settings.general.title",
    labelFallback: "General",
    keywords: [
      "theme",
      "language",
      "appearance",
      "preferences",
      "startup",
      "hotkey",
      "shortcut",
      "keybinding",
      "keyboard",
    ],
    groupLabelKey: "settings.preferences.title",
    groupLabelFallback: "Preferences",
  },
  {
    key: "about",
    labelKey: "settings.about.title",
    labelFallback: "About",
    keywords: [
      "about",
      "tours",
      "walkthrough",
      "legal",
      "terms",
      "privacy",
      "cookie",
      "licence",
      "license",
      "attribution",
      "dependencies",
    ],
    groupLabelKey: "settings.about.title",
    groupLabelFallback: "About",
  },
];