import useSettings, { SettingsValue } from "@/hooks/useSettings"; import { Button, Checkbox, Dropdown, Field, Option, OptionOnSelectData } from "@fluentui/react-components"; import { KeyCommand20Regular } from "@fluentui/react-icons"; import { useOptionsStyles } from "../hooks/useOptionsStyles"; export default function GeneralSection(): React.ReactElement { const [alwaysShowToolbars, setAlwaysShowToolbars] = useSettings("alwaysShowToolbars"); const [ignorePinned, setIgnorePinned] = useSettings("ignorePinned"); const [deletePrompt, setDeletePrompt] = useSettings("deletePrompt"); const [showBadge, setShowBadge] = useSettings("showBadge"); const [notifyOnSave, setNotifyOnSave] = useSettings("notifyOnSave"); const [dismissOnLoad, setDismissOnLoad] = useSettings("dismissOnLoad"); const [listLocation, setListLocation] = useSettings("listLocation"); const [contextAction, setContextAction] = useSettings("contextAction"); const cls = useOptionsStyles(); const openShortcutsPage = (): Promise => browser.tabs.create({ url: "chrome://extensions/shortcuts", active: true }); const handleListLocationChange = (_: any, e: OptionOnSelectData): void => { if (e.optionValue === "popup" && contextAction !== "open") setContextAction("open"); setListLocation(e.optionValue as ListLocationType); }; return ( <>
setAlwaysShowToolbars(e.checked as boolean) } /> setIgnorePinned(!e.checked) } /> setDeletePrompt(e.checked as boolean) } /> setShowBadge(e.checked as boolean) } /> setNotifyOnSave(e.checked as boolean) } /> setDismissOnLoad(e.checked as boolean) } />
{ Object.entries(listLocationOptions).map(([key, value]) => ) } setContextAction(e.optionValue as ContextActionType) } disabled={ listLocation === "popup" } > { Object.entries(contextActionOptions).map(([key, value]) => key === "context" && import.meta.env.FIREFOX ? <> : ) } { !import.meta.env.FIREFOX && } ); } type ListLocationType = SettingsValue<"listLocation">; type ContextActionType = SettingsValue<"contextAction">; const listLocationOptions: Record = { "sidebar": i18n.t("options_page.general.options.list_locations.options.sidebar"), "popup": i18n.t("options_page.general.options.list_locations.options.popup"), "tab": i18n.t("options_page.general.options.list_locations.options.tab"), "pinned": i18n.t("options_page.general.options.list_locations.options.pinned") }; const contextActionOptions: Record = { "action": i18n.t("options_page.general.options.icon_action.options.action"), "context": i18n.t("options_page.general.options.icon_action.options.context"), "open": i18n.t("options_page.general.options.icon_action.options.open") };