Farmbot-Web-App/frontend/farmware/farmware_config_menu.tsx

53 lines
1.8 KiB
TypeScript
Raw Normal View History

2018-06-21 15:04:21 -06:00
import * as React from "react";
import { getDevice } from "../device";
import { FarmwareConfigMenuProps } from "./interfaces";
import { commandErr } from "../devices/actions";
import { toggleWebAppBool } from "../config_storage/actions";
2018-11-02 13:53:17 -06:00
import { destroyAll } from "../api/crud";
2019-06-24 15:39:49 -06:00
import { success, error } from "../toast/toast";
2018-11-02 13:53:17 -06:00
import { Feature } from "../devices/interfaces";
2019-04-02 13:59:37 -06:00
import { t } from "../i18next_wrapper";
2019-06-14 17:00:42 -06:00
import { BooleanSetting } from "../session_keys";
2018-06-21 15:04:21 -06:00
/** First-party Farmware settings. */
export function FarmwareConfigMenu(props: FarmwareConfigMenuProps) {
const listBtnColor = props.show ? "green" : "red";
2018-11-02 13:53:17 -06:00
return <div className="farmware-settings-menu-contents">
2018-06-21 15:04:21 -06:00
<label>
{t("First-party Farmware")}
</label>
<fieldset>
<label>
{t("Reinstall")}
</label>
<button
className="fb-button gray fa fa-download"
onClick={() => {
const p = getDevice().installFirstPartyFarmware();
2020-01-03 13:04:45 -07:00
p?.catch(commandErr("Farmware installation"));
2018-06-21 15:04:21 -06:00
}}
disabled={props.firstPartyFwsInstalled} />
</fieldset>
<fieldset>
<label>
{t("Show in list")}
</label>
<button
className={"fb-button fb-toggle-button " + listBtnColor}
2019-06-14 17:00:42 -06:00
onClick={() => props.dispatch(
toggleWebAppBool(BooleanSetting.show_first_party_farmware))} />
2018-06-21 15:04:21 -06:00
</fieldset>
2018-11-02 13:53:17 -06:00
{props.shouldDisplay(Feature.api_farmware_env) &&
<fieldset>
<label>
{t("Delete all Farmware data")}
</label>
<button
className={"fb-button red fa fa-trash"}
onClick={() => destroyAll("FarmwareEnv")
.then(() => success(t("Farmware data successfully deleted.")))
.catch(() => error(t("Error deleting Farmware data")))} />
</fieldset>}
2018-06-21 15:04:21 -06:00
</div>;
}