commit
1a8d7024a7
|
@ -190,6 +190,9 @@
|
|||
input {
|
||||
height: 3rem;
|
||||
}
|
||||
.execute-row{
|
||||
margin-top:1rem;
|
||||
}
|
||||
}
|
||||
&.execute-step {
|
||||
background: $light_gray;
|
||||
|
|
|
@ -104,7 +104,7 @@ describe("renderCeleryNode()", () => {
|
|||
lhs: "pin0", op: "is", rhs: 0, _then: { kind: "nothing", args: {} },
|
||||
_else: { kind: "nothing", args: {} }
|
||||
}
|
||||
} as If, expected: "THEN"
|
||||
} as If, expected: "Then Execute"
|
||||
},
|
||||
{
|
||||
node: {
|
||||
|
|
|
@ -37,19 +37,16 @@ describe("<TileIf/>", () => {
|
|||
expect(inputs.length).toEqual(2);
|
||||
expect(labels.length).toEqual(5);
|
||||
expect(buttons.length).toEqual(4);
|
||||
expect(inputs.first().props().placeholder).toEqual("If Statement");
|
||||
expect(block.text()).toContain("IF...");
|
||||
expect(inputs.first().props().placeholder).toEqual("If ...");
|
||||
expect(labels.at(0).text()).toEqual("Variable");
|
||||
expect(buttons.at(0).text()).toEqual("Pin 0");
|
||||
expect(labels.at(1).text()).toEqual("Operator");
|
||||
expect(buttons.at(1).text()).toEqual("is");
|
||||
expect(labels.at(2).text()).toEqual("Value");
|
||||
expect(inputs.at(1).props().value).toEqual(0);
|
||||
expect(block.text()).toContain("THEN...");
|
||||
expect(labels.at(3).text()).toEqual("Execute Sequence");
|
||||
expect(labels.at(3).text()).toEqual("Then Execute");
|
||||
expect(buttons.at(2).text()).toEqual("None");
|
||||
expect(block.text()).toContain("ELSE...");
|
||||
expect(labels.at(4).text()).toEqual("Execute Sequence");
|
||||
expect(labels.at(4).text()).toEqual("Else Execute");
|
||||
expect(buttons.at(3).text()).toEqual("None");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ function translate(input: Step): string {
|
|||
// i18next might not have the correct translation loaded. To get around this,
|
||||
// I had to put the translations in the function.
|
||||
const TRANSLATIONS: Partial<Record<SequenceBodyItem["kind"], string>> = {
|
||||
"_if": t("If Statement"),
|
||||
"_if": t("If ..."),
|
||||
"execute_script": t("Run Farmware"),
|
||||
"execute": t("Execute Sequence"),
|
||||
"find_home": t("Find Home"),
|
||||
|
|
|
@ -76,7 +76,7 @@ describe("LHSOptions()", () => {
|
|||
describe("<InnerIf />", () => {
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<InnerIf {...fakeProps()} />);
|
||||
["IF", "THEN", "ELSE"].map(string =>
|
||||
["Variable", "Operator", "Value", "Then Execute", "Else Execute"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
});
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@ describe("<ThenElse/>", () => {
|
|||
|
||||
it("renders 'then'", () => {
|
||||
const wrapper = mount(<ThenElse {...fakeProps()} />);
|
||||
["THEN", "Execute Sequence"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
expect(wrapper.text()).toContain("Then Execute");
|
||||
expect(wrapper.find("button").length).toEqual(1);
|
||||
});
|
||||
|
||||
|
@ -40,8 +39,7 @@ describe("<ThenElse/>", () => {
|
|||
const p = fakeProps();
|
||||
p.thenElseKey = "_else";
|
||||
const wrapper = mount(<ThenElse {...p} />);
|
||||
["ELSE", "Execute Sequence"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
expect(wrapper.text()).toContain("Else Execute");
|
||||
expect(wrapper.find("button").length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -39,9 +39,6 @@ export function If_(props: IfParams) {
|
|||
const lhsOptions = LHSOptions(resources, !!props.showPins);
|
||||
|
||||
return <Row>
|
||||
<Col xs={12}>
|
||||
<h4 className="top">{t("IF...")}</h4>
|
||||
</Col>
|
||||
<Col xs={4}>
|
||||
<label>{t("Variable")}</label>
|
||||
<FBSelect
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as React from "react";
|
||||
import { DropDownItem, NULL_CHOICE } from "../../../ui/index";
|
||||
import { DropDownItem, NULL_CHOICE, Row } from "../../../ui/index";
|
||||
import { TaggedSequence, ParameterApplication } from "farmbot";
|
||||
import { If, Execute, Nothing } from "farmbot/dist";
|
||||
import { ResourceIndex } from "../../../resources/interfaces";
|
||||
|
@ -104,8 +104,10 @@ export function InnerIf(props: IfParams) {
|
|||
</StepHeader>
|
||||
<StepContent className={className}>
|
||||
<If_ {...props} />
|
||||
<ThenElse thenElseKey={"_then"} {...props} />
|
||||
<ThenElse thenElseKey={"_else"} {...props} />
|
||||
<Row>
|
||||
<ThenElse thenElseKey={"_then"} {...props} />
|
||||
<ThenElse thenElseKey={"_else"} {...props} />
|
||||
</Row>
|
||||
</StepContent>
|
||||
</StepWrapper>;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from "react";
|
||||
import { ThenElseParams, seqDropDown, IfBlockDropDownHandler } from "./index";
|
||||
import { Row, Col, FBSelect } from "../../../ui";
|
||||
import { Col, FBSelect } from "../../../ui";
|
||||
import { LocalsList } from "../../locals_list/locals_list";
|
||||
import { AllowedVariableNodes } from "../../locals_list/locals_list_support";
|
||||
import { t } from "../../../i18next_wrapper";
|
||||
|
@ -10,30 +10,28 @@ export function ThenElse(props: ThenElseParams) {
|
|||
onChange, selectedItem, calledSequenceVariableData, assignVariable
|
||||
} = IfBlockDropDownHandler(props);
|
||||
const { body } = props.currentStep.args[props.thenElseKey];
|
||||
return <Row>
|
||||
<Col xs={12} md={12}>
|
||||
<h4>{props.thenElseKey === "_then" ? t("THEN...") : t("ELSE...")}</h4>
|
||||
</Col>
|
||||
<Col xs={12} md={12}>
|
||||
<label>{t("Execute Sequence")}</label>
|
||||
<FBSelect
|
||||
key={JSON.stringify(props.currentSequence)}
|
||||
allowEmpty={true}
|
||||
list={seqDropDown(props.resources)}
|
||||
onChange={onChange}
|
||||
selectedItem={selectedItem()} />
|
||||
{!!calledSequenceVariableData &&
|
||||
<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>}
|
||||
</Col>
|
||||
</Row>;
|
||||
return <Col xs={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 &&
|
||||
<Col xs={6}>
|
||||
<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>}
|
||||
</Col>;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue