Farmbot-Web-App/webpack/farmware/weed_detector/selectors.ts
Gabriel Burnworth 29a14e3997 Misc bug fixes and refactoring (#627)
* allow external docs links

* match upgrade path test cases

* style updates: prefer return < over (

* refactor util

* import refactor

* fix sequence step scroll

* refactor mocked paths

* remove unnecessary prop

* zoom level checks

* misc fixes

* sync and estop button fixes

* don't sync WebAppConfigs
2018-01-20 07:46:44 -07:00

19 lines
752 B
TypeScript

import { DropDownItem, NULL_CHOICE } from "../../ui/index";
import { SPECIAL_VALUE_DDI } from "./constants";
import { WD_ENV } from "./remote_env/interfaces";
import { envGet } from "./remote_env/selectors";
/** Convert values like SPECIAL_VALUES.TRUE to drop down items with friendly
* label/value pairs. */
export let translateSpecialValue = (input: number): DropDownItem => {
return SPECIAL_VALUE_DDI[input] || NULL_CHOICE;
};
/** Generates a lookup function to convert WeedDetector ENV items to
* DropDownItems. Used to display currently selected options within dropdown
* menus. */
export let getDropdownSelection = (env: Partial<WD_ENV>) =>
(key: keyof WD_ENV): DropDownItem => {
return translateSpecialValue(envGet(key, env));
};