import * as React from "react"; import { Content, DeviceSetting } from "../../constants"; import { t } from "../../i18next_wrapper"; import { setWebAppConfigValue } from "../../config_storage/actions"; import { Row, Col } from "../../ui"; import { ToggleButton } from "../../controls/toggle_button"; import { BooleanSetting, NumericSetting } from "../../session_keys"; import { resetVirtualTrail } from "../map/layers/farmbot/bot_trail"; import { MapSizeInputs } from "../map_size_setting"; import { isUndefined } from "lodash"; import { Collapse } from "@blueprintjs/core"; import { Header } from "../../devices/components/hardware_settings/header"; import { Highlight } from "../../devices/components/maybe_highlight"; import { DesignerSettingsSectionProps, SettingProps, DesignerSettingsPropsBase, SettingDescriptionProps, } from "./interfaces"; export const Designer = (props: DesignerSettingsSectionProps) => { const { getConfigValue, dispatch, controlPanelState } = props; const settingsProps = { getConfigValue, dispatch }; return
{PlainDesignerSettings(settingsProps)} ; }; export const PlainDesignerSettings = (settingsProps: DesignerSettingsPropsBase) => DESIGNER_SETTINGS(settingsProps).map(setting => ); const Setting = (props: SettingProps) => { const { title, setting, callback, defaultOn } = props; const raw_value = setting ? props.getConfigValue(setting) : undefined; const value = (defaultOn && isUndefined(raw_value)) ? true : !!raw_value; return
{setting && { props.dispatch(setWebAppConfigValue(setting, !value)); callback?.(); }} title={`${t("toggle")} ${title}`} customText={{ textFalse: t("off"), textTrue: t("on") }} />}

{t(props.description)}

{props.children}
; }; const DESIGNER_SETTINGS = (settingsProps: DesignerSettingsPropsBase): SettingDescriptionProps[] => ([ { title: DeviceSetting.animations, description: t(Content.PLANT_ANIMATIONS), setting: BooleanSetting.disable_animations, invert: true }, { title: DeviceSetting.trail, description: t(Content.VIRTUAL_TRAIL), setting: BooleanSetting.display_trail, callback: resetVirtualTrail, }, { title: DeviceSetting.dynamicMap, description: t(Content.DYNAMIC_MAP_SIZE), setting: BooleanSetting.dynamic_map, }, { title: DeviceSetting.mapSize, description: t(Content.MAP_SIZE), children: , disabled: !!settingsProps.getConfigValue(BooleanSetting.dynamic_map), }, { title: DeviceSetting.rotateMap, description: t(Content.MAP_SWAP_XY), setting: BooleanSetting.xy_swap, }, { title: DeviceSetting.mapOrigin, description: t(Content.MAP_ORIGIN), children: }, { title: DeviceSetting.confirmPlantDeletion, description: t(Content.CONFIRM_PLANT_DELETION), setting: BooleanSetting.confirm_plant_deletion, defaultOn: true, }, ]); const OriginSelector = (props: DesignerSettingsPropsBase) => { const quadrant = props.getConfigValue(NumericSetting.bot_origin_quadrant); const update = (value: number) => () => props.dispatch(setWebAppConfigValue( NumericSetting.bot_origin_quadrant, value)); return
{[2, 1, 3, 4].map(q =>
)}
; };