Skip to content

Commit

Permalink
Merge pull request #1724 from FarmBot/labeling-improvements
Browse files Browse the repository at this point in the history
Labeling improvements and refactoring
  • Loading branch information
RickCarlino committed Feb 28, 2020
2 parents cccecf5 + 4d2ea00 commit 2c6033f
Show file tree
Hide file tree
Showing 533 changed files with 2,688 additions and 1,953 deletions.
5 changes: 4 additions & 1 deletion frontend/__test_support__/control_panel_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export const panelState = (): ControlPanelState => {
pin_bindings: false,
danger_zone: false,
power_and_reset: false,
pin_guard: false
pin_guard: false,
farm_designer: false,
firmware: false,
farmbot_os: false,
};
};
13 changes: 2 additions & 11 deletions frontend/__test_support__/fake_state/bot.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
import { Everything } from "../../interfaces";
import { panelState } from "../control_panel_state";

export const bot: Everything["bot"] = {
"consistent": true,
"stepSize": 100,
"controlPanelState": {
homing_and_calibration: false,
motors: false,
encoders: false,
endstops: false,
error_handling: false,
pin_bindings: false,
danger_zone: false,
power_and_reset: false,
pin_guard: false,
},
"controlPanelState": panelState(),
"hardware": {
"gpio_registry": {},
"mcu_params": {
Expand Down
2 changes: 1 addition & 1 deletion frontend/__test_support__/fake_state/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ export const fakeImages: TaggedImage[] = [
}
},
"uuid": "Image.7.5"
}
},
];
2 changes: 1 addition & 1 deletion frontend/__test_support__/fake_state/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from "farmbot";
import { fakeResource } from "../fake_resource";
import {
ExecutableType, PinBindingType, Folder
ExecutableType, PinBindingType, Folder,
} from "farmbot/dist/resources/api_resources";
import { FirmwareConfig } from "farmbot/dist/resources/configs/firmware";
import { MessageType } from "../../sequences/interfaces";
Expand Down
2 changes: 1 addition & 1 deletion frontend/__test_support__/fake_variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Coordinate } from "farmbot";
import { VariableNameSet } from "../resources/interfaces";

