diff --git a/frontend/constants.ts b/frontend/constants.ts
index 44c97ab0d1..747697abba 100644
--- a/frontend/constants.ts
+++ b/frontend/constants.ts
@@ -1870,16 +1870,13 @@ export enum DeviceSetting {
osAutoUpdate = `auto update`,
farmbotOS = `Farmbot OS`,
bootSequence = `Boot Sequence`,
-
- // Firmware
- firmwareSection = `Firmware`,
firmware = `Firmware`,
firmwarePath = `Firmware path`,
- restartFirmware = `Restart Firmware`,
flashFirmware = `Flash firmware`,
// Power and Reset
powerAndReset = `Power and Reset`,
+ restartFirmware = `Restart Firmware`,
restartFarmbot = `Restart Farmbot`,
shutdownFarmbot = `Shutdown Farmbot`,
softReset = `Soft Reset`,
diff --git a/frontend/settings/fbos_settings/__tests__/farmbot_os_settings_test.tsx b/frontend/settings/fbos_settings/__tests__/farmbot_os_settings_test.tsx
index 16da81f110..52d7cebadc 100644
--- a/frontend/settings/fbos_settings/__tests__/farmbot_os_settings_test.tsx
+++ b/frontend/settings/fbos_settings/__tests__/farmbot_os_settings_test.tsx
@@ -2,19 +2,34 @@ jest.mock("../boot_sequence_selector", () => ({
BootSequenceSelector: () =>
}));
+const mockDevice = {
+ flashFirmware: jest.fn((_) => Promise.resolve()),
+};
+jest.mock("../../../device", () => ({ getDevice: () => mockDevice }));
+
import React from "react";
import { FarmBotSettings } from "../farmbot_os_settings";
-import { shallow } from "enzyme";
+import { mount, shallow } from "enzyme";
import { bot } from "../../../__test_support__/fake_state/bot";
import { FarmbotSettingsProps } from "../interfaces";
import { fakeTimeSettings } from "../../../__test_support__/fake_time_settings";
-import { fakeDevice } from "../../../__test_support__/resource_index_builder";
+import {
+ buildResourceIndex, fakeDevice,
+} from "../../../__test_support__/resource_index_builder";
import { settingsPanelState } from "../../../__test_support__/panel_state";
+import { clickButton } from "../../../__test_support__/helpers";
+import { fakeFbosConfig } from "../../../__test_support__/fake_state/resources";
+import { fakeState } from "../../../__test_support__/fake_state";
+import { isFunction } from "lodash";
describe("", () => {
+ const fakeConfig = fakeFbosConfig();
+ const state = fakeState();
+ state.resources = buildResourceIndex([fakeConfig, fakeDevice()]);
+
const fakeProps = (): FarmbotSettingsProps => ({
device: fakeDevice(),
- dispatch: jest.fn(),
+ dispatch: jest.fn(x => isFunction(x) && x(jest.fn(), () => state)),
bot,
alerts: [],
botOnline: true,
@@ -22,6 +37,7 @@ describe("", () => {
({ value: bot.hardware.configuration[x], consistent: true }),
timeSettings: fakeTimeSettings(),
settingsPanelState: settingsPanelState(),
+ showAdvanced: true,
});
it("displays boot sequence selector", () => {
@@ -30,4 +46,14 @@ describe("", () => {
const osSettings = shallow();
expect(osSettings.find("BootSequenceSelector").length).toEqual(1);
});
+
+ it("flashes firmware", () => {
+ const p = fakeProps();
+ p.settingsPanelState.farmbot_settings = true;
+ p.sourceFbosConfig = () => ({ value: "arduino", consistent: true });
+ const wrapper = mount();
+ expect(wrapper.text().toLowerCase()).toContain("flash");
+ clickButton(wrapper, 5, "flash");
+ expect(mockDevice.flashFirmware).toHaveBeenCalledWith("arduino");
+ });
});
diff --git a/frontend/settings/fbos_settings/__tests__/power_and_reset_test.tsx b/frontend/settings/fbos_settings/__tests__/power_and_reset_test.tsx
index 57f98a1823..9440c32d5d 100644
--- a/frontend/settings/fbos_settings/__tests__/power_and_reset_test.tsx
+++ b/frontend/settings/fbos_settings/__tests__/power_and_reset_test.tsx
@@ -11,6 +11,7 @@ import { fakeFbosConfig } from "../../../__test_support__/fake_state/resources";
import {
buildResourceIndex,
} from "../../../__test_support__/resource_index_builder";
+import { clickButton } from "../../../__test_support__/helpers";
describe("", () => {
const fakeConfig = fakeFbosConfig();
@@ -21,6 +22,7 @@ describe("", () => {
settingsPanelState: settingsPanelState(),
dispatch: jest.fn(x => x(jest.fn(), () => state)),
botOnline: true,
+ showAdvanced: true,
});
it("renders in open state", () => {
@@ -41,4 +43,14 @@ describe("", () => {
expect(wrapper.text().toLowerCase())
.not.toContain("Soft Reset".toLowerCase());
});
+
+ it("restarts firmware", () => {
+ const p = fakeProps();
+ p.settingsPanelState.power_and_reset = true;
+ const wrapper = mount();
+ expect(wrapper.text().toLowerCase())
+ .toContain("Restart Firmware".toLowerCase());
+ clickButton(wrapper, 0, "restart");
+ expect(mockDevice.rebootFirmware).toHaveBeenCalled();
+ });
});
diff --git a/frontend/settings/fbos_settings/boot_sequence_selector.tsx b/frontend/settings/fbos_settings/boot_sequence_selector.tsx
index 4ff2723a6c..7c9af7284b 100644
--- a/frontend/settings/fbos_settings/boot_sequence_selector.tsx
+++ b/frontend/settings/fbos_settings/boot_sequence_selector.tsx
@@ -72,14 +72,12 @@ export class RawBootSequenceSelector
render() {
return
-
+
-
-
-
+
diff --git a/frontend/settings/fbos_settings/farmbot_os_settings.tsx b/frontend/settings/fbos_settings/farmbot_os_settings.tsx
index 2907e89bd1..55520424d9 100644
--- a/frontend/settings/fbos_settings/farmbot_os_settings.tsx
+++ b/frontend/settings/fbos_settings/farmbot_os_settings.tsx
@@ -12,6 +12,9 @@ import { DeviceSetting } from "../../constants";
import { Collapse } from "@blueprintjs/core";
import { OrderNumberRow } from "./order_number_row";
import { GardenLocationRow } from "./garden_location_row";
+import { BoardType } from "../firmware/board_type";
+import { FirmwarePathRow } from "../firmware/firmware_path";
+import { validFirmwareHardware } from "../firmware/firmware_hardware_support";
export enum ColWidth {
label = 3,
@@ -23,6 +26,8 @@ export const FarmBotSettings = (props: FarmbotSettingsProps) => {
const {
dispatch, device, timeSettings, sourceFbosConfig, botOnline,
} = props;
+ const { value } = props.sourceFbosConfig("firmware_hardware");
+ const firmwareHardware = validFirmwareHardware(value);
const commonProps = { dispatch, device };
return
@@ -47,6 +52,18 @@ export const FarmBotSettings = (props: FarmbotSettingsProps) => {
botOnline={botOnline}
timeSettings={timeSettings} />
+
+
;
};
diff --git a/frontend/settings/fbos_settings/fbos_button_row.tsx b/frontend/settings/fbos_settings/fbos_button_row.tsx
index 61dfd1c5dd..8c1d016e51 100644
--- a/frontend/settings/fbos_settings/fbos_button_row.tsx
+++ b/frontend/settings/fbos_settings/fbos_button_row.tsx
@@ -10,11 +10,15 @@ export interface FbosButtonRowProps {
description: string;
buttonText: string;
color: string;
+ advanced?: boolean;
+ showAdvanced?: boolean;
action: () => void;
}
export const FbosButtonRow = (props: FbosButtonRowProps) => {
- return
+ return
-
+
+ { restartFirmware(); }} />
Promise.resolve()),
- flashFirmware: jest.fn((_) => Promise.resolve()),
-};
-jest.mock("../../../device", () => ({ getDevice: () => mockDevice }));
-
-import React from "react";
-import { mount } from "enzyme";
-import { Firmware } from "../firmware";
-import { FirmwareProps } from "../interfaces";
-import { fakeState } from "../../../__test_support__/fake_state";
-import { clickButton } from "../../../__test_support__/helpers";
-import { fakeFbosConfig } from "../../../__test_support__/fake_state/resources";
-import {
- buildResourceIndex,
-} from "../../../__test_support__/resource_index_builder";
-import {
- fakeTimeSettings,
-} from "../../../__test_support__/fake_time_settings";
-import { bot } from "../../../__test_support__/fake_state/bot";
-import { settingsPanelState } from "../../../__test_support__/panel_state";
-
-describe("", () => {
- const fakeConfig = fakeFbosConfig();
- const state = fakeState();
- state.resources = buildResourceIndex([fakeConfig]);
-
- const fakeProps = (): FirmwareProps => ({
- dispatch: jest.fn(x => x(jest.fn(), () => state)),
- sourceFbosConfig: () => ({ value: true, consistent: true }),
- botOnline: true,
- bot: bot,
- alerts: [],
- timeSettings: fakeTimeSettings(),
- settingsPanelState: settingsPanelState(),
- showAdvanced: true,
- });
-
- it("restarts firmware", () => {
- const p = fakeProps();
- p.settingsPanelState.firmware = true;
- const wrapper = mount();
- expect(wrapper.text().toLowerCase())
- .toContain("Restart Firmware".toLowerCase());
- clickButton(wrapper, 3, "restart");
- expect(mockDevice.rebootFirmware).toHaveBeenCalled();
- });
-
- it("flashes firmware", () => {
- const p = fakeProps();
- p.settingsPanelState.firmware = true;
- p.sourceFbosConfig = () => ({ value: "arduino", consistent: true });
- const wrapper = mount();
- expect(wrapper.text().toLowerCase())
- .toContain("Flash Firmware".toLowerCase());
- clickButton(wrapper, 0, "flash firmware");
- expect(mockDevice.flashFirmware).toHaveBeenCalledWith("arduino");
- });
-});
diff --git a/frontend/settings/firmware/board_type.tsx b/frontend/settings/firmware/board_type.tsx
index 423f6fce99..591c9429fc 100644
--- a/frontend/settings/firmware/board_type.tsx
+++ b/frontend/settings/firmware/board_type.tsx
@@ -1,7 +1,6 @@
import React from "react";
import { Row, Col, DropDownItem, FBSelect } from "../../ui";
import { info } from "../../toast/toast";
-import { ColWidth } from "../fbos_settings/farmbot_os_settings";
import { updateConfig } from "../../devices/actions";
import { BoardTypeProps } from "./interfaces";
import { t } from "../../i18next_wrapper";
@@ -50,12 +49,12 @@ export class BoardType extends React.Component {
render() {
return
-
+
-
+
{
dispatch={this.props.dispatch}
timeSettings={this.props.timeSettings} />
-
+
-
-
-
+
diff --git a/frontend/settings/firmware/firmware.tsx b/frontend/settings/firmware/firmware.tsx
deleted file mode 100644
index deaed45fa2..0000000000
--- a/frontend/settings/firmware/firmware.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import React from "react";
-import { Header } from "../hardware_settings/header";
-import { Collapse } from "@blueprintjs/core";
-import { FirmwareProps } from "./interfaces";
-import { FbosButtonRow } from "../fbos_settings/fbos_button_row";
-import { Content, DeviceSetting } from "../../constants";
-import { restartFirmware } from "../../devices/actions";
-import { t } from "../../i18next_wrapper";
-import { Highlight } from "../maybe_highlight";
-import { BoardType } from "./board_type";
-import { validFirmwareHardware } from "./firmware_hardware_support";
-import { FirmwarePathRow } from "./firmware_path";
-
-export function Firmware(props: FirmwareProps) {
- const { dispatch, sourceFbosConfig, botOnline } = props;
- const { firmware } = props.settingsPanelState;
-
- const { value } = props.sourceFbosConfig("firmware_hardware");
- const firmwareHardware = validFirmwareHardware(value);
- return
-
-
-
-
- { restartFirmware(); }} />
-
- ;
-}
diff --git a/frontend/settings/firmware/firmware_hardware_status.tsx b/frontend/settings/firmware/firmware_hardware_status.tsx
index c656ab0824..3b0b26f6ff 100644
--- a/frontend/settings/firmware/firmware_hardware_status.tsx
+++ b/frontend/settings/firmware/firmware_hardware_status.tsx
@@ -46,6 +46,7 @@ export interface FirmwareHardwareStatusDetailsProps {
export interface FlashFirmwareBtnProps {
apiFirmwareValue: string | undefined;
botOnline: boolean;
+ short?: boolean;
}
export const FlashFirmwareBtn = (props: FlashFirmwareBtnProps) => {
@@ -55,7 +56,7 @@ export const FlashFirmwareBtn = (props: FlashFirmwareBtnProps) => {
title={t("flash firmware")}
onClick={() => isFwHardwareValue(apiFirmwareValue) &&
flashFirmware(apiFirmwareValue)}>
- {t("flash firmware")}
+ {props.short ? t("flash") : t("flash firmware")}
;
};
diff --git a/frontend/settings/firmware/firmware_path.tsx b/frontend/settings/firmware/firmware_path.tsx
index c496ac4932..cb6feca676 100644
--- a/frontend/settings/firmware/firmware_path.tsx
+++ b/frontend/settings/firmware/firmware_path.tsx
@@ -66,17 +66,15 @@ export const FirmwarePathRow = (props: FirmwarePathRowProps) =>
hidden={!props.showAdvanced}
className={"advanced"}>
-
+
-
+
{props.firmwarePath || t("not set")}
-
-
-
+
diff --git a/frontend/settings/hardware_settings/__tests__/parameter_management_test.tsx b/frontend/settings/hardware_settings/__tests__/parameter_management_test.tsx
index c17982872f..acadf94188 100644
--- a/frontend/settings/hardware_settings/__tests__/parameter_management_test.tsx
+++ b/frontend/settings/hardware_settings/__tests__/parameter_management_test.tsx
@@ -75,6 +75,7 @@ describe("", () => {
const fakeProps = (): ParameterImportProps => ({
dispatch: jest.fn(),
arduinoBusy: false,
+ showAdvanced: true,
});
it("updates", () => {
diff --git a/frontend/settings/hardware_settings/parameter_management.tsx b/frontend/settings/hardware_settings/parameter_management.tsx
index bb47099885..3cf32dce89 100644
--- a/frontend/settings/hardware_settings/parameter_management.tsx
+++ b/frontend/settings/hardware_settings/parameter_management.tsx
@@ -67,7 +67,9 @@ export function ParameterManagement(props: ParameterManagementProps) {
-
+
-
+
-
+