Skip to content

Commit 25ff4fb

Browse files
adjust cards and fix box top buttons
1 parent 0897f17 commit 25ff4fb

File tree

18 files changed

+146
-70
lines changed

18 files changed

+146
-70
lines changed

app/models/alert.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
class Alert < ApplicationRecord
22
belongs_to :device
33
DEFAULTS = [
4-
SEED_DATA = { problem_tag: "api.seed_data.missing", priority: 400 },
5-
DOCUMENTATION = { problem_tag: "api.documentation.unread", priority: 300 },
6-
TOUR = { problem_tag: "api.tour.not_taken", priority: 200 },
4+
SEED_DATA = { problem_tag: "api.seed_data.missing", priority: 200 },
5+
DOCUMENTATION = { problem_tag: "api.documentation.unread", priority: 400 },
6+
TOUR = { problem_tag: "api.tour.not_taken", priority: 300 },
77
USER = { problem_tag: "api.user.not_welcomed", priority: 100 },
88
BULLETIN = { problem_tag: "api.bulletin.unread", priority: 100 },
99
DEMO = { problem_tag: "api.demo_account.in_use", priority: 100 },

app/mutations/devices/create.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ class Create < Mutations::Command
1616
def execute
1717
merge_default_values
1818
device = Device.create!({ name: "FarmBot" }.merge(inputs.except(:user)))
19-
Alerts::Create.run!(Alert::SEED_DATA.merge(device: device))
20-
Alerts::Create.run!(Alert::TOUR.merge(device: device))
2119
Alerts::Create.run!(Alert::USER.merge(device: device))
2220
Alerts::Create.run!(Alert::DOCUMENTATION.merge(device: device))
2321

app/mutations/devices/seeders/demo_account_seeder.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def marketing_bulletin
151151
DEMO_ALERTS = [
152152
Alert::DEMO,
153153
Alert::BULLETIN.merge(slug: "buy-a-farmbot", priority: 9999),
154+
Alert::TOUR,
154155
]
155156

156157
DEMO_LOGS = [

frontend/constants.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,12 @@ export namespace SetupWizardContent {
16701670
while answering no will display a list of results that can be selected for
16711671
specific troubleshooting tips.`);
16721672

1673+
export const FB_ORDER_NUMBER =
1674+
trim(`Please enter your FarmBot order number. This is not necessary to
1675+
use the app but is helpful if you ever need additional support.
1676+
If you do not have your original order number you may leave this field
1677+
blank.`);
1678+
16731679
export const RPI =
16741680
trim(`Inspect the ports on the top edge of the Raspberry Pi and select
16751681
which Raspberry Pi model is in your FarmBot.`);
@@ -1985,6 +1991,12 @@ export namespace SetupWizardContent {
19851991
recommend setting Button 5 to the 'Find Home' sequence. You can change
19861992
this later from the controls pop-up.`);
19871993

1994+
export const CUSTOM_BUTTONS_v18 =
1995+
trim(`Customize which Action or Sequence you want FarmBot to execute
1996+
when you press Button 3 on the electronics box. To start, we
1997+
recommend setting Button 3 to the 'Find Home' sequence. You can change
1998+
this later from the controls pop-up.`);
1999+
19882000
export const PROBLEM_GETTING_IMAGE =
19892001
trim(`There is a 'camera not detected' or 'problem getting image' error
19902002
log`);

frontend/messages/cards.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ const DocumentationUnread = (props: CommonAlertCardProps) =>
378378
<AlertCardTemplate
379379
alert={props.alert}
380380
className={"documentation-unread-alert"}
381-
title={t("Learn more about the app")}
381+
title={t("Learn more")}
382382
message={t(Content.READ_THE_DOCS)}
383383
timeSettings={props.timeSettings}
384384
dispatch={props.dispatch}

frontend/messages/state_to_props.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import { getFwHardwareValue } from "../settings/firmware/firmware_hardware_support";
99
import { ResourceIndex } from "../resources/interfaces";
1010
import { Alert } from "farmbot";
11+
import { forceOnline } from "../devices/must_be_online";
1112

1213
export const mapStateToProps = (props: Everything): MessagesProps => {
1314
return {
@@ -22,7 +23,7 @@ export const mapStateToProps = (props: Everything): MessagesProps => {
2223
export const getAllAlerts = (resources: Everything["resources"]) => ([
2324
...getApiAlerts(resources.index),
2425
...getLocalAlerts(resources.consumers.alerts),
25-
...(maybeGetDevice(resources.index)?.body.setup_completed_at
26+
...((maybeGetDevice(resources.index)?.body.setup_completed_at || forceOnline())
2627
? []
2728
: [setupIncompleteAlert]),
2829
]);
@@ -36,6 +37,6 @@ const getLocalAlerts = ({ alerts }: AlertReducerState): Alert[] =>
3637
export const setupIncompleteAlert = {
3738
created_at: 1,
3839
problem_tag: "api.setup.not_completed",
39-
priority: 500,
40+
priority: 200,
4041
slug: "setup-incomplete",
4142
};

frontend/sequences/step_tiles/pin_support/__tests__/pin_and_peripheral_support_test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ describe("pinsAsDropdowns()", () => {
103103
});
104104

105105
it("write_pin: displays box LEDs", () => {
106-
const ri = buildResourceIndex([]);
106+
const fbosConfig = fakeFbosConfig();
107+
fbosConfig.body.firmware_hardware = "farmduino_k17";
108+
const ri = buildResourceIndex([fbosConfig]);
107109
const result = PinSupport.pinsAsDropdowns("write_pin")(ri.index, true);
108110
expect(JSON.stringify(result)).toContain("Box LED");
109111
});

frontend/settings/firmware/firmware_hardware_support.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ const NO_TOOLS = [...EXPRESS_BOARDS];
4848
const NO_ETHERNET = ["express_k10"];
4949
const NO_ZERO_2 = ["express_k10"];
5050
const NO_EXTRA_BUTTONS = [...EXPRESS_BOARDS];
51+
const MANY_BUTTONS =
52+
["farmduino_k14", "farmduino_k15", "farmduino_k16", "farmduino_k17"];
5153
const NO_TMC = ["arduino", "farmduino", "farmduino_k14"];
5254
const HAS_WEEDER = [
5355
"arduino", "farmduino", "farmduino_k14", "farmduino_k15", "farmduino_k16",
@@ -61,11 +63,25 @@ export const isTMCBoard = (firmwareHardware: FirmwareHardware | undefined) =>
6163
export const isExpress = (firmwareHardware: FirmwareHardware | undefined) =>
6264
!!(firmwareHardware && EXPRESS_BOARDS.includes(firmwareHardware));
6365

66+
export const btnIndexList = (
67+
firmwareHardware: FirmwareHardware | undefined,
68+
): { btns: number[], leds: number[] } => {
69+
if (!firmwareHardware) { return { btns: [], leds: [] }; }
70+
if (NO_BUTTONS.includes(firmwareHardware)) { return { btns: [], leds: [] }; }
71+
if (NO_EXTRA_BUTTONS.includes(firmwareHardware)) {
72+
return { btns: [0], leds: [] };
73+
}
74+
if (MANY_BUTTONS.includes(firmwareHardware)) {
75+
return { btns: [0, 1, 2, 3, 4], leds: [0, 1, 2, 3] };
76+
}
77+
return { btns: [0, 1, 2], leds: [0, 1] };
78+
};
79+
6480
export const hasButtons = (firmwareHardware: FirmwareHardware | undefined) =>
65-
!firmwareHardware || !NO_BUTTONS.includes(firmwareHardware);
81+
btnIndexList(firmwareHardware).btns.length > 0;
6682

6783
export const hasExtraButtons = (firmwareHardware: FirmwareHardware | undefined) =>
68-
!firmwareHardware || !NO_EXTRA_BUTTONS.includes(firmwareHardware);
84+
btnIndexList(firmwareHardware).btns.length > 1;
6985

7086
export const hasEncoders = (firmwareHardware: FirmwareHardware | undefined) =>
7187
!firmwareHardware || !NO_ENCODERS.includes(firmwareHardware);

frontend/settings/pin_bindings/__tests__/box_top_gpio_diagram_test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("<BoxTopGpioDiagram />", () => {
2929
boundPins: [16],
3030
setSelectedPin: jest.fn(),
3131
selectedPin: undefined,
32-
firmwareHardware: undefined,
32+
firmwareHardware: "farmduino_k17",
3333
});
3434

3535
it("renders", () => {
@@ -81,7 +81,7 @@ describe("<BoxTopButtons />", () => {
8181
bot.hardware.informational_settings.sync_status = "synced";
8282
bot.hardware.informational_settings.locked = false;
8383
return {
84-
firmwareHardware: "arduino",
84+
firmwareHardware: "farmduino_k17",
8585
isEditing: true,
8686
dispatch: jest.fn(),
8787
resources,
@@ -92,7 +92,7 @@ describe("<BoxTopButtons />", () => {
9292

9393
it("renders: genesis", () => {
9494
const p = fakeProps();
95-
p.firmwareHardware = "arduino";
95+
p.firmwareHardware = "farmduino_k17";
9696
const wrapper = mount(<BoxTopButtons {...p} />);
9797
expect(wrapper.find("#button").length).toEqual(9);
9898
});

frontend/settings/pin_bindings/__tests__/model_test.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import { bot } from "../../../__test_support__/fake_state/bot";
4747
import { execSequence } from "../../../devices/actions";
4848
import { ButtonPin } from "../list_and_label_support";
4949
import { BoxTopBaseProps } from "../interfaces";
50+
import { FirmwareHardware } from "farmbot";
5051

5152
describe("setZForAllInGroup()", () => {
5253
it("sets z", () => {
@@ -78,7 +79,7 @@ describe("<ElectronicsBoxModel />", () => {
7879
resources: buildResourceIndex([binding, sequence]).index,
7980
botOnline: true,
8081
bot,
81-
firmwareHardware: "arduino",
82+
firmwareHardware: "farmduino_k17",
8283
};
8384
};
8485

@@ -188,4 +189,15 @@ describe("<ElectronicsBoxModel />", () => {
188189
mount(<Model {...p} />);
189190
expect(mockSetColor).not.toHaveBeenCalledWith(IColor.unlock.on);
190191
});
192+
193+
it.each<[FirmwareHardware, number]>([
194+
["express_k11", 1],
195+
["farmduino_k17", 5],
196+
["farmduino_k18", 3],
197+
])("renders: %s", (firmwareHardware, count) => {
198+
const p = fakeProps();
199+
p.firmwareHardware = firmwareHardware;
200+
const wrapper = mount(<Model {...p} />);
201+
expect(wrapper.find({ name: "button-center" }).length).toEqual(count);
202+
});
191203
});

0 commit comments

Comments
 (0)