dep updates (fe)

dep_updates
gabrielburnworth 2020-05-08 13:27:15 -07:00
parent 8700d50c81
commit 4a7a683ba7
19 changed files with 23 additions and 44 deletions

View File

@ -134,7 +134,6 @@ export function fakeToolSlot(): TaggedToolSlotPointer {
x: 0, x: 0,
y: 0, y: 0,
z: 0, z: 0,
radius: 25,
pointer_type: "ToolSlot", pointer_type: "ToolSlot",
meta: {}, meta: {},
tool_id: undefined, tool_id: undefined,
@ -181,6 +180,7 @@ export function fakeWeed(): TaggedWeedPointer {
y: 400, y: 400,
z: 0, z: 0,
radius: 100, radius: 100,
plant_stage: "planned",
meta: { created_by: "plant-detection", color: "red" } meta: { created_by: "plant-detection", color: "red" }
}); });
} }

View File

@ -265,7 +265,6 @@ const tr11: TaggedPoint = {
"pointer_type": "ToolSlot", "pointer_type": "ToolSlot",
"pullout_direction": 0, "pullout_direction": 0,
"gantry_mounted": false, "gantry_mounted": false,
"radius": 25,
"x": 10, "x": 10,
"y": 10, "y": 10,
"z": 10, "z": 10,
@ -329,6 +328,7 @@ const tr16: TaggedPoint = {
}, },
name: "untitled", name: "untitled",
pointer_type: "Weed", pointer_type: "Weed",
plant_stage: "planned",
radius: 10, radius: 10,
x: 490, x: 490,
y: 421, y: 421,

View File

