pull/684/head
Rick Carlino 2018-02-27 10:02:35 -06:00
parent 7f4d7733e8
commit 3a25110c8b
4 changed files with 16 additions and 23 deletions

View File

@ -22,7 +22,7 @@ export interface Subscription { fn: (state: Everything) => void; env: EnvName; }
/** To make it easier to manage all things watching the state tree,
* we keep subscriber functions in this array. */
export let subscriptions: Subscription[] =
[{ env: "*", fn: dontExitIfBrowserIsOnHold }];
[{ env: "production", fn: dontExitIfBrowserIsOnHold }];
export function registerSubscribers(store: Store) {
const ENV_LIST = [process.env.NODE_ENV, "*"];

View File

@ -4,6 +4,9 @@ import { buildResourceIndex } from "../../__test_support__/resource_index_builde
import { shallow } from "enzyme";
import { TaggedSequence, SpecialStatus } from "../../resources/tagged_resources";
import { maybeTagSteps } from "../../resources/sequence_tagging";
import { TileMoveRelative } from "../step_tiles/tile_move_relative";
import { TileReadPin } from "../step_tiles/tile_read_pin";
import { TileWritePin } from "../step_tiles/tile_write_pin";
describe("<AllSteps/>", () => {
const TEST_CASE = {
@ -59,12 +62,9 @@ describe("<AllSteps/>", () => {
onDrop={() => { }}
dispatch={jest.fn()}
resources={buildResourceIndex([]).index} />);
[
"TileMoveRelative",
"TileReadPin",
"TileWritePin"
].map(q => {
expect(el.find(q).length).toEqual(1);
});
[TileMoveRelative, TileReadPin, TileWritePin]
.map(q => {
expect(el.find(q).length).toEqual(1);
});
});
});

View File

@ -1,6 +1,6 @@
import * as React from "react";
import { TaggedSequence } from "../resources/tagged_resources";
import { SequenceBodyItem, LegalSequenceKind } from "farmbot/dist";
import { SequenceBodyItem } from "farmbot/dist";
import { DropArea } from "../draggable/drop_area";
import { StepDragger } from "../draggable/step_dragger";
import { renderCeleryNode } from "./step_tiles/index";
@ -21,7 +21,7 @@ export class AllSteps extends React.Component<AllStepsProps, {}> {
render() {
const {
sequence, onDrop, dispatch, hardwareFlags, farmwareInfo
} = this.props;
} = this.props;
const items = (sequence.body.body || [])
.map((currentStep: SequenceBodyItem, index, arr) => {
/** HACK: React's diff algorithm (probably?) can't keep track of steps
@ -39,10 +39,10 @@ export class AllSteps extends React.Component<AllStepsProps, {}> {
intent="step_move"
draggerId={index}>
<div>
{renderCeleryNode(currentStep.kind as LegalSequenceKind, {
{renderCeleryNode({
currentStep,
index,
dispatch: dispatch,
dispatch,
currentSequence: sequence,
resources: this.props.resources,
hardwareFlags,

View File

@ -3,7 +3,7 @@ import { SequenceBodyItem as Step } from "farmbot";
import { NUMERIC_FIELDS } from "../interfaces";
import { ExecuteBlock } from "./tile_execute";
import { StepParams, StepInputProps, StepTitleBarProps } from "../interfaces";
import { defensiveClone, move as arrayMover, equals } from "../../util";
import { defensiveClone, move as arrayMover } from "../../util";
import { TileIf } from "./tile_if";
import { TileWait } from "./tile_wait";
import { TileMoveAbsolute } from "./tile_move_absolute";
@ -14,9 +14,7 @@ import { TileWritePin } from "./tile_write_pin";
import { TileExecuteScript } from "./tile_execute_script";
import { TileTakePhoto } from "./tile_take_photo";
import * as _ from "lodash";
import {
CeleryNode, LegalSequenceKind, LegalArgString, If, Execute, Nothing
} from "farmbot";
import { CeleryNode, LegalArgString, If, Execute, Nothing } from "farmbot";
import { TaggedSequence } from "../../resources/tagged_resources";
import { overwrite } from "../../api/crud";
import { TileFindHome } from "./tile_find_home";
@ -95,12 +93,7 @@ export function updateStep(props: StepInputProps) {
}
seqCopy.body[index] = stepCopy;
if (equals(sequence.body.body, seqCopy.body)) {
console.log("equal => NO OP.");
} else {
console.log("Not equal => mutating.");
dispatch(overwrite(sequence, seqCopy));
}
dispatch(overwrite(sequence, seqCopy));
};
}
@ -127,7 +120,7 @@ function numericNonsense(val: string, copy: CeleryNode, field: LegalArgString) {
return _.assign(copy.args, { [field]: num });
}
export function renderCeleryNode(kind: LegalSequenceKind, props: StepParams) {
export function renderCeleryNode(props: StepParams) {
switch (props.currentStep.kind) {
case "_if": return <TileIf {...props} />;
case "execute_script": return <TileExecuteScript {...props} />;