Farmbot-Web-App/frontend/sequences/step_tiles/tile_if/then_else.tsx

38 lines
1.4 KiB
TypeScript
Raw Normal View History

2019-02-11 19:44:45 -07:00
import * as React from "react";
import { ThenElseParams, seqDropDown, IfBlockDropDownHandler } from "./index";
import { Col, FBSelect } from "../../../ui";
2019-02-11 19:44:45 -07:00
import { LocalsList } from "../../locals_list/locals_list";
2019-02-22 19:09:40 -07:00
import { AllowedVariableNodes } from "../../locals_list/locals_list_support";
2019-04-02 13:59:37 -06:00
import { t } from "../../../i18next_wrapper";
2019-02-11 19:44:45 -07:00
export function ThenElse(props: ThenElseParams) {
const {
onChange, selectedItem, calledSequenceVariableData, assignVariable
} = IfBlockDropDownHandler(props);
const { body } = props.currentStep.args[props.thenElseKey];
2020-05-06 16:02:53 -06:00
return <Col xs={12} lg={6}>
<div className="execute-row">
<label>{props.thenElseKey === "_then" ? t("Then Execute") : t("Else Execute")}
</label>
</div>
<FBSelect
key={JSON.stringify(props.currentSequence)}
allowEmpty={true}
list={seqDropDown(props.resources)}
onChange={onChange}
selectedItem={selectedItem()} />
{!!calledSequenceVariableData &&
2020-05-06 16:02:53 -06:00
<Col xs={12}>
<LocalsList
bodyVariables={body}
variableData={calledSequenceVariableData}
sequenceUuid={props.currentSequence.uuid}
resources={props.resources}
onChange={assignVariable(body || [])}
locationDropdownKey={JSON.stringify(props.currentSequence)}
allowedVariableNodes={AllowedVariableNodes.identifier}
shouldDisplay={props.shouldDisplay || (() => false)} />
</Col>}
2019-09-04 12:54:21 -06:00
</Col>;
2019-02-11 19:44:45 -07:00
}