diff --git a/frontend/constants.ts b/frontend/constants.ts index 49bc3ffeb..ea11a3eb2 100644 --- a/frontend/constants.ts +++ b/frontend/constants.ts @@ -348,9 +348,6 @@ export namespace ToolTips { For example, you can mark a plant as "planted" during a seeding sequence or mark a weed as "removed" after removing it.`); - export const REBOOT = - trim(`Power cycle FarmBot's onboard computer.`); - export const SET_SERVO_ANGLE = trim(`Move a servo to the provided angle. An angle of 90 degrees corresponds to the servo midpoint (or, for a continuous rotation @@ -362,6 +359,9 @@ export namespace ToolTips { export const MOVE_TO_HOME = trim(`Move FarmBot to home for the provided axis.`); + export const ASSERTION = + trim(`Evaluate Lua commands. For power users and software developers.`); + export const FIRMWARE_ACTION = trim(`FarmBot OS or micro-controller firmware action.`); @@ -740,6 +740,15 @@ export namespace Content { encoders, stall detection, or endstops enabled for the chosen axis. Enable endstops, encoders, or stall detection from the Device page for: `); + export const REBOOT_STEP = + trim(`Power cycle FarmBot's onboard computer.`); + + export const SHUTDOWN_STEP = + trim(`Power down FarmBot's onboard computer.`); + + export const ESTOP_STEP = + trim(`Unlocking a device requires user intervention.`); + export const IN_USE = trim(`Used in another resource. Protected from deletion.`); diff --git a/frontend/css/steps.scss b/frontend/css/steps.scss index d8dc65365..f62097440 100644 --- a/frontend/css/steps.scss +++ b/frontend/css/steps.scss @@ -136,6 +136,9 @@ &.reboot-step { background: $brown; } + &.shutdown-step { + background: $brown; + } &.unknown-step { background: $gray; } @@ -253,6 +256,9 @@ &.emergency-stop-step { background: $light_red; } + &.shutdown-step { + background: $light_brown; + } &.reboot-step { background: $light_brown; } diff --git a/frontend/sequences/step_button_cluster.tsx b/frontend/sequences/step_button_cluster.tsx index 9425e4842..b2c21e283 100644 --- a/frontend/sequences/step_button_cluster.tsx +++ b/frontend/sequences/step_button_cluster.tsx @@ -95,6 +95,11 @@ export function StepButtonCluster(props: StepButtonProps) { color="brown"> {t("REBOOT")} , + + {t("SHUTDOWN")} + , diff --git a/frontend/sequences/step_tiles/__tests__/tile_reboot_test.tsx b/frontend/sequences/step_tiles/__tests__/tile_reboot_test.tsx index 7ec14dfca..35300c886 100644 --- a/frontend/sequences/step_tiles/__tests__/tile_reboot_test.tsx +++ b/frontend/sequences/step_tiles/__tests__/tile_reboot_test.tsx @@ -5,59 +5,56 @@ import { render } from "enzyme"; import React from "react"; import { StepParams } from "../../interfaces"; import { fakeSequence } from "../../../__test_support__/fake_state/resources"; -import { buildResourceIndex } from "../../../__test_support__/resource_index_builder"; +import { + buildResourceIndex, +} from "../../../__test_support__/resource_index_builder"; import { editStep } from "../../../api/crud"; import { Reboot } from "farmbot"; +import { Content } from "../../../constants"; -const fakeProps = (): StepParams => { - const currentSequence = fakeSequence(); - const resources = buildResourceIndex().index; - - return { - currentSequence, - currentStep: { - kind: "reboot", - args: { - package: "farmbot_os" - } - }, - dispatch: jest.fn(), - index: 1, - resources, - confirmStepDeletion: false, - }; -}; +const fakeProps = (): StepParams => ({ + currentSequence: fakeSequence(), + currentStep: { + kind: "reboot", + args: { + package: "farmbot_os" + } + }, + dispatch: jest.fn(), + index: 1, + resources: buildResourceIndex().index, + confirmStepDeletion: false, +}); describe("", () => { it("renders", () => { - const el = render(); - const verbiage = el.text(); - expect(verbiage).toContain("Power cycle FarmBot's onboard computer."); + const block = render(); + expect(block.text()).toContain(Content.REBOOT_STEP); }); it("crashes if the step is of the wrong `kind`", () => { - const props = fakeProps(); - props.currentStep = { kind: "sync", args: {} }; - const boom = () => TileReboot(props); + const p = fakeProps(); + p.currentStep = { kind: "sync", args: {} }; + const boom = () => TileReboot(p); expect(boom).toThrowError(); }); it("edits the reboot step", () => { - const props = fakeProps(); - const editFn = editTheRebootStep(props); + const p = fakeProps(); + const editFn = editTheRebootStep(p); editFn("arduino_firmware"); - expect(props.dispatch).toHaveBeenCalled(); + expect(p.dispatch).toHaveBeenCalled(); expect(editStep).toHaveBeenCalledWith({ - step: props.currentStep, - index: props.index, - sequence: props.currentSequence, + step: p.currentStep, + index: p.index, + sequence: p.currentSequence, executor: expect.any(Function), }); }); it("executes the executor", () => { - const props = fakeProps(); - const step = props.currentStep as Reboot; + const p = fakeProps(); + const step = p.currentStep as Reboot; step.args.package = "X"; const fn = rebootExecutor("arduino_firmware"); fn(step); diff --git a/frontend/sequences/step_tiles/__tests__/tile_shutdown_test.tsx b/frontend/sequences/step_tiles/__tests__/tile_shutdown_test.tsx new file mode 100644 index 000000000..e7d037b31 --- /dev/null +++ b/frontend/sequences/step_tiles/__tests__/tile_shutdown_test.tsx @@ -0,0 +1,29 @@ +import * as React from "react"; +import { mount } from "enzyme"; +import { TileShutdown } from "../tile_shutdown"; +import { fakeSequence } from "../../../__test_support__/fake_state/resources"; +import { PowerOff } from "farmbot"; +import { emptyState } from "../../../resources/reducer"; +import { StepParams } from "../../interfaces"; +import { Content } from "../../../constants"; + +describe("", () => { + const currentStep: PowerOff = { + kind: "power_off", + args: {}, + }; + + const fakeProps = (): StepParams => ({ + currentSequence: fakeSequence(), + currentStep: currentStep, + dispatch: jest.fn(), + index: 0, + resources: emptyState().index, + confirmStepDeletion: false, + }); + + it("renders step", () => { + const block = mount(); + expect(block.text()).toContain(Content.SHUTDOWN_STEP); + }); +}); diff --git a/frontend/sequences/step_tiles/index.tsx b/frontend/sequences/step_tiles/index.tsx index 09e0442cf..2adb54227 100644 --- a/frontend/sequences/step_tiles/index.tsx +++ b/frontend/sequences/step_tiles/index.tsx @@ -34,6 +34,7 @@ import { TileAssertion } from "./tile_assertion"; import { TileEmergencyStop } from "./tile_emergency_stop"; import { TileReboot } from "./tile_reboot"; import { TileOldMarkAs } from "./tile_old_mark_as"; +import { TileShutdown } from "./tile_shutdown"; interface MoveParams { step: Step; @@ -161,7 +162,8 @@ export function renderCeleryNode(props: StepParams) { case "reboot": return ; case "emergency_lock": return ; case "assertion": return ; - case "sync": case "power_off": case "read_status": + case "power_off": return ; + case "sync": case "read_status": case "emergency_unlock": case "install_first_party_farmware": return ; case "check_updates": case "factory_reset": diff --git a/frontend/sequences/step_tiles/tile_assertion.tsx b/frontend/sequences/step_tiles/tile_assertion.tsx index 53371acf9..dc6ea5c35 100644 --- a/frontend/sequences/step_tiles/tile_assertion.tsx +++ b/frontend/sequences/step_tiles/tile_assertion.tsx @@ -7,6 +7,7 @@ import { TypePart } from "./tile_assertion/type_part"; import { LuaPart } from "./tile_assertion/lua_part"; import { SequencePart } from "./tile_assertion/sequence_part"; import { Assertion } from "farmbot/dist/corpus"; +import { ToolTips } from "../../constants"; export interface AssertionStepProps extends StepParams { currentStep: Assertion; @@ -24,7 +25,7 @@ export function TileAssertion(props: StepParams) { return

- {t("Unlocking a device requires user intervention.")} + {t(Content.ESTOP_STEP)}

diff --git a/frontend/sequences/step_tiles/tile_reboot.tsx b/frontend/sequences/step_tiles/tile_reboot.tsx index ab0db3a89..044c352b9 100644 --- a/frontend/sequences/step_tiles/tile_reboot.tsx +++ b/frontend/sequences/step_tiles/tile_reboot.tsx @@ -1,6 +1,6 @@ import * as React from "react"; import { StepParams } from "../interfaces"; -import { ToolTips } from "../../constants"; +import { Content } from "../../constants"; import { StepWrapper, StepHeader, StepContent } from "../step_ui/index"; import { t } from "../../i18next_wrapper"; import { ALLOWED_PACKAGES, SequenceBodyItem, Reboot } from "farmbot"; @@ -44,7 +44,7 @@ export function TileReboot(props: StepParams) { return

- {t(ToolTips.REBOOT)} + {t(Content.REBOOT_STEP)}

{/* + + +

{t(Content.SHUTDOWN_STEP)}

+
+
; +}