Skip to content

Commit

Permalink
Merge pull request #1977 from FarmBot/staging
Browse files Browse the repository at this point in the history
Recovery deploy, 22 SEP 2020
  • Loading branch information
RickCarlino committed Sep 22, 2020
2 parents 5953fe0 + 6112dde commit 112f44d
Show file tree
Hide file tree
Showing 34 changed files with 270 additions and 190 deletions.
3 changes: 2 additions & 1 deletion frontend/__tests__/app_test.tsx
Expand Up @@ -90,7 +90,8 @@ describe("<App />: Loading", () => {
const wrapper = mount(<App {...fakeProps()} />);
jest.runAllTimers();
expect(error).toHaveBeenCalledWith(
expect.stringContaining("App could not be fully loaded"), "Warning");
expect.stringContaining("App could not be fully loaded"),
{ title: "Warning" });
wrapper.unmount();
});

Expand Down
2 changes: 1 addition & 1 deletion frontend/__tests__/controls_popup_test.tsx
Expand Up @@ -98,7 +98,7 @@ describe("<ControlsPopup />", () => {
expect(btn.props().title).toEqual(Content.NO_CAMERA_SELECTED);
btn.simulate("click");
expect(error).toHaveBeenCalledWith(
ToolTips.SELECT_A_CAMERA, Content.NO_CAMERA_SELECTED);
ToolTips.SELECT_A_CAMERA, { title: Content.NO_CAMERA_SELECTED });
expect(mockDevice.takePhoto).not.toHaveBeenCalled();
});
});
Expand Down
4 changes: 2 additions & 2 deletions frontend/app.tsx
@@ -1,4 +1,4 @@
import * as React from "react";
import React from "react";
import { connect, ConnectedComponent } from "react-redux";
import { init, error } from "./toast/toast";
import { NavBar } from "./nav";
Expand Down Expand Up @@ -126,7 +126,7 @@ export class RawApp extends React.Component<AppProps, {}> {
componentDidMount() {
setTimeout(() => {
if (!this.isLoaded) {
error(t(Content.APP_LOAD_TIMEOUT_MESSAGE), t("Warning"));
error(t(Content.APP_LOAD_TIMEOUT_MESSAGE), { title: t("Warning") });
}
}, LOAD_TIME_FAILURE_MS);
}
Expand Down
8 changes: 5 additions & 3 deletions frontend/connectivity/__tests__/connect_device/index_test.ts
Expand Up @@ -127,7 +127,9 @@ describe("showLogOnScreen", () => {
it("routes `debug` to toastr.info()", () => {
const log = fakeLog(MessageType.debug, ["toast"]);
showLogOnScreen(log);
expect(info).toHaveBeenCalledWith(log.message, TITLE(), "gray");
expect(info).toHaveBeenCalledWith(log.message, {
title: TITLE(), color: "gray",
});
});
});

Expand Down Expand Up @@ -178,7 +180,7 @@ describe("onOffline", () => {
onOffline();
expect(dispatchNetworkDown).toHaveBeenCalledWith("user.mqtt", ANY_NUMBER);
expect(error).toHaveBeenCalledWith(
Content.MQTT_DISCONNECTED, "Error", "red", "offline");
Content.MQTT_DISCONNECTED, { idPrefix: "offline" });
});
});

Expand All @@ -196,7 +198,7 @@ describe("onReconnect()", () => {
onReconnect();
expect(warning).toHaveBeenCalledWith(
"Attempting to reconnect to the message broker",
"Offline", "yellow", "offline");
{ title: "Offline", color: "yellow", idPrefix: "offline" });
});
});

