Skip to content

Commit

Permalink
Merge pull request #2455 from FarmBot/staging
Browse files Browse the repository at this point in the history
v15.9.0
  • Loading branch information
gabrielburnworth committed Jan 19, 2024
2 parents 2e94865 + 5edc171 commit d98f412
Show file tree
Hide file tree
Showing 75 changed files with 1,340 additions and 283 deletions.
10 changes: 8 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,16 @@ commands:
- run:
name: Report coverage to Coveralls
command: |
if [ "$COVERAGE_AVAILABLE" ]
if [ "$CIRCLE_BRANCH" == "staging" ]; then set +eo pipefail; fi
if [ "$COVERAGE_AVAILABLE" ] && [ "$COVERALLS_REPO_TOKEN" ]
then
sudo docker compose run -e COVERALLS_REPO_TOKEN="$COVERALLS_REPO_TOKEN" web npm run coverage || [ $CIRCLE_BRANCH == "staging" ]
curl -sLO https://github.com/coverallsapp/coverage-reporter/releases/latest/download/coveralls-linux.tar.gz
curl -sLO https://github.com/coverallsapp/coverage-reporter/releases/latest/download/coveralls-checksums.txt
cat coveralls-checksums.txt | grep coveralls-linux.tar.gz | sha256sum --check
tar -xzf coveralls-linux.tar.gz
./coveralls report coverage_fe/lcov.info
fi
if [ "$CIRCLE_BRANCH" == "staging" ]; then echo; fi
when: always # change to `on_success` for a stricter comparison


Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ GEM
docile (1.4.0)
e2mmap (0.1.0)
erubi (1.12.0)
factory_bot (6.4.2)
factory_bot (6.4.4)
activesupport (>= 5.0.0)
factory_bot_rails (6.4.2)
factory_bot (~> 6.4)
Expand Down Expand Up @@ -222,7 +222,7 @@ GEM
multipart-post (2.3.0)
mutations (0.9.1)
activesupport
net-imap (0.4.8)
net-imap (0.4.9)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -232,7 +232,7 @@ GEM
net-smtp (0.4.0)
net-protocol
nio4r (2.7.0)
nokogiri (1.15.5-x86_64-linux)
nokogiri (1.16.0-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
os (1.1.4)
Expand Down Expand Up @@ -336,7 +336,7 @@ GEM
activerecord (>= 4.0.0)
railties (>= 4.0.0)
secure_headers (6.5.0)
set (1.0.4)
set (1.1.0)
signet (0.18.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
Expand Down Expand Up @@ -433,4 +433,4 @@ RUBY VERSION
ruby 3.1.4p223

BUNDLED WITH
2.5.0
2.5.3
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class Application < Rails::Application
"'unsafe-inline'",
"'unsafe-eval'",
"'self'",
"blob:", # 3D
],
style_src: %w(
maxcdn.bootstrapcdn.com
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddEnable3dElectronicsBoxTopToWebAppConfig < ActiveRecord::Migration[6.1]
def up
add_column :web_app_configs, :enable_3d_electronics_box_top, :boolean, default: true
end

def down
remove_column :web_app_configs, :enable_3d_electronics_box_top
end
end
6 changes: 4 additions & 2 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,8 @@ CREATE TABLE public.web_app_configs (
go_button_axes character varying(3) DEFAULT 'XY'::character varying NOT NULL,
show_uncropped_camera_view_area boolean DEFAULT false,
default_plant_depth integer DEFAULT 5,
show_missed_step_plot boolean DEFAULT false
show_missed_step_plot boolean DEFAULT false,
enable_3d_electronics_box_top boolean DEFAULT true
);


Expand Down Expand Up @@ -3979,6 +3980,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20230712201622'),
('20230714010144'),
('20230714173031'),
('20230808192946');
('20230808192946'),
('20240118204046');


7 changes: 7 additions & 0 deletions frontend/__test_support__/additional_mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,10 @@ jest.mock("../history", () => ({
push: jest.fn(),
getPathArray: () => [],
}));

window.ResizeObserver = (() => ({
observe: jest.fn(),
unobserve: jest.fn(),
disconnect: jest.fn(),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
})) as any;
1 change: 1 addition & 0 deletions frontend/__test_support__/fake_designer_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const fakeDesignerState = (): DesignerState => ({
hoveredMapImage: undefined,
cameraViewGridId: undefined,
gridIds: [],
gridStart: { x: 100, y: 100 },
soilHeightLabels: false,
profileOpen: false,
profileAxis: "x",
Expand Down
4 changes: 4 additions & 0 deletions frontend/__test_support__/fake_state/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ import {
} from "farmbot/dist/resources/api_resources";
import { MessageType } from "../../sequences/interfaces";
import { TaggedPointGroup } from "../../resources/interfaces";
import {
BooleanConfigKey as BooleanWebAppConfigKey,
} from "farmbot/dist/resources/configs/web_app";

export const resources: Everything["resources"] = buildResourceIndex();
let idCounter = 1;
Expand Down Expand Up @@ -333,6 +336,7 @@ export function fakeWebAppConfig(): TaggedWebAppConfig {
display_map_missed_steps: false,
display_trail: false,
dynamic_map: false,
["enable_3d_electronics_box_top" as BooleanWebAppConfigKey]: true,
encoder_figure: false,
go_button_axes: "XY",
hide_webcam_widget: false,
Expand Down
3 changes: 2 additions & 1 deletion frontend/connectivity/batch_queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { store } from "../redux/store";
import { batchInitResources, bothUp } from "./connect_device";
import { maybeGetDevice } from "../resources/selectors";
import { deviceIsThrottled } from "./device_is_throttled";
import { UnknownAction } from "redux";

/** Performs resource initialization (Eg: a storm of incoming logs) in batches
* at a regular interval. We only need one work queue for the whole app,
Expand All @@ -25,7 +26,7 @@ export class BatchQueue {
work = () => {
const dev = maybeGetDevice(store.getState().resources.index);
if (!deviceIsThrottled(dev ? dev.body : undefined)) {
store.dispatch(batchInitResources(this.queue));
store.dispatch(batchInitResources(this.queue) as unknown as UnknownAction);
}
this.clear();
bothUp();
Expand Down
5 changes: 3 additions & 2 deletions frontend/connectivity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { store } from "../redux/store";
import { networkUp, networkDown } from "./actions";
import { Edge } from "./interfaces";
import { Actions } from "../constants";
import { UnknownAction } from "redux";

/* ABOUT THIS FILE: These functions allow us to mark the network as up or
down from anywhere within the app (even outside of React-Redux). I usually avoid
Expand Down Expand Up @@ -39,13 +40,13 @@ export const dispatchQosStart = (id: string) => {

export const dispatchNetworkUp = (edge: Edge, at: number) => {
if (shouldThrottle(edge, at)) { return; }
store.dispatch(networkUp(edge, at));
store.dispatch(networkUp(edge, at) as unknown as UnknownAction);
bumpThrottle(edge, at);
};

export const dispatchNetworkDown = (edge: Edge, at: number) => {
if (shouldThrottle(edge, at)) { return; }
store.dispatch(networkDown(edge, at));
store.dispatch(networkDown(edge, at) as unknown as UnknownAction);
bumpThrottle(edge, at);
};

Expand Down
8 changes: 7 additions & 1 deletion frontend/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,10 @@ export namespace Content {
trim(`If not using sensors, use this setting to remove the
panel from the Farm Designer.`);

export const ENABLE_3D_ELECTRONICS_BOX_TOP =
trim(`Show a 3D model of FarmBot's electronics box instead of a 2D view
in the Peripherals tab of the Controls pop-up.`);

export const BROWSER_SPEAK_LOGS =
trim(`Have the browser also read aloud log messages on the
"Speak" channel that are spoken by FarmBot.`);
Expand Down Expand Up @@ -1868,7 +1872,7 @@ export namespace SetupWizardContent {
trim(`Customize which Action or Sequence you want FarmBot to execute
when you press Button 3, 4, or 5 on the electronics box. To start, we
recommend setting Button 5 to the 'Find Home' sequence. You can change
this later from the controls panel.`);
this later from the controls pop-up.`);

export const PROBLEM_GETTING_IMAGE =
trim(`There is a 'camera not detected' or 'problem getting image' error
Expand Down Expand Up @@ -2197,6 +2201,7 @@ export enum DeviceSetting {
showSecondsInTime = `Show seconds in time`,
hideWebcamWidget = `Hide Webcam widget`,
hideSensorsPanel = `Hide Sensors panel`,
enable3dElectronicsBox = `Enable 3D electronics box`,
readSpeakLogsInBrowser = `Read speak logs in browser`,
landingPage = `Landing page`,
browserFarmbotActivityBeep = `Browser FarmBot activity beep`,
Expand Down Expand Up @@ -2391,6 +2396,7 @@ export enum Actions {
HIGHLIGHT_MAP_IMAGE = "HIGHLIGHT_MAP_IMAGE",
SHOW_CAMERA_VIEW_POINTS = "SHOW_CAMERA_VIEW_POINTS",
TOGGLE_GRID_ID = "TOGGLE_GRID_ID",
SET_GRID_START = "SET_GRID_START",
TOGGLE_SOIL_HEIGHT_LABELS = "TOGGLE_SOIL_HEIGHT_LABELS",
SET_PROFILE_OPEN = "SET_PROFILE_OPEN",
SET_PROFILE_AXIS = "SET_PROFILE_AXIS",
Expand Down
1 change: 1 addition & 0 deletions frontend/controls/controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export class ControlsPanel extends React.Component<ControlsPanelProps> {
Peripherals = () => {
return <div className={"peripherals-tab"}>
<Peripherals
getConfigValue={this.props.getConfigValue}
firmwareHardware={this.props.firmwareHardware}
bot={this.props.bot}
peripherals={this.props.peripherals}
Expand Down
1 change: 1 addition & 0 deletions frontend/controls/peripherals/__tests__/index_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe("<Peripherals />", () => {
dispatch: jest.fn(),
firmwareHardware: undefined,
resources: buildResourceIndex([]).index,
getConfigValue: () => false,
});

it("renders", () => {
Expand Down
29 changes: 19 additions & 10 deletions frontend/controls/peripherals/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import { Content } from "../../constants";
import { uniq, isNumber } from "lodash";
import { t } from "../../i18next_wrapper";
import { DIGITAL } from "farmbot";
import { isBotOnlineFromState } from "../../devices/must_be_online";
import { BoxTopButtons } from "../../settings/pin_bindings/box_top_gpio_diagram";
import { isBotOnline } from "../../devices/must_be_online";
import { getStatus } from "../../connectivity/reducer_support";
import { BoxTop } from "../../settings/pin_bindings/box_top";
import { BooleanSetting } from "../../session_keys";

export class Peripherals
extends React.Component<PeripheralsProps, PeripheralState> {
Expand All @@ -20,9 +22,16 @@ export class Peripherals
this.state = { isEditing: false };
}

get botOnline() {
const { hardware, connectivity } = this.props.bot;
const { sync_status } = hardware.informational_settings;
const botToMqttStatus = getStatus(connectivity.uptime["bot.mqtt"]);
return isBotOnline(sync_status, botToMqttStatus);
}

get disabled() {
return !!this.props.bot.hardware.informational_settings.busy
|| !isBotOnlineFromState(this.props.bot);
|| !this.botOnline;
}

toggle = () => this.setState({ isEditing: !this.state.isEditing });
Expand Down Expand Up @@ -114,15 +123,15 @@ export class Peripherals
: t("Edit");
return <div className={"peripherals-widget"}>
{!this.props.hidePinBindings &&
<BoxTopButtons
firmwareHardware={this.props.firmwareHardware}
<BoxTop
threeDimensions={!!this.props.getConfigValue(
BooleanSetting.enable_3d_electronics_box_top)}
isEditing={isEditing}
dispatch={this.props.dispatch}
resources={this.props.resources}
botOnline={isBotOnlineFromState(this.props.bot)}
syncStatus={this.props.bot.hardware.informational_settings.sync_status}
locked={this.props.bot.hardware.informational_settings.locked}
isEditing={isEditing} />}
<hr />
firmwareHardware={this.props.firmwareHardware}
bot={this.props.bot}
botOnline={this.botOnline} />}
<EmptyStateWrapper
notEmpty={this.props.peripherals.length > 0 || isEditing}
graphic={EmptyStateGraphic.regimens}
Expand Down
2 changes: 2 additions & 0 deletions frontend/controls/peripherals/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Pins, TaggedPeripheral, FirmwareHardware } from "farmbot";
import { BotState } from "../../devices/interfaces";
import { ResourceIndex } from "../../resources/interfaces";
import { GetWebAppConfigValue } from "../../config_storage/actions";

export interface PeripheralState {
isEditing: boolean;
Expand All @@ -26,4 +27,5 @@ export interface PeripheralsProps {
firmwareHardware: FirmwareHardware | undefined;
resources: ResourceIndex;
hidePinBindings?: boolean;
getConfigValue: GetWebAppConfigValue;
}
2 changes: 1 addition & 1 deletion frontend/controls/pin_form_fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface NameInputBoxProps {

export const NameInputBox = (props: NameInputBoxProps) =>
<input type="text"
name="name"
name="pinName"
placeholder={t("Name")}
value={props.value}
onChange={e => props.dispatch(edit(props.resource, {
Expand Down
Loading

0 comments on commit d98f412

Please sign in to comment.