All files / src/components/settings/sections GeneralSettingsSection.tsx

0% Statements 0/49
0% Branches 0/1
0% Functions 0/1
0% Lines 0/49

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75                                                                                                                                                     
import { VSCodeCheckbox, VSCodeLink } from "@vscode/webview-ui-toolkit/react"
import HeroTooltip from "@/components/common/HeroTooltip"
import { useExtensionState } from "@/context/ExtensionStateContext"
import PreferredLanguageSetting from "../PreferredLanguageSetting"
import Section from "../Section"
import { updateSetting } from "../utils/settingsHandlers"
 
interface GeneralSettingsSectionProps {
	renderSectionHeader: (tabId: string) => JSX.Element | null
}
 
const GeneralSettingsSection = ({ renderSectionHeader }: GeneralSettingsSectionProps) => {
	const { telemetrySetting, remoteConfigSettings } = useExtensionState()
	const isDisabledByRemoteConfig = remoteConfigSettings?.telemetrySetting !== undefined
 
	return (
		<div>
			{renderSectionHeader("general")}
			<Section>
				<PreferredLanguageSetting />
 
				<div className="mb-[5px]">
					{isDisabledByRemoteConfig ? (
						<HeroTooltip content="This setting is managed by your organization's remote configuration">
							<div className="flex items-center gap-2 mb-[5px]">
								<VSCodeCheckbox
									checked={remoteConfigSettings?.telemetrySetting === "enabled"}
									disabled={true}
									onChange={(e: any) => {
										const checked = e.target.checked === true
										updateSetting("telemetrySetting", checked ? "enabled" : "disabled")
									}}>
									Allow error and usage reporting
								</VSCodeCheckbox>
								<i className="codicon codicon-lock text-[var(--vscode-descriptionForeground)] text-sm" />
							</div>
						</HeroTooltip>
					) : (
						<VSCodeCheckbox
							checked={telemetrySetting === "enabled"}
							className="mb-[5px]"
							disabled={false}
							onChange={(e: any) => {
								const checked = e.target.checked === true
								updateSetting("telemetrySetting", checked ? "enabled" : "disabled")
							}}>
							Allow error and usage reporting
						</VSCodeCheckbox>
					)}
					<p className="text-xs mt-[5px] text-[var(--vscode-descriptionForeground)]">
						Help improve AI-Hydro by sending usage data and error reports. No code, prompts, or personal information
						are ever sent. See our{" "}
						<VSCodeLink
							className="text-inherit"
							href="https://github.com/AI-Hydro/AI-Hydro#readme"
							style={{ fontSize: "inherit", textDecoration: "underline" }}>
							telemetry overview
						</VSCodeLink>{" "}
						and{" "}
						<VSCodeLink
							className="text-inherit"
							href="https://github.com/AI-Hydro/AI-Hydro#readme"
							style={{ fontSize: "inherit", textDecoration: "underline" }}>
							privacy policy
						</VSCodeLink>{" "}
						for more details.
					</p>
				</div>
			</Section>
		</div>
	)
}
 
export default GeneralSettingsSection