|
| 1 | +import { HTMLAttributes } from "react" |
| 2 | +import { useAppTranslation } from "@/i18n/TranslationContext" |
| 3 | +import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react" |
| 4 | +import { Monitor } from "lucide-react" |
| 5 | + |
| 6 | +import { SetCachedStateField } from "./types" |
| 7 | +import { SectionHeader } from "./SectionHeader" |
| 8 | +import { Section } from "./Section" |
| 9 | +import { Slider } from "../ui" |
| 10 | +import { vscode } from "@/utils/vscode" |
| 11 | + |
| 12 | +type InterfaceSettingsProps = HTMLAttributes<HTMLDivElement> & { |
| 13 | + filesChangedEnabled?: boolean |
| 14 | + filesChangedMaxDisplayFiles?: number |
| 15 | + setCachedStateField: SetCachedStateField<"filesChangedEnabled" | "filesChangedMaxDisplayFiles"> |
| 16 | +} |
| 17 | + |
| 18 | +export const InterfaceSettings = ({ |
| 19 | + filesChangedEnabled, |
| 20 | + filesChangedMaxDisplayFiles, |
| 21 | + setCachedStateField, |
| 22 | + ...props |
| 23 | +}: InterfaceSettingsProps) => { |
| 24 | + const { t } = useAppTranslation() |
| 25 | + |
| 26 | + return ( |
| 27 | + <div {...props}> |
| 28 | + <SectionHeader> |
| 29 | + <div className="flex items-center gap-2"> |
| 30 | + <Monitor className="w-4" /> |
| 31 | + <div>{t("settings:sections.interface")}</div> |
| 32 | + </div> |
| 33 | + </SectionHeader> |
| 34 | + |
| 35 | + <Section> |
| 36 | + {/* Files Changed Settings Section */} |
| 37 | + <div> |
| 38 | + <div className="flex items-center gap-2 font-bold mb-3"> |
| 39 | + <span className="codicon codicon-file-diff" /> |
| 40 | + <div>{t("settings:interface.filesChanged.title")}</div> |
| 41 | + </div> |
| 42 | + |
| 43 | + <div> |
| 44 | + <VSCodeCheckbox |
| 45 | + checked={filesChangedEnabled ?? true} |
| 46 | + onChange={(e: any) => { |
| 47 | + setCachedStateField("filesChangedEnabled", e.target.checked) |
| 48 | + vscode.postMessage({ |
| 49 | + type: "filesChangedEnabled", |
| 50 | + bool: e.target.checked, |
| 51 | + }) |
| 52 | + }} |
| 53 | + data-testid="files-changed-enabled-checkbox"> |
| 54 | + {t("settings:interface.filesChanged.enabled.label")} |
| 55 | + </VSCodeCheckbox> |
| 56 | + <div className="text-vscode-descriptionForeground text-sm mt-1 mb-3"> |
| 57 | + {t("settings:interface.filesChanged.enabled.description")} |
| 58 | + </div> |
| 59 | + </div> |
| 60 | + |
| 61 | + <div> |
| 62 | + <span className="block font-medium mb-1"> |
| 63 | + {t("settings:interface.filesChanged.maxDisplayFiles.label")} |
| 64 | + </span> |
| 65 | + <div className="flex items-center gap-2"> |
| 66 | + <Slider |
| 67 | + min={10} |
| 68 | + max={200} |
| 69 | + step={1} |
| 70 | + value={[filesChangedMaxDisplayFiles ?? 50]} |
| 71 | + onValueChange={([value]) => { |
| 72 | + setCachedStateField("filesChangedMaxDisplayFiles", value) |
| 73 | + vscode.postMessage({ |
| 74 | + type: "filesChangedMaxDisplayFiles", |
| 75 | + value: value, |
| 76 | + }) |
| 77 | + }} |
| 78 | + data-testid="files-changed-max-display-files-slider" |
| 79 | + /> |
| 80 | + <span className="w-10">{filesChangedMaxDisplayFiles ?? 50}</span> |
| 81 | + </div> |
| 82 | + <div className="text-vscode-descriptionForeground text-sm mt-1"> |
| 83 | + {t("settings:interface.filesChanged.maxDisplayFiles.description")} |
| 84 | + </div> |
| 85 | + </div> |
| 86 | + </div> |
| 87 | + </Section> |
| 88 | + </div> |
| 89 | + ) |
| 90 | +} |
0 commit comments