Farmbot-Web-App/frontend/devices/components/fbos_settings/factory_reset_row.tsx

81 lines
2.4 KiB
TypeScript
Raw Normal View History

2017-11-09 09:45:11 -07:00
import * as React from "react";
import { Row, Col } from "../../../ui/index";
2019-04-02 13:59:37 -06:00
2017-11-09 09:45:11 -07:00
import { Content } from "../../../constants";
import { factoryReset, updateConfig } from "../../actions";
import { ToggleButton } from "../../../controls/toggle_button";
2018-01-27 02:29:13 -07:00
import { BotConfigInputBox } from "../bot_config_input_box";
import { FactoryResetRowProps } from "./interfaces";
import { ColWidth } from "../farmbot_os_settings";
2019-04-02 13:59:37 -06:00
import { t } from "../../../i18next_wrapper";
2017-11-09 09:45:11 -07:00
2018-01-27 02:29:13 -07:00
export function FactoryResetRow(props: FactoryResetRowProps) {
const { dispatch, sourceFbosConfig, botOnline } = props;
2018-01-29 10:21:46 -07:00
const disableFactoryReset = sourceFbosConfig("disable_factory_reset");
const maybeDisableTimer = disableFactoryReset.value ? { color: "grey" } : {};
return <div>
<Row>
<Col xs={ColWidth.label}>
<label>
{t("Factory Reset")}
</label>
</Col>
<Col xs={ColWidth.description}>
<p>
{t(Content.FACTORY_RESET_WARNING)}
</p>
</Col>
<Col xs={ColWidth.button}>
<button
className="fb-button red"
type="button"
onClick={factoryReset}
disabled={!botOnline}>
{t("FACTORY RESET")}
</button>
</Col>
</Row>
<Row>
<Col xs={ColWidth.label}>
<label>
{t("Automatic Factory Reset")}
</label>
</Col>
<Col xs={ColWidth.description}>
<p>
{t(Content.AUTO_FACTORY_RESET)}
</p>
</Col>
<Col xs={ColWidth.button}>
2018-01-27 02:29:13 -07:00
<ToggleButton
2018-01-29 10:21:46 -07:00
toggleValue={!disableFactoryReset.value}
dim={!disableFactoryReset.consistent}
toggleAction={() => {
2018-01-27 02:29:13 -07:00
dispatch(updateConfig({
2018-01-29 10:21:46 -07:00
disable_factory_reset: !disableFactoryReset.value
2018-01-27 02:29:13 -07:00
}));
}} />
</Col>
</Row>
<Row>
<Col xs={ColWidth.label}>
<label style={maybeDisableTimer}>
{t("Connection Attempt Period")}
</label>
</Col>
<Col xs={ColWidth.description}>
<p style={maybeDisableTimer}>
{t(Content.AUTO_FACTORY_RESET_PERIOD)}
</p>
</Col>
<Col xs={ColWidth.button}>
<BotConfigInputBox
setting="network_not_found_timer"
2018-01-27 02:29:13 -07:00
dispatch={dispatch}
2018-01-29 10:21:46 -07:00
disabled={!!disableFactoryReset.value}
2018-01-27 02:29:13 -07:00
sourceFbosConfig={sourceFbosConfig} />
</Col>
</Row >
</div >;
2017-11-09 09:45:11 -07:00
}