export const fakeVariableNameSet = (
label = "parent", vector = { x: 0, y: 0, z: 0 }
label = "parent", vector = { x: 0, y: 0, z: 0 },
): VariableNameSet => {
const data_value: Coordinate = {
kind: "coordinate", args: vector
Expand Down
12 changes: 6 additions & 6 deletions frontend/__test_support__/farm_event_calendar_support.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import moment from "moment";
import {
FarmEventWithExecutable
FarmEventWithExecutable,
} from "../farm_designer/farm_events/calendar/interfaces";

export const TIME = {
Expand All @@ -24,7 +24,7 @@ export const fakeFarmEventWithExecutable = (): FarmEventWithExecutable => {
color: "red",
name: "faker",
kind: "sequence",
args: { version: 0, locals: { kind: "scope_declaration", args: {} }, }
args: { version: 0, locals: { kind: "scope_declaration", args: {} } }
}
};
};
Expand Down Expand Up @@ -84,7 +84,7 @@ export const calendarRows = [
"subheading": "25",
"id": 79,
"childExecutableName": "Goto 0, 0, 0 123"
}
},
]
},
{
Expand Down Expand Up @@ -171,7 +171,7 @@ export const calendarRows = [
"subheading": "25",
"id": 79,
"childExecutableName": "Goto 0, 0, 0 123"
}
},
]
},
{
Expand Down Expand Up @@ -258,7 +258,7 @@ export const calendarRows = [
"subheading": "25",
"id": 79,
"childExecutableName": "Goto 0, 0, 0 123"
}
},
]
}
},
];
6 changes: 3 additions & 3 deletions frontend/__test_support__/resource_index_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const tr0: TaggedResource = {
},
"speed": 100
}
}
},
],
"args": {
"version": 4,
Expand Down Expand Up @@ -287,7 +287,7 @@ const tr12: TaggedResource = {
"regimen_id": 11,
"sequence_id": 23,
"time_offset": 345900000
}
},
],
body: [],
},
Expand Down Expand Up @@ -345,7 +345,7 @@ export const FAKE_RESOURCES: TaggedResource[] = [
tr0,
tr14,
tr15,
log
log,
];
const KIND: keyof TaggedResource = "kind"; // Safety first, kids.
type ResourceGroupNumber = 0 | 1 | 2 | 3 | 4;
Expand Down
6 changes: 3 additions & 3 deletions frontend/__tests__/app_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { RawApp as App, AppProps, mapStateToProps } from "../app";
import { mount } from "enzyme";
import { bot } from "../__test_support__/fake_state/bot";
import {
fakeUser, fakeWebAppConfig, fakeFbosConfig, fakeFarmwareEnv
fakeUser, fakeWebAppConfig, fakeFbosConfig, fakeFarmwareEnv,
} from "../__test_support__/fake_state/resources";
import { fakeState } from "../__test_support__/fake_state";
import {
buildResourceIndex
buildResourceIndex,
} from "../__test_support__/resource_index_builder";
import { ResourceName } from "farmbot";
import { fakeTimeSettings } from "../__test_support__/fake_time_settings";
Expand Down Expand Up @@ -125,7 +125,7 @@ describe("<App />: NavBar", () => {
"Device",
"Sequences",
"Regimens",
"Farmware"
"Farmware",
];
strings.map(string => expect(t).toContain(string));
wrapper.unmount();
Expand Down
2 changes: 1 addition & 1 deletion frontend/__tests__/attach_app_to_dom_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jest.mock("../redux/store", () => {
});

jest.mock("../account/dev/dev_support", () => ({
DevSettings: { futureFeaturesEnabled: () => false, }
DevSettings: { futureFeaturesEnabled: () => false }
}));

jest.mock("../config/actions", () => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/__tests__/interceptors_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jest.mock("../session", () => ({
}));

import {
responseFulfilled, isLocalRequest, requestFulfilled, responseRejected
responseFulfilled, isLocalRequest, requestFulfilled, responseRejected,
} from "../interceptors";
import { AxiosResponse, Method } from "axios";
import { uuid } from "farmbot";
Expand Down
2 changes: 1 addition & 1 deletion frontend/__tests__/refresh_token_no_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jest.mock("axios", () => ({

}));

jest.mock("../session", () => ({ Session: { clear: jest.fn(), } }));
jest.mock("../session", () => ({ Session: { clear: jest.fn() } }));

import { maybeRefreshToken } from "../refresh_token";
import { API } from "../api/index";
Expand Down
2 changes: 1 addition & 1 deletion frontend/__tests__/resource_index_builder_test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
buildResourceIndex,
FAKE_RESOURCES
FAKE_RESOURCES,
} from "../__test_support__/resource_index_builder";
import { TaggedFarmEvent, SpecialStatus } from "farmbot";

Expand Down
2 changes: 1 addition & 1 deletion frontend/__tests__/route_config_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Info = UnboundRouteConfig<{}, {}>;
const fakeCallback = (
component: ConnectedComponent,
child: ConnectedComponent | undefined,
info: Info
info: Info,
) => {
if (info.$ == "*") {
expect(component.name).toEqual("FourOhFour");
Expand Down
2 changes: 1 addition & 1 deletion frontend/account/__tests__/request_account_exports_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jest.mock("axios", () => ({
import { API } from "../../api";
import { Content } from "../../constants";
import {
requestAccountExport, generateFilename
requestAccountExport, generateFilename,
} from "../request_account_export";
import { success } from "../../toast/toast";
import axios from "axios";
Expand Down
2 changes: 1 addition & 1 deletion frontend/account/components/change_password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
Widget,
WidgetHeader,
WidgetBody,
SaveBtn
SaveBtn,
} from "../../ui/index";
import { SpecialStatus } from "farmbot";
import Axios from "axios";
Expand Down
3 changes: 2 additions & 1 deletion frontend/account/components/dangerous_delete_widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class DangerousDeleteWidget extends
return <Widget>
<WidgetHeader title={this.props.title} />
<WidgetBody>
<div>
<div className={"dangerous-delete-warning-messages"}>
{t(this.props.warning)}
<br /><br />
{t(this.props.confirmation)}
Expand All @@ -42,6 +42,7 @@ export class DangerousDeleteWidget extends
<button
onClick={this.onClick}
className="red fb-button"
title={t(this.props.title)}
type="button">
{t(this.props.title)}
</button>
Expand Down
3 changes: 2 additions & 1 deletion frontend/account/components/export_account_panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function ExportAccountPanel(props: { onClick: () => void }) {
return <Widget>
<WidgetHeader title={t("Export Account Data")} />
<WidgetBody>
<div>
<div className={"export-account-data-description"}>
{t(Content.EXPORT_DATA_DESC)}
</div>
<form>
Expand All @@ -19,6 +19,7 @@ export function ExportAccountPanel(props: { onClick: () => void }) {
</Col>
<Col xs={4}>
<button className="green fb-button" type="button"
title={t("Export")}
onClick={props.onClick}>
{t("Export")}
</button>
Expand Down
2 changes: 1 addition & 1 deletion frontend/account/components/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import {
BlurableInput, Widget, WidgetHeader, WidgetBody, SaveBtn
BlurableInput, Widget, WidgetHeader, WidgetBody, SaveBtn,
} from "../../ui/index";
import { SettingsPropTypes } from "../interfaces";
import { t } from "../../i18next_wrapper";
Expand Down
2 changes: 1 addition & 1 deletion frontend/account/dev/__tests__/dev_mode_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { DevMode } from "../dev_mode";
import * as React from "react";
import { range } from "lodash";
import {
setWebAppConfigValue
setWebAppConfigValue,
} from "../../../config_storage/actions";
import { warning } from "../../../toast/toast";

Expand Down
2 changes: 1 addition & 1 deletion frontend/account/dev/__tests__/dev_widget_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jest.mock("../../../config_storage/actions", () => ({
import * as React from "react";
import { mount, shallow } from "enzyme";
import {
DevWidget, DevWidgetFERow, DevWidgetFBOSRow, DevWidgetDelModeRow
DevWidget, DevWidgetFERow, DevWidgetFBOSRow, DevWidgetDelModeRow,
} from "../dev_widget";
import { DevSettings } from "../dev_support";
import { setWebAppConfigValue } from "../../../config_storage/actions";
Expand Down
2 changes: 1 addition & 1 deletion frontend/account/dev/dev_support.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { store } from "../../redux/store";
import {
getWebAppConfigValue, setWebAppConfigValue
getWebAppConfigValue, setWebAppConfigValue,
} from "../../config_storage/actions";
import { BooleanConfigKey } from "farmbot/dist/resources/configs/web_app";

Expand Down
2 changes: 1 addition & 1 deletion frontend/account/dev/dev_widget.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import {
Widget, WidgetHeader, WidgetBody, Row, Col, BlurableInput
Widget, WidgetHeader, WidgetBody, Row, Col, BlurableInput,
} from "../../ui";
import { ToggleButton } from "../../controls/toggle_button";
import { setWebAppConfigValue } from "../../config_storage/actions";
Expand Down
13 changes: 7 additions & 6 deletions frontend/account/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from "react";
import { connect } from "react-redux";
import {
Settings, ChangePassword, ExportAccountPanel, DangerousDeleteWidget
Settings, ChangePassword, ExportAccountPanel, DangerousDeleteWidget,
} from "./components";
import { Props } from "./interfaces";
import { Page, Row, Col } from "../ui";
Expand Down Expand Up @@ -47,12 +47,13 @@ export class RawAccount extends React.Component<Props, State> {
(key: keyof User) => (key === "email") && this.setState({ warnThem: true });

onChange = (e: React.FormEvent<HTMLInputElement>) => {
const { name, value } = e.currentTarget;
if (isKey(name)) {
this.tempHack(name);
this.props.dispatch(edit(this.props.user, { [name]: value }));
const { value } = e.currentTarget;
const field = e.currentTarget.name;
if (isKey(field)) {
this.tempHack(field);
this.props.dispatch(edit(this.props.user, { [field]: value }));
} else {
throw new Error("Bad key: " + name);
throw new Error("Bad key: " + field);
}
};

Expand Down
2 changes: 1 addition & 1 deletion frontend/account/labs/__tests__/labs_features_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const mockFeatures = [
storageKey: "weedDetector",
callback: jest.fn(),
value: false
}
},
];

const mocks = {
Expand Down
4 changes: 2 additions & 2 deletions frontend/account/labs/labs_features_list_data.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BooleanSetting } from "../../session_keys";
import { Content } from "../../constants";
import {
GetWebAppConfigValue, setWebAppConfigValue
GetWebAppConfigValue, setWebAppConfigValue,
} from "../../config_storage/actions";
import { BooleanConfigKey } from "farmbot/dist/resources/configs/web_app";
import { t } from "../../i18next_wrapper";
Expand Down Expand Up @@ -78,7 +78,7 @@ export const fetchLabFeatures =
storageKey: BooleanSetting.user_interface_read_only_mode,
value: false,
displayInvert: false,
}
},
].map(fetchSettingValue(getConfigValue)));

/** Always allow toggling from true => false (deactivate).
Expand Down
3 changes: 2 additions & 1 deletion frontend/account/labs/labs_features_list_ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface LabsFeaturesListProps {
}

export function LabsFeaturesList(props: LabsFeaturesListProps) {
return <div>
return <div className="labs-features-list">
{fetchLabFeatures(props.getConfigValue).map((feature, i) => {
const displayValue = feature.displayInvert ? !feature.value : feature.value;
return <Row key={i}>
Expand All @@ -23,6 +23,7 @@ export function LabsFeaturesList(props: LabsFeaturesListProps) {
</Col>
<Col xs={2}>
<ToggleButton
title={t("toggle feature")}
toggleValue={displayValue ? 1 : 0}
toggleAction={() => props.onToggle(feature)
.then(() => feature.callback && feature.callback())}
Expand Down
5 changes: 2 additions & 3 deletions frontend/account/request_account_export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ interface DataDumpExport { device?: DeviceAccountSettings; }
type Response = AxiosResponse<DataDumpExport | undefined>;

export function generateFilename({ device }: DataDumpExport): string {
let name: string;
name = device ? (device.name + "_" + device.id) : "farmbot";
return `export_${name}.json`.toLowerCase();
const nameAndId = device ? (device.name + "_" + device.id) : "farmbot";
return `export_${nameAndId}.json`.toLowerCase();
}

// Thanks, @KOL - https://stackoverflow.com/a/19328891/1064917
Expand Down
4 changes: 2 additions & 2 deletions frontend/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { validBotLocationData, validFwConfig, validFbosConfig } from "./util";
import { BooleanSetting } from "./session_keys";
import { getPathArray } from "./history";
import {
getWebAppConfigValue, GetWebAppConfigValue
getWebAppConfigValue, GetWebAppConfigValue,
} from "./config_storage/actions";
import { takeSortedLogs } from "./logs/state_to_props";
import { FirmwareConfig } from "farmbot/dist/resources/configs/firmware";
Expand Down Expand Up @@ -99,7 +99,7 @@ const MUST_LOAD: ResourceName[] = [
"FarmEvent",
"Point",
"Device",
"Tool" // Sequence editor needs this for rendering.
"Tool", // Sequence editor needs this for rendering.
];

export class RawApp extends React.Component<AppProps, {}> {
Expand Down
Loading

0 comments on commit 2c6033f

Please sign in to comment.