diff --git a/frontend/messages/interfaces.ts b/frontend/messages/interfaces.ts
index 12d71ce6e..124faeee9 100644
--- a/frontend/messages/interfaces.ts
+++ b/frontend/messages/interfaces.ts
@@ -1,12 +1,14 @@
import { FirmwareHardware, Enigma } from "farmbot";
import { TimeSettings } from "../interfaces";
import { BotState } from "../devices/interfaces";
+import { UUID } from "../resources/interfaces";
export interface MessagesProps {
alerts: Alert[];
apiFirmwareValue: FirmwareHardware | undefined;
timeSettings: TimeSettings;
dispatch: Function;
+ findApiAlertById(id: number): UUID;
}
export interface AlertsProps {
@@ -14,6 +16,7 @@ export interface AlertsProps {
apiFirmwareValue: string | undefined;
timeSettings: TimeSettings;
dispatch: Function;
+ findApiAlertById(id: number): UUID;
}
export interface ProblemTag {
@@ -36,11 +39,14 @@ export interface AlertCardProps {
apiFirmwareValue: string | undefined;
timeSettings: TimeSettings;
dispatch: Function;
+ findApiAlertById?(id: number): UUID;
}
export interface CommonAlertCardProps {
alert: Alert;
timeSettings: TimeSettings;
+ findApiAlertById?(id: number): UUID;
+ dispatch?: Function;
}
export interface AlertCardTemplateProps {
@@ -50,6 +56,14 @@ export interface AlertCardTemplateProps {
message: string;
timeSettings: TimeSettings;
children?: React.ReactNode;
+ findApiAlertById?(id: number): UUID;
+ dispatch?: Function;
+}
+
+export interface DismissAlertProps {
+ id?: number;
+ findApiAlertById?(id: number): UUID;
+ dispatch?: Function;
}
export interface FirmwareMissingProps extends CommonAlertCardProps {
diff --git a/frontend/messages/state_to_props.ts b/frontend/messages/state_to_props.ts
index 699002fff..bafe8bdb2 100644
--- a/frontend/messages/state_to_props.ts
+++ b/frontend/messages/state_to_props.ts
@@ -1,11 +1,15 @@
import { Everything } from "../interfaces";
-import { MessagesProps } from "./interfaces";
+import { MessagesProps, Alert } from "./interfaces";
import { validFbosConfig, betterCompact } from "../util";
import { getFbosConfig } from "../resources/getters";
import { sourceFbosConfigValue } from "../devices/components/source_config_value";
import { DevSettings } from "../account/dev/dev_support";
-import { selectAllEnigmas, maybeGetTimeSettings } from "../resources/selectors";
+import {
+ selectAllEnigmas, maybeGetTimeSettings, findResourceById
+} from "../resources/selectors";
import { isFwHardwareValue } from "../devices/components/fbos_settings/board_type";
+import { ResourceIndex, UUID } from "../resources/interfaces";
+import { BotState } from "../devices/interfaces";
export const mapStateToProps = (props: Everything): MessagesProps => {
const { hardware } = props.bot;
@@ -13,15 +17,23 @@ export const mapStateToProps = (props: Everything): MessagesProps => {
const sourceFbosConfig =
sourceFbosConfigValue(fbosConfig, hardware.configuration);
const apiFirmwareValue = sourceFbosConfig("firmware_hardware").value;
- const botAlerts = betterCompact(Object.values(props.bot.hardware.enigmas || {}));
- const apiAlerts = selectAllEnigmas(props.resources.index).map(x => x.body);
- const alerts =
- botAlerts.concat(DevSettings.futureFeaturesEnabled() ? apiAlerts : []);
+ const findApiAlertById = (id: number): UUID =>
+ findResourceById(props.resources.index, "Enigma", id);
return {
- alerts,
+ alerts: getAlerts(props.resources.index, props.bot),
apiFirmwareValue: isFwHardwareValue(apiFirmwareValue)
? apiFirmwareValue : undefined,
timeSettings: maybeGetTimeSettings(props.resources.index),
dispatch: props.dispatch,
+ findApiAlertById,
};
};
+
+export const getAlerts =
+ (resourceIndex: ResourceIndex, bot: BotState): Alert[] => {
+ const botAlerts = betterCompact(Object.values(bot.hardware.enigmas || {}));
+ const apiAlerts = selectAllEnigmas(resourceIndex).map(x => x.body)
+ .filter(x => DevSettings.futureFeaturesEnabled() ||
+ x.problem_tag !== "api.seed_data.missing");
+ return botAlerts.concat(apiAlerts);
+ };
diff --git a/frontend/util/__tests__/page_test.ts b/frontend/util/__tests__/page_test.ts
deleted file mode 100644
index 5b7b1082e..000000000
--- a/frontend/util/__tests__/page_test.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { stopIE } from "../stop_ie";
-
-describe("stopIE()", () => {
- it("not IE", () => {
- expect(stopIE).not.toThrow();
- });
-});
diff --git a/frontend/util/__tests__/page_test.tsx b/frontend/util/__tests__/page_test.tsx
new file mode 100644
index 000000000..be8ba5133
--- /dev/null
+++ b/frontend/util/__tests__/page_test.tsx
@@ -0,0 +1,25 @@
+import { updatePageInfo, attachToRoot } from "../page";
+import React from "react";
+
+describe("updatePageInfo()", () => {
+ it("sets page title", () => {
+ updatePageInfo("page name");
+ expect(document.title).toEqual("Page name - FarmBot");
+ });
+
+ it("sets page title: Farm Designer", () => {
+ updatePageInfo("designer");
+ expect(document.title).toEqual("Farm designer - FarmBot");
+ });
+});
+
+describe("attachToRoot()", () => {
+ class Foo extends React.Component<{ text: string }> {
+ render() { return
{this.props.text}
; }
+ }
+ it("attaches page", () => {
+ attachToRoot(Foo, { text: "Bar" });
+ expect(document.body.innerHTML).toEqual(`
`);
+ expect(document.body.textContent).toEqual("Bar");
+ });
+});
diff --git a/frontend/util/page.ts b/frontend/util/page.ts
index 56deaacf4..f7ac67d13 100644
--- a/frontend/util/page.ts
+++ b/frontend/util/page.ts
@@ -4,14 +4,13 @@ import {
Attributes
} from "react";
import { render } from "react-dom";
-
import { capitalize } from "lodash";
import { t } from "../i18next_wrapper";
/** Dynamically change the meta title of the page. */
export function updatePageInfo(pageName: string) {
if (pageName === "designer") { pageName = "Farm Designer"; }
- document.title = t(capitalize(pageName));
+ document.title = `${t(capitalize(pageName))} - FarmBot`;
// Possibly add meta "content" here dynamically as well
}