Expand Down
8 changes: 4 additions & 4 deletions frontend/connectivity/connect_device.ts
Expand Up @@ -63,7 +63,7 @@ export function showLogOnScreen(log: Log) {
case MessageType.busy:
return busy;
case MessageType.debug:
return (msg: string, title: string) => info(msg, title, "gray");
return (msg: string, title: string) => info(msg, { title, color: "gray" });
case MessageType.info:
default:
return info;
Expand Down Expand Up @@ -141,17 +141,17 @@ export function onMalformed() {

export const onOnline = () => {
removeToast("offline");
success(t("Reconnected to the message broker."), t("Online"));
success(t("Reconnected to the message broker."), { title: t("Online") });
dispatchNetworkUp("user.mqtt", now());
};

export const onReconnect = () =>
warning(t("Attempting to reconnect to the message broker"),
t("Offline"), "yellow", "offline");
{ title: t("Offline"), color: "yellow", idPrefix: "offline" });

export const onOffline = () => {
dispatchNetworkDown("user.mqtt", now());
error(t(Content.MQTT_DISCONNECTED), t("Error"), "red", "offline");
error(t(Content.MQTT_DISCONNECTED), { idPrefix: "offline" });
};

export function onPublicBroadcast(payl: unknown) {
Expand Down
4 changes: 4 additions & 0 deletions frontend/constants.ts
Expand Up @@ -926,6 +926,10 @@ export namespace Content {
trim(`Your version of FarmBot OS is outdated and will soon no longer
be supported. Please update your device as soon as possible.`);

export const OLD_FBOS_UNSUPPORTED =
trim(`You are running an old version of FarmBot OS that is no longer
supported.`);

export const EXPERIMENTAL_WARNING =
trim(`Warning! This is an EXPERIMENTAL feature. This feature may be
broken and may break or otherwise hinder your usage of the rest of the
Expand Down
4 changes: 2 additions & 2 deletions frontend/controls/move/__tests__/jog_buttons_test.tsx
Expand Up @@ -10,7 +10,7 @@ jest.mock("../../../device", () => ({
getDevice: () => (mockDevice)
}));

import * as React from "react";
import React from "react";
import { mount } from "enzyme";
import { JogButtons } from "../jog_buttons";
import { JogMovementControlsProps } from "../interfaces";
Expand Down Expand Up @@ -86,7 +86,7 @@ describe("<JogButtons/>", function () {
expect(cameraBtn.props().title).toEqual(Content.NO_CAMERA_SELECTED);
cameraBtn.simulate("click");
expect(error).toHaveBeenCalledWith(
ToolTips.SELECT_A_CAMERA, Content.NO_CAMERA_SELECTED);
ToolTips.SELECT_A_CAMERA, { title: Content.NO_CAMERA_SELECTED });
expect(mockDevice.takePhoto).not.toHaveBeenCalled();
});

Expand Down
24 changes: 16 additions & 8 deletions frontend/devices/__tests__/actions_test.ts
Expand Up @@ -25,6 +25,8 @@ jest.mock("../../api/crud", () => ({
save: jest.fn(),
}));

jest.mock("../../history", () => ({ push: jest.fn() }));

let mockGet: Promise<{}> = Promise.resolve({});
jest.mock("axios", () => ({ get: jest.fn(() => mockGet) }));

Expand All @@ -40,6 +42,8 @@ import { success, error, warning, info } from "../../toast/toast";
import { edit, save } from "../../api/crud";
import { DeepPartial } from "redux";
import { Farmbot } from "farmbot";
import { push } from "../../history";
import { linkToFbosSettings } from "../../settings/maybe_highlight";

const replaceDeviceWith = async (d: DeepPartial<Farmbot>, cb: Function) => {
jest.clearAllMocks();
Expand Down Expand Up @@ -134,19 +138,17 @@ describe("sync()", function () {
state.bot.hardware.informational_settings.controller_version = "1.0.0";
actions.sync()(jest.fn(), () => state);
expect(mockDevice.current.sync).not.toHaveBeenCalled();
expect(info).toBeCalledWith(
expect.stringContaining("old version"),
expect.stringContaining("Please Update"),
"red");
expectBadVersionCall();
});

it("doesn't call sync: disconnected", () => {
const state = fakeState();
state.bot.hardware.informational_settings.controller_version = undefined;
actions.sync()(jest.fn(), () => state);
expect(mockDevice.current.sync).not.toHaveBeenCalled();
const expectedMessage = ["FarmBot is not connected.", "Disconnected", "red"];
expect(info).toBeCalledWith(...expectedMessage);
expect(info).toBeCalledWith("FarmBot is not connected.", {
title: "Disconnected", color: "red",
});
});
});

Expand Down Expand Up @@ -431,10 +433,16 @@ describe("updateConfig()", () => {
});
});

const expectBadVersionCall = () => {
expect(push).toHaveBeenCalledWith(linkToFbosSettings());
expect(error).toHaveBeenCalledWith(
expect.stringContaining("old version"),
{ title: "Please Update", noDismiss: true });
};

describe("badVersion()", () => {
it("warns of old FBOS version", () => {
actions.badVersion();
expect(info).toHaveBeenCalledWith(
expect.stringContaining("old version"), "Please Update", "red");
expectBadVersionCall();
});
});
13 changes: 9 additions & 4 deletions frontend/devices/actions.ts
Expand Up @@ -23,6 +23,8 @@ import { getFirmwareConfig, getFbosConfig } from "../resources/getters";
import { isObject, isString, get, noop } from "lodash";
import { t } from "../i18next_wrapper";
import { ExternalUrl } from "../external_urls";
import { linkToFbosSettings } from "../settings/maybe_highlight";
import { push } from "../history";

const ON = 1, OFF = 0;
export type ConfigKey = keyof McuParams;
Expand Down Expand Up @@ -52,7 +54,7 @@ export const commandErr =
/** Toast message upon request success. */
export const commandOK = (noun = "Command") => () => {
const msg = t(noun) + t(" request sent to device.");
success(msg, t("Request sent"));
success(msg, { title: t("Request sent") });
};

/** Update FBOS. */
Expand Down Expand Up @@ -136,7 +138,9 @@ export function sync(): Thunk {
if (currentFBOSversion) {
badVersion();
} else {
info(t("FarmBot is not connected."), t("Disconnected"), "red");
info(t("FarmBot is not connected."), {
title: t("Disconnected"), color: "red",
});
}
}
};
Expand Down Expand Up @@ -366,6 +370,7 @@ export function changeStepSize(integer: number) {
}

export function badVersion() {
info(t("You are running an old version of FarmBot OS."),
t("Please Update"), "red");
push(linkToFbosSettings());
error(t(Content.OLD_FBOS_UNSUPPORTED),
{ title: t("Please Update"), noDismiss: true });
}
12 changes: 6 additions & 6 deletions frontend/farm_designer/map/layers/farmbot/bot_figure.tsx
@@ -1,4 +1,4 @@
import * as React from "react";
import React from "react";
import { AxisNumberProperty, MapTransformProps } from "../../interfaces";
import { getMapSize, transformXY } from "../../util";
import { BotPosition } from "../../../../devices/interfaces";
Expand Down Expand Up @@ -215,7 +215,7 @@ export const CameraViewArea = (props: CameraViewAreaProps) => {
<ViewRectangle id={"angled-camera-view-area"}
dashed={cropPhotos} position={angledView} />
</g>}
{cropPhotos && croppedView && (largeCrop(rotationAngle)
{cropPhotos && croppedView && (largeCrop(rotationAngle) && angledView
? <ViewCircle id={"cropped-camera-view-area"}
center={scaledCenter}
radius={scaledShortEdge / 2}
Expand Down Expand Up @@ -246,17 +246,17 @@ interface ViewCircleProps {
id: string;
center: Record<"x" | "y", number>;
radius: number;
position: MapImagePositionData | undefined;
position: MapImagePositionData;
}

const ViewCircle = (props: ViewCircleProps) =>
<circle id={props.id}
cx={props.center.x}
cy={props.center.y}
r={props.radius}
data-comment={props.position?.comment}
transform={props.position?.transform}
style={{ transformOrigin: props.position?.transformOrigin }} />;
data-comment={props.position.comment}
transform={props.position.transform}
style={{ transformOrigin: props.position.transformOrigin }} />;

interface ImageLogVisualsProps {
position: MapImagePositionData | undefined;
Expand Down
8 changes: 4 additions & 4 deletions frontend/farm_events/__tests__/edit_fe_form_test.tsx
Expand Up @@ -255,7 +255,7 @@ describe("<EditFEForm />", () => {
const expectStartTimeToBeRejected = () => {
expect(error).toHaveBeenCalledWith(
"Event start time needs to be in the future, not the past.",
"Unable to save event.");
{ title: "Unable to save event." });
};

it("displays error message on save (add): start time has passed", () => {
Expand All @@ -276,7 +276,7 @@ describe("<EditFEForm />", () => {
const i = instance(p);
i.commitViewModel(moment("2017-06-22T05:00:00.000Z"));
expect(error).toHaveBeenCalledWith(expect.stringContaining(
"Nothing to run."), "Unable to save event.");
"Nothing to run."), { title: "Unable to save event." });
});

it("displays error message on save: no items", async () => {
Expand All @@ -287,7 +287,7 @@ describe("<EditFEForm />", () => {
const i = instance(p);
await i.commitViewModel(moment("2017-06-22T05:00:00.000Z"));
expect(error).toHaveBeenCalledWith(expect.stringContaining(
"Nothing to run."), "Unable to save event.");
"Nothing to run."), { title: "Unable to save event." });
});

it("displays error message on save: save error", async () => {
Expand Down Expand Up @@ -640,6 +640,6 @@ describe("<FarmEventDeleteButton />", () => {
await wrapper.find("button").simulate("click");
expect(destroy).toHaveBeenCalledWith(p.farmEvent.uuid);
expect(history.push).toHaveBeenCalledWith("/app/designer/events");
expect(success).toHaveBeenCalledWith("Deleted event.", "Deleted");
expect(success).toHaveBeenCalledWith("Deleted event.", { title: "Deleted" });
});
});
6 changes: 3 additions & 3 deletions frontend/farm_events/edit_fe_form.tsx
Expand Up @@ -89,14 +89,14 @@ const startTimeWarning = () => {
const message =
t("Event start time needs to be in the future, not the past.");
const title = t("Unable to save event.");
error(message, title);
error(message, { title });
};

const nothingToRunWarning = () => {
const message =
t("All items scheduled before the start time. Nothing to run.");
const title = t("Unable to save event.");
error(message, title);
error(message, { title });
};

type RecombineOptions = { forceRegimensToMidnight: boolean };
Expand Down Expand Up @@ -508,7 +508,7 @@ export const FarmEventDeleteButton = (props: FarmEventDeleteButtonProps) =>
props.dispatch(destroy(props.farmEvent.uuid))
.then(() => {
history.push("/app/designer/events");
success(t("Deleted event."), t("Deleted"));
success(t("Deleted event."), { title: t("Deleted") });
})}>
{t("Delete")}
</button>;
Expand Down
2 changes: 1 addition & 1 deletion frontend/front_page/__tests__/front_page_test.tsx
Expand Up @@ -161,7 +161,7 @@ describe("<FrontPage />", () => {
await expect(axios.post).toHaveBeenCalledWith("resetPath",
{ email: "foo@bar.io" });
await expect(success).toHaveBeenCalledWith(
"Email has been sent.", "Forgot Password");
"Email has been sent.", { title: "Forgot Password" });
expect(el.instance().state.activePanel).toEqual("login");
});

Expand Down
2 changes: 1 addition & 1 deletion frontend/front_page/front_page.tsx
Expand Up @@ -141,7 +141,7 @@ export class FrontPage extends React.Component<{}, Partial<FrontPageState>> {
const data = { email };
axios.post(API.current.passwordResetPath, data)
.then(() => {
success(t("Email has been sent."), t("Forgot Password"));
success(t("Email has been sent."), { title: t("Forgot Password") });
this.setState({ activePanel: "login" });
}).catch(error => {
let errorMessage = prettyPrintApiErrors(error);
Expand Down
2 changes: 1 addition & 1 deletion frontend/messages/__tests__/actions_test.ts
Expand Up @@ -30,7 +30,7 @@ describe("seedAccount()", () => {
expect(axios.post).toHaveBeenCalledWith("/api/stub", {
product_line: "genesis_1.2"
});
expect(info).toHaveBeenCalledWith("Seeding in progress.", "Busy");
expect(info).toHaveBeenCalledWith("Seeding in progress.", { title: "Busy" });
expect(dismiss).toHaveBeenCalled();
});

Expand Down
2 changes: 1 addition & 1 deletion frontend/messages/actions.ts
Expand Up @@ -19,6 +19,6 @@ export const fetchBulletinContent =
export const seedAccount = (onClick: () => void) => (ddi: DropDownItem) =>
axios.post(API.current.accountSeedPath, { product_line: ddi.value })
.then(() => {
info(t("Seeding in progress."), "Busy");
info(t("Seeding in progress."), { title: t("Busy") });
onClick();
}, (err: UnsafeError) => toastErrors({ err }));
Expand Up @@ -121,7 +121,7 @@ describe("<CameraCalibration/>", () => {
expect(btn.props().title).toEqual(Content.NO_CAMERA_SELECTED);
btn.simulate("click");
expect(error).toHaveBeenCalledWith(
ToolTips.SELECT_A_CAMERA, Content.NO_CAMERA_SELECTED);
ToolTips.SELECT_A_CAMERA, { title: Content.NO_CAMERA_SELECTED });
});

it("toggles simple version on", () => {
Expand Down

0 comments on commit 112f44d

Please sign in to comment.