@ -32,7 +32,6 @@ export const specialActionLabelLookup: { [x: string]: string } = {
export const specialActionList: DropDownItem[] = export const specialActionList: DropDownItem[] =
Object.values(PinBindingSpecialAction) Object.values(PinBindingSpecialAction)
.filter(action => action != PinBindingSpecialAction.dump_info)
.map((action: PinBindingSpecialAction) => .map((action: PinBindingSpecialAction) =>
({ label: specialActionLabelLookup[action], value: action })); ({ label: specialActionLabelLookup[action], value: action }));

View File

@ -18,8 +18,6 @@ import { generateUuid } from "../../resources/util";
import { DevSettings } from "../../account/dev/dev_support"; import { DevSettings } from "../../account/dev/dev_support";
describe("mapStateToProps()", () => { describe("mapStateToProps()", () => {
const DISCARDED_AT = "2018-01-01T00:00:00.000Z";
it("hovered plantUUID is undefined", () => { it("hovered plantUUID is undefined", () => {
const state = fakeState(); const state = fakeState();
state.resources.consumers.farm_designer.hoveredPlant = { state.resources.consumers.farm_designer.hoveredPlant = {
@ -55,11 +53,8 @@ describe("mapStateToProps()", () => {
const webAppConfig = fakeWebAppConfig(); const webAppConfig = fakeWebAppConfig();
(webAppConfig.body as WebAppConfig).show_historic_points = true; (webAppConfig.body as WebAppConfig).show_historic_points = true;
const point1 = fakePoint(); const point1 = fakePoint();
point1.body.discarded_at = undefined;
const point2 = fakePoint(); const point2 = fakePoint();
point2.body.discarded_at = DISCARDED_AT;
const point3 = fakePoint(); const point3 = fakePoint();
point3.body.discarded_at = DISCARDED_AT;
state.resources = buildResourceIndex([ state.resources = buildResourceIndex([
webAppConfig, point1, point2, point3, fakeDevice(), webAppConfig, point1, point2, point3, fakeDevice(),
]); ]);
@ -71,15 +66,12 @@ describe("mapStateToProps()", () => {
const webAppConfig = fakeWebAppConfig(); const webAppConfig = fakeWebAppConfig();
(webAppConfig.body as WebAppConfig).show_historic_points = false; (webAppConfig.body as WebAppConfig).show_historic_points = false;
const point1 = fakePoint(); const point1 = fakePoint();
point1.body.discarded_at = undefined;
const point2 = fakePoint(); const point2 = fakePoint();
point2.body.discarded_at = DISCARDED_AT;
const point3 = fakePoint(); const point3 = fakePoint();
point3.body.discarded_at = DISCARDED_AT;
state.resources = buildResourceIndex([ state.resources = buildResourceIndex([
webAppConfig, point1, point2, point3, fakeDevice(), webAppConfig, point1, point2, point3, fakeDevice(),
]); ]);
expect(mapStateToProps(state).genericPoints.length).toEqual(1); expect(mapStateToProps(state).genericPoints.length).toEqual(3);
}); });
it("returns sensor readings", () => { it("returns sensor readings", () => {

View File

@ -22,7 +22,6 @@ describe("<ToolSlotLayer/>", () => {
pointer_type: "ToolSlot", pointer_type: "ToolSlot",
tool_id: undefined, tool_id: undefined,
name: "Name", name: "Name",
radius: 50,
x: 1, x: 1,
y: 2, y: 2,
z: 3, z: 3,

View File

@ -7,7 +7,6 @@ import { t } from "../../i18next_wrapper";
import { UUID } from "../../resources/interfaces"; import { UUID } from "../../resources/interfaces";
import { edit, save } from "../../api/crud"; import { edit, save } from "../../api/crud";
import { EditPlantStatusProps } from "./plant_panel"; import { EditPlantStatusProps } from "./plant_panel";
import { PlantPointer } from "farmbot/dist/resources/api_resources";
export const PLANT_STAGE_DDI_LOOKUP = (): { [x: string]: DropDownItem } => ({ export const PLANT_STAGE_DDI_LOOKUP = (): { [x: string]: DropDownItem } => ({
planned: { label: t("Planned"), value: "planned" }, planned: { label: t("Planned"), value: "planned" },
@ -77,8 +76,9 @@ export const PlantStatusBulkUpdate = (props: PlantStatusBulkUpdateProps) =>
const points = props.allPoints.filter(point => const points = props.allPoints.filter(point =>
props.selected.includes(point.uuid) props.selected.includes(point.uuid)
&& point.kind === "Point" && point.kind === "Point"
&& ["Plant", "Weed"].includes(point.body.pointer_type) && (point.body.pointer_type == "Plant"
&& (point.body as unknown as PlantPointer).plant_stage != plant_stage); || point.body.pointer_type == "Weed")
&& point.body.plant_stage != plant_stage);
points.length > 0 && confirm( points.length > 0 && confirm(
t("Change status to '{{ status }}' for {{ num }} items?", t("Change status to '{{ status }}' for {{ num }} items?",
{ status: plant_stage, num: points.length })) { status: plant_stage, num: points.length }))
@ -98,10 +98,6 @@ export interface EditWeedStatusProps {
export const EditWeedStatus = (props: EditWeedStatusProps) => export const EditWeedStatus = (props: EditWeedStatusProps) =>
<FBSelect <FBSelect
list={PLANT_STAGE_LIST().filter(ddi => WEED_STATUSES.includes("" + ddi.value))} list={PLANT_STAGE_LIST().filter(ddi => WEED_STATUSES.includes("" + ddi.value))}
selectedItem={WEED_STAGE_DDI_LOOKUP()[( selectedItem={WEED_STAGE_DDI_LOOKUP()[props.weed.body.plant_stage]}
props.weed.body as unknown as PlantPointer).plant_stage]}
onChange={ddi => onChange={ddi =>
props.updateWeed({ props.updateWeed({ plant_stage: ddi.value as PlantStage })} />;
["plant_stage" as keyof TaggedWeedPointer["body"]]:
ddi.value as PlantStage
})} />;

View File

@ -133,6 +133,7 @@ describe("<CreatePoints />", () => {
meta: { color: "green", created_by: "farm-designer", type: "point" }, meta: { color: "green", created_by: "farm-designer", type: "point" },
name: "Created Point", name: "Created Point",
pointer_type: "GenericPointer", pointer_type: "GenericPointer",
plant_stage: "planned",
radius: 30, x: 10, y: 20, z: 0, radius: 30, x: 10, y: 20, z: 0,
}); });
}); });
@ -146,6 +147,7 @@ describe("<CreatePoints />", () => {
meta: { color: "red", created_by: "farm-designer", type: "weed" }, meta: { color: "red", created_by: "farm-designer", type: "weed" },
name: "Created Weed", name: "Created Weed",
pointer_type: "Weed", pointer_type: "Weed",
plant_stage: "planned",
radius: 30, x: 10, y: 20, z: 0, radius: 30, x: 10, y: 20, z: 0,
}); });
}); });

View File

@ -69,9 +69,8 @@ describe("mapStateToProps()", () => {
const state = fakeState(); const state = fakeState();
const point = fakePoint(); const point = fakePoint();
const discarded = fakePoint(); const discarded = fakePoint();
discarded.body.discarded_at = "2016-05-22T05:00:00.000Z";
state.resources = buildResourceIndex([point, discarded]); state.resources = buildResourceIndex([point, discarded]);
const props = mapStateToProps(state); const props = mapStateToProps(state);
expect(props.genericPoints).toEqual([point]); expect(props.genericPoints).toEqual([point, discarded]);
}); });
}); });

View File

@ -183,6 +183,7 @@ export class RawCreatePoints
x: this.attr("cx"), x: this.attr("cx"),
y: this.attr("cy"), y: this.attr("cy"),
z: 0, z: 0,
plant_stage: "planned",
radius: this.attr("r"), radius: this.attr("r"),
}; };
this.props.dispatch(initSave("Point", body)); this.props.dispatch(initSave("Point", body));

View File

@ -29,7 +29,7 @@ export function mapStateToProps(props: Everything): PointsProps {
const { hoveredPoint } = props.resources.consumers.farm_designer; const { hoveredPoint } = props.resources.consumers.farm_designer;
return { return {
genericPoints: selectAllGenericPointers(props.resources.index) genericPoints: selectAllGenericPointers(props.resources.index)
.filter(x => !x.body.discarded_at), .filter(x => x),
dispatch: props.dispatch, dispatch: props.dispatch,
hoveredPoint, hoveredPoint,
}; };

View File

@ -57,7 +57,7 @@ export function mapStateToProps(props: Everything): Props {
const allGenericPoints = selectAllGenericPointers(props.resources.index); const allGenericPoints = selectAllGenericPointers(props.resources.index);
const genericPoints = getConfigValue(BooleanSetting.show_historic_points) const genericPoints = getConfigValue(BooleanSetting.show_historic_points)
? allGenericPoints ? allGenericPoints
: allGenericPoints.filter(x => !x.body.discarded_at); : allGenericPoints.filter(x => x);
const weeds = selectAllWeedPointers(props.resources.index); const weeds = selectAllWeedPointers(props.resources.index);
const fwConfig = validFwConfig(getFirmwareConfig(props.resources.index)); const fwConfig = validFwConfig(getFirmwareConfig(props.resources.index));

View File

@ -43,7 +43,7 @@ describe("<AddToolSlot />", () => {
"direction", "gantry-mounted", "direction", "gantry-mounted",
].map(string => expect(wrapper.text().toLowerCase()).toContain(string)); ].map(string => expect(wrapper.text().toLowerCase()).toContain(string));
expect(init).toHaveBeenCalledWith("Point", { expect(init).toHaveBeenCalledWith("Point", {
pointer_type: "ToolSlot", name: "Slot", radius: 0, meta: {}, pointer_type: "ToolSlot", name: "Slot", meta: {},
x: 0, y: 0, z: 0, tool_id: undefined, x: 0, y: 0, z: 0, tool_id: undefined,
pullout_direction: ToolPulloutDirection.NONE, pullout_direction: ToolPulloutDirection.NONE,
gantry_mounted: false, gantry_mounted: false,
@ -119,7 +119,7 @@ describe("<AddToolSlot />", () => {
const wrapper = mount(<AddToolSlot {...p} />); const wrapper = mount(<AddToolSlot {...p} />);
expect(wrapper.text().toLowerCase()).not.toContain("tool"); expect(wrapper.text().toLowerCase()).not.toContain("tool");
expect(init).toHaveBeenCalledWith("Point", { expect(init).toHaveBeenCalledWith("Point", {
pointer_type: "ToolSlot", name: "Slot", radius: 0, meta: {}, pointer_type: "ToolSlot", name: "Slot", meta: {},
x: 0, y: 0, z: 0, tool_id: undefined, x: 0, y: 0, z: 0, tool_id: undefined,
pullout_direction: ToolPulloutDirection.NONE, pullout_direction: ToolPulloutDirection.NONE,
gantry_mounted: true, gantry_mounted: true,

View File

@ -21,7 +21,7 @@ export class RawAddToolSlot
componentDidMount() { componentDidMount() {
const action = init("Point", { const action = init("Point", {
pointer_type: "ToolSlot", name: t("Slot"), radius: 0, meta: {}, pointer_type: "ToolSlot", name: t("Slot"), meta: {},
x: 0, y: 0, z: 0, tool_id: undefined, x: 0, y: 0, z: 0, tool_id: undefined,
pullout_direction: ToolPulloutDirection.NONE, pullout_direction: ToolPulloutDirection.NONE,
gantry_mounted: !hasUTM(this.props.firmwareHardware) ? true : false, gantry_mounted: !hasUTM(this.props.firmwareHardware) ? true : false,

View File

@ -28,7 +28,6 @@ const fakeSlot: TaggedToolSlotPointer = arrayUnwrap(newTaggedResource("Point",
{ {
tool_id: TOOL_ID, tool_id: TOOL_ID,
pointer_type: "ToolSlot", pointer_type: "ToolSlot",
radius: 0,
x: 0, x: 0,
y: 0, y: 0,
z: 0, z: 0,

View File

@ -79,7 +79,7 @@ export const selectAllPoints =
export const selectAllPointGroups = export const selectAllPointGroups =
(i: ResourceIndex) => findAll<TaggedPointGroup>(i, "PointGroup"); (i: ResourceIndex) => findAll<TaggedPointGroup>(i, "PointGroup");
export const selectAllActivePoints = (input: ResourceIndex) => export const selectAllActivePoints = (input: ResourceIndex) =>
selectAllPoints(input).filter(x => !x.body.discarded_at); selectAllPoints(input).filter(x => x);
export const selectAllFarmwareEnvs = export const selectAllFarmwareEnvs =
(i: ResourceIndex) => findAll<TaggedFarmwareEnv>(i, "FarmwareEnv"); (i: ResourceIndex) => findAll<TaggedFarmwareEnv>(i, "FarmwareEnv");

View File

@ -32,7 +32,6 @@ export function fakeResourceIndex(extra: TaggedResource[] = []): ResourceIndex {
"meta": {}, "meta": {},
"name": "ToolSlot 1", "name": "ToolSlot 1",
"pointer_type": "ToolSlot", "pointer_type": "ToolSlot",
"radius": 100,
"x": 100, "x": 100,
"y": 200, "y": 200,
"z": 300, "z": 300,

View File

@ -59,8 +59,8 @@ const TOOL_SLOT_FIELDS: ToolSlotFields = (BASE_FIELDS as ToolSlotFields)
.concat(["tool_id", "pullout_direction", "gantry_mounted"]); .concat(["tool_id", "pullout_direction", "gantry_mounted"]);
const GENERIC_POINTER_FIELDS: GenericPointerFields = const GENERIC_POINTER_FIELDS: GenericPointerFields =
(BASE_FIELDS as GenericPointerFields).concat(["radius"]); (BASE_FIELDS as GenericPointerFields).concat(["radius"]);
const WEED_FIELDS: WeedFields = (BASE_FIELDS as PlantFields) const WEED_FIELDS: WeedFields = (BASE_FIELDS as WeedFields)
.concat(["plant_stage", "radius"]) as WeedFields; .concat(["plant_stage", "radius"]);
const POINT_FIELDS: PointFields = (BASE_FIELDS as PointFields) const POINT_FIELDS: PointFields = (BASE_FIELDS as PointFields)
.concat(PLANT_FIELDS) .concat(PLANT_FIELDS)
.concat(TOOL_SLOT_FIELDS) .concat(TOOL_SLOT_FIELDS)

View File

@ -2,13 +2,6 @@ module.exports = {
"clearMocks": true, "clearMocks": true,
"logHeapUsage": true, "logHeapUsage": true,
"globals": { "globals": {
"ts-jest": {
"diagnostics": {
"ignoreCodes": [
151001
]
}
},
"globalConfig": { "globalConfig": {
"NODE_ENV": "development", "NODE_ENV": "development",
"TOS_URL": "https://farm.bot/tos/", "TOS_URL": "https://farm.bot/tos/",

View File

@ -45,7 +45,7 @@
"coveralls": "3.1.0", "coveralls": "3.1.0",
"enzyme": "3.11.0", "enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.2", "enzyme-adapter-react-16": "1.15.2",
"farmbot": "10.0.0-rc1", "farmbot": "10.0.0-rc2",
"i18next": "19.4.4", "i18next": "19.4.4",
"install": "0.13.0", "install": "0.13.0",
"lodash": "4.17.15", "lodash": "4.17.15",
@ -53,7 +53,7 @@
"markdown-it-emoji": "1.4.0", "markdown-it-emoji": "1.4.0",
"moment": "2.25.3", "moment": "2.25.3",
"moxios": "0.4.0", "moxios": "0.4.0",
"mqtt": "4.0.0", "mqtt": "4.0.1",
"npm": "6.14.5", "npm": "6.14.5",
"parcel-bundler": "1.12.4", "parcel-bundler": "1.12.4",
"promise-timeout": "1.3.0", "promise-timeout": "1.3.0",
@ -83,7 +83,7 @@
"jest-junit": "10.0.0", "jest-junit": "10.0.0",
"jest-skipped-reporter": "0.0.5", "jest-skipped-reporter": "0.0.5",
"jshint": "2.11.0", "jshint": "2.11.0",
"madge": "3.8.0", "madge": "3.9.0",
"sass": "1.26.5" "sass": "1.26.5"
} }
} }