From f5982bf1af5ddb4326ffe8af79e642c8270e4f17 Mon Sep 17 00:00:00 2001 From: gabrielburnworth Date: Mon, 23 Sep 2019 11:56:35 -0700 Subject: [PATCH 1/6] cleanup --- .../__test_support__/fake_state/resources.ts | 4 +- frontend/__tests__/app_test.tsx | 44 ++++--- frontend/account/__tests__/index_test.tsx | 3 +- .../__tests__/request_account_exports_test.ts | 12 +- .../components/export_account_panel.tsx | 3 +- frontend/account/components/settings.tsx | 1 - frontend/account/request_account_export.ts | 1 - frontend/api/crud.ts | 1 - frontend/connectivity/__tests__/index_test.ts | 5 +- frontend/connectivity/auto_sync.ts | 15 +-- frontend/connectivity/connect_device.ts | 5 +- frontend/controls/__tests__/controls_test.tsx | 4 +- frontend/controls/axis_display_group.tsx | 1 - frontend/controls/axis_input_box_group.tsx | 3 +- frontend/controls/move/bot_position_rows.tsx | 1 - frontend/controls/move/jog_controls_group.tsx | 1 - .../controls/move/motor_position_plot.tsx | 5 +- frontend/controls/move/settings_menu.tsx | 22 ++-- frontend/controls/pin_form_fields.tsx | 2 +- frontend/controls/toggle_button.tsx | 1 - frontend/controls/webcam/edit.tsx | 1 - frontend/controls/webcam/index.tsx | 1 - frontend/controls/webcam/show.tsx | 1 - frontend/devices/__tests__/devices_test.tsx | 4 +- frontend/devices/actions.ts | 3 +- .../__tests__/farmbot_os_settings_test.tsx | 14 +-- .../__tests__/pin_guard_input_group_test.tsx | 8 +- .../components/axis_tracking_status.ts | 7 +- .../components/diagnostic_dump_row.tsx | 6 +- .../components/farmbot_os_settings.tsx | 10 +- .../fbos_settings/auto_sync_row.tsx | 1 - .../fbos_settings/auto_update_row.tsx | 1 - .../fbos_settings/change_ownership_form.tsx | 1 - .../fbos_settings/factory_reset_row.tsx | 5 +- .../fbos_settings/farmbot_os_row.tsx | 2 +- .../fbos_settings/fbos_button_row.tsx | 1 - .../fbos_settings/os_update_button.tsx | 1 - .../fbos_settings/power_and_reset.tsx | 1 - .../hardware_settings/calibration_row.tsx | 1 - .../hardware_settings/danger_zone.tsx | 1 - .../hardware_settings/encoder_type.tsx | 1 - .../hardware_settings/space_panel_header.tsx | 1 - .../components/hardware_settings/zero_row.tsx | 3 +- .../devices/components/lockable_button.tsx | 2 +- .../components/send_diagnostic_report.tsx | 1 - .../devices/connectivity/status_checks.tsx | 4 +- .../pin_bindings/pin_binding_input_group.tsx | 2 +- .../devices/pin_bindings/pin_bindings.tsx | 2 +- frontend/draggable/drop_area.tsx | 2 +- frontend/draggable/step_dragger.tsx | 4 +- frontend/extras/fallback_widget.tsx | 1 - .../__tests__/click_map_plant_test.ts | 34 ++---- .../__tests__/farm_designer_test.tsx | 109 ++++++++++-------- .../farm_designer/__tests__/move_to_test.tsx | 6 +- .../farm_designer/__tests__/settings_test.tsx | 15 ++- .../__tests__/add_farm_event_test.tsx | 4 +- .../__tests__/edit_farm_event_test.tsx | 10 +- .../farm_events/calendar/interfaces.ts | 5 +- .../farm_events/map_state_to_props.ts | 7 +- .../farm_designer/farm_events/tz_warning.tsx | 1 - .../farm_designer/map/easter_eggs/bugs.tsx | 1 - .../plants/__tests__/add_plant_test.tsx | 4 +- .../plants/__tests__/create_points_test.tsx | 22 ++-- .../plants/__tests__/crop_catalog_test.tsx | 6 +- .../plants/__tests__/crop_info_test.tsx | 8 +- .../plants/__tests__/plant_info_test.tsx | 2 - .../plants/__tests__/plant_inventory_test.tsx | 10 +- .../plants/__tests__/point_info_test.tsx | 17 +-- .../plants/__tests__/point_inventory_test.tsx | 16 ++- .../plants/__tests__/select_plants_test.tsx | 6 +- frontend/farm_designer/plants/add_plant.tsx | 1 - .../farm_designer/plants/crop_catalog.tsx | 1 - frontend/farm_designer/plants/crop_info.tsx | 2 +- .../farm_designer/plants/plant_inventory.tsx | 1 - frontend/farm_designer/plants/plant_panel.tsx | 2 +- .../__tests__/fetch_group_from_url_test.ts | 13 +-- .../__tests__/group_list_panel_test.tsx | 10 +- .../point_groups/group_detail_active.tsx | 8 +- .../__tests__/saved_gardens_test.tsx | 5 +- .../saved_gardens/garden_snapshot.tsx | 1 - frontend/farm_designer/search_selectors.ts | 1 - .../tools/__tests__/add_tool_test.tsx | 6 +- .../tools/__tests__/edit_tool_test.tsx | 6 +- .../tools/__tests__/index_test.tsx | 6 +- frontend/farmware/__tests__/farmware_test.tsx | 4 +- .../camera_calibration/camera_calibration.tsx | 2 +- frontend/farmware/farmware_forms.tsx | 4 +- frontend/farmware/farmware_list.tsx | 2 +- frontend/farmware/images/image_flipper.tsx | 1 - .../__tests__/weed_detector_test.tsx | 10 +- frontend/farmware/weed_detector/config.tsx | 13 ++- frontend/farmware/weed_detector/constants.ts | 1 - .../weed_detector/image_workspace.tsx | 2 +- frontend/farmware/weed_detector/index.tsx | 6 +- .../weed_detector/remote_env/selectors.ts | 1 - frontend/front_page/forgot_password.tsx | 2 +- frontend/front_page/login.tsx | 2 +- frontend/front_page/resend_verification.tsx | 1 - frontend/front_page/terms_checkbox.tsx | 1 - frontend/help/__tests__/help_test.tsx | 4 +- frontend/help/docs.tsx | 1 - frontend/help/tours.ts | 1 - frontend/loading_plant.tsx | 1 - frontend/logs/__tests__/index_test.tsx | 2 - frontend/messages/__tests__/index_test.tsx | 4 +- frontend/nav/mobile_menu.tsx | 1 - frontend/nav/nav_links.tsx | 1 - frontend/nav/ticker_list.tsx | 2 +- frontend/regimens/__tests__/index_test.tsx | 46 ++++---- frontend/regimens/__tests__/reducer_test.ts | 1 - .../bulk_scheduler/__tests__/index_test.tsx | 4 +- .../regimens/bulk_scheduler/add_button.tsx | 2 +- .../regimens/bulk_scheduler/week_grid.tsx | 3 +- frontend/regimens/editor/copy_button.tsx | 1 - .../regimens/editor/regimen_name_input.tsx | 1 - frontend/regimens/list/add_button.tsx | 1 - frontend/regimens/list/regimen_list_item.tsx | 1 - frontend/resources/__tests__/in_use_test.ts | 14 ++- .../resources/__tests__/sequence_meta_test.ts | 11 +- frontend/resources/in_use.ts | 6 +- frontend/resources/reducer.ts | 11 +- frontend/resources/reducer_support.ts | 3 +- frontend/routes.tsx | 3 +- .../sequences/__tests__/sequences_test.tsx | 6 +- .../__tests__/state_to_props_test.ts | 6 +- .../sequences/__tests__/test_button_test.tsx | 18 +-- .../__tests__/default_value_form_test.tsx | 4 +- .../sequences/locals_list/handle_select.ts | 3 +- frontend/sequences/reducer.ts | 9 +- frontend/sequences/step_button_cluster.tsx | 2 +- frontend/sequences/step_buttons/index.tsx | 4 +- .../pin_and_peripheral_support_test.tsx | 4 +- .../__tests__/tile_assertion_test.tsx | 4 +- frontend/sequences/step_tiles/index.tsx | 10 +- frontend/sequences/step_tiles/mark_as.tsx | 1 - .../step_tiles/pin_and_peripheral_support.tsx | 24 ++-- .../sequences/step_tiles/tile_execute.tsx | 1 - .../tile_execute_script_support.tsx | 1 - .../sequences/step_tiles/tile_find_home.tsx | 1 - .../step_tiles/tile_firmware_action.tsx | 1 - .../step_tiles/tile_if/__tests__/lhs_test.ts | 3 +- .../sequences/step_tiles/tile_if/index.tsx | 5 +- .../tile_move_absolute_conflict_check.tsx | 1 - .../sequences/step_tiles/tile_move_home.tsx | 1 - .../step_tiles/tile_move_relative.tsx | 1 - .../sequences/step_tiles/tile_pin_support.tsx | 1 - .../step_tiles/tile_send_message.tsx | 1 - .../step_tiles/tile_send_message_support.tsx | 1 - .../step_tiles/tile_set_servo_angle.tsx | 1 - .../sequences/step_tiles/tile_take_photo.tsx | 1 - .../sequences/step_tiles/tile_toggle_pin.tsx | 1 - .../sequences/step_tiles/tile_unknown.tsx | 1 - frontend/sequences/step_tiles/tile_wait.tsx | 1 - frontend/sequences/step_ui/step_header.tsx | 1 - frontend/sequences/step_ui/step_radio.tsx | 1 - frontend/sequences/step_ui/step_warning.tsx | 3 +- frontend/sequences/test_button.tsx | 3 +- frontend/session.ts | 4 +- frontend/tools/__tests__/index_test.tsx | 4 +- frontend/tools/components/tool_list.tsx | 1 - .../toolbay_slot_direction_selection.tsx | 1 - .../tools/components/toolbay_slot_menu.tsx | 1 - frontend/tools/interfaces.ts | 6 +- frontend/tos_update/component.tsx | 1 - frontend/ui/blurable_input.tsx | 1 - frontend/ui/color_picker.tsx | 2 +- frontend/ui/help.tsx | 2 +- frontend/ui/save_button.tsx | 3 +- frontend/ui/tooltip.tsx | 1 - frontend/ui/widget_header.tsx | 1 - frontend/util/errors.ts | 1 - 171 files changed, 410 insertions(+), 495 deletions(-) diff --git a/frontend/__test_support__/fake_state/resources.ts b/frontend/__test_support__/fake_state/resources.ts index b54c6e845..120d7ce4f 100644 --- a/frontend/__test_support__/fake_state/resources.ts +++ b/frontend/__test_support__/fake_state/resources.ts @@ -28,7 +28,9 @@ import { TaggedPointGroup, } from "farmbot"; import { fakeResource } from "../fake_resource"; -import { ExecutableType, PinBindingType } from "farmbot/dist/resources/api_resources"; +import { + ExecutableType, PinBindingType +} from "farmbot/dist/resources/api_resources"; import { FirmwareConfig } from "farmbot/dist/resources/configs/firmware"; import { MessageType } from "../../sequences/interfaces"; diff --git a/frontend/__tests__/app_test.tsx b/frontend/__tests__/app_test.tsx index 3df5e6cb0..1ee15bbad 100644 --- a/frontend/__tests__/app_test.tsx +++ b/frontend/__tests__/app_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - let mockPath = ""; jest.mock("../history", () => ({ getPathArray: jest.fn(() => mockPath.split("/")), @@ -7,7 +5,7 @@ jest.mock("../history", () => ({ })); import * as React from "react"; -import { App, AppProps, mapStateToProps } from "../app"; +import { RawApp as App, AppProps, mapStateToProps } from "../app"; import { mount } from "enzyme"; import { bot } from "../__test_support__/fake_state/bot"; import { @@ -25,27 +23,25 @@ import { fakePings } from "../__test_support__/fake_state/pings"; const FULLY_LOADED: ResourceName[] = [ "Sequence", "Regimen", "FarmEvent", "Point", "Tool", "Device"]; -const fakeProps = (): AppProps => { - return { - timeSettings: fakeTimeSettings(), - dispatch: jest.fn(), - loaded: [], - logs: [], - user: fakeUser(), - bot: bot, - consistent: true, - axisInversion: { x: false, y: false, z: false }, - firmwareConfig: undefined, - xySwap: false, - animate: false, - getConfigValue: jest.fn(), - tour: undefined, - resources: buildResourceIndex().index, - autoSync: false, - alertCount: 0, - pings: fakePings() - }; -}; +const fakeProps = (): AppProps => ({ + timeSettings: fakeTimeSettings(), + dispatch: jest.fn(), + loaded: [], + logs: [], + user: fakeUser(), + bot: bot, + consistent: true, + axisInversion: { x: false, y: false, z: false }, + firmwareConfig: undefined, + xySwap: false, + animate: false, + getConfigValue: jest.fn(), + tour: undefined, + resources: buildResourceIndex().index, + autoSync: false, + alertCount: 0, + pings: fakePings() +}); describe(": Controls Pop-Up", () => { function controlsPopUp(page: string, exists: boolean) { diff --git a/frontend/account/__tests__/index_test.tsx b/frontend/account/__tests__/index_test.tsx index 92cf757e9..bbd217083 100644 --- a/frontend/account/__tests__/index_test.tsx +++ b/frontend/account/__tests__/index_test.tsx @@ -1,11 +1,10 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); jest.mock("../labs/labs_features", () => ({ LabsFeatures: () =>
})); import * as React from "react"; import { fakeState } from "../../__test_support__/fake_state"; import { mapStateToProps } from "../state_to_props"; import { shallow, mount } from "enzyme"; -import { Account } from "../index"; +import { RawAccount as Account } from "../index"; import { edit } from "../../api/crud"; describe("", () => { diff --git a/frontend/account/__tests__/request_account_exports_test.ts b/frontend/account/__tests__/request_account_exports_test.ts index b2b43a44e..4cb97b3cf 100644 --- a/frontend/account/__tests__/request_account_exports_test.ts +++ b/frontend/account/__tests__/request_account_exports_test.ts @@ -4,12 +4,15 @@ const mock = { } }; -jest.mock("axios", - () => ({ post: jest.fn(() => Promise.resolve(mock.response)) })); +jest.mock("axios", () => ({ + post: jest.fn(() => Promise.resolve(mock.response)) +})); import { API } from "../../api"; import { Content } from "../../constants"; -import { requestAccountExport, generateFilename } from "../request_account_export"; +import { + requestAccountExport, generateFilename +} from "../request_account_export"; import { success } from "../../toast/toast"; import axios from "axios"; import { fakeDevice } from "../../__test_support__/resource_index_builder"; @@ -32,7 +35,8 @@ describe("requestAccountExport", () => { expect(success).toHaveBeenCalledWith(Content.EXPORT_SENT); }); - it("downloads the data synchronously (when API has no email support)", async () => { + it("downloads the data synchronously (when API has no email support)", async ( + ) => { mock.response.data = {}; window.URL = window.URL || ({} as typeof window.URL); window.URL.createObjectURL = jest.fn(); diff --git a/frontend/account/components/export_account_panel.tsx b/frontend/account/components/export_account_panel.tsx index fa43e5be4..d431f0b8c 100644 --- a/frontend/account/components/export_account_panel.tsx +++ b/frontend/account/components/export_account_panel.tsx @@ -18,7 +18,8 @@ export function ExportAccountPanel(props: { onClick: () => void }) { - diff --git a/frontend/account/components/settings.tsx b/frontend/account/components/settings.tsx index 8a24ffcf0..ff59123d9 100644 --- a/frontend/account/components/settings.tsx +++ b/frontend/account/components/settings.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { BlurableInput, Widget, WidgetHeader, WidgetBody, SaveBtn } from "../../ui/index"; diff --git a/frontend/account/request_account_export.ts b/frontend/account/request_account_export.ts index 75b30d01e..95bc0d568 100644 --- a/frontend/account/request_account_export.ts +++ b/frontend/account/request_account_export.ts @@ -1,7 +1,6 @@ import { API } from "../api"; import { Content } from "../constants"; import { success } from "../toast/toast"; - import axios, { AxiosResponse } from "axios"; import { DeviceAccountSettings } from "farmbot/dist/resources/api_resources"; import { t } from "../i18next_wrapper"; diff --git a/frontend/api/crud.ts b/frontend/api/crud.ts index 969bce424..c1a2f871f 100644 --- a/frontend/api/crud.ts +++ b/frontend/api/crud.ts @@ -17,7 +17,6 @@ import { ResourceIndex } from "../resources/interfaces"; import { SequenceBodyItem } from "farmbot/dist"; import { Actions } from "../constants"; import { maybeStartTracking } from "./maybe_start_tracking"; - import { newTaggedResource } from "../sync/actions"; import { arrayUnwrap } from "../resources/util"; import { findByUuid } from "../resources/reducer_support"; diff --git a/frontend/connectivity/__tests__/index_test.ts b/frontend/connectivity/__tests__/index_test.ts index 6b2d5afa0..52fcdd643 100644 --- a/frontend/connectivity/__tests__/index_test.ts +++ b/frontend/connectivity/__tests__/index_test.ts @@ -21,7 +21,10 @@ jest.mock("../../redux/store", () => { jest.mock("../auto_sync_handle_inbound", () => ({ handleInbound: jest.fn() })); -import { dispatchNetworkUp, dispatchNetworkDown, dispatchQosStart, networkUptimeThrottleStats } from "../index"; +import { + dispatchNetworkUp, dispatchNetworkDown, dispatchQosStart, + networkUptimeThrottleStats, +} from "../index"; import { networkUp, networkDown } from "../actions"; import { GetState } from "../../redux/interfaces"; import { autoSync, routeMqttData } from "../auto_sync"; diff --git a/frontend/connectivity/auto_sync.ts b/frontend/connectivity/auto_sync.ts index 0cec3f594..94972a8d4 100644 --- a/frontend/connectivity/auto_sync.ts +++ b/frontend/connectivity/auto_sync.ts @@ -1,12 +1,11 @@ import { GetState } from "../redux/interfaces"; import { maybeDetermineUuid } from "../resources/selectors"; -import { - TaggedResource, - SpecialStatus -} from "farmbot"; +import { TaggedResource, SpecialStatus } from "farmbot"; import { overwrite, init } from "../api/crud"; import { handleInbound } from "./auto_sync_handle_inbound"; -import { SyncPayload, MqttDataResult, Reason, UpdateMqttData } from "./interfaces"; +import { + SyncPayload, MqttDataResult, Reason, UpdateMqttData +} from "./interfaces"; import { outstandingRequests } from "./data_consistency"; import { newTaggedResource } from "../sync/actions"; @@ -16,7 +15,8 @@ export function decodeBinary(payload: Buffer): SyncPayload { const SKIP_THESE = ["DeviceSerialNumber"]; // Only FBOS Cares about this one. -export function routeMqttData(chan: string, payload: Buffer): MqttDataResult { +export function routeMqttData(chan: string, payload: Buffer): + MqttDataResult { /** Skip irrelevant messages: only resource auto-sync messages are desired. * eg, `bot/device_#/sync/Resource/#` */ if (!(chan.split("/")[2] == "sync")) { return { status: "SKIP" }; } @@ -37,7 +37,8 @@ export function routeMqttData(chan: string, payload: Buffer): MqttDataResult): TaggedResource { +export function asTaggedResource(data: UpdateMqttData): + TaggedResource { return newTaggedResource(data.kind, data.body)[0]; } diff --git a/frontend/connectivity/connect_device.ts b/frontend/connectivity/connect_device.ts index 9ca749bc4..b0b04233c 100644 --- a/frontend/connectivity/connect_device.ts +++ b/frontend/connectivity/connect_device.ts @@ -43,8 +43,9 @@ export const HACKY_FLAGS = { export const incomingLegacyStatus = (statusMessage: HardwareState) => ({ type: Actions.LEGACY_BOT_CHANGE, payload: statusMessage }); -export const incomingStatus = - (payload: DeepPartial) => ({ type: Actions.STATUS_UPDATE, payload }); +export const incomingStatus = (payload: DeepPartial) => ({ + type: Actions.STATUS_UPDATE, payload +}); /** Determine if an incoming log has a certain channel. If it is, execute the * supplied callback. */ diff --git a/frontend/controls/__tests__/controls_test.tsx b/frontend/controls/__tests__/controls_test.tsx index e8de14c8c..202db055e 100644 --- a/frontend/controls/__tests__/controls_test.tsx +++ b/frontend/controls/__tests__/controls_test.tsx @@ -1,8 +1,6 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - import * as React from "react"; import { mount } from "enzyme"; -import { Controls } from "../controls"; +import { RawControls as Controls } from "../controls"; import { bot } from "../../__test_support__/fake_state/bot"; import { fakePeripheral, fakeWebcamFeed, fakeSensor diff --git a/frontend/controls/axis_display_group.tsx b/frontend/controls/axis_display_group.tsx index d729ccd16..9e2447d7e 100644 --- a/frontend/controls/axis_display_group.tsx +++ b/frontend/controls/axis_display_group.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { Row, Col } from "../ui/index"; import { AxisDisplayGroupProps } from "./interfaces"; import { isNumber } from "lodash"; diff --git a/frontend/controls/axis_input_box_group.tsx b/frontend/controls/axis_input_box_group.tsx index cb117ae3d..ed31119f7 100644 --- a/frontend/controls/axis_input_box_group.tsx +++ b/frontend/controls/axis_input_box_group.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { AxisInputBox } from "./axis_input_box"; - import { Row, Col } from "../ui/index"; import { AxisInputBoxGroupProps, AxisInputBoxGroupState } from "./interfaces"; import { isNumber } from "lodash"; @@ -59,7 +58,7 @@ export class AxisInputBoxGroup extends onClick={this.clicked} disabled={this.props.disabled || false} title={t("Move to chosen location")} - className="full-width green go fb-button" > + className="full-width green go fb-button"> {t("GO")} diff --git a/frontend/controls/move/bot_position_rows.tsx b/frontend/controls/move/bot_position_rows.tsx index 62034d3ef..4b5b6695c 100644 --- a/frontend/controls/move/bot_position_rows.tsx +++ b/frontend/controls/move/bot_position_rows.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { Row, Col } from "../../ui"; import { BotLocationData } from "../../devices/interfaces"; import { moveAbs } from "../../devices/actions"; diff --git a/frontend/controls/move/jog_controls_group.tsx b/frontend/controls/move/jog_controls_group.tsx index 3092baa20..dc9434d38 100644 --- a/frontend/controls/move/jog_controls_group.tsx +++ b/frontend/controls/move/jog_controls_group.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { McuParams } from "farmbot"; import { BotPosition } from "../../devices/interfaces"; import { changeStepSize } from "../../devices/actions"; diff --git a/frontend/controls/move/motor_position_plot.tsx b/frontend/controls/move/motor_position_plot.tsx index 09f9ebbdf..353a7bfb7 100644 --- a/frontend/controls/move/motor_position_plot.tsx +++ b/frontend/controls/move/motor_position_plot.tsx @@ -3,8 +3,9 @@ import { Xyz, LocationName, Dictionary } from "farmbot"; import moment from "moment"; import { BotLocationData, BotPosition } from "../../devices/interfaces"; import { trim } from "../../util"; - -import { cloneDeep, max, get, isNumber, isEqual, takeRight, ceil, range } from "lodash"; +import { + cloneDeep, max, get, isNumber, isEqual, takeRight, ceil, range +} from "lodash"; import { t } from "../../i18next_wrapper"; const HEIGHT = 50; diff --git a/frontend/controls/move/settings_menu.tsx b/frontend/controls/move/settings_menu.tsx index 4285976a2..6367372c8 100644 --- a/frontend/controls/move/settings_menu.tsx +++ b/frontend/controls/move/settings_menu.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { BooleanSetting } from "../../session_keys"; import { ToggleButton } from "../toggle_button"; import { ToggleWebAppBool, GetWebAppBool } from "./interfaces"; @@ -7,16 +6,17 @@ import { BooleanConfigKey } from "farmbot/dist/resources/configs/web_app"; import { DevSettings } from "../../account/dev/dev_support"; import { t } from "../../i18next_wrapper"; -export const moveWidgetSetting = (toggle: ToggleWebAppBool, getValue: GetWebAppBool) => - ({ label, setting }: { label: string, setting: BooleanConfigKey }) => -
- - -
; +export const moveWidgetSetting = + (toggle: ToggleWebAppBool, getValue: GetWebAppBool) => + ({ label, setting }: { label: string, setting: BooleanConfigKey }) => +
+ + +
; export const MoveWidgetSettingsMenu = ({ toggle, getValue }: { toggle: ToggleWebAppBool, diff --git a/frontend/controls/pin_form_fields.tsx b/frontend/controls/pin_form_fields.tsx index 09bd8039b..73e131658 100644 --- a/frontend/controls/pin_form_fields.tsx +++ b/frontend/controls/pin_form_fields.tsx @@ -89,4 +89,4 @@ export const DeleteButton = (props: DeleteButtonProps) => props.dispatch(destroy(props.uuid)) .then(props.onDestroy || (() => { }))}> {props.children || } - ; + ; diff --git a/frontend/controls/toggle_button.tsx b/frontend/controls/toggle_button.tsx index a6b328694..a724ee954 100644 --- a/frontend/controls/toggle_button.tsx +++ b/frontend/controls/toggle_button.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { ToggleButtonProps } from "./interfaces"; import { t } from "../i18next_wrapper"; diff --git a/frontend/controls/webcam/edit.tsx b/frontend/controls/webcam/edit.tsx index e3cb3e6ee..ed29ec8a3 100644 --- a/frontend/controls/webcam/edit.tsx +++ b/frontend/controls/webcam/edit.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { Widget, WidgetHeader, WidgetBody } from "../../ui/index"; - import { ToolTips } from "../../constants"; import { WebcamPanelProps } from "./interfaces"; import { KeyValEditRow } from "../key_val_edit_row"; diff --git a/frontend/controls/webcam/index.tsx b/frontend/controls/webcam/index.tsx index 51cfb635f..b8367d432 100644 --- a/frontend/controls/webcam/index.tsx +++ b/frontend/controls/webcam/index.tsx @@ -5,7 +5,6 @@ import { WebcamPanelProps } from "./interfaces"; import { TaggedWebcamFeed, SpecialStatus } from "farmbot"; import { edit, save, destroy, init } from "../../api/crud"; import { error } from "../../toast/toast"; - import { WebcamFeed } from "farmbot/dist/resources/api_resources"; import { t } from "../../i18next_wrapper"; diff --git a/frontend/controls/webcam/show.tsx b/frontend/controls/webcam/show.tsx index 6a420293b..8eb3ae485 100644 --- a/frontend/controls/webcam/show.tsx +++ b/frontend/controls/webcam/show.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { Widget, WidgetHeader, FallbackImg, WidgetBody } from "../../ui/index"; - import { ToolTips } from "../../constants"; import { WebcamPanelProps } from "./interfaces"; import { PLACEHOLDER_FARMBOT } from "../../farmware/images/image_flipper"; diff --git a/frontend/devices/__tests__/devices_test.tsx b/frontend/devices/__tests__/devices_test.tsx index e43cb9d68..db7a7589b 100644 --- a/frontend/devices/__tests__/devices_test.tsx +++ b/frontend/devices/__tests__/devices_test.tsx @@ -1,8 +1,6 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - import * as React from "react"; import { shallow, render } from "enzyme"; -import { Devices } from "../devices"; +import { RawDevices as Devices } from "../devices"; import { Props } from "../interfaces"; import { auth } from "../../__test_support__/fake_state/token"; import { bot } from "../../__test_support__/fake_state/bot"; diff --git a/frontend/devices/actions.ts b/frontend/devices/actions.ts index 1b1f83466..e322dc4c5 100644 --- a/frontend/devices/actions.ts +++ b/frontend/devices/actions.ts @@ -400,5 +400,6 @@ export function changeStepSize(integer: number) { } export function badVersion() { - info(t("You are running an old version of FarmBot OS."), t("Please Update"), "red"); + info(t("You are running an old version of FarmBot OS."), + t("Please Update"), "red"); } diff --git a/frontend/devices/components/__tests__/farmbot_os_settings_test.tsx b/frontend/devices/components/__tests__/farmbot_os_settings_test.tsx index 97c515eba..e6f986844 100644 --- a/frontend/devices/components/__tests__/farmbot_os_settings_test.tsx +++ b/frontend/devices/components/__tests__/farmbot_os_settings_test.tsx @@ -1,4 +1,3 @@ - let mockReleaseNoteData = {}; jest.mock("axios", () => ({ get: jest.fn(() => Promise.resolve(mockReleaseNoteData)) @@ -9,6 +8,10 @@ jest.mock("../../../api/crud", () => ({ save: jest.fn(), })); +jest.mock("../fbos_settings/boot_sequence_selector", () => ({ + BootSequenceSelector: () =>
+})); + import * as React from "react"; import { FarmbotOsSettings } from "../farmbot_os_settings"; import { mount, shallow } from "enzyme"; @@ -19,14 +22,6 @@ import axios from "axios"; import { fakeTimeSettings } from "../../../__test_support__/fake_time_settings"; import { edit } from "../../../api/crud"; -jest.mock("react-redux", () => ({ - connect: jest.fn(() => { - return () => { - return () => ""; - }; - }) -})); - describe("", () => { beforeEach(() => { window.alert = jest.fn(); @@ -87,5 +82,4 @@ describe("", () => { .simulate("change", { currentTarget: { value: newName } }); expect(edit).toHaveBeenCalledWith(p.deviceAccount, { name: newName }); }); - }); diff --git a/frontend/devices/components/__tests__/pin_guard_input_group_test.tsx b/frontend/devices/components/__tests__/pin_guard_input_group_test.tsx index e23a91bac..1cc9d7d80 100644 --- a/frontend/devices/components/__tests__/pin_guard_input_group_test.tsx +++ b/frontend/devices/components/__tests__/pin_guard_input_group_test.tsx @@ -1,6 +1,4 @@ -jest.mock("../../actions", () => ({ - settingToggle: jest.fn() -})); +jest.mock("../../actions", () => ({ settingToggle: jest.fn() })); import * as React from "react"; import { PinGuardMCUInputGroup } from "../pin_guard_input_group"; @@ -8,7 +6,9 @@ import { mount } from "enzyme"; import { PinGuardMCUInputGroupProps } from "../interfaces"; import { bot } from "../../../__test_support__/fake_state/bot"; import { settingToggle } from "../../actions"; -import { buildResourceIndex } from "../../../__test_support__/resource_index_builder"; +import { + buildResourceIndex +} from "../../../__test_support__/resource_index_builder"; describe("", () => { const fakeProps = (): PinGuardMCUInputGroupProps => { diff --git a/frontend/devices/components/axis_tracking_status.ts b/frontend/devices/components/axis_tracking_status.ts index bcfdc52d9..2ac18c294 100644 --- a/frontend/devices/components/axis_tracking_status.ts +++ b/frontend/devices/components/axis_tracking_status.ts @@ -15,9 +15,10 @@ interface AxisStatus { * If neither of these are enabled, FarmBot can do some pretty dangerous things, * such as smashing tools and ramming into tool bays. * - * This function returns a 2 dimensional array describing whether or not a particular - * axis has at least one of the precautions in place. Useful for checking if it is safe - * to proceed with certain actions that could damage the bot. + * This function returns a 2 dimensional array describing whether or not + * a particular axis has at least one of the precautions in place. + * Useful for checking if it is safe to proceed with certain actions that + * could damage the bot. */ export function axisTrackingStatus(h: McuParams): AxisStatus[] { const stats = enabledAxisMap(h); diff --git a/frontend/devices/components/diagnostic_dump_row.tsx b/frontend/devices/components/diagnostic_dump_row.tsx index 6d42f9c6a..aa4461d43 100644 --- a/frontend/devices/components/diagnostic_dump_row.tsx +++ b/frontend/devices/components/diagnostic_dump_row.tsx @@ -20,7 +20,9 @@ export class DiagnosticDumpRow extends React.Component { render() { return - {t("Report {{ticket}} (Saved {{age}})", { ticket: this.ticket, age: this.age })} + {t("Report {{ticket}} (Saved {{age}})", { + ticket: this.ticket, age: this.age + })} - ; + ; } } diff --git a/frontend/devices/components/farmbot_os_settings.tsx b/frontend/devices/components/farmbot_os_settings.tsx index ee4eeff5a..3d81dfa1d 100644 --- a/frontend/devices/components/farmbot_os_settings.tsx +++ b/frontend/devices/components/farmbot_os_settings.tsx @@ -1,4 +1,6 @@ import * as React from "react"; +import axios from "axios"; +import { t } from "../../i18next_wrapper"; import { FarmbotOsProps, FarmbotOsState } from "../interfaces"; import { Widget, WidgetHeader, WidgetBody, Row, Col } from "../../ui"; import { save, edit } from "../../api/crud"; @@ -14,8 +16,6 @@ import { AutoSyncRow } from "./fbos_settings/auto_sync_row"; import { isUndefined } from "lodash"; import { PowerAndReset } from "./fbos_settings/power_and_reset"; import { SendDiagnosticReport } from "./send_diagnostic_report"; -import axios from "axios"; -import { t } from "../../i18next_wrapper"; import { BootSequenceSelector } from "./fbos_settings/boot_sequence_selector"; export enum ColWidth { @@ -70,11 +70,7 @@ export class FarmbotOsSettings maybeWarnTz = () => { const wrongTZ = timezoneMismatch(this.props.deviceAccount.body.timezone); - if (wrongTZ) { - return t(Content.DIFFERENT_TZ_WARNING); - } else { - return ""; - } + return wrongTZ ? t(Content.DIFFERENT_TZ_WARNING) : ""; } render() { diff --git a/frontend/devices/components/fbos_settings/auto_sync_row.tsx b/frontend/devices/components/fbos_settings/auto_sync_row.tsx index 6de3eb903..2816da661 100644 --- a/frontend/devices/components/fbos_settings/auto_sync_row.tsx +++ b/frontend/devices/components/fbos_settings/auto_sync_row.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { Row, Col } from "../../../ui/index"; - import { ToggleButton } from "../../../controls/toggle_button"; import { Content } from "../../../constants"; import { updateConfig } from "../../actions"; diff --git a/frontend/devices/components/fbos_settings/auto_update_row.tsx b/frontend/devices/components/fbos_settings/auto_update_row.tsx index 73d8ec4c4..aed54e373 100644 --- a/frontend/devices/components/fbos_settings/auto_update_row.tsx +++ b/frontend/devices/components/fbos_settings/auto_update_row.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { Row, Col } from "../../../ui/index"; - import { ColWidth } from "../farmbot_os_settings"; import { ToggleButton } from "../../../controls/toggle_button"; import { updateConfig } from "../../actions"; diff --git a/frontend/devices/components/fbos_settings/change_ownership_form.tsx b/frontend/devices/components/fbos_settings/change_ownership_form.tsx index 398bb6a9e..2effbfaf4 100644 --- a/frontend/devices/components/fbos_settings/change_ownership_form.tsx +++ b/frontend/devices/components/fbos_settings/change_ownership_form.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { Row, Col, BlurableInput } from "../../../ui/index"; - import { success, error } from "../../../toast/toast"; import { getDevice } from "../../../device"; import { transferOwnership } from "../../transfer_ownership/transfer_ownership"; diff --git a/frontend/devices/components/fbos_settings/factory_reset_row.tsx b/frontend/devices/components/fbos_settings/factory_reset_row.tsx index de19bc577..0a42a8f3a 100644 --- a/frontend/devices/components/fbos_settings/factory_reset_row.tsx +++ b/frontend/devices/components/fbos_settings/factory_reset_row.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { Row, Col } from "../../../ui/index"; - import { Content } from "../../../constants"; import { factoryReset, updateConfig } from "../../actions"; import { ToggleButton } from "../../../controls/toggle_button"; @@ -75,6 +74,6 @@ export function FactoryResetRow(props: FactoryResetRowProps) { disabled={!!disableFactoryReset.value} sourceFbosConfig={sourceFbosConfig} /> - -
; + +
; } diff --git a/frontend/devices/components/fbos_settings/farmbot_os_row.tsx b/frontend/devices/components/fbos_settings/farmbot_os_row.tsx index 1bbbcbc25..f62114ab3 100644 --- a/frontend/devices/components/fbos_settings/farmbot_os_row.tsx +++ b/frontend/devices/components/fbos_settings/farmbot_os_row.tsx @@ -61,5 +61,5 @@ export function FarmbotOsRow(props: FarmbotOsRowProps) { shouldDisplay={props.shouldDisplay} botOnline={botOnline} /> - ; + ; } diff --git a/frontend/devices/components/fbos_settings/fbos_button_row.tsx b/frontend/devices/components/fbos_settings/fbos_button_row.tsx index 6b0f94fee..1cf1d3a58 100644 --- a/frontend/devices/components/fbos_settings/fbos_button_row.tsx +++ b/frontend/devices/components/fbos_settings/fbos_button_row.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { Row, Col } from "../../../ui"; - import { ColWidth } from "../farmbot_os_settings"; import { t } from "../../../i18next_wrapper"; diff --git a/frontend/devices/components/fbos_settings/os_update_button.tsx b/frontend/devices/components/fbos_settings/os_update_button.tsx index be3599e68..45172a47e 100644 --- a/frontend/devices/components/fbos_settings/os_update_button.tsx +++ b/frontend/devices/components/fbos_settings/os_update_button.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { JobProgress, ConfigurationName } from "farmbot/dist"; import { SemverResult, semverCompare } from "../../../util"; import { OsUpdateButtonProps } from "./interfaces"; diff --git a/frontend/devices/components/fbos_settings/power_and_reset.tsx b/frontend/devices/components/fbos_settings/power_and_reset.tsx index 03a8381dd..5c5b50d24 100644 --- a/frontend/devices/components/fbos_settings/power_and_reset.tsx +++ b/frontend/devices/components/fbos_settings/power_and_reset.tsx @@ -4,7 +4,6 @@ import { Collapse, Popover, Position } from "@blueprintjs/core"; import { FactoryResetRow } from "./factory_reset_row"; import { PowerAndResetProps } from "./interfaces"; import { ChangeOwnershipForm } from "./change_ownership_form"; - import { Feature } from "../../interfaces"; import { FbosButtonRow } from "./fbos_button_row"; import { Content } from "../../../constants"; diff --git a/frontend/devices/components/hardware_settings/calibration_row.tsx b/frontend/devices/components/hardware_settings/calibration_row.tsx index b5bafff7d..53606a4d6 100644 --- a/frontend/devices/components/hardware_settings/calibration_row.tsx +++ b/frontend/devices/components/hardware_settings/calibration_row.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { getDevice } from "../../../device"; import { Axis } from "../../interfaces"; import { LockableButton } from "../lockable_button"; diff --git a/frontend/devices/components/hardware_settings/danger_zone.tsx b/frontend/devices/components/hardware_settings/danger_zone.tsx index 0ca2a3576..cd78e7f23 100644 --- a/frontend/devices/components/hardware_settings/danger_zone.tsx +++ b/frontend/devices/components/hardware_settings/danger_zone.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { DangerZoneProps } from "../interfaces"; import { Row, Col } from "../../../ui/index"; import { Header } from "./header"; diff --git a/frontend/devices/components/hardware_settings/encoder_type.tsx b/frontend/devices/components/hardware_settings/encoder_type.tsx index e6261cb7a..8bd800efb 100644 --- a/frontend/devices/components/hardware_settings/encoder_type.tsx +++ b/frontend/devices/components/hardware_settings/encoder_type.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { McuParams, Encoder, McuParamName } from "farmbot/dist"; - import { FBSelect, DropDownItem } from "../../../ui/index"; import { t } from "../../../i18next_wrapper"; diff --git a/frontend/devices/components/hardware_settings/space_panel_header.tsx b/frontend/devices/components/hardware_settings/space_panel_header.tsx index 7e024210c..dfb70cedd 100644 --- a/frontend/devices/components/hardware_settings/space_panel_header.tsx +++ b/frontend/devices/components/hardware_settings/space_panel_header.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { Row, Col } from "../../../ui/index"; import { t } from "../../../i18next_wrapper"; diff --git a/frontend/devices/components/hardware_settings/zero_row.tsx b/frontend/devices/components/hardware_settings/zero_row.tsx index 773cd65f5..005c42707 100644 --- a/frontend/devices/components/hardware_settings/zero_row.tsx +++ b/frontend/devices/components/hardware_settings/zero_row.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { getDevice } from "../../../device"; import { Axis } from "../../interfaces"; import { ToolTips } from "../../../constants"; @@ -17,7 +16,7 @@ export function ZeroButton(props: { axis: Axis; disabled: boolean; }) { return ; } diff --git a/frontend/devices/components/lockable_button.tsx b/frontend/devices/components/lockable_button.tsx index 1f67eaa46..65ace1da2 100644 --- a/frontend/devices/components/lockable_button.tsx +++ b/frontend/devices/components/lockable_button.tsx @@ -11,7 +11,7 @@ export function LockableButton({ onClick, disabled, children }: Props) { return ; } diff --git a/frontend/devices/components/send_diagnostic_report.tsx b/frontend/devices/components/send_diagnostic_report.tsx index 8bac6f943..b596c6fb3 100644 --- a/frontend/devices/components/send_diagnostic_report.tsx +++ b/frontend/devices/components/send_diagnostic_report.tsx @@ -1,7 +1,6 @@ import * as React from "react"; import { Row, Col } from "../../ui"; import { ColWidth } from "./farmbot_os_settings"; - import { Collapse } from "@blueprintjs/core"; import { Header } from "./hardware_settings/header"; import { ShouldDisplay, Feature } from "../interfaces"; diff --git a/frontend/devices/connectivity/status_checks.tsx b/frontend/devices/connectivity/status_checks.tsx index a85983517..fc3961493 100644 --- a/frontend/devices/connectivity/status_checks.tsx +++ b/frontend/devices/connectivity/status_checks.tsx @@ -34,7 +34,9 @@ export function botToAPI(stat: string | undefined, from: "FarmBot", to: "Web App", connectionStatus, - children: stat ? t("Last message seen ") + `${ago(new Date(stat).getTime())}.` : NOT_SEEN + children: stat + ? t("Last message seen ") + `${ago(new Date(stat).getTime())}.` + : NOT_SEEN }; } diff --git a/frontend/devices/pin_bindings/pin_binding_input_group.tsx b/frontend/devices/pin_bindings/pin_binding_input_group.tsx index 0ad479f40..7eb87c550 100644 --- a/frontend/devices/pin_bindings/pin_binding_input_group.tsx +++ b/frontend/devices/pin_bindings/pin_binding_input_group.tsx @@ -134,7 +134,7 @@ export class PinBindingInputGroup diff --git a/frontend/devices/pin_bindings/pin_bindings.tsx b/frontend/devices/pin_bindings/pin_bindings.tsx index 7e97c9fc2..76a085c77 100644 --- a/frontend/devices/pin_bindings/pin_bindings.tsx +++ b/frontend/devices/pin_bindings/pin_bindings.tsx @@ -83,7 +83,7 @@ export const PinBindings = (props: PinBindingsProps) => { + popoverClassName={"help"}>
{t(ToolTips.PIN_BINDING_WARNING)} diff --git a/frontend/draggable/drop_area.tsx b/frontend/draggable/drop_area.tsx index e5488196c..f400bdf90 100644 --- a/frontend/draggable/drop_area.tsx +++ b/frontend/draggable/drop_area.tsx @@ -36,7 +36,7 @@ export class DropArea extends React.Component { }} onDragOver={this.dragOver} onDrop={this.drop} - style={{ minHeight: "2rem" }} > + style={{ minHeight: "2rem" }}> {this.props.children}
; } diff --git a/frontend/draggable/step_dragger.tsx b/frontend/draggable/step_dragger.tsx index d79a99a99..9672b2adf 100644 --- a/frontend/draggable/step_dragger.tsx +++ b/frontend/draggable/step_dragger.tsx @@ -14,7 +14,7 @@ export const NULL_DRAGGER_ID = 0xCAFEF00D; * Example usage: * * * */ @@ -36,7 +36,7 @@ export function StepDragger({ dispatch, onDragStart={stepDragEventHandler(dispatch, step, intent, - draggerId)} > + draggerId)}> {children} ; } diff --git a/frontend/extras/fallback_widget.tsx b/frontend/extras/fallback_widget.tsx index d6a01d581..e4c80f907 100644 --- a/frontend/extras/fallback_widget.tsx +++ b/frontend/extras/fallback_widget.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { Widget, WidgetHeader, WidgetBody } from "../ui"; import { t } from "../i18next_wrapper"; diff --git a/frontend/farm_designer/__tests__/click_map_plant_test.ts b/frontend/farm_designer/__tests__/click_map_plant_test.ts index 5f8852163..2410ed9b7 100644 --- a/frontend/farm_designer/__tests__/click_map_plant_test.ts +++ b/frontend/farm_designer/__tests__/click_map_plant_test.ts @@ -1,36 +1,24 @@ - -jest.mock("../../api/crud", () => { - return { overwrite: jest.fn() }; -}); - -jest.mock("../point_groups/group_detail", () => { - return { - fetchGroupFromUrl: jest.fn(() => mockGroup) - }; -}); +jest.mock("../point_groups/group_detail", () => ({ + fetchGroupFromUrl: jest.fn(() => mockGroup) +})); jest.mock("../../api/crud", () => ({ overwrite: jest.fn(), - edit: jest.fn() + edit: jest.fn(), })); let mockMode = "none"; +jest.mock("../map/util", () => ({ getMode: jest.fn(() => mockMode) })); -jest.mock("../map/util", () => { - return { - getMode: jest.fn(() => mockMode) - }; -}); - -import { fakePlant, fakePointGroup } from "../../__test_support__/fake_state/resources"; +import { + fakePlant, fakePointGroup +} from "../../__test_support__/fake_state/resources"; import { fakeState } from "../../__test_support__/fake_state"; import { GetState } from "../../redux/interfaces"; +import { clickMapPlant, selectPlant, toggleHoveredPlant } from "../actions"; import { - clickMapPlant, - selectPlant, - toggleHoveredPlant -} from "../actions"; -import { buildResourceIndex } from "../../__test_support__/resource_index_builder"; + buildResourceIndex +} from "../../__test_support__/resource_index_builder"; import { overwrite } from "../../api/crud"; const mockGroup = fakePointGroup(); diff --git a/frontend/farm_designer/__tests__/farm_designer_test.tsx b/frontend/farm_designer/__tests__/farm_designer_test.tsx index 22373a23b..83f697a24 100644 --- a/frontend/farm_designer/__tests__/farm_designer_test.tsx +++ b/frontend/farm_designer/__tests__/farm_designer_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - let mockPath = "/app/designer/plants"; jest.mock("../../history", () => ({ history: { getCurrentLocation: jest.fn(() => ({ pathname: mockPath })) }, @@ -11,8 +9,10 @@ jest.mock("../../api/crud", () => ({ save: jest.fn(), })); +jest.mock("../plants/plant_inventory", () => ({ Plants: () =>
})); + import * as React from "react"; -import { RawFarmDesigner } from "../index"; +import { RawFarmDesigner as FarmDesigner } from "../index"; import { mount } from "enzyme"; import { Props } from "../interfaces"; import { GardenMapLegendProps } from "../map/interfaces"; @@ -22,48 +22,47 @@ import { } from "../../__test_support__/fake_state/resources"; import { fakeDesignerState } from "../../__test_support__/fake_designer_state"; import { fakeTimeSettings } from "../../__test_support__/fake_time_settings"; -import { buildResourceIndex } from "../../__test_support__/resource_index_builder"; +import { + buildResourceIndex +} from "../../__test_support__/resource_index_builder"; import { fakeState } from "../../__test_support__/fake_state"; import { edit } from "../../api/crud"; import { BooleanSetting } from "../../session_keys"; -describe("", () => { - function fakeProps(): Props { - - return { - dispatch: jest.fn(), - selectedPlant: undefined, - designer: fakeDesignerState(), - hoveredPlant: undefined, - points: [], - plants: [], - toolSlots: [], - crops: [], - botLocationData: { - position: { x: undefined, y: undefined, z: undefined }, - scaled_encoders: { x: undefined, y: undefined, z: undefined }, - raw_encoders: { x: undefined, y: undefined, z: undefined }, - }, - botMcuParams: bot.hardware.mcu_params, - stepsPerMmXY: { x: undefined, y: undefined }, - peripherals: [], - eStopStatus: false, - latestImages: [], - cameraCalibrationData: { - scale: undefined, rotation: undefined, - offset: { x: undefined, y: undefined }, - origin: undefined, - calibrationZ: undefined - }, - timeSettings: fakeTimeSettings(), - getConfigValue: jest.fn(), - sensorReadings: [], - sensors: [], - }; - } +describe("", () => { + const fakeProps = (): Props => ({ + dispatch: jest.fn(), + selectedPlant: undefined, + designer: fakeDesignerState(), + hoveredPlant: undefined, + points: [], + plants: [], + toolSlots: [], + crops: [], + botLocationData: { + position: { x: undefined, y: undefined, z: undefined }, + scaled_encoders: { x: undefined, y: undefined, z: undefined }, + raw_encoders: { x: undefined, y: undefined, z: undefined }, + }, + botMcuParams: bot.hardware.mcu_params, + stepsPerMmXY: { x: undefined, y: undefined }, + peripherals: [], + eStopStatus: false, + latestImages: [], + cameraCalibrationData: { + scale: undefined, rotation: undefined, + offset: { x: undefined, y: undefined }, + origin: undefined, + calibrationZ: undefined + }, + timeSettings: fakeTimeSettings(), + getConfigValue: jest.fn(), + sensorReadings: [], + sensors: [], + }); it("loads default map settings", () => { - const wrapper = mount(); + const wrapper = mount(); const legendProps = wrapper.find("GardenMapLegend").props() as GardenMapLegendProps; expect(legendProps.legendMenuOpen).toBeFalsy(); @@ -86,7 +85,7 @@ describe("", () => { image1.body.created_at = "2001-01-03T00:00:00.000Z"; image2.body.created_at = "2001-01-01T00:00:00.000Z"; p.latestImages = [image1, image2]; - const wrapper = mount(); + const wrapper = mount(); const legendProps = wrapper.find("GardenMapLegend").props() as GardenMapLegendProps; expect(legendProps.imageAgeInfo) @@ -95,28 +94,34 @@ describe("", () => { it("renders nav titles", () => { mockPath = "/app/designer/plants"; - const wrapper = mount(); + const wrapper = mount(); ["Map", "Plants", "Events"].map(string => expect(wrapper.text()).toContain(string)); - expect(wrapper.find(".panel-nav").first().hasClass("hidden")).toBeTruthy(); - expect(wrapper.find(".farm-designer-panels").hasClass("panel-open")).toBeTruthy(); - expect(wrapper.find(".farm-designer-map").hasClass("panel-open")).toBeTruthy(); + expect(wrapper.find(".panel-nav").first().hasClass("hidden")) + .toBeTruthy(); + expect(wrapper.find(".farm-designer-panels").hasClass("panel-open")) + .toBeTruthy(); + expect(wrapper.find(".farm-designer-map").hasClass("panel-open")) + .toBeTruthy(); }); it("hides panel", () => { mockPath = "/app/designer"; - const wrapper = mount(); + const wrapper = mount(); ["Map", "Plants", "Events"].map(string => expect(wrapper.text()).toContain(string)); - expect(wrapper.find(".panel-nav").first().hasClass("hidden")).toBeFalsy(); - expect(wrapper.find(".farm-designer-panels").hasClass("panel-open")).toBeFalsy(); - expect(wrapper.find(".farm-designer-map").hasClass("panel-open")).toBeFalsy(); + expect(wrapper.find(".panel-nav").first().hasClass("hidden")) + .toBeFalsy(); + expect(wrapper.find(".farm-designer-panels").hasClass("panel-open")) + .toBeFalsy(); + expect(wrapper.find(".farm-designer-map").hasClass("panel-open")) + .toBeFalsy(); }); it("renders saved garden indicator", () => { const p = fakeProps(); p.designer.openedSavedGarden = "SavedGardenUuid"; - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.text().toLowerCase()).toContain("viewing saved garden"); }); @@ -126,8 +131,10 @@ describe("", () => { const dispatch = jest.fn(); state.resources = buildResourceIndex([fakeWebAppConfig()]); p.dispatch = jest.fn(x => x(dispatch, () => state)); - const wrapper = mount(); + const wrapper = mount(); wrapper.instance().toggle(BooleanSetting.show_plants)(); - expect(edit).toHaveBeenCalledWith(expect.any(Object), { bot_origin_quadrant: 2 }); + expect(edit).toHaveBeenCalledWith(expect.any(Object), { + bot_origin_quadrant: 2 + }); }); }); diff --git a/frontend/farm_designer/__tests__/move_to_test.tsx b/frontend/farm_designer/__tests__/move_to_test.tsx index 863b7bd70..ac15b57af 100644 --- a/frontend/farm_designer/__tests__/move_to_test.tsx +++ b/frontend/farm_designer/__tests__/move_to_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - const mockDevice = { moveAbsolute: jest.fn(() => Promise.resolve()) }; jest.mock("../../device", () => ({ getDevice: () => mockDevice })); @@ -12,8 +10,8 @@ jest.mock("../../history", () => ({ import * as React from "react"; import { mount, shallow } from "enzyme"; import { - MoveTo, MoveToProps, MoveToForm, MoveToFormProps, MoveModeLink, chooseLocation, - mapStateToProps + RawMoveTo as MoveTo, MoveToProps, MoveToForm, MoveToFormProps, + MoveModeLink, chooseLocation, mapStateToProps, } from "../move_to"; import { history } from "../../history"; import { Actions } from "../../constants"; diff --git a/frontend/farm_designer/__tests__/settings_test.tsx b/frontend/farm_designer/__tests__/settings_test.tsx index bd4b9e4ec..82deb77fb 100644 --- a/frontend/farm_designer/__tests__/settings_test.tsx +++ b/frontend/farm_designer/__tests__/settings_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - jest.mock("../../config_storage/actions", () => ({ getWebAppConfigValue: jest.fn(x => { x(); return jest.fn(() => true); }), setWebAppConfigValue: jest.fn(), @@ -8,7 +6,8 @@ jest.mock("../../config_storage/actions", () => ({ import * as React from "react"; import { mount, ReactWrapper } from "enzyme"; import { - RawDesignerSettings, DesignerSettingsProps, mapStateToProps + RawDesignerSettings as DesignerSettings, DesignerSettingsProps, + mapStateToProps, } from "../settings"; import { fakeState } from "../../__test_support__/fake_state"; import { BooleanSetting, NumericSetting } from "../../session_keys"; @@ -22,14 +21,14 @@ const getSetting = return setting; }; -describe("", () => { +describe("", () => { const fakeProps = (): DesignerSettingsProps => ({ dispatch: jest.fn(), getConfigValue: jest.fn(), }); it("renders settings", () => { - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.text()).toContain("size"); const settings = wrapper.find(".designer-setting"); expect(settings.length).toEqual(7); @@ -38,13 +37,13 @@ describe("", () => { it("renders defaultOn setting", () => { const p = fakeProps(); p.getConfigValue = () => undefined; - const wrapper = mount(); + const wrapper = mount(); const confirmDeletion = getSetting(wrapper, 6, "confirm plant"); expect(confirmDeletion.find("button").text()).toEqual("on"); }); it("toggles setting", () => { - const wrapper = mount(); + const wrapper = mount(); const trailSetting = getSetting(wrapper, 1, "trail"); trailSetting.find("button").simulate("click"); expect(setWebAppConfigValue) @@ -54,7 +53,7 @@ describe("", () => { it("changes origin", () => { const p = fakeProps(); p.getConfigValue = () => 2; - const wrapper = mount(); + const wrapper = mount(); const originSetting = getSetting(wrapper, 5, "origin"); originSetting.find("div").last().simulate("click"); expect(setWebAppConfigValue).toHaveBeenCalledWith( diff --git a/frontend/farm_designer/farm_events/__tests__/add_farm_event_test.tsx b/frontend/farm_designer/farm_events/__tests__/add_farm_event_test.tsx index 9685335c2..46692e8eb 100644 --- a/frontend/farm_designer/farm_events/__tests__/add_farm_event_test.tsx +++ b/frontend/farm_designer/farm_events/__tests__/add_farm_event_test.tsx @@ -1,10 +1,8 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - jest.mock("../../../history", () => ({ history: { push: jest.fn() } })); import * as React from "react"; import { mount } from "enzyme"; -import { AddFarmEvent } from "../add_farm_event"; +import { RawAddFarmEvent as AddFarmEvent } from "../add_farm_event"; import { AddEditFarmEventProps } from "../../interfaces"; import { fakeFarmEvent, fakeSequence, fakeRegimen diff --git a/frontend/farm_designer/farm_events/__tests__/edit_farm_event_test.tsx b/frontend/farm_designer/farm_events/__tests__/edit_farm_event_test.tsx index 1a6c6dff9..d6b3b94ba 100644 --- a/frontend/farm_designer/farm_events/__tests__/edit_farm_event_test.tsx +++ b/frontend/farm_designer/farm_events/__tests__/edit_farm_event_test.tsx @@ -1,16 +1,10 @@ -jest.mock("react-redux", () => ({ - connect: jest.fn(() => (x: {}) => x) -})); - jest.mock("../../../history", () => ({ - history: { - push: jest.fn() - } + history: { push: jest.fn() } })); import * as React from "react"; import { mount } from "enzyme"; -import { EditFarmEvent } from "../edit_farm_event"; +import { RawEditFarmEvent as EditFarmEvent } from "../edit_farm_event"; import { AddEditFarmEventProps } from "../../interfaces"; import { fakeFarmEvent, fakeSequence diff --git a/frontend/farm_designer/farm_events/calendar/interfaces.ts b/frontend/farm_designer/farm_events/calendar/interfaces.ts index d57b03fee..992a04ee3 100644 --- a/frontend/farm_designer/farm_events/calendar/interfaces.ts +++ b/frontend/farm_designer/farm_events/calendar/interfaces.ts @@ -2,12 +2,13 @@ import { Regimen } from "../../../regimens/interfaces"; import { Sequence } from "../../../sequences/interfaces"; import { FarmEvent } from "farmbot/dist/resources/api_resources"; -/** Would it be better to make a fully formed farm event? Join regimen, sequence, etc. */ +/** Make a fully formed farm event: join regimen, sequence, etc. */ /** STEP 1: Extract querying of data and formatting of data into two * sep. function. This function will join `executable` on `farm_event`. */ -export type FarmEventWithExecutable = FarmEventWithRegimen | FarmEventWithSequence; +export type FarmEventWithExecutable = + FarmEventWithRegimen | FarmEventWithSequence; /** Takes a farm event and merges it with its sequence object. */ export interface FarmEventWithSequence extends FarmEvent { diff --git a/frontend/farm_designer/farm_events/map_state_to_props.ts b/frontend/farm_designer/farm_events/map_state_to_props.ts index ddd476c19..f490d1d2a 100644 --- a/frontend/farm_designer/farm_events/map_state_to_props.ts +++ b/frontend/farm_designer/farm_events/map_state_to_props.ts @@ -10,7 +10,9 @@ import { maybeGetTimeSettings, } from "../../resources/selectors"; import { ResourceIndex } from "../../resources/interfaces"; -import { FarmEventWithRegimen, FarmEventWithSequence } from "./calendar/interfaces"; +import { + FarmEventWithRegimen, FarmEventWithSequence +} from "./calendar/interfaces"; import { scheduleForFarmEvent } from "./calendar/scheduler"; import { last } from "lodash"; import { RegimenItem } from "../../regimens/interfaces"; @@ -63,7 +65,8 @@ export const nextRegItemTimes = && time.isSameOrAfter(moment(startTime))); }; -export let regimenCalendarAdder = (index: ResourceIndex, timeSettings: TimeSettings) => +export let regimenCalendarAdder = ( + index: ResourceIndex, timeSettings: TimeSettings) => (f: FarmEventWithRegimen, c: Calendar, now = moment()) => { const { regimen_items } = f.executable; const gracePeriod = itemGracePeriod(now); diff --git a/frontend/farm_designer/farm_events/tz_warning.tsx b/frontend/farm_designer/farm_events/tz_warning.tsx index b68cb1c18..cb5062d9b 100644 --- a/frontend/farm_designer/farm_events/tz_warning.tsx +++ b/frontend/farm_designer/farm_events/tz_warning.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { timezoneMismatch } from "../../devices/timezones/guess_timezone"; import { Content } from "../../constants"; import { t } from "../../i18next_wrapper"; diff --git a/frontend/farm_designer/map/easter_eggs/bugs.tsx b/frontend/farm_designer/map/easter_eggs/bugs.tsx index ddd0ae4cf..0b81947e1 100644 --- a/frontend/farm_designer/map/easter_eggs/bugs.tsx +++ b/frontend/farm_designer/map/easter_eggs/bugs.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { transformXY } from "../util"; import { MapTransformProps, BotSize } from "../interfaces"; import { random, range, some, clamp, sample } from "lodash"; diff --git a/frontend/farm_designer/plants/__tests__/add_plant_test.tsx b/frontend/farm_designer/plants/__tests__/add_plant_test.tsx index aa662412b..a0854d0b8 100644 --- a/frontend/farm_designer/plants/__tests__/add_plant_test.tsx +++ b/frontend/farm_designer/plants/__tests__/add_plant_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - let mockPath = ""; jest.mock("../../../history", () => ({ history: { push: jest.fn() }, @@ -8,7 +6,7 @@ jest.mock("../../../history", () => ({ import * as React from "react"; import { mount } from "enzyme"; -import { AddPlant, AddPlantProps } from "../add_plant"; +import { RawAddPlant as AddPlant, AddPlantProps } from "../add_plant"; import { history } from "../../../history"; import { fakeCropLiveSearchResult diff --git a/frontend/farm_designer/plants/__tests__/create_points_test.tsx b/frontend/farm_designer/plants/__tests__/create_points_test.tsx index 9698c17d8..8817825cd 100644 --- a/frontend/farm_designer/plants/__tests__/create_points_test.tsx +++ b/frontend/farm_designer/plants/__tests__/create_points_test.tsx @@ -1,10 +1,4 @@ -jest.mock("react-redux", () => ({ - connect: jest.fn(() => (x: {}) => x) -})); - -jest.mock("../../../api/crud", () => ({ - initSave: jest.fn() -})); +jest.mock("../../../api/crud", () => ({ initSave: jest.fn() })); jest.mock("../../../farmware/weed_detector/actions", () => ({ deletePoints: jest.fn() @@ -49,14 +43,12 @@ describe("mapStateToProps", () => { }); describe("", () => { - const fakeProps = (): CreatePointsProps => { - return { - dispatch: jest.fn(), - currentPoint: undefined, - deviceY: 1.23, - deviceX: 3.21 - }; - }; + const fakeProps = (): CreatePointsProps => ({ + dispatch: jest.fn(), + currentPoint: undefined, + deviceY: 1.23, + deviceX: 3.21 + }); const fakeInstance = () => { const props = fakeProps(); diff --git a/frontend/farm_designer/plants/__tests__/crop_catalog_test.tsx b/frontend/farm_designer/plants/__tests__/crop_catalog_test.tsx index 9db5c07b6..7991eb022 100644 --- a/frontend/farm_designer/plants/__tests__/crop_catalog_test.tsx +++ b/frontend/farm_designer/plants/__tests__/crop_catalog_test.tsx @@ -1,7 +1,3 @@ -jest.mock("react-redux", () => ({ - connect: jest.fn(() => (x: {}) => x) -})); - jest.mock("lodash", () => ({ debounce: jest.fn(x => x), trim: jest.fn(x => x), @@ -14,7 +10,7 @@ jest.mock("lodash", () => ({ jest.mock("../../../history", () => ({ history: { push: jest.fn() } })); import * as React from "react"; -import { CropCatalog } from "../crop_catalog"; +import { RawCropCatalog as CropCatalog } from "../crop_catalog"; import { mount, shallow } from "enzyme"; import { CropCatalogProps } from "../../interfaces"; import { Actions } from "../../../constants"; diff --git a/frontend/farm_designer/plants/__tests__/crop_info_test.tsx b/frontend/farm_designer/plants/__tests__/crop_info_test.tsx index 1139fc65e..f1a3578dd 100644 --- a/frontend/farm_designer/plants/__tests__/crop_info_test.tsx +++ b/frontend/farm_designer/plants/__tests__/crop_info_test.tsx @@ -1,14 +1,10 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - let mockPath = ""; jest.mock("../../../history", () => ({ getPathArray: jest.fn(() => { return mockPath.split("/"); }), history: { push: jest.fn() } })); -jest.mock("../../../api/crud", () => ({ - initSave: jest.fn() -})); +jest.mock("../../../api/crud", () => ({ initSave: jest.fn() })); jest.mock("../../actions", () => ({ unselectPlant: jest.fn(() => jest.fn()), @@ -16,7 +12,7 @@ jest.mock("../../actions", () => ({ })); import * as React from "react"; -import { CropInfo, searchForCurrentCrop } from "../crop_info"; +import { RawCropInfo as CropInfo, searchForCurrentCrop } from "../crop_info"; import { mount } from "enzyme"; import { CropInfoProps } from "../../interfaces"; import { initSave } from "../../../api/crud"; diff --git a/frontend/farm_designer/plants/__tests__/plant_info_test.tsx b/frontend/farm_designer/plants/__tests__/plant_info_test.tsx index 2fe2d2d52..7f0381210 100644 --- a/frontend/farm_designer/plants/__tests__/plant_info_test.tsx +++ b/frontend/farm_designer/plants/__tests__/plant_info_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - let mockPath = "/app/designer/plants/1"; jest.mock("../../../history", () => ({ getPathArray: jest.fn(() => mockPath.split("/")), diff --git a/frontend/farm_designer/plants/__tests__/plant_inventory_test.tsx b/frontend/farm_designer/plants/__tests__/plant_inventory_test.tsx index 337484e27..2b6124e0e 100644 --- a/frontend/farm_designer/plants/__tests__/plant_inventory_test.tsx +++ b/frontend/farm_designer/plants/__tests__/plant_inventory_test.tsx @@ -1,7 +1,5 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - import * as React from "react"; -import { RawPlants, PlantInventoryProps } from "../plant_inventory"; +import { RawPlants as Plants, PlantInventoryProps } from "../plant_inventory"; import { mount, shallow } from "enzyme"; import { fakePlant } from "../../../__test_support__/fake_state/resources"; @@ -13,7 +11,7 @@ describe("", () => { }); it("renders", () => { - const wrapper = mount(); + const wrapper = mount(); ["Map", "Plants", "Events", @@ -25,13 +23,13 @@ describe("", () => { }); it("has link to crops", () => { - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.html()).toContain("fa-plus"); expect(wrapper.html()).toContain("/app/designer/plants/crop_search"); }); it("updates search term", () => { - const wrapper = shallow(); + const wrapper = shallow(); expect(wrapper.state().searchTerm).toEqual(""); wrapper.find("input").first().simulate("change", { currentTarget: { value: "mint" } }); diff --git a/frontend/farm_designer/plants/__tests__/point_info_test.tsx b/frontend/farm_designer/plants/__tests__/point_info_test.tsx index 5dd0095b8..6a1fd77a1 100644 --- a/frontend/farm_designer/plants/__tests__/point_info_test.tsx +++ b/frontend/farm_designer/plants/__tests__/point_info_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - let mockPath = "/app/designer/points/1"; jest.mock("../../../history", () => ({ getPathArray: jest.fn(() => mockPath.split("/")), @@ -7,17 +5,20 @@ jest.mock("../../../history", () => ({ })); const mockMoveAbs = jest.fn(); - -jest.mock("../../../device", () => { - return { getDevice: () => ({ moveAbsolute: mockMoveAbs }) }; -}); +jest.mock("../../../device", () => ({ + getDevice: () => ({ moveAbsolute: mockMoveAbs }) +})); import * as React from "react"; import { mount } from "enzyme"; -import { EditPoint, EditPointProps, mapStateToProps, moveToPoint } from "../point_info"; +import { + RawEditPoint as EditPoint, EditPointProps, mapStateToProps, moveToPoint +} from "../point_info"; import { fakePoint } from "../../../__test_support__/fake_state/resources"; import { fakeState } from "../../../__test_support__/fake_state"; -import { buildResourceIndex } from "../../../__test_support__/resource_index_builder"; +import { + buildResourceIndex +} from "../../../__test_support__/resource_index_builder"; import { getDevice } from "../../../device"; describe("", () => { diff --git a/frontend/farm_designer/plants/__tests__/point_inventory_test.tsx b/frontend/farm_designer/plants/__tests__/point_inventory_test.tsx index 65f9bb919..6f0b0e8ee 100644 --- a/frontend/farm_designer/plants/__tests__/point_inventory_test.tsx +++ b/frontend/farm_designer/plants/__tests__/point_inventory_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - jest.mock("../../../history", () => ({ push: jest.fn(), getPathArray: () => [], @@ -7,7 +5,7 @@ jest.mock("../../../history", () => ({ import * as React from "react"; import { mount, shallow } from "enzyme"; -import { RawPoints, PointsProps } from "../point_inventory"; +import { RawPoints as Points, PointsProps } from "../point_inventory"; import { fakePoint } from "../../../__test_support__/fake_state/resources"; import { push } from "../../../history"; import { fakeState } from "../../../__test_support__/fake_state"; @@ -16,21 +14,21 @@ import { } from "../../../__test_support__/resource_index_builder"; import { mapStateToProps } from "../point_inventory"; -describe(" />", () => { +describe(" />", () => { const fakeProps = (): PointsProps => ({ points: [], dispatch: jest.fn(), }); it("renders no points", () => { - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.text()).toContain("No points yet."); }); it("renders points", () => { const p = fakeProps(); p.points = [fakePoint()]; - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.text()).toContain("Point 1"); }); @@ -38,7 +36,7 @@ describe(" />", () => { const p = fakeProps(); p.points = [fakePoint()]; p.points[0].body.id = 1; - const wrapper = mount(); + const wrapper = mount(); wrapper.find(".point-search-item").first().simulate("click"); expect(push).toHaveBeenCalledWith("/app/designer/points/1"); }); @@ -48,7 +46,7 @@ describe(" />", () => { p.points = [fakePoint(), fakePoint()]; p.points[0].body.name = "point 0"; p.points[1].body.name = "point 1"; - const wrapper = shallow(); + const wrapper = shallow(); wrapper.find("input").first().simulate("change", { currentTarget: { value: "0" } }); expect(wrapper.state().searchTerm).toEqual("0"); @@ -59,7 +57,7 @@ describe(" />", () => { p.points = [fakePoint(), fakePoint()]; p.points[0].body.name = "point 0"; p.points[1].body.name = "point 1"; - const wrapper = mount(); + const wrapper = mount(); wrapper.setState({ searchTerm: "0" }); expect(wrapper.text()).not.toContain("point 1"); }); diff --git a/frontend/farm_designer/plants/__tests__/select_plants_test.tsx b/frontend/farm_designer/plants/__tests__/select_plants_test.tsx index 2160fd04f..fc60031dc 100644 --- a/frontend/farm_designer/plants/__tests__/select_plants_test.tsx +++ b/frontend/farm_designer/plants/__tests__/select_plants_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - let mockPath = ""; jest.mock("../../../history", () => ({ history: { push: jest.fn() }, @@ -17,7 +15,9 @@ jest.mock("../../point_groups/actions", () => ({ createGroup: jest.fn() })); import * as React from "react"; import { mount } from "enzyme"; -import { SelectPlants, SelectPlantsProps } from "../select_plants"; +import { + RawSelectPlants as SelectPlants, SelectPlantsProps +} from "../select_plants"; import { fakePlant } from "../../../__test_support__/fake_state/resources"; import { Actions } from "../../../constants"; import { clickButton } from "../../../__test_support__/helpers"; diff --git a/frontend/farm_designer/plants/add_plant.tsx b/frontend/farm_designer/plants/add_plant.tsx index 5157ba24f..8884e4f6d 100644 --- a/frontend/farm_designer/plants/add_plant.tsx +++ b/frontend/farm_designer/plants/add_plant.tsx @@ -1,7 +1,6 @@ import * as React from "react"; import { Everything } from "../../interfaces"; import { connect } from "react-redux"; - import { history } from "../../history"; import { svgToUrl } from "../../open_farm/icons"; import { CropLiveSearchResult, OpenfarmSearch } from "../interfaces"; diff --git a/frontend/farm_designer/plants/crop_catalog.tsx b/frontend/farm_designer/plants/crop_catalog.tsx index 2cf7c6482..66e7907ed 100644 --- a/frontend/farm_designer/plants/crop_catalog.tsx +++ b/frontend/farm_designer/plants/crop_catalog.tsx @@ -1,7 +1,6 @@ import * as React from "react"; import { Everything } from "../../interfaces"; import { connect } from "react-redux"; - import { OpenFarmResults } from "./openfarm_search_results"; import { CropCatalogProps } from "../interfaces"; import { OFSearch } from "../util"; diff --git a/frontend/farm_designer/plants/crop_info.tsx b/frontend/farm_designer/plants/crop_info.tsx index 48de0a7a1..f38bfc96d 100644 --- a/frontend/farm_designer/plants/crop_info.tsx +++ b/frontend/farm_designer/plants/crop_info.tsx @@ -170,7 +170,7 @@ const EditOnOpenFarm = ({ slug }: { slug: string }) => ; diff --git a/frontend/farm_designer/plants/plant_inventory.tsx b/frontend/farm_designer/plants/plant_inventory.tsx index dae2dc6a2..2657bb1f9 100644 --- a/frontend/farm_designer/plants/plant_inventory.tsx +++ b/frontend/farm_designer/plants/plant_inventory.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { connect } from "react-redux"; - import { PlantInventoryItem } from "./plant_inventory_item"; import { Everything } from "../../interfaces"; import { Panel, DesignerNavTabs } from "../panel_header"; diff --git a/frontend/farm_designer/plants/plant_panel.tsx b/frontend/farm_designer/plants/plant_panel.tsx index dc5c1735c..b34cc82dc 100644 --- a/frontend/farm_designer/plants/plant_panel.tsx +++ b/frontend/farm_designer/plants/plant_panel.tsx @@ -157,7 +157,7 @@ const DeleteButtons = (props: DeleteButtonsProps) =>
; diff --git a/frontend/farm_designer/point_groups/__tests__/fetch_group_from_url_test.ts b/frontend/farm_designer/point_groups/__tests__/fetch_group_from_url_test.ts index 5d246e8f5..ba8ba2d16 100644 --- a/frontend/farm_designer/point_groups/__tests__/fetch_group_from_url_test.ts +++ b/frontend/farm_designer/point_groups/__tests__/fetch_group_from_url_test.ts @@ -1,14 +1,13 @@ const mockId = 123; - -jest.mock("../../../history", () => { - return { - getPathArray: jest.fn(() => [mockId]) - }; -}); +jest.mock("../../../history", () => ({ + getPathArray: jest.fn(() => [mockId]) +})); import { fetchGroupFromUrl } from "../group_detail"; import { fakePointGroup } from "../../../__test_support__/fake_state/resources"; -import { buildResourceIndex } from "../../../__test_support__/resource_index_builder"; +import { + buildResourceIndex +} from "../../../__test_support__/resource_index_builder"; describe("fetchGroupFromUrl", () => { it("fetches a group from URL", () => { diff --git a/frontend/farm_designer/point_groups/__tests__/group_list_panel_test.tsx b/frontend/farm_designer/point_groups/__tests__/group_list_panel_test.tsx index 406414563..a6a851b45 100644 --- a/frontend/farm_designer/point_groups/__tests__/group_list_panel_test.tsx +++ b/frontend/farm_designer/point_groups/__tests__/group_list_panel_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - jest.mock("../../../history", () => ({ getPathArray: jest.fn(() => ["L", "O", "L"]), history: { push: jest.fn() } @@ -7,11 +5,15 @@ jest.mock("../../../history", () => ({ import React from "react"; import { mount, shallow } from "enzyme"; -import { RawGroupListPanel as GroupListPanel, GroupListPanelProps, mapStateToProps } from "../group_list_panel"; +import { + RawGroupListPanel as GroupListPanel, GroupListPanelProps, mapStateToProps +} from "../group_list_panel"; import { fakePointGroup } from "../../../__test_support__/fake_state/resources"; import { history } from "../../../history"; import { fakeState } from "../../../__test_support__/fake_state"; -import { buildResourceIndex } from "../../../__test_support__/resource_index_builder"; +import { + buildResourceIndex +} from "../../../__test_support__/resource_index_builder"; describe("", () => { const fakeProps = (): GroupListPanelProps => { diff --git a/frontend/farm_designer/point_groups/group_detail_active.tsx b/frontend/farm_designer/point_groups/group_detail_active.tsx index 35e0280dc..20e268176 100644 --- a/frontend/farm_designer/point_groups/group_detail_active.tsx +++ b/frontend/farm_designer/point_groups/group_detail_active.tsx @@ -53,8 +53,8 @@ export const LittleIcon = ; }; -export class GroupDetailActive extends React.Component { - +export class GroupDetailActive + extends React.Component { state: State = { icons: {} }; update = ({ currentTarget }: React.SyntheticEvent) => { @@ -126,7 +126,9 @@ export class GroupDetailActive extends React.Component - +

{t("Click plants in map to add or remove.")}

diff --git a/frontend/farm_designer/saved_gardens/__tests__/saved_gardens_test.tsx b/frontend/farm_designer/saved_gardens/__tests__/saved_gardens_test.tsx index ce450003c..93187adcc 100644 --- a/frontend/farm_designer/saved_gardens/__tests__/saved_gardens_test.tsx +++ b/frontend/farm_designer/saved_gardens/__tests__/saved_gardens_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - jest.mock("../actions", () => ({ snapshotGarden: jest.fn(), applyGarden: jest.fn(), @@ -25,7 +23,8 @@ jest.mock("../../../account/dev/dev_support", () => ({ import * as React from "react"; import { mount, shallow } from "enzyme"; import { - SavedGardens, mapStateToProps, SavedGardensLink, SavedGardenHUD, savedGardenOpen + RawSavedGardens as SavedGardens, mapStateToProps, SavedGardensLink, + SavedGardenHUD, savedGardenOpen, } from "../saved_gardens"; import { clickButton } from "../../../__test_support__/helpers"; import { diff --git a/frontend/farm_designer/saved_gardens/garden_snapshot.tsx b/frontend/farm_designer/saved_gardens/garden_snapshot.tsx index c23c136eb..97662e075 100644 --- a/frontend/farm_designer/saved_gardens/garden_snapshot.tsx +++ b/frontend/farm_designer/saved_gardens/garden_snapshot.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { snapshotGarden, newSavedGarden, copySavedGarden } from "./actions"; import { TaggedPlantTemplate, TaggedSavedGarden } from "farmbot"; import { t } from "../../i18next_wrapper"; diff --git a/frontend/farm_designer/search_selectors.ts b/frontend/farm_designer/search_selectors.ts index 46b4f154b..ca5a985bb 100644 --- a/frontend/farm_designer/search_selectors.ts +++ b/frontend/farm_designer/search_selectors.ts @@ -1,5 +1,4 @@ import { CropLiveSearchResult } from "./interfaces"; - import { DEFAULT_ICON } from "../open_farm/icons"; import { startCase, find } from "lodash"; import { t } from "../i18next_wrapper"; diff --git a/frontend/farm_designer/tools/__tests__/add_tool_test.tsx b/frontend/farm_designer/tools/__tests__/add_tool_test.tsx index 8e4c5ac97..ae8e3d2c1 100644 --- a/frontend/farm_designer/tools/__tests__/add_tool_test.tsx +++ b/frontend/farm_designer/tools/__tests__/add_tool_test.tsx @@ -1,10 +1,10 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - jest.mock("../../../api/crud", () => ({ initSave: jest.fn() })); import * as React from "react"; import { mount, shallow } from "enzyme"; -import { RawAddTool as AddTool, AddToolProps, mapStateToProps } from "../add_tool"; +import { + RawAddTool as AddTool, AddToolProps, mapStateToProps +} from "../add_tool"; import { fakeState } from "../../../__test_support__/fake_state"; import { SaveBtn } from "../../../ui"; import { initSave } from "../../../api/crud"; diff --git a/frontend/farm_designer/tools/__tests__/edit_tool_test.tsx b/frontend/farm_designer/tools/__tests__/edit_tool_test.tsx index 140cdae2b..36ed25cc4 100644 --- a/frontend/farm_designer/tools/__tests__/edit_tool_test.tsx +++ b/frontend/farm_designer/tools/__tests__/edit_tool_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - jest.mock("../../../api/crud", () => ({ edit: jest.fn() })); jest.mock("../../../history", () => ({ @@ -9,7 +7,9 @@ jest.mock("../../../history", () => ({ import * as React from "react"; import { mount, shallow } from "enzyme"; -import { RawEditTool as EditTool, EditToolProps, mapStateToProps } from "../edit_tool"; +import { + RawEditTool as EditTool, EditToolProps, mapStateToProps +} from "../edit_tool"; import { fakeTool } from "../../../__test_support__/fake_state/resources"; import { fakeState } from "../../../__test_support__/fake_state"; import { diff --git a/frontend/farm_designer/tools/__tests__/index_test.tsx b/frontend/farm_designer/tools/__tests__/index_test.tsx index 6bf576d38..6cba551b5 100644 --- a/frontend/farm_designer/tools/__tests__/index_test.tsx +++ b/frontend/farm_designer/tools/__tests__/index_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - jest.mock("../../../history", () => ({ history: { push: jest.fn() }, getPathArray: () => "/app/designer/tools".split("/"), @@ -13,7 +11,9 @@ import { } from "../../../__test_support__/fake_state/resources"; import { history } from "../../../history"; import { fakeState } from "../../../__test_support__/fake_state"; -import { buildResourceIndex } from "../../../__test_support__/resource_index_builder"; +import { + buildResourceIndex +} from "../../../__test_support__/resource_index_builder"; describe("", () => { const fakeProps = (): ToolsProps => ({ diff --git a/frontend/farmware/__tests__/farmware_test.tsx b/frontend/farmware/__tests__/farmware_test.tsx index 6369a1561..e7b6a856e 100644 --- a/frontend/farmware/__tests__/farmware_test.tsx +++ b/frontend/farmware/__tests__/farmware_test.tsx @@ -1,11 +1,9 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - const mockDevice = { execScript: jest.fn(() => Promise.resolve({})) }; jest.mock("../../device", () => ({ getDevice: () => mockDevice })); import * as React from "react"; import { mount } from "enzyme"; -import { FarmwarePage, BasicFarmwarePage } from "../index"; +import { RawFarmwarePage as FarmwarePage, BasicFarmwarePage } from "../index"; import { FarmwareProps } from "../../devices/interfaces"; import { fakeFarmware, fakeFarmwares diff --git a/frontend/farmware/camera_calibration/camera_calibration.tsx b/frontend/farmware/camera_calibration/camera_calibration.tsx index 9aa4f8400..915b4f08f 100644 --- a/frontend/farmware/camera_calibration/camera_calibration.tsx +++ b/frontend/farmware/camera_calibration/camera_calibration.tsx @@ -36,7 +36,7 @@ export class CameraCalibration extends lockOpen={process.env.NODE_ENV !== "production"}> diff --git a/frontend/farmware/farmware_forms.tsx b/frontend/farmware/farmware_forms.tsx index daaa265c0..c77fac4c9 100644 --- a/frontend/farmware/farmware_forms.tsx +++ b/frontend/farmware/farmware_forms.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { Col, BlurableInput } from "../ui/index"; - import { Pair, FarmwareConfig } from "farmbot"; import { getDevice } from "../device"; import { @@ -25,7 +24,8 @@ export function getConfigEnvName(farmwareName: string, configName: string) { } /** Farmware description and version info for help text contents. */ -export function farmwareHelpText(farmware: FarmwareManifestInfo | undefined): string { +export function farmwareHelpText(farmware: FarmwareManifestInfo | undefined): + string { if (farmware) { const description = farmware.meta.description; const versionString = " (version: " + farmware.meta.version + ")"; diff --git a/frontend/farmware/farmware_list.tsx b/frontend/farmware/farmware_list.tsx index 60e5e7703..3816c9654 100644 --- a/frontend/farmware/farmware_list.tsx +++ b/frontend/farmware/farmware_list.tsx @@ -37,7 +37,7 @@ const farmwareListItem = (dispatch: Function, current: string | undefined) => to={`/app/farmware/${urlFriendly(farmwareName)}`} key={farmwareName} onClick={click}> -
+

{displayName}

; diff --git a/frontend/farmware/images/image_flipper.tsx b/frontend/farmware/images/image_flipper.tsx index 520ac8f0c..3730429a4 100644 --- a/frontend/farmware/images/image_flipper.tsx +++ b/frontend/farmware/images/image_flipper.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { ImageFlipperProps, ImageFlipperState } from "./interfaces"; import { Content } from "../../constants"; import { t } from "../../i18next_wrapper"; diff --git a/frontend/farmware/weed_detector/__tests__/weed_detector_test.tsx b/frontend/farmware/weed_detector/__tests__/weed_detector_test.tsx index bb8f81710..29ae0cdc5 100644 --- a/frontend/farmware/weed_detector/__tests__/weed_detector_test.tsx +++ b/frontend/farmware/weed_detector/__tests__/weed_detector_test.tsx @@ -2,19 +2,13 @@ const mockDevice = { execScript: jest.fn(() => Promise.resolve()), setUserEnv: jest.fn(() => Promise.resolve()), }; - -jest.mock("../../../device", () => ({ - getDevice: () => { - return mockDevice; - } -})); -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); +jest.mock("../../../device", () => ({ getDevice: () => mockDevice })); jest.mock("../../images/actions", () => ({ selectImage: jest.fn() })); import * as React from "react"; import { mount, shallow } from "enzyme"; -import { RawWeedDetector as WeedDetector, namespace } from "../index"; +import { WeedDetector, namespace } from "../index"; import { FarmwareProps } from "../../../devices/interfaces"; import { API } from "../../../api"; import { selectImage } from "../../images/actions"; diff --git a/frontend/farmware/weed_detector/config.tsx b/frontend/farmware/weed_detector/config.tsx index 9626c3ca3..9d775c606 100644 --- a/frontend/farmware/weed_detector/config.tsx +++ b/frontend/farmware/weed_detector/config.tsx @@ -26,7 +26,8 @@ export class WeedDetectorConfig extends React.Component { this.props.onChange(conf, parseFloat(e.currentTarget.value))} + onCommit={e => + this.props.onChange(conf, parseFloat(e.currentTarget.value))} placeholder={label} />
; }; @@ -54,10 +55,12 @@ export class WeedDetectorConfig extends React.Component { this.props.onChange("CAMERA_CALIBRATION_invert_hue_selection", - e.currentTarget.checked ? - SPECIAL_VALUES.TRUE : SPECIAL_VALUES.FALSE)} /> + checked={!!envGet("CAMERA_CALIBRATION_invert_hue_selection", + this.props.values)} + onChange={e => + this.props.onChange("CAMERA_CALIBRATION_invert_hue_selection", + e.currentTarget.checked ? + SPECIAL_VALUES.TRUE : SPECIAL_VALUES.FALSE)} /> { title="Scan this image" onClick={this.maybeProcessPhoto} disabled={!this.props.botOnline} - hidden={!this.props.images.length} > + hidden={!this.props.images.length}> {t("Scan image")} diff --git a/frontend/farmware/weed_detector/index.tsx b/frontend/farmware/weed_detector/index.tsx index 7192a70f9..542e37190 100644 --- a/frontend/farmware/weed_detector/index.tsx +++ b/frontend/farmware/weed_detector/index.tsx @@ -1,12 +1,10 @@ import * as React from "react"; -import { connect } from "react-redux"; import { DetectorState } from "./interfaces"; import { Row, Col } from "../../ui/index"; import { deletePoints, scanImage, test } from "./actions"; import { selectImage } from "../images/actions"; import { Progress } from "../../util"; import { FarmwareProps, Feature } from "../../devices/interfaces"; -import { mapStateToProps } from "../../farmware/state_to_props"; import { ImageWorkspace } from "./image_workspace"; import { WDENVKey, isWDENVKey } from "./remote_env/interfaces"; import { envGet } from "./remote_env/selectors"; @@ -23,7 +21,7 @@ export const namespace = (prefix: string) => (key: string): WDENVKey => { } }; -export class RawWeedDetector +export class WeedDetector extends React.Component> { constructor(props: FarmwareProps) { @@ -102,5 +100,3 @@ export class RawWeedDetector ; } } - -export const WeedDetector = connect(mapStateToProps)(RawWeedDetector); diff --git a/frontend/farmware/weed_detector/remote_env/selectors.ts b/frontend/farmware/weed_detector/remote_env/selectors.ts index 83110dd83..83b0226e5 100644 --- a/frontend/farmware/weed_detector/remote_env/selectors.ts +++ b/frontend/farmware/weed_detector/remote_env/selectors.ts @@ -1,4 +1,3 @@ - import { WDENVKey, WD_ENV } from "./interfaces"; import { WD_KEY_DEFAULTS, EVERY_WD_KEY } from "./constants"; import { defensiveClone, betterParseNum } from "../../../util"; diff --git a/frontend/front_page/forgot_password.tsx b/frontend/front_page/forgot_password.tsx index 1b6dd28d8..cf11f87ab 100644 --- a/frontend/front_page/forgot_password.tsx +++ b/frontend/front_page/forgot_password.tsx @@ -22,7 +22,7 @@ export function ForgotPassword(props: ForgotPasswordProps) { diff --git a/frontend/front_page/login.tsx b/frontend/front_page/login.tsx index 444c741af..b96af88e3 100644 --- a/frontend/front_page/login.tsx +++ b/frontend/front_page/login.tsx @@ -74,7 +74,7 @@ export class Login extends React.Component { - + {t("Forgot password?")} diff --git a/frontend/front_page/resend_verification.tsx b/frontend/front_page/resend_verification.tsx index 07099f51d..e4eea3283 100644 --- a/frontend/front_page/resend_verification.tsx +++ b/frontend/front_page/resend_verification.tsx @@ -1,5 +1,4 @@ import { Col, Widget, WidgetHeader } from "../ui/index"; - import axios, { AxiosResponse } from "axios"; import * as React from "react"; import { API } from "../api/index"; diff --git a/frontend/front_page/terms_checkbox.tsx b/frontend/front_page/terms_checkbox.tsx index 1c841ef1b..7751040e6 100644 --- a/frontend/front_page/terms_checkbox.tsx +++ b/frontend/front_page/terms_checkbox.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { PartialFormEvent } from "./front_page"; import { t } from "../i18next_wrapper"; diff --git a/frontend/help/__tests__/help_test.tsx b/frontend/help/__tests__/help_test.tsx index 45ddc228d..f93b214db 100644 --- a/frontend/help/__tests__/help_test.tsx +++ b/frontend/help/__tests__/help_test.tsx @@ -1,8 +1,6 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - import * as React from "react"; import { mount } from "enzyme"; -import { Help, mapStateToProps } from "../help"; +import { RawHelp as Help, mapStateToProps } from "../help"; import { fakeState } from "../../__test_support__/fake_state"; import { clickButton } from "../../__test_support__/helpers"; import { tourNames } from "../tours"; diff --git a/frontend/help/docs.tsx b/frontend/help/docs.tsx index f8e6995bb..8ad5a5c2d 100644 --- a/frontend/help/docs.tsx +++ b/frontend/help/docs.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { Widget, WidgetBody, WidgetHeader, docLink, DOC_SLUGS, DocSlug } from "../ui"; diff --git a/frontend/help/tours.ts b/frontend/help/tours.ts index 63a2098ca..f01fe0dec 100644 --- a/frontend/help/tours.ts +++ b/frontend/help/tours.ts @@ -1,6 +1,5 @@ import { history } from "../history"; import { Step as TourStep } from "react-joyride"; - import { TourContent } from "../constants"; import { t } from "../i18next_wrapper"; diff --git a/frontend/loading_plant.tsx b/frontend/loading_plant.tsx index 837652c47..0c70ac0d9 100644 --- a/frontend/loading_plant.tsx +++ b/frontend/loading_plant.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { Color } from "./ui"; import { t } from "./i18next_wrapper"; diff --git a/frontend/logs/__tests__/index_test.tsx b/frontend/logs/__tests__/index_test.tsx index 2389be973..9d68e66af 100644 --- a/frontend/logs/__tests__/index_test.tsx +++ b/frontend/logs/__tests__/index_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - const mockStorj: Dictionary = {}; import * as React from "react"; diff --git a/frontend/messages/__tests__/index_test.tsx b/frontend/messages/__tests__/index_test.tsx index db8204273..ff07171a0 100644 --- a/frontend/messages/__tests__/index_test.tsx +++ b/frontend/messages/__tests__/index_test.tsx @@ -1,8 +1,6 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - import * as React from "react"; import { mount } from "enzyme"; -import { Messages } from "../index"; +import { RawMessages as Messages } from "../index"; import { MessagesProps } from "../interfaces"; import { fakeTimeSettings } from "../../__test_support__/fake_time_settings"; diff --git a/frontend/nav/mobile_menu.tsx b/frontend/nav/mobile_menu.tsx index b666c243f..e99691cb2 100644 --- a/frontend/nav/mobile_menu.tsx +++ b/frontend/nav/mobile_menu.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { Overlay, Classes } from "@blueprintjs/core"; - import { NavLinks } from "./nav_links"; import { MobileMenuProps } from "./interfaces"; diff --git a/frontend/nav/nav_links.tsx b/frontend/nav/nav_links.tsx index ba323581b..f42e9b4ab 100644 --- a/frontend/nav/nav_links.tsx +++ b/frontend/nav/nav_links.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { NavLinksProps } from "./interfaces"; import { getPathArray } from "../history"; import { diff --git a/frontend/nav/ticker_list.tsx b/frontend/nav/ticker_list.tsx index 307d4b61e..15a44f563 100644 --- a/frontend/nav/ticker_list.tsx +++ b/frontend/nav/ticker_list.tsx @@ -74,7 +74,7 @@ const Ticker = (log: TaggedLog, timeSettings: TimeSettings) => { /** The logs ticker, with closed/open views, and a link to the Logs page. */ export let TickerList = (props: TickerListProps) => { return -
+
{Ticker(getfirstTickerLog(props.getConfigValue)(props.logs), props.timeSettings)} diff --git a/frontend/regimens/__tests__/index_test.tsx b/frontend/regimens/__tests__/index_test.tsx index bf9267de5..639da9504 100644 --- a/frontend/regimens/__tests__/index_test.tsx +++ b/frontend/regimens/__tests__/index_test.tsx @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - jest.mock("../../history", () => ({ push: () => jest.fn(), history: { getCurrentLocation: () => ({ pathname: "" }) } @@ -7,34 +5,36 @@ jest.mock("../../history", () => ({ import * as React from "react"; import { mount } from "enzyme"; -import { Regimens, RegimenBackButtonProps, RegimenBackButton } from "../index"; +import { + RawRegimens as Regimens, RegimenBackButtonProps, RegimenBackButton +} from "../index"; import { Props } from "../interfaces"; import { bot } from "../../__test_support__/fake_state/bot"; import { auth } from "../../__test_support__/fake_state/token"; -import { buildResourceIndex } from "../../__test_support__/resource_index_builder"; +import { + buildResourceIndex +} from "../../__test_support__/resource_index_builder"; import { fakeRegimen } from "../../__test_support__/fake_state/resources"; import { Actions } from "../../constants"; describe("", () => { - function fakeProps(): Props { - return { - dispatch: jest.fn(), - sequences: [], - resources: buildResourceIndex([]).index, - auth, - current: fakeRegimen(), - regimens: [], - selectedSequence: undefined, - dailyOffsetMs: 1000, - weeks: [], - bot, - calendar: [], - regimenUsageStats: {}, - shouldDisplay: () => false, - variableData: {}, - schedulerOpen: false, - }; - } + const fakeProps = (): Props => ({ + dispatch: jest.fn(), + sequences: [], + resources: buildResourceIndex([]).index, + auth, + current: fakeRegimen(), + regimens: [], + selectedSequence: undefined, + dailyOffsetMs: 1000, + weeks: [], + bot, + calendar: [], + regimenUsageStats: {}, + shouldDisplay: () => false, + variableData: {}, + schedulerOpen: false, + }); it("renders", () => { const wrapper = mount(); diff --git a/frontend/regimens/__tests__/reducer_test.ts b/frontend/regimens/__tests__/reducer_test.ts index f72f142f7..a0209ed82 100644 --- a/frontend/regimens/__tests__/reducer_test.ts +++ b/frontend/regimens/__tests__/reducer_test.ts @@ -1,4 +1,3 @@ - import { regimensReducer, RegimenState } from "../reducer"; import { Actions } from "../../constants"; import { popWeek, pushWeek, selectDays, deselectDays } from "../bulk_scheduler/actions"; diff --git a/frontend/regimens/bulk_scheduler/__tests__/index_test.tsx b/frontend/regimens/bulk_scheduler/__tests__/index_test.tsx index bf6b7e81b..da5fcd71f 100644 --- a/frontend/regimens/bulk_scheduler/__tests__/index_test.tsx +++ b/frontend/regimens/bulk_scheduler/__tests__/index_test.tsx @@ -2,7 +2,9 @@ import * as React from "react"; import { mount, shallow } from "enzyme"; import { BulkScheduler } from "../index"; import { BulkEditorProps } from "../interfaces"; -import { buildResourceIndex } from "../../../__test_support__/resource_index_builder"; +import { + buildResourceIndex +} from "../../../__test_support__/resource_index_builder"; import { Actions } from "../../../constants"; import { fakeSequence } from "../../../__test_support__/fake_state/resources"; diff --git a/frontend/regimens/bulk_scheduler/add_button.tsx b/frontend/regimens/bulk_scheduler/add_button.tsx index 7863b1a06..77c12c39d 100644 --- a/frontend/regimens/bulk_scheduler/add_button.tsx +++ b/frontend/regimens/bulk_scheduler/add_button.tsx @@ -5,7 +5,7 @@ export function AddButton({ active, click }: AddButtonProps) { if (!active) { return
; } return ; } diff --git a/frontend/regimens/bulk_scheduler/week_grid.tsx b/frontend/regimens/bulk_scheduler/week_grid.tsx index 5772db64a..0895f74ec 100644 --- a/frontend/regimens/bulk_scheduler/week_grid.tsx +++ b/frontend/regimens/bulk_scheduler/week_grid.tsx @@ -2,7 +2,6 @@ import * as React from "react"; import { WeekRow } from "./week_row"; import { WeekGridProps } from "./interfaces"; import { pushWeek, popWeek, deselectDays, selectDays } from "./actions"; - import { Row, Col } from "../../ui/index"; import { t } from "../../i18next_wrapper"; @@ -49,5 +48,5 @@ export function WeekGrid({ weeks, dispatch }: WeekGridProps) {
-
; +
; } diff --git a/frontend/regimens/editor/copy_button.tsx b/frontend/regimens/editor/copy_button.tsx index 20fc889a5..6ffff2c79 100644 --- a/frontend/regimens/editor/copy_button.tsx +++ b/frontend/regimens/editor/copy_button.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { CopyButtonProps } from "./interfaces"; - import { init } from "../../api/crud"; import { TaggedRegimen } from "farmbot"; import { defensiveClone, urlFriendly } from "../../util"; diff --git a/frontend/regimens/editor/regimen_name_input.tsx b/frontend/regimens/editor/regimen_name_input.tsx index 8e383c9fd..598fc739f 100644 --- a/frontend/regimens/editor/regimen_name_input.tsx +++ b/frontend/regimens/editor/regimen_name_input.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { RegimenProps } from "../interfaces"; - import { Row, Col, ColorPicker } from "../../ui/index"; import { editRegimen } from "../actions"; import { t } from "../../i18next_wrapper"; diff --git a/frontend/regimens/list/add_button.tsx b/frontend/regimens/list/add_button.tsx index 9057691e8..9214ce38c 100644 --- a/frontend/regimens/list/add_button.tsx +++ b/frontend/regimens/list/add_button.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { AddRegimenProps } from "../interfaces"; import { push } from "../../history"; import { TaggedRegimen } from "farmbot"; diff --git a/frontend/regimens/list/regimen_list_item.tsx b/frontend/regimens/list/regimen_list_item.tsx index 4f0c6465b..2efd1eb1b 100644 --- a/frontend/regimens/list/regimen_list_item.tsx +++ b/frontend/regimens/list/regimen_list_item.tsx @@ -2,7 +2,6 @@ import * as React from "react"; import { RegimenListItemProps } from "../interfaces"; import { lastUrlChunk, urlFriendly } from "../../util"; import { selectRegimen } from "../actions"; - import { Content } from "../../constants"; import { Link } from "../../link"; import { t } from "../../i18next_wrapper"; diff --git a/frontend/resources/__tests__/in_use_test.ts b/frontend/resources/__tests__/in_use_test.ts index 62c397f31..ef2231ef8 100644 --- a/frontend/resources/__tests__/in_use_test.ts +++ b/frontend/resources/__tests__/in_use_test.ts @@ -1,6 +1,8 @@ import { TaggedResource, TaggedRegimen, TaggedSequence } from "farmbot"; import { ResourceIndex } from "../interfaces"; -import { buildResourceIndex } from "../../__test_support__/resource_index_builder"; +import { + buildResourceIndex +} from "../../__test_support__/resource_index_builder"; import { EVERY_USAGE_KIND, UsageIndex, resourceUsageList } from "../in_use"; import { DeepPartial } from "redux"; import { @@ -29,8 +31,11 @@ describe("resourceUsageList", () => { "Sequence.FbosConfig": { "Device.99.99": { "Sequence.12.12": true } } }; const actual = Object.keys(resourceUsageList(x)).sort(); - const expected = - ["FarmEvent.0.0", "FarmEvent.3.3", "Regimen.6.6", "Regimen.9.9", "Device.99.99"].sort(); + const expected = [ + "FarmEvent.0.0", "FarmEvent.3.3", + "Regimen.6.6", "Regimen.9.9", + "Device.99.99", + ].sort(); expect(actual.length).toEqual(expected.length); expected.map(y => expect(actual).toContain(y)); }); @@ -44,7 +49,8 @@ describe("in_use tracking at reducer level", () => { const assertShape = (inUse: UsageIndex, expected: DeepPartial) => { - EVERY_USAGE_KIND.map(kind => expect(inUse[kind]).toEqual(expected[kind] || {})); + EVERY_USAGE_KIND.map(kind => + expect(inUse[kind]).toEqual(expected[kind] || {})); }; it("loads defaults", () => assertShape(testCase([]).inUse, {})); diff --git a/frontend/resources/__tests__/sequence_meta_test.ts b/frontend/resources/__tests__/sequence_meta_test.ts index 4c3076a0d..82515613c 100644 --- a/frontend/resources/__tests__/sequence_meta_test.ts +++ b/frontend/resources/__tests__/sequence_meta_test.ts @@ -11,7 +11,9 @@ import { fakeTool, fakeToolSlot } from "../../__test_support__/fake_state/resources"; -import { buildResourceIndex } from "../../__test_support__/resource_index_builder"; +import { + buildResourceIndex +} from "../../__test_support__/resource_index_builder"; import { sanitizeNodes } from "../../sequences/locals_list/sanitize_nodes"; @@ -68,8 +70,11 @@ describe("determineDropdown", () => { kind: "parameter_application", args: { label: "x", - // tslint:disable-next-line:no-any - data_value: { kind: "every_point", args: { every_point_type: "Plant" } } as any + data_value: { + kind: "every_point", + args: { every_point_type: "Plant" } + // tslint:disable-next-line:no-any + } as any } }, buildResourceIndex([]).index); expect(r.label).toBe("All plants"); diff --git a/frontend/resources/in_use.ts b/frontend/resources/in_use.ts index be10756f4..ba8dd4826 100644 --- a/frontend/resources/in_use.ts +++ b/frontend/resources/in_use.ts @@ -3,9 +3,9 @@ import { UUID } from "./interfaces"; /** Used for fast lookups of unique UUIDs. */ type UUIDSet = Record; -/** The key side of the Record represents the resource that cannot be deleted (hence forward - * the "in use resource". - * The value represents a set of resource that make it unsafe to delete the +/** The key side of the Record + * represents the resource that cannot be deleted (the "in use resource"). + * The value represents a set of resources that make it unsafe to delete the * "in use resource". */ export type UsageMap = Record; diff --git a/frontend/resources/reducer.ts b/frontend/resources/reducer.ts index 7e9842da0..b94dd1a5f 100644 --- a/frontend/resources/reducer.ts +++ b/frontend/resources/reducer.ts @@ -108,11 +108,12 @@ export let resourceReducer = mutateSpecialStatus(uuid, s.index, specialStatus); return s; }) - .add>(Actions.RESOURCE_READY, (s, { payload }) => { - !s.loaded.includes(payload.kind) && s.loaded.push(payload.kind); - indexUpsert(s.index, payload.body, "initial"); - return s; - }) + .add>(Actions.RESOURCE_READY, + (s, { payload }) => { + !s.loaded.includes(payload.kind) && s.loaded.push(payload.kind); + indexUpsert(s.index, payload.body, "initial"); + return s; + }) .add(Actions.REFRESH_RESOURCE_OK, (s, { payload }) => { indexUpsert(s.index, [payload], "ongoing"); mutateSpecialStatus(payload.uuid, s.index); diff --git a/frontend/resources/reducer_support.ts b/frontend/resources/reducer_support.ts index 756452d3f..7e3d9aa45 100644 --- a/frontend/resources/reducer_support.ts +++ b/frontend/resources/reducer_support.ts @@ -72,7 +72,8 @@ const BY_KIND_AND_ID: Indexer = { }, }; -export function updateSequenceUsageIndex(myUuid: string, ids: number[], i: ResourceIndex) { +export function updateSequenceUsageIndex( + myUuid: string, ids: number[], i: ResourceIndex) { ids.map(id => { const uuid = i.byKindAndId[joinKindAndId("Sequence", id)]; if (uuid) { // `undefined` usually means "not ready". diff --git a/frontend/routes.tsx b/frontend/routes.tsx index 4c75fc907..305d00294 100644 --- a/frontend/routes.tsx +++ b/frontend/routes.tsx @@ -24,7 +24,8 @@ interface RootComponentState { ChildRoute?: React.ComponentType; } -export class RootComponent extends React.Component { +export class RootComponent + extends React.Component { state: RootComponentState = { Route: () =>
Loading...
}; UNSAFE_componentWillMount() { diff --git a/frontend/sequences/__tests__/sequences_test.tsx b/frontend/sequences/__tests__/sequences_test.tsx index 8f1fcc7a4..a0fb88ab5 100644 --- a/frontend/sequences/__tests__/sequences_test.tsx +++ b/frontend/sequences/__tests__/sequences_test.tsx @@ -1,12 +1,12 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - jest.mock("../../history", () => ({ push: jest.fn(), history: { getCurrentLocation: () => "" }, })); import * as React from "react"; -import { Sequences, SequenceBackButtonProps, SequenceBackButton } from "../sequences"; +import { + RawSequences as Sequences, SequenceBackButtonProps, SequenceBackButton +} from "../sequences"; import { shallow, mount } from "enzyme"; import { Props } from "../interfaces"; import { diff --git a/frontend/sequences/__tests__/state_to_props_test.ts b/frontend/sequences/__tests__/state_to_props_test.ts index 7172718a1..5cf1d94cd 100644 --- a/frontend/sequences/__tests__/state_to_props_test.ts +++ b/frontend/sequences/__tests__/state_to_props_test.ts @@ -1,5 +1,3 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - import { mapStateToProps } from "../state_to_props"; import { fakeState } from "../../__test_support__/fake_state"; import { Feature } from "../../devices/interfaces"; @@ -7,7 +5,9 @@ import { fakeFarmwareManifestV1 } from "../../__test_support__/fake_farmwares"; import { fakeSequence, fakeWebAppConfig } from "../../__test_support__/fake_state/resources"; -import { buildResourceIndex } from "../../__test_support__/resource_index_builder"; +import { + buildResourceIndex +} from "../../__test_support__/resource_index_builder"; import { TaggedSequence } from "farmbot"; describe("mapStateToProps()", () => { diff --git a/frontend/sequences/__tests__/test_button_test.tsx b/frontend/sequences/__tests__/test_button_test.tsx index ad47e1d02..9c54fc715 100644 --- a/frontend/sequences/__tests__/test_button_test.tsx +++ b/frontend/sequences/__tests__/test_button_test.tsx @@ -17,7 +17,8 @@ jest.mock("@blueprintjs/core", () => ({ import * as React from "react"; import { TestButton, TestBtnProps, setMenuOpen } from "../test_button"; import { - TaggedSequence, SpecialStatus, ParameterApplication, ParameterDeclaration, Coordinate + TaggedSequence, SpecialStatus, ParameterApplication, ParameterDeclaration, + Coordinate, } from "farmbot"; import { mount } from "enzyme"; import { buildResourceIndex } from "../../__test_support__/resource_index_builder"; @@ -135,7 +136,9 @@ describe("", () => { expect(wrapper.state().bodyVariables).toEqual([variable]); }); - const COORDINATE: Coordinate = { kind: "coordinate", args: { x: 0, y: 0, z: 0 } }; + const COORDINATE: Coordinate = { + kind: "coordinate", args: { x: 0, y: 0, z: 0 } + }; it("calls sequence with bodyVariables when synced", () => { const declaration: ParameterDeclaration = { @@ -153,11 +156,12 @@ describe("", () => { props.resources.sequenceMetas[props.sequence.uuid] = varData; const wrapper = mount(); clickButton(wrapper, 1, "test"); - expect(mockDevice.execSequence).toHaveBeenCalledWith(props.sequence.body.id, [{ - kind: "parameter_application", - args: { label: "label", data_value: COORDINATE } - } - ]); + expect(mockDevice.execSequence) + .toHaveBeenCalledWith(props.sequence.body.id, [{ + kind: "parameter_application", + args: { label: "label", data_value: COORDINATE } + } + ]); }); it("doesn't call sequence with bodyVariables when not synced", () => { diff --git a/frontend/sequences/locals_list/__tests__/default_value_form_test.tsx b/frontend/sequences/locals_list/__tests__/default_value_form_test.tsx index 8fe9b5e6c..d3e22ffbc 100644 --- a/frontend/sequences/locals_list/__tests__/default_value_form_test.tsx +++ b/frontend/sequences/locals_list/__tests__/default_value_form_test.tsx @@ -1,7 +1,9 @@ import * as React from "react"; import { mount } from "enzyme"; import { DefaultValueFormProps, DefaultValueForm } from "../default_value_form"; -import { buildResourceIndex } from "../../../__test_support__/resource_index_builder"; +import { + buildResourceIndex +} from "../../../__test_support__/resource_index_builder"; import { Coordinate } from "farmbot"; describe("", () => { diff --git a/frontend/sequences/locals_list/handle_select.ts b/frontend/sequences/locals_list/handle_select.ts index d8fb56101..d32802ba0 100644 --- a/frontend/sequences/locals_list/handle_select.ts +++ b/frontend/sequences/locals_list/handle_select.ts @@ -160,7 +160,8 @@ export const addOrEditBodyVariables = ( return Object.values(items); }; -/** Add a new declaration or replace an existing one with the same label. (sequences) */ +/** Add a new declaration or replace an existing one with the same label. + * (sequences) */ export const addOrEditDeclarationLocals = ( declarations: ScopeDeclarationBodyItem[], updatedItem: ScopeDeclarationBodyItem diff --git a/frontend/sequences/reducer.ts b/frontend/sequences/reducer.ts index cf13bc41c..a5416cdcf 100644 --- a/frontend/sequences/reducer.ts +++ b/frontend/sequences/reducer.ts @@ -26,7 +26,8 @@ export let sequenceReducer = generateReducer(initialState) s.menuOpen = payload; return s; }) - .add(Actions.SET_SEQUENCE_STEP_POSITION, function (s, { payload }) { - s.stepIndex = payload; - return s; - }); + .add(Actions.SET_SEQUENCE_STEP_POSITION, + function (s, { payload }) { + s.stepIndex = payload; + return s; + }); diff --git a/frontend/sequences/step_button_cluster.tsx b/frontend/sequences/step_button_cluster.tsx index 10d3ba962..4875068f3 100644 --- a/frontend/sequences/step_button_cluster.tsx +++ b/frontend/sequences/step_button_cluster.tsx @@ -123,7 +123,7 @@ export function StepButtonCluster(props: StepButtonProps) { + step={{ kind: "take_photo", args: {} }}> {t("TAKE PHOTO")} , ]; diff --git a/frontend/sequences/step_buttons/index.tsx b/frontend/sequences/step_buttons/index.tsx index 86681018b..ac6eb9b93 100644 --- a/frontend/sequences/step_buttons/index.tsx +++ b/frontend/sequences/step_buttons/index.tsx @@ -27,10 +27,10 @@ export function StepButton({ children, step, color, dispatch, current, index }: dispatch={dispatch} step={step} intent="step_splice" - draggerId={NULL_DRAGGER_ID} > + draggerId={NULL_DRAGGER_ID}> diff --git a/frontend/sequences/step_tiles/__tests__/pin_and_peripheral_support_test.tsx b/frontend/sequences/step_tiles/__tests__/pin_and_peripheral_support_test.tsx index 0b1ee6629..ab880c80d 100644 --- a/frontend/sequences/step_tiles/__tests__/pin_and_peripheral_support_test.tsx +++ b/frontend/sequences/step_tiles/__tests__/pin_and_peripheral_support_test.tsx @@ -279,8 +279,8 @@ describe("Pin and Peripheral support files", () => { it("Sets step.args.pin_number", () => { const resources = newIndex(); const dispatch = jest.fn(); - const currentSequence = - resources.references[Object.keys(resources.byKind.Sequence)[0]] as TaggedSequence; + const currentSequence = resources.references[ + Object.keys(resources.byKind.Sequence)[0]] as TaggedSequence; const index = 0; const currentStep = (currentSequence.body.body || [])[index]; const stepParams: StepParams = { diff --git a/frontend/sequences/step_tiles/__tests__/tile_assertion_test.tsx b/frontend/sequences/step_tiles/__tests__/tile_assertion_test.tsx index bc3915461..92e44af91 100644 --- a/frontend/sequences/step_tiles/__tests__/tile_assertion_test.tsx +++ b/frontend/sequences/step_tiles/__tests__/tile_assertion_test.tsx @@ -5,7 +5,9 @@ import { Wait } from "farmbot"; import { StepWrapper } from "../../step_ui/step_wrapper"; import { DeepPartial } from "redux"; 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 { renderCeleryNode } from ".."; const EMPTY: DeepPartial = {}; diff --git a/frontend/sequences/step_tiles/index.tsx b/frontend/sequences/step_tiles/index.tsx index 2c36e2971..5d565df8f 100644 --- a/frontend/sequences/step_tiles/index.tsx +++ b/frontend/sequences/step_tiles/index.tsx @@ -18,7 +18,6 @@ import { TileExecuteScript } from "./tile_execute_script"; import { TileTakePhoto } from "./tile_take_photo"; import { overwrite } from "../../api/crud"; import { TileFindHome } from "./tile_find_home"; - import { MarkAs } from "./mark_as"; import { TileUnknown } from "./tile_unknown"; import { forceSetStepTag } from "../../resources/sequence_tagging"; @@ -164,10 +163,11 @@ export function renderCeleryNode(props: StepParams) { } } -const checkBranch = (branch: Execute | Nothing, _step: If, sequence: TaggedSequence) => { - return (branch.kind === "execute") - && (branch.args.sequence_id === sequence.body.id); -}; +const checkBranch = + (branch: Execute | Nothing, _step: If, sequence: TaggedSequence) => { + return (branch.kind === "execute") + && (branch.args.sequence_id === sequence.body.id); + }; export function isRecursive(step: If, sequence: TaggedSequence) { return checkBranch(step.args._else, step, sequence) diff --git a/frontend/sequences/step_tiles/mark_as.tsx b/frontend/sequences/step_tiles/mark_as.tsx index b2be1235a..ccc1d507c 100644 --- a/frontend/sequences/step_tiles/mark_as.tsx +++ b/frontend/sequences/step_tiles/mark_as.tsx @@ -1,7 +1,6 @@ import { Row, Col, FBSelect, DropDownItem } from "../../ui/index"; import { StepParams } from "../interfaces"; import { StepWrapper, StepHeader, StepContent } from "../step_ui/index"; - import { ToolTips } from "../../constants"; import * as React from "react"; import { unpackStep } from "./mark_as/unpack_step"; diff --git a/frontend/sequences/step_tiles/pin_and_peripheral_support.tsx b/frontend/sequences/step_tiles/pin_and_peripheral_support.tsx index e0808bfbe..ff0555ba7 100644 --- a/frontend/sequences/step_tiles/pin_and_peripheral_support.tsx +++ b/frontend/sequences/step_tiles/pin_and_peripheral_support.tsx @@ -35,17 +35,25 @@ const BOX_LED_LABELS = (): { [x: string]: string } => ({ [BoxLed.BoxLed4]: t("Box LED 4"), }); -export const PERIPHERAL_HEADING = (): DropDownItem => - ({ heading: true, label: t("Peripherals"), value: 0, headingId: PinGroupName.Peripheral }); +export const PERIPHERAL_HEADING = (): DropDownItem => ({ + heading: true, headingId: PinGroupName.Peripheral, + label: t("Peripherals"), value: 0, +}); -export const SENSOR_HEADING = (): DropDownItem => - ({ heading: true, label: t("Sensors"), value: 0, headingId: PinGroupName.Sensor }); +export const SENSOR_HEADING = (): DropDownItem => ({ + heading: true, headingId: PinGroupName.Sensor, + label: t("Sensors"), value: 0, +}); -export const BOX_LED_HEADING = (): DropDownItem => - ({ heading: true, label: t("Box LEDs"), value: 0, headingId: PinGroupName.BoxLed }); +export const BOX_LED_HEADING = (): DropDownItem => ({ + heading: true, headingId: PinGroupName.BoxLed, + label: t("Box LEDs"), value: 0, +}); -export const PIN_HEADING = (): DropDownItem => - ({ heading: true, label: t("Pins"), value: 0, headingId: PinGroupName.Pin }); +export const PIN_HEADING = (): DropDownItem => ({ + heading: true, headingId: PinGroupName.Pin, + label: t("Pins"), value: 0, +}); /** Pass it the number X and it will generate a DropDownItem for `pin x`. */ export const pinNumber2DropDown = diff --git a/frontend/sequences/step_tiles/tile_execute.tsx b/frontend/sequences/step_tiles/tile_execute.tsx index 53e629f67..3e7e38df8 100644 --- a/frontend/sequences/step_tiles/tile_execute.tsx +++ b/frontend/sequences/step_tiles/tile_execute.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { StepParams } from "../interfaces"; - import { Row, Col, DropDownItem } from "../../ui/index"; import { Execute, ParameterApplication } from "farmbot/dist"; import { TaggedSequence } from "farmbot"; diff --git a/frontend/sequences/step_tiles/tile_execute_script_support.tsx b/frontend/sequences/step_tiles/tile_execute_script_support.tsx index ee9b572fe..0f2a2cb82 100644 --- a/frontend/sequences/step_tiles/tile_execute_script_support.tsx +++ b/frontend/sequences/step_tiles/tile_execute_script_support.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { FarmwareInfo } from "../interfaces"; - import { DropDownItem, BlurableInput, Help } from "../../ui/index"; import { without, isNumber } from "lodash"; import { ExecuteScript, Pair, FarmwareConfig } from "farmbot"; diff --git a/frontend/sequences/step_tiles/tile_find_home.tsx b/frontend/sequences/step_tiles/tile_find_home.tsx index 978983ea1..6daa82dcb 100644 --- a/frontend/sequences/step_tiles/tile_find_home.tsx +++ b/frontend/sequences/step_tiles/tile_find_home.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { FindHome, Xyz, TaggedSequence } from "farmbot"; import { StepParams, HardwareFlags } from "../interfaces"; import { ResourceIndex } from "../../resources/interfaces"; diff --git a/frontend/sequences/step_tiles/tile_firmware_action.tsx b/frontend/sequences/step_tiles/tile_firmware_action.tsx index fb3737b3e..f01c73361 100644 --- a/frontend/sequences/step_tiles/tile_firmware_action.tsx +++ b/frontend/sequences/step_tiles/tile_firmware_action.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { StepInputBox } from "../inputs/step_input_box"; import { StepParams } from "../interfaces"; import { ToolTips } from "../../constants"; diff --git a/frontend/sequences/step_tiles/tile_if/__tests__/lhs_test.ts b/frontend/sequences/step_tiles/tile_if/__tests__/lhs_test.ts index 92e95969a..2f4b92c70 100644 --- a/frontend/sequences/step_tiles/tile_if/__tests__/lhs_test.ts +++ b/frontend/sequences/step_tiles/tile_if/__tests__/lhs_test.ts @@ -126,7 +126,8 @@ describe("updateLhs", () => { describe("displayLhs", () => { it("Finds peripherals to display", () => { - const p = resources.index.references[Object.keys(resources.index.byKind.Peripheral)[0]]; + const p = resources.index.references[ + Object.keys(resources.index.byKind.Peripheral)[0]]; if (!p) { throw new Error("Never"); } diff --git a/frontend/sequences/step_tiles/tile_if/index.tsx b/frontend/sequences/step_tiles/tile_if/index.tsx index 18eac03f7..87a04ab2d 100644 --- a/frontend/sequences/step_tiles/tile_if/index.tsx +++ b/frontend/sequences/step_tiles/tile_if/index.tsx @@ -47,7 +47,10 @@ export type Operator = "lhs" export const LHSOptions = (resources: ResourceIndex, showPins: boolean ): DropDownItem[] => [ - { heading: true, label: t("Positions"), value: 0, headingId: PinGroupName.Position }, + { + heading: true, headingId: PinGroupName.Position, + label: t("Positions"), value: 0, + }, { value: "x", label: t("X position"), headingId: "Position" }, { value: "y", label: t("Y position"), headingId: "Position" }, { value: "z", label: t("Z position"), headingId: "Position" }, diff --git a/frontend/sequences/step_tiles/tile_move_absolute_conflict_check.tsx b/frontend/sequences/step_tiles/tile_move_absolute_conflict_check.tsx index 86c4ec304..93371928e 100644 --- a/frontend/sequences/step_tiles/tile_move_absolute_conflict_check.tsx +++ b/frontend/sequences/step_tiles/tile_move_absolute_conflict_check.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { CheckConflictCaseProps, MoveAbsoluteWarningProps } from "../interfaces"; import { Xyz } from "../../devices/interfaces"; import { StepWarning, conflictsString } from "../step_ui/index"; diff --git a/frontend/sequences/step_tiles/tile_move_home.tsx b/frontend/sequences/step_tiles/tile_move_home.tsx index 537c47eda..57dc12241 100644 --- a/frontend/sequences/step_tiles/tile_move_home.tsx +++ b/frontend/sequences/step_tiles/tile_move_home.tsx @@ -3,7 +3,6 @@ import { StepParams } from "../interfaces"; import { ToolTips } from "../../constants"; import { StepWrapper, StepHeader, StepContent } from "../step_ui/index"; import { StepRadio } from "../step_ui/step_radio"; - import { StepInputBox } from "../inputs/step_input_box"; import { Row, Col } from "../../ui"; import { t } from "../../i18next_wrapper"; diff --git a/frontend/sequences/step_tiles/tile_move_relative.tsx b/frontend/sequences/step_tiles/tile_move_relative.tsx index 28839505f..ba4a53fad 100644 --- a/frontend/sequences/step_tiles/tile_move_relative.tsx +++ b/frontend/sequences/step_tiles/tile_move_relative.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { StepInputBox } from "../inputs/step_input_box"; import { StepParams } from "../interfaces"; import { ToolTips } from "../../constants"; diff --git a/frontend/sequences/step_tiles/tile_pin_support.tsx b/frontend/sequences/step_tiles/tile_pin_support.tsx index 8dc0c001b..56c5ea0c5 100644 --- a/frontend/sequences/step_tiles/tile_pin_support.tsx +++ b/frontend/sequences/step_tiles/tile_pin_support.tsx @@ -1,4 +1,3 @@ - import { editStep } from "../../api/crud"; import { WritePin, SequenceBodyItem, ALLOWED_PIN_MODES } from "farmbot"; import { DropDownItem } from "../../ui/index"; diff --git a/frontend/sequences/step_tiles/tile_send_message.tsx b/frontend/sequences/step_tiles/tile_send_message.tsx index 9f6b17a2f..988e007a2 100644 --- a/frontend/sequences/step_tiles/tile_send_message.tsx +++ b/frontend/sequences/step_tiles/tile_send_message.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { FBSelect, DropDownItem, Row, Col } from "../../ui/index"; - import { StepInputBox } from "../inputs/step_input_box"; import { SendMessage, TaggedSequence } from "farmbot"; import { StepParams, ChannelName, isMessageType } from "../interfaces"; diff --git a/frontend/sequences/step_tiles/tile_send_message_support.tsx b/frontend/sequences/step_tiles/tile_send_message_support.tsx index 51e0617d2..d8c1bb56d 100644 --- a/frontend/sequences/step_tiles/tile_send_message_support.tsx +++ b/frontend/sequences/step_tiles/tile_send_message_support.tsx @@ -1,4 +1,3 @@ - import { Channel } from "farmbot/dist"; import { ChannelName, MessageType } from "../interfaces"; import { t } from "../../i18next_wrapper"; diff --git a/frontend/sequences/step_tiles/tile_set_servo_angle.tsx b/frontend/sequences/step_tiles/tile_set_servo_angle.tsx index 4a80836ef..8f5b3029f 100644 --- a/frontend/sequences/step_tiles/tile_set_servo_angle.tsx +++ b/frontend/sequences/step_tiles/tile_set_servo_angle.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { StepInputBox } from "../inputs/step_input_box"; import { StepParams } from "../interfaces"; import { ToolTips } from "../../constants"; diff --git a/frontend/sequences/step_tiles/tile_take_photo.tsx b/frontend/sequences/step_tiles/tile_take_photo.tsx index 3f72019a8..1fd674d65 100644 --- a/frontend/sequences/step_tiles/tile_take_photo.tsx +++ b/frontend/sequences/step_tiles/tile_take_photo.tsx @@ -3,7 +3,6 @@ import { StepParams } from "../interfaces"; import { ToolTips } from "../../constants"; import { StepWrapper, StepHeader, StepContent } from "../step_ui"; import { Col, Row } from "../../ui/index"; - import { Link } from "../../link"; import { t } from "../../i18next_wrapper"; diff --git a/frontend/sequences/step_tiles/tile_toggle_pin.tsx b/frontend/sequences/step_tiles/tile_toggle_pin.tsx index b58534286..84ec7bb0b 100644 --- a/frontend/sequences/step_tiles/tile_toggle_pin.tsx +++ b/frontend/sequences/step_tiles/tile_toggle_pin.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { StepInputBox } from "../inputs/step_input_box"; import { StepParams } from "../interfaces"; import { ToolTips } from "../../constants"; diff --git a/frontend/sequences/step_tiles/tile_unknown.tsx b/frontend/sequences/step_tiles/tile_unknown.tsx index ad2b1e386..3ab7e628b 100644 --- a/frontend/sequences/step_tiles/tile_unknown.tsx +++ b/frontend/sequences/step_tiles/tile_unknown.tsx @@ -3,7 +3,6 @@ import { StepParams } from "../interfaces"; import { ToolTips } from "../../constants"; import { StepWrapper, StepHeader, StepContent } from "../step_ui"; import { Col, Row } from "../../ui/index"; - import { StepInputBox } from "../inputs/step_input_box"; import { LegalArgString } from "farmbot"; import { t } from "../../i18next_wrapper"; diff --git a/frontend/sequences/step_tiles/tile_wait.tsx b/frontend/sequences/step_tiles/tile_wait.tsx index 59500d79c..9cc07ba7e 100644 --- a/frontend/sequences/step_tiles/tile_wait.tsx +++ b/frontend/sequences/step_tiles/tile_wait.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { StepInputBox } from "../inputs/step_input_box"; import { StepParams } from "../interfaces"; import { ToolTips } from "../../constants"; diff --git a/frontend/sequences/step_ui/step_header.tsx b/frontend/sequences/step_ui/step_header.tsx index 65727879c..909fb489a 100644 --- a/frontend/sequences/step_ui/step_header.tsx +++ b/frontend/sequences/step_ui/step_header.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { Row, Col } from "../../ui/index"; import { TaggedSequence, SequenceBodyItem } from "farmbot"; import { StepTitleBar } from "../step_tiles/step_title_bar"; diff --git a/frontend/sequences/step_ui/step_radio.tsx b/frontend/sequences/step_ui/step_radio.tsx index 3fc62914a..f098fab38 100644 --- a/frontend/sequences/step_ui/step_radio.tsx +++ b/frontend/sequences/step_ui/step_radio.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { Row, Col } from "../../ui/index"; import { TaggedSequence, SequenceBodyItem, ALLOWED_AXIS diff --git a/frontend/sequences/step_ui/step_warning.tsx b/frontend/sequences/step_ui/step_warning.tsx index 521c6976c..0cc276740 100644 --- a/frontend/sequences/step_ui/step_warning.tsx +++ b/frontend/sequences/step_ui/step_warning.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { Popover, Position, PopoverInteractionKind } from "@blueprintjs/core"; import { Xyz } from "farmbot"; import { t } from "../../i18next_wrapper"; @@ -31,7 +30,7 @@ export function StepWarning(props: StepWarningProps) { + popoverClassName={"help"}>
{warning} diff --git a/frontend/sequences/test_button.tsx b/frontend/sequences/test_button.tsx index 42dc32918..59d1f491d 100644 --- a/frontend/sequences/test_button.tsx +++ b/frontend/sequences/test_button.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { SyncStatus, ParameterApplication } from "farmbot/dist"; import { TaggedSequence } from "farmbot"; import { isParameterized } from "./locals_list/is_parameterized"; @@ -88,7 +87,7 @@ const Test = (props: TestProps) => { const normalColor = props.canTest ? "orange" : "pseudo-disabled"; return ; }; diff --git a/frontend/session.ts b/frontend/session.ts index a08251e42..8f1b09bd6 100644 --- a/frontend/session.ts +++ b/frontend/session.ts @@ -1,7 +1,9 @@ import { AuthState } from "./auth/interfaces"; import { box } from "boxed_value"; import { BooleanSetting, NumericSetting } from "./session_keys"; -import { BooleanConfigKey, NumberConfigKey } from "farmbot/dist/resources/configs/web_app"; +import { + BooleanConfigKey, NumberConfigKey +} from "farmbot/dist/resources/configs/web_app"; /** The `Session` namespace is a wrapper for `localStorage`. * Use this to avoid direct access of `localStorage` where possible. diff --git a/frontend/tools/__tests__/index_test.tsx b/frontend/tools/__tests__/index_test.tsx index 44a83def5..c7bd984f2 100644 --- a/frontend/tools/__tests__/index_test.tsx +++ b/frontend/tools/__tests__/index_test.tsx @@ -1,8 +1,6 @@ -jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); - import * as React from "react"; import { mount, shallow } from "enzyme"; -import { Tools } from "../index"; +import { RawTools as Tools } from "../index"; import { Props } from "../interfaces"; import { fakeToolSlot, fakeTool diff --git a/frontend/tools/components/tool_list.tsx b/frontend/tools/components/tool_list.tsx index c1565eed3..2de0a9eac 100644 --- a/frontend/tools/components/tool_list.tsx +++ b/frontend/tools/components/tool_list.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import { Row, Col, Widget, WidgetBody, WidgetHeader } from "../../ui"; - import { ToolListAndFormProps } from "../interfaces"; import { TaggedTool } from "farmbot"; import { ToolTips } from "../../constants"; diff --git a/frontend/tools/components/toolbay_slot_direction_selection.tsx b/frontend/tools/components/toolbay_slot_direction_selection.tsx index f67aac293..b826fdeeb 100644 --- a/frontend/tools/components/toolbay_slot_direction_selection.tsx +++ b/frontend/tools/components/toolbay_slot_direction_selection.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { FBSelect, DropDownItem } from "../../ui"; import { TaggedToolSlotPointer } from "farmbot"; import { edit } from "../../api/crud"; diff --git a/frontend/tools/components/toolbay_slot_menu.tsx b/frontend/tools/components/toolbay_slot_menu.tsx index 9fb11994b..f4311f7da 100644 --- a/frontend/tools/components/toolbay_slot_menu.tsx +++ b/frontend/tools/components/toolbay_slot_menu.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { isNumber } from "lodash"; import { BotPosition } from "../../devices/interfaces"; import { TaggedToolSlotPointer } from "farmbot"; diff --git a/frontend/tools/interfaces.ts b/frontend/tools/interfaces.ts index bc89ec5d4..eed35a9ef 100644 --- a/frontend/tools/interfaces.ts +++ b/frontend/tools/interfaces.ts @@ -19,7 +19,8 @@ export interface Props { getToolSlots(): TaggedToolSlotPointer[]; dispatch: Function; isActive: (tool: TaggedTool) => boolean; - changeToolSlot(t: TaggedToolSlotPointer, dispatch: Function): (d: DropDownItem) => void; + changeToolSlot(t: TaggedToolSlotPointer, dispatch: Function): + (d: DropDownItem) => void; botPosition: BotPosition; } @@ -43,7 +44,8 @@ export interface ToolBayFormProps { getToolOptions(): DropDownItem[]; getChosenToolOption(uuid: string | undefined): DropDownItem; getToolSlots(): TaggedToolSlotPointer[]; - changeToolSlot(t: TaggedToolSlotPointer, dispatch: Function): (d: DropDownItem) => void; + changeToolSlot(t: TaggedToolSlotPointer, dispatch: Function): + (d: DropDownItem) => void; } export interface ToolListAndFormProps { diff --git a/frontend/tos_update/component.tsx b/frontend/tos_update/component.tsx index 3980539d8..df93f2639 100644 --- a/frontend/tos_update/component.tsx +++ b/frontend/tos_update/component.tsx @@ -1,6 +1,5 @@ import * as React from "react"; import axios from "axios"; - import { fun as log, error as logError, init as logInit } from "../toast/toast"; import { AuthState } from "../auth/interfaces"; import { Session } from "../session"; diff --git a/frontend/ui/blurable_input.tsx b/frontend/ui/blurable_input.tsx index da8fce50c..aee1c526d 100644 --- a/frontend/ui/blurable_input.tsx +++ b/frontend/ui/blurable_input.tsx @@ -1,7 +1,6 @@ import * as React from "react"; import { equals, parseIntInput } from "../util"; import { isNumber } from "lodash"; - import { InputError } from "./input_error"; import { t } from "../i18next_wrapper"; import { error } from "../toast/toast"; diff --git a/frontend/ui/color_picker.tsx b/frontend/ui/color_picker.tsx index 5d3215063..6b108ff2d 100644 --- a/frontend/ui/color_picker.tsx +++ b/frontend/ui/color_picker.tsx @@ -14,7 +14,7 @@ export class ColorPicker extends React.Component { private renderColors(color: ResourceColor, key: number) { const isActive = color === this.props.current; const cb = this.props.onChange || function () { }; - return
cb(color)} > + return
cb(color)}>
; } diff --git a/frontend/ui/help.tsx b/frontend/ui/help.tsx index 24b7ad898..b292b2f1e 100644 --- a/frontend/ui/help.tsx +++ b/frontend/ui/help.tsx @@ -12,7 +12,7 @@ export function Help(props: HelpProps) { position={Position.LEFT_TOP} interactionKind={props.requireClick ? PopoverInteractionKind.CLICK : PopoverInteractionKind.HOVER} - popoverClassName={"help"} > + popoverClassName={"help"}>
{t(props.text)}
; diff --git a/frontend/ui/save_button.tsx b/frontend/ui/save_button.tsx index 1b4b7ec39..3bcfa0d22 100644 --- a/frontend/ui/save_button.tsx +++ b/frontend/ui/save_button.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { SpecialStatus } from "farmbot"; import { t } from "../i18next_wrapper"; @@ -38,7 +37,7 @@ export function SaveBtn(props: SaveBtnProps) { const spinnerEl = (props.status === SpecialStatus.SAVING) ? spinner : ""; - return ; } diff --git a/frontend/ui/tooltip.tsx b/frontend/ui/tooltip.tsx index 27a47f3f8..d0bd8ee6e 100644 --- a/frontend/ui/tooltip.tsx +++ b/frontend/ui/tooltip.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { DocSlug, docLink } from "."; import { t } from "../i18next_wrapper"; diff --git a/frontend/ui/widget_header.tsx b/frontend/ui/widget_header.tsx index 60462d85e..c5aec526f 100644 --- a/frontend/ui/widget_header.tsx +++ b/frontend/ui/widget_header.tsx @@ -1,5 +1,4 @@ import * as React from "react"; - import { docLink, DocSlug } from "./doc_link"; import { t } from "../i18next_wrapper"; diff --git a/frontend/util/errors.ts b/frontend/util/errors.ts index c820ceb90..eec02cc82 100644 --- a/frontend/util/errors.ts +++ b/frontend/util/errors.ts @@ -1,5 +1,4 @@ import { Dictionary } from "farmbot"; - import { Content } from "../constants"; import { capitalize, map } from "lodash"; import { t } from "../i18next_wrapper"; From b11e5a0e152d1b8ee3751cb4663dcbbb57a26177 Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Tue, 24 Sep 2019 10:31:57 -0500 Subject: [PATCH 2/6] Upgrade FBJS (every_point, point_group celery node additions). --- app/models/celery_script_settings_bag.rb | 19 ++++++++++++++- .../resources/__tests__/sequence_meta_test.ts | 3 +-- frontend/resources/sequence_meta.ts | 11 ++++----- .../__tests__/handle_select_test.ts | 3 +-- .../locals_list/default_value_form.tsx | 24 ++++++++++++------- .../sequences/locals_list/handle_select.ts | 17 +++++++------ .../__tests__/tile_move_absolute_test.tsx | 7 +++--- .../step_tiles/tile_move_absolute.tsx | 10 ++++---- package.json | 2 +- 9 files changed, 61 insertions(+), 35 deletions(-) diff --git a/app/models/celery_script_settings_bag.rb b/app/models/celery_script_settings_bag.rb index 49b761692..e5a176600 100644 --- a/app/models/celery_script_settings_bag.rb +++ b/app/models/celery_script_settings_bag.rb @@ -130,7 +130,7 @@ module CeleryScriptSettingsBag defn: [n(:execute), n(:nothing)], }, data_value: { - defn: ANY_VAR_TOKENIZED, + defn: ANY_VAR_TOKENIZED + [n(:point_group), n(:every_point)], }, default_value: { defn: ANY_VAR_TOKENIZED, @@ -270,6 +270,9 @@ module CeleryScriptSettingsBag lua: { defn: [v(:string)], }, + every_point_type: { + defn: [e(:PointType)], + }, }.map do |(name, conf)| blk = conf[:blk] defn = conf.fetch(:defn) @@ -514,6 +517,18 @@ module CeleryScriptSettingsBag check_resource_type(n, resource_type, resource_id, Device.current) end, }, + point_group: { + args: [:resource_id], + tags: [:data, :list_like], + blk: ->(n) do + resource_id = n.args.fetch(:resource_id).value + check_resource_type(n, "PointGroup", resource_id, Device.current) + end, + }, + every_point: { + args: [:every_point_type], + tags: [:data, :list_like], + }, }.map { |(name, list)| Corpus.node(name, **list) } HASH = Corpus.as_json @@ -535,6 +550,8 @@ module CeleryScriptSettingsBag # the current_device. # For convenience, we try to set it here, defaulting to 0 node.args[:resource_id].instance_variable_set("@value", owner.id) + when "PointGroup" + no_resource(node, PointGroup, resource_id) unless PointGroup.exists?(resource_id) when *ALLOWED_RESOURCE_TYPE.without("Device") klass = Kernel.const_get(resource_type) resource_ok = klass.exists?(resource_id) diff --git a/frontend/resources/__tests__/sequence_meta_test.ts b/frontend/resources/__tests__/sequence_meta_test.ts index 4c3076a0d..8ce6ef145 100644 --- a/frontend/resources/__tests__/sequence_meta_test.ts +++ b/frontend/resources/__tests__/sequence_meta_test.ts @@ -68,8 +68,7 @@ describe("determineDropdown", () => { kind: "parameter_application", args: { label: "x", - // tslint:disable-next-line:no-any - data_value: { kind: "every_point", args: { every_point_type: "Plant" } } as any + data_value: { kind: "every_point", args: { every_point_type: "Plant" } } } }, buildResourceIndex([]).index); expect(r.label).toBe("All plants"); diff --git a/frontend/resources/sequence_meta.ts b/frontend/resources/sequence_meta.ts index 101e10a8e..e192babb1 100644 --- a/frontend/resources/sequence_meta.ts +++ b/frontend/resources/sequence_meta.ts @@ -13,7 +13,6 @@ import { COORDINATE_DDI } from "../sequences/locals_list/location_form_list"; import { VariableNode } from "../sequences/locals_list/locals_list_support"; -import { EveryPointShape } from "../sequences/locals_list/handle_select"; import { t } from "../i18next_wrapper"; export interface SequenceMeta { @@ -104,9 +103,8 @@ export const determineDropdown = const { label } = data_value.args; const varName = determineVarDDILabel({ label, resources, uuid }); return { label: varName, value: "?" }; - // tslint:disable-next-line:no-any - case "every_point" as any: - const { every_point_type } = (data_value as unknown as EveryPointShape).args; + case "every_point": + const { every_point_type } = data_value.args; return everyPointDDI(safeEveryPointType(every_point_type)); case "point": const { pointer_id, pointer_type } = data_value.args; @@ -117,8 +115,9 @@ export const determineDropdown = const { tool_id } = data_value.args; const toolSlot = findSlotByToolId(resources, tool_id); return formatTool(findToolById(resources, tool_id), toolSlot); - // tslint:disable-next-line:no-any // Empty, user must make a selection. - case "nothing" as any: + case "point_group": + throw new Error("Not yet implemented"); + case "nothing" as unknown: return NO_VALUE_SELECTED_DDI(); } throw new Error("WARNING: Unknown, possibly new data_value.kind?"); diff --git a/frontend/sequences/locals_list/__tests__/handle_select_test.ts b/frontend/sequences/locals_list/__tests__/handle_select_test.ts index a86ecd125..f7b2ba763 100644 --- a/frontend/sequences/locals_list/__tests__/handle_select_test.ts +++ b/frontend/sequences/locals_list/__tests__/handle_select_test.ts @@ -114,8 +114,7 @@ describe("convertDDItoDeclaration()", () => { label: "label", data_value: { kind: "every_point", args: { every_point_type: "Plant" } - // tslint:disable-next-line:no-any - } as any + } } }; expect(variable).toEqual(expected); diff --git a/frontend/sequences/locals_list/default_value_form.tsx b/frontend/sequences/locals_list/default_value_form.tsx index c4d924b4c..408e0ff1c 100644 --- a/frontend/sequences/locals_list/default_value_form.tsx +++ b/frontend/sequences/locals_list/default_value_form.tsx @@ -37,14 +37,22 @@ export const DefaultValueForm = (props: DefaultValueFormProps) => const change = (onChange: (v: ParameterDeclaration) => void, variable: VariableNode) => - (formResponse: ParameterApplication) => - onChange({ - kind: "parameter_declaration", - args: { - label: variable.args.label, - default_value: formResponse.args.data_value - } - }); + (formResponse: ParameterApplication) => { + const { data_value } = formResponse.args; + switch (data_value.kind) { + case "every_point": + case "point_group": + return; + default: + onChange({ + kind: "parameter_declaration", + args: { + label: variable.args.label, + default_value: data_value + } + }); + } + }; const defaultValueVariableData = ( resources: ResourceIndex, diff --git a/frontend/sequences/locals_list/handle_select.ts b/frontend/sequences/locals_list/handle_select.ts index d8fb56101..fe65ae7e3 100644 --- a/frontend/sequences/locals_list/handle_select.ts +++ b/frontend/sequences/locals_list/handle_select.ts @@ -12,6 +12,8 @@ import { ScopeDeclarationBodyItem, VariableDeclaration, PointType, + EveryPoint, + PointGroup, } from "farmbot"; import { VariableNode, AllowedVariableNodes } from "./locals_list_support"; import { betterCompact } from "../../util"; @@ -24,13 +26,13 @@ import { betterCompact } from "../../util"; // tslint:disable-next-line:no-any export const NOTHING_SELECTED: any = { kind: "nothing", args: {} }; -export interface EveryPointShape { - kind: "every_point"; - args: { every_point_type: PointType; } -} -// tslint:disable-next-line:no-any -type EveryPoint = any; -type DataValue = Coordinate | Identifier | Point | Tool | EveryPoint; +type DataValue = + | Coordinate + | EveryPoint + | Identifier + | Point + | PointGroup + | Tool; type CreateVariableDeclaration = (label: string, data_value: DataValue) => VariableDeclaration; @@ -130,6 +132,7 @@ const newVariableCreator = (ddi: DropDownItem): case "parameter": return newParameter; // Caller decides X/Y/Z case "every_point": return everyPointVar(ddi.value); case "Coordinate": return manualEntry(ddi.value); + case "point_group": throw new Error("TODO"); } return () => undefined; }; diff --git a/frontend/sequences/step_tiles/__tests__/tile_move_absolute_test.tsx b/frontend/sequences/step_tiles/__tests__/tile_move_absolute_test.tsx index ae6154918..6fe2c3cf6 100644 --- a/frontend/sequences/step_tiles/__tests__/tile_move_absolute_test.tsx +++ b/frontend/sequences/step_tiles/__tests__/tile_move_absolute_test.tsx @@ -5,7 +5,7 @@ import { fakeSequence, fakePoint, fakeTool } from "../../../__test_support__/fake_state/resources"; import { - MoveAbsolute, Point, Coordinate, Tool, ParameterApplication + MoveAbsolute, Point, Coordinate, Tool, ParameterApplication, EveryPoint } from "farmbot"; import { fakeHardwareFlags @@ -180,11 +180,10 @@ describe("", () => { it("does not handle every_point nodes", () => { const p = fakeProps(); const block = ordinaryMoveAbs(p); - const data_value = { + const data_value: EveryPoint = { kind: "every_point", args: { every_point_type: "Plant" } - // tslint:disable-next-line:no-any - } as any; + }; const boom = () => block.updateLocation({ kind: "parameter_application", args: { label: "parent", data_value } diff --git a/frontend/sequences/step_tiles/tile_move_absolute.tsx b/frontend/sequences/step_tiles/tile_move_absolute.tsx index bd96fd71a..99c29a9f4 100644 --- a/frontend/sequences/step_tiles/tile_move_absolute.tsx +++ b/frontend/sequences/step_tiles/tile_move_absolute.tsx @@ -57,10 +57,12 @@ export class TileMoveAbsolute extends React.Component /** Handle changes to step.args.location. */ updateLocation = (variable: ParameterApplication) => { const location = variable.args.data_value; - if (location.kind === "every_point" as unknown) { - throw new Error("Can't put `every_point` into `move_abs"); - } else { - this.updateArgs({ location }); + switch (location.kind) { + case "every_point": + case "point_group": + throw new Error("Can't put `every_point` into `move_abs"); + default: + this.updateArgs({ location }); } } diff --git a/package.json b/package.json index 89c5e8468..4668b0cdf 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "coveralls": "3.0.6", "enzyme": "3.10.0", "enzyme-adapter-react-16": "1.14.0", - "farmbot": "8.2.2", + "farmbot": "8.3.0-rc0", "i18next": "17.0.16", "lodash": "4.17.15", "markdown-it": "10.0.0", From 9a5939571586aab18a986664b4e70f5d9b143196 Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Tue, 24 Sep 2019 11:05:43 -0500 Subject: [PATCH 3/6] Merge conflicts, part II --- frontend/resources/__tests__/sequence_meta_test.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/frontend/resources/__tests__/sequence_meta_test.ts b/frontend/resources/__tests__/sequence_meta_test.ts index 7a95c740b..598284db3 100644 --- a/frontend/resources/__tests__/sequence_meta_test.ts +++ b/frontend/resources/__tests__/sequence_meta_test.ts @@ -70,15 +70,7 @@ describe("determineDropdown", () => { kind: "parameter_application", args: { label: "x", -<<<<<<< HEAD data_value: { kind: "every_point", args: { every_point_type: "Plant" } } -======= - data_value: { - kind: "every_point", - args: { every_point_type: "Plant" } - // tslint:disable-next-line:no-any - } as any ->>>>>>> a3d73b35c6816f37dd0ad295d5fb9462ee24ed02 } }, buildResourceIndex([]).index); expect(r.label).toBe("All plants"); From fc1f80c4fc7f08ce1893d83c7f684c3cab882c23 Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Tue, 24 Sep 2019 11:48:11 -0500 Subject: [PATCH 4/6] Remove useless guard clauses, test for older code --- .../controls/webcam/__tests__/show_test.tsx | 14 +++++++++++--- .../farm_events/calendar/selectors.ts | 8 ++------ .../group_regimen_items_by_week.ts | 6 +----- .../inputs/__tests__/step_input_box_test.tsx | 19 +++++++++++++++++++ frontend/sequences/inputs/step_input_box.tsx | 17 +++++++++++++---- 5 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 frontend/sequences/inputs/__tests__/step_input_box_test.tsx diff --git a/frontend/controls/webcam/__tests__/show_test.tsx b/frontend/controls/webcam/__tests__/show_test.tsx index 91aacfca1..25c4aad35 100644 --- a/frontend/controls/webcam/__tests__/show_test.tsx +++ b/frontend/controls/webcam/__tests__/show_test.tsx @@ -3,18 +3,26 @@ import { fakeWebcamFeed } from "../../../__test_support__/fake_state/resources"; import { mount } from "enzyme"; import { Show, IndexIndicator } from "../show"; import { props } from "../test_helpers"; +import { PLACEHOLDER_FARMBOT } from "../../../farmware/images/image_flipper"; describe("", () => { + const feed1 = fakeWebcamFeed(); + const feed2 = fakeWebcamFeed(); + const p = props([feed1, feed2]); + it("Renders feed title", () => { - const feed1 = fakeWebcamFeed(); - const feed2 = fakeWebcamFeed(); - const p = props([feed1, feed2]); const el = mount(); expect(el.text()).toContain(feed1.body.name); el.find(".image-flipper-right").first().simulate("click"); el.render(); expect(el.text()).toContain(feed2.body.name); }); + + it("returns a PLACEHOLDER_FEED", () => { + const comp = new Show(p); + const result = comp.getMessage("http://geocities.com/" + PLACEHOLDER_FARMBOT); + expect(result).toEqual("Click the edit button to add or edit a feed URL."); + }); }); describe("", () => { diff --git a/frontend/farm_designer/farm_events/calendar/selectors.ts b/frontend/farm_designer/farm_events/calendar/selectors.ts index aa1366491..bdb914554 100644 --- a/frontend/farm_designer/farm_events/calendar/selectors.ts +++ b/frontend/farm_designer/farm_events/calendar/selectors.ts @@ -27,9 +27,8 @@ export function joinFarmEventsToExecutable( executable_type: body.executable_type, executable: executable1.body }; - } else { - throw new Error("Bad executable ID (sequence): " + id); } + break; case "Regimen": const executable2 = regimenById[id]; if (executable2) { @@ -38,12 +37,9 @@ export function joinFarmEventsToExecutable( executable_type: body.executable_type, executable: executable2.body }; - } else { - throw new Error("Bad executable ID (regimen): " + id); } } - } else { - throw new Error("Farmevent had no ID"); } + throw new Error("Impossible?"); })); } diff --git a/frontend/regimens/bulk_scheduler/group_regimen_items_by_week.ts b/frontend/regimens/bulk_scheduler/group_regimen_items_by_week.ts index e5983c8e8..8d226b02a 100644 --- a/frontend/regimens/bulk_scheduler/group_regimen_items_by_week.ts +++ b/frontend/regimens/bulk_scheduler/group_regimen_items_by_week.ts @@ -38,10 +38,6 @@ export function groupRegimenItemsByWeek(weeks: Week[], OFFSET: number, }) // Transform the sorted array of values into a regimenItem[] array. .map(time_offset => { - if (seq.id) { - return { time_offset, sequence_id: seq.id }; - } else { - throw new Error("Impossible???"); - } + return { time_offset, sequence_id: seq.id || -1 }; }); } diff --git a/frontend/sequences/inputs/__tests__/step_input_box_test.tsx b/frontend/sequences/inputs/__tests__/step_input_box_test.tsx new file mode 100644 index 000000000..f671b3a06 --- /dev/null +++ b/frontend/sequences/inputs/__tests__/step_input_box_test.tsx @@ -0,0 +1,19 @@ +jest.mock("../input_unknown", () => ({ + InputUnknown: jest.fn(() => { }) +})); + +import { StepInputBox } from "../step_input_box"; +import { DeepPartial } from "redux"; +import { StepInputProps } from "../../interfaces"; +import { InputUnknown } from "../input_unknown"; + +describe("StepInputBox", () => { + it("handles unknown `field` via ", () => { + const props: DeepPartial = { + // tslint:disable-next-line:no-any + field: ("something else" as any) + }; + StepInputBox(props as StepInputProps); + expect(InputUnknown).toHaveBeenCalledWith(props); + }); +}); diff --git a/frontend/sequences/inputs/step_input_box.tsx b/frontend/sequences/inputs/step_input_box.tsx index c7dc1f830..5de1583ae 100644 --- a/frontend/sequences/inputs/step_input_box.tsx +++ b/frontend/sequences/inputs/step_input_box.tsx @@ -6,13 +6,22 @@ import { StepInputProps } from "../interfaces"; export function StepInputBox(props: StepInputProps) { if (props.fieldOverride) { return ; } switch (props.field) { - case "label": case "lhs": case "message": case "milliseconds": case "op": - case "pin_mode": case "pin_number": case "pin_value": case "rhs": + case "label": + case "lhs": + case "message": + case "milliseconds": + case "op": + case "pin_mode": + case "pin_number": + case "pin_value": + case "rhs": case "sequence_id": - case "x": case "y": case "z": case "speed": + case "x": + case "y": + case "z": return ; default: - return ; + return InputUnknown(props); } } From d576656fbdeb0de4dcaea03ee2f8c327395eb14f Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Tue, 24 Sep 2019 14:25:08 -0500 Subject: [PATCH 5/6] Rename some device table columns, add tests for point_groups CS node. MIGRATION REQUIRED --- ...evice_last_ota_checkto_last_ota_checkup.rb | 7 +++++ db/structure.sql | 5 ++-- package.json | 2 +- spec/lib/celery_script/corpus_spec.rb | 26 +++++++++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20190924190539_rename_device_last_ota_checkto_last_ota_checkup.rb diff --git a/db/migrate/20190924190539_rename_device_last_ota_checkto_last_ota_checkup.rb b/db/migrate/20190924190539_rename_device_last_ota_checkto_last_ota_checkup.rb new file mode 100644 index 000000000..7e85ad772 --- /dev/null +++ b/db/migrate/20190924190539_rename_device_last_ota_checkto_last_ota_checkup.rb @@ -0,0 +1,7 @@ +class RenameDeviceLastOtaChecktoLastOtaCheckup < ActiveRecord::Migration[5.2] + safety_assured + + def change + rename_column :devices, :last_ota_check, :last_ota_checkup + end +end diff --git a/db/structure.sql b/db/structure.sql index e22d6f68d..683567302 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -277,7 +277,7 @@ CREATE TABLE public.devices ( serial_number character varying(32), mqtt_rate_limit_email_sent_at timestamp without time zone, last_ota timestamp without time zone, - last_ota_check timestamp without time zone + last_ota_checkup timestamp without time zone ); @@ -3274,6 +3274,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20190804194135'), ('20190804194154'), ('20190823164837'), -('20190918185359'); +('20190918185359'), +('20190924190539'); diff --git a/package.json b/package.json index 4668b0cdf..b2c5b80ec 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "coveralls": "3.0.6", "enzyme": "3.10.0", "enzyme-adapter-react-16": "1.14.0", - "farmbot": "8.3.0-rc0", + "farmbot": "8.3.0-rc1", "i18next": "17.0.16", "lodash": "4.17.15", "markdown-it": "10.0.0", diff --git a/spec/lib/celery_script/corpus_spec.rb b/spec/lib/celery_script/corpus_spec.rb index 0c1f9207c..817e25fa5 100644 --- a/spec/lib/celery_script/corpus_spec.rb +++ b/spec/lib/celery_script/corpus_spec.rb @@ -230,4 +230,30 @@ describe CeleryScript::Corpus do expect(check.valid?).to be_falsey expect(check.error.message).to include("cannot exceed 3 minutes") end + + it "allows valid `point_group` nodes" do + device.auto_sync_transaction do + pg = PointGroups::Create.run!(device: device, + name: "cs checks", + point_ids: []) + bad = CeleryScript::AstNode.new({ + kind: "point_group", + args: { resource_id: pg.id }, + }) + check = CeleryScript::Checker.new(bad, corpus, device) + expect(check.valid?).to be true + end + end + + it "disallows invalid `point_group` nodes" do + device.auto_sync_transaction do + bad = CeleryScript::AstNode.new({ + kind: "point_group", + args: { resource_id: -1 }, + }) + check = CeleryScript::Checker.new(bad, corpus, device) + expect(check.valid?).to be false + expect(check.error.message).to eq("Can't find PointGroup with id of -1") + end + end end From a8cf0b455bcbb54c04842e31ba942229f66c36e3 Mon Sep 17 00:00:00 2001 From: gabrielburnworth Date: Tue, 24 Sep 2019 14:50:32 -0700 Subject: [PATCH 6/6] add new fbos details --- app/mutations/devices/update.rb | 2 ++ app/serializers/device_serializer.rb | 2 +- .../__tests__/fbos_details_test.tsx | 30 +++++++++++++++++++ .../components/fbos_settings/fbos_details.tsx | 21 +++++++++++-- 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/app/mutations/devices/update.rb b/app/mutations/devices/update.rb index ed185413a..922507542 100644 --- a/app/mutations/devices/update.rb +++ b/app/mutations/devices/update.rb @@ -10,6 +10,8 @@ module Devices string :name string :timezone time :last_saw_mq + time :last_ota + time :last_ota_checkup integer :mounted_tool_id, nils: true end diff --git a/app/serializers/device_serializer.rb b/app/serializers/device_serializer.rb index 9a145b2a0..7a74d11af 100644 --- a/app/serializers/device_serializer.rb +++ b/app/serializers/device_serializer.rb @@ -2,5 +2,5 @@ class DeviceSerializer < ApplicationSerializer attributes :fbos_version, :last_saw_api, :last_saw_mq, :mounted_tool_id, :name, :serial_number, :throttled_at, :throttled_until, :timezone, - :tz_offset_hrs + :tz_offset_hrs, :last_ota, :last_ota_checkup end diff --git a/frontend/devices/components/fbos_settings/__tests__/fbos_details_test.tsx b/frontend/devices/components/fbos_settings/__tests__/fbos_details_test.tsx index 47d981d21..a601f13d4 100644 --- a/frontend/devices/components/fbos_settings/__tests__/fbos_details_test.tsx +++ b/frontend/devices/components/fbos_settings/__tests__/fbos_details_test.tsx @@ -173,6 +173,36 @@ describe("", () => { const wrapper = mount(); expect(wrapper.text().toLowerCase()).toContain("voltage"); }); + + it("displays cpu usage", () => { + const p = fakeProps(); + // tslint:disable-next-line:no-any + (p.botInfoSettings as any).cpu_usage = 10; + const wrapper = mount(); + expect(wrapper.text().toLowerCase()).toContain("cpu usage: 10%"); + }); + + it("displays ip address", () => { + const p = fakeProps(); + p.botInfoSettings.private_ip = "192.168.0.100"; + const wrapper = mount(); + expect(wrapper.text().toLowerCase()).toContain("ip address"); + }); + + it("displays last OTA check date", () => { + const p = fakeProps(); + p.deviceAccount.body.last_ota_checkup = "2018-01-11T20:20:38.362Z"; + const wrapper = mount(); + expect(wrapper.text().toLowerCase()) + .toContain("last checked for updates: january"); + }); + + it("displays last OTA date", () => { + const p = fakeProps(); + p.deviceAccount.body.last_ota = "2018-02-11T20:20:38.362Z"; + const wrapper = mount(); + expect(wrapper.text().toLowerCase()).toContain("last updated: february"); + }); }); describe("betaReleaseOptIn()", () => { diff --git a/frontend/devices/components/fbos_settings/fbos_details.tsx b/frontend/devices/components/fbos_settings/fbos_details.tsx index b2b584e2f..fdbea87b4 100644 --- a/frontend/devices/components/fbos_settings/fbos_details.tsx +++ b/frontend/devices/components/fbos_settings/fbos_details.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import { Saucer } from "../../../ui/index"; import { ToggleButton } from "../../../controls/toggle_button"; import { updateConfig } from "../../actions"; -import { last, isNumber } from "lodash"; +import { last, isNumber, isString } from "lodash"; import { Content } from "../../../constants"; import { FbosDetailsProps } from "./interfaces"; import { SourceFbosConfig, ShouldDisplay, Feature } from "../../interfaces"; @@ -10,6 +10,9 @@ import { ConfigurationName } from "farmbot"; import { t } from "../../../i18next_wrapper"; import { LastSeen } from "./last_seen_row"; import { Popover } from "@blueprintjs/core"; +import moment from "moment"; +import { timeFormatString } from "../../../util"; +import { TimeSettings } from "../../../interfaces"; /** Return an indicator color for the given temperature (C). */ export const colorFromTemp = (temp: number | undefined): string => { @@ -258,14 +261,21 @@ const BetaReleaseOptInButton = ( ; }; +/** Format datetime string for display. */ +const reformatDatetime = (datetime: string, timeSettings: TimeSettings) => + moment(datetime) + .utcOffset(timeSettings.utcOffset) + .format(`MMMM D, ${timeFormatString(timeSettings)}`); + /** Current technical information about FarmBot OS running on the device. */ export function FbosDetails(props: FbosDetailsProps) { const { env, commit, target, node_name, firmware_version, firmware_commit, soc_temp, wifi_level, uptime, memory_usage, disk_usage, throttled, - wifi_level_percent, + wifi_level_percent, cpu_usage, private_ip, // tslint:disable-next-line:no-any } = props.botInfoSettings as any; + const { last_ota, last_ota_checkup } = props.deviceAccount.body; return

{t("Target")}: {target}

{t("Node name")}: {last((node_name || "").split("@"))}

+

{t("Device ID")}: {props.deviceAccount.body.id}

+ {isString(private_ip) &&

{t("Local IP address")}: {private_ip}

}

{t("Firmware")}: {firmware_version}

@@ -284,6 +296,7 @@ export function FbosDetails(props: FbosDetailsProps) { {isNumber(memory_usage) &&

{t("Memory usage")}: {memory_usage}MB

} {isNumber(disk_usage) &&

{t("Disk usage")}: {disk_usage}%

} + {isNumber(cpu_usage) &&

{t("CPU usage")}: {cpu_usage}%

} @@ -292,5 +305,9 @@ export function FbosDetails(props: FbosDetailsProps) { dispatch={props.dispatch} shouldDisplay={props.shouldDisplay} sourceFbosConfig={props.sourceFbosConfig} /> + {last_ota_checkup &&

{t("Last checked for updates")}: + {reformatDatetime(last_ota_checkup, props.timeSettings)}

} + {last_ota &&

{t("Last updated")}: + {reformatDatetime(last_ota, props.timeSettings)}

}
; }