1import type { ComponentType } from "react";
2import {
3 ArchiveIcon,
4 BlocksIcon,
5 BotIcon,
6 CalendarClockIcon,
7 createLucideIcon,
8 GitBranchIcon,
9 HardDriveIcon,
10 KeyboardIcon,
11 Link2Icon,
12 PaletteIcon,
13 PanelsTopLeftIcon,
14 Settings2Icon,
15} from "lucide-react";
16
17import {
18 isSettingsOverviewVisible,
19 SETTINGS_SECTION_LABELS,
20 type SettingsPath,
21} from "./settingsSearch";
22import type { SettingsScopeSearch } from "./settingsScope";
23
24const SnapShotIcon = createLucideIcon("snap-shot", [
25 [
26 "path",
27 {
28 d: "M8 3H6a3 3 0 0 0-3 3v2M16 3h2a3 3 0 0 1 3 3v2M21 16v2a3 3 0 0 1-3 3h-2M8 21H6a3 3 0 0 1-3-3v-2",
29 key: "capture-frame",
30 },
31 ],
32 ["rect", { width: "10", height: "8", x: "7", y: "8", rx: "2", key: "window" }],
33 ["circle", { cx: "12", cy: "12", r: "1.5", key: "lens" }],
34]);
35
36export const SETTINGS_SECTION_ICONS: Readonly<
37 Record<SettingsPath, ComponentType<{ className?: string }>>
38> = {
39 "/settings/general": Settings2Icon,
40 "/settings/diagnostics": Settings2Icon,
41 "/settings/appearance": PaletteIcon,
42 "/settings/projects": PanelsTopLeftIcon,
43 "/settings/keybindings": KeyboardIcon,
44 "/settings/snap-shot": SnapShotIcon,
45 "/settings/providers": BotIcon,
46 "/settings/integrations": BlocksIcon,
47 "/settings/scheduled-tasks": CalendarClockIcon,
48 "/settings/source-control": GitBranchIcon,
49 "/settings/storage": HardDriveIcon,
50 "/settings/connections": Link2Icon,
51 "/settings/archived": ArchiveIcon,
52};
53
54const SETTINGS_NAV_ITEMS: ReadonlyArray<{
55 label: string;
56 to: SettingsPath;
57 icon: ComponentType<{ className?: string }>;
58}> = (Object.keys(SETTINGS_SECTION_LABELS) as SettingsPath[])
59 .filter((to) => to !== "/settings/diagnostics" && to !== "/settings/snap-shot")
60 .map((to) => ({
61 to,
62 label: SETTINGS_SECTION_LABELS[to],
63 icon: SETTINGS_SECTION_ICONS[to],
64 }));
65
66export function getSettingsNavigationItems(scopeSearch: SettingsScopeSearch) {
67 return SETTINGS_NAV_ITEMS.filter(
68 (item) => item.to !== "/settings/projects" || isSettingsOverviewVisible(scopeSearch),
69 );
70}