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

47 lines
1.3 KiB
TypeScript
Raw Normal View History

2018-09-24 13:34:38 -06:00
import * as React from "react";
import { Row, Col } from "../../../ui";
import { ColWidth } from "../farmbot_os_settings";
2019-04-02 13:59:37 -06:00
import { t } from "../../../i18next_wrapper";
2020-02-18 12:21:09 -07:00
import { Highlight } from "../maybe_highlight";
import { DeviceSetting } from "../../../constants";
2020-03-13 15:06:40 -06:00
import { DevSettings } from "../../../account/dev/dev_support";
2018-09-24 13:34:38 -06:00
export interface FbosButtonRowProps {
botOnline: boolean;
2020-02-18 12:21:09 -07:00
label: DeviceSetting;
2018-09-24 13:34:38 -06:00
description: string;
buttonText: string;
color: string;
action: () => void;
}
export const FbosButtonRow = (props: FbosButtonRowProps) => {
2020-03-13 15:06:40 -06:00
const newFormat = DevSettings.futureFeaturesEnabled();
return <Highlight settingName={props.label}>
<Row>
<Col xs={newFormat ? 7 : ColWidth.label}>
2020-02-18 12:21:09 -07:00
<label>
{t(props.label)}
</label>
</Col>
2020-03-13 15:06:40 -06:00
{!newFormat &&
<Col xs={ColWidth.description}>
<p>
{t(props.description)}
</p>
</Col>}
<Col xs={newFormat ? 5 : ColWidth.button}>
2020-02-18 12:21:09 -07:00
<button
className={`fb-button ${props.color}`}
type="button"
onClick={props.action}
2020-02-28 09:34:28 -07:00
title={t(props.buttonText)}
2020-02-18 12:21:09 -07:00
disabled={!props.botOnline}>
{t(props.buttonText)}
</button>
</Col>
2020-03-13 15:06:40 -06:00
</Row>
{newFormat && <Row><p>{t(props.description)}</p></Row>}
</Highlight>;
2018-09-24 13:34:38 -06:00
};