From 4b831663a74b15921fbf177fdfd669e9a955980a Mon Sep 17 00:00:00 2001 From: gabrielburnworth Date: Wed, 19 Jun 2024 09:09:47 -0700 Subject: [PATCH] add OTA time step to setup wizard --- frontend/constants.ts | 9 ++++ .../settings/__tests__/default_values_test.ts | 4 +- frontend/wizard/__tests__/checks_test.tsx | 14 ++++++ frontend/wizard/checks.tsx | 19 ++++++- frontend/wizard/data.ts | 50 ++++++++++++------- 5 files changed, 74 insertions(+), 22 deletions(-) diff --git a/frontend/constants.ts b/frontend/constants.ts index cc9f55559..5f1cb9279 100644 --- a/frontend/constants.ts +++ b/frontend/constants.ts @@ -1702,6 +1702,15 @@ export namespace SetupWizardContent { re-flashing the SD card via Etcher. If possible, ensure line-of-sight between devices when trying to connect.`); + export const AUTO_UPDATE = + trim(`Set the time you wish for FarmBot to automatically download and + install updates when available. During this time FarmBot will reboot + to apply the update, so you should never schedule any events to occur + during the same hour. We recommend selecting 3 AM.`); + + export const AUTO_UPDATE_QUESTION = + trim(`Did you select a time when you will not need to use your FarmBot?`); + export const MAP_ORIENTATION = trim(`Watch the video below showing how to match the virtual FarmBot map to your real life FarmBot. The relevant controls are available diff --git a/frontend/settings/__tests__/default_values_test.ts b/frontend/settings/__tests__/default_values_test.ts index 800de398a..c9db697fe 100644 --- a/frontend/settings/__tests__/default_values_test.ts +++ b/frontend/settings/__tests__/default_values_test.ts @@ -1,6 +1,8 @@ import { fakeState } from "../../__test_support__/fake_state"; import { buildResourceIndex } from "../../__test_support__/resource_index_builder"; -import { fakeFbosConfig, fakeWebAppConfig } from "../../__test_support__/fake_state/resources"; +import { + fakeFbosConfig, fakeWebAppConfig, +} from "../../__test_support__/fake_state/resources"; const mockState = fakeState(); const config = fakeWebAppConfig(); config.body.highlight_modified_settings = true; diff --git a/frontend/wizard/__tests__/checks_test.tsx b/frontend/wizard/__tests__/checks_test.tsx index 569020913..520aab77a 100644 --- a/frontend/wizard/__tests__/checks_test.tsx +++ b/frontend/wizard/__tests__/checks_test.tsx @@ -40,6 +40,7 @@ import { } from "../../__test_support__/resource_index_builder"; import { AssemblyDocs, + AutoUpdate, AxisActions, BootSequence, CameraCalibrationCard, @@ -478,6 +479,19 @@ describe("", () => { }); }); +describe("", () => { + it("renders OTA time selector", () => { + const p = fakeProps(); + const config = fakeFbosConfig(); + config.body.os_auto_update = true; + const device = fakeDevice(); + device.body.ota_hour = 1; + p.resources = buildResourceIndex([config, device]).index; + const wrapper = mount(); + expect(wrapper.text()).toEqual("1:00 AM"); + }); +}); + describe("", () => { const state = fakeState(); const config = fakeFirmwareConfig(); diff --git a/frontend/wizard/checks.tsx b/frontend/wizard/checks.tsx index d033f582d..f159e6044 100644 --- a/frontend/wizard/checks.tsx +++ b/frontend/wizard/checks.tsx @@ -13,6 +13,7 @@ import { selectAllFarmwareEnvs, selectAllImages, selectAllLogs, selectAllPeripherals, selectAllSensors, selectAllTools, + maybeGetTimeSettings, } from "../resources/selectors"; import { last, some, uniq } from "lodash"; import { @@ -25,7 +26,7 @@ import { } from "../settings/fbos_settings/fbos_details"; import { ExternalUrl } from "../external_urls"; import { getFbosConfig, getFirmwareConfig } from "../resources/getters"; -import { validFwConfig } from "../util"; +import { validFbosConfig, validFwConfig } from "../util"; import { validBotLocationData } from "../util/location"; import { getFwHardwareValue, isExpress, @@ -43,7 +44,9 @@ import { FirmwareHardware, TaggedLog, Xyz } from "farmbot"; import { ConnectivityDiagram } from "../devices/connectivity/diagram"; import { Diagnosis } from "../devices/connectivity/diagnosis"; import { connectivityData } from "../devices/connectivity/generate_data"; -import { sourceFwConfigValue } from "../settings/source_config_value"; +import { + sourceFbosConfigValue, sourceFwConfigValue, +} from "../settings/source_config_value"; import { emergencyUnlock, findAxisLength, findHome, setHome, settingToggle, } from "../devices/actions"; @@ -99,6 +102,7 @@ import { import { WaterFlowRateInput } from "../tools/edit_tool"; import { RPI_OPTIONS } from "../settings/fbos_settings/rpi_model"; import { BoxTop } from "../settings/pin_bindings/box_top"; +import { OtaTimeSelector } from "../settings/fbos_settings/ota_time_selector"; export const Language = (props: WizardStepComponentProps) => { const user = getUserAccountSettings(props.resources); @@ -461,6 +465,17 @@ export const Connectivity = (props: WizardStepComponentProps) => { ; }; +export const AutoUpdate = (props: WizardStepComponentProps) => { + return ; +}; + export const InvertJogButton = (axis: Xyz) => (props: WizardOutcomeComponentProps) => { const setting: Record = { diff --git a/frontend/wizard/data.ts b/frontend/wizard/data.ts index 642359ebb..4de66cf8c 100644 --- a/frontend/wizard/data.ts +++ b/frontend/wizard/data.ts @@ -43,6 +43,7 @@ import { DownloadOS, DownloadImager, Language, + AutoUpdate, } from "./checks"; import { TaggedWizardStepResult } from "farmbot"; import { @@ -128,6 +129,7 @@ export enum WizardStepSlug { configuratorBrowser = "configuratorBrowser", configuratorSteps = "configuratorSteps", connection = "connection", + autoUpdate = "autoUpdate", mapOrientation = "mapOrientation", xMotor = "xMotor", yMotor = "yMotor", @@ -480,6 +482,16 @@ export const WIZARD_STEPS = (props: WizardStepDataProps): WizardSteps => { }, ], }, + { + section: WizardSectionSlug.connectivity, + slug: WizardStepSlug.autoUpdate, + title: t("Auto update"), + content: SetupWizardContent.AUTO_UPDATE, + component: AutoUpdate, + question: t(SetupWizardContent.AUTO_UPDATE_QUESTION), + outcomes: [ + ], + }, { section: WizardSectionSlug.map, slug: WizardStepSlug.mapOrientation, @@ -719,17 +731,22 @@ export const WIZARD_STEPS = (props: WizardStepDataProps): WizardSteps => { }, { section: WizardSectionSlug.home, - slug: WizardStepSlug.xAxisFindHome, - title: t("Home X"), + slug: WizardStepSlug.zAxisFindHome, + title: t("Home Z"), prerequisites: [botOnlineReq], - content: t(SetupWizardContent.FIND_HOME, { axis: "X" }), - component: AxisActions, - question: SetupWizardContent.HOME, + content: isExpress(firmwareHardware) + ? SetupWizardContent.FIND_HOME_Z_EXPRESS + : t(SetupWizardContent.FIND_HOME, { axis: "Z" }), + component: isExpress(firmwareHardware) ? undefined : AxisActions, + controlsCheckOptions: isExpress(firmwareHardware) ? {} : undefined, + question: isExpress(firmwareHardware) + ? SetupWizardContent.HOME_Z_EXPRESS + : SetupWizardContent.HOME, outcomes: [ { slug: "notAtHome", description: t("The axis is not at the home position"), - tips: t(SetupWizardContent.HOME_AXIS, { axis: "x" }), + tips: t(SetupWizardContent.HOME_AXIS, { axis: "z" }), component: CheckForResistance, controlsCheckOptions: { home: true }, }, @@ -737,7 +754,7 @@ export const WIZARD_STEPS = (props: WizardStepDataProps): WizardSteps => { slug: "notZero", description: t("The coordinate is not zero"), tips: "", - component: SetHome("x"), + component: SetHome("z"), }, ], }, @@ -767,22 +784,17 @@ export const WIZARD_STEPS = (props: WizardStepDataProps): WizardSteps => { }, { section: WizardSectionSlug.home, - slug: WizardStepSlug.zAxisFindHome, - title: t("Home Z"), + slug: WizardStepSlug.xAxisFindHome, + title: t("Home X"), prerequisites: [botOnlineReq], - content: isExpress(firmwareHardware) - ? SetupWizardContent.FIND_HOME_Z_EXPRESS - : t(SetupWizardContent.FIND_HOME, { axis: "Z" }), - component: isExpress(firmwareHardware) ? undefined : AxisActions, - controlsCheckOptions: isExpress(firmwareHardware) ? {} : undefined, - question: isExpress(firmwareHardware) - ? SetupWizardContent.HOME_Z_EXPRESS - : SetupWizardContent.HOME, + content: t(SetupWizardContent.FIND_HOME, { axis: "X" }), + component: AxisActions, + question: SetupWizardContent.HOME, outcomes: [ { slug: "notAtHome", description: t("The axis is not at the home position"), - tips: t(SetupWizardContent.HOME_AXIS, { axis: "z" }), + tips: t(SetupWizardContent.HOME_AXIS, { axis: "x" }), component: CheckForResistance, controlsCheckOptions: { home: true }, }, @@ -790,7 +802,7 @@ export const WIZARD_STEPS = (props: WizardStepDataProps): WizardSteps => { slug: "notZero", description: t("The coordinate is not zero"), tips: "", - component: SetHome("z"), + component: SetHome("x"), }, ], },