Skip to content

Commit

Permalink
Merge pull request #2362 from FarmBot/staging
Browse files Browse the repository at this point in the history
v15.4.1
  • Loading branch information
gabrielburnworth authored Jul 14, 2022
2 parents c15a98d + 5d02670 commit 9dac273
Show file tree
Hide file tree
Showing 36 changed files with 295 additions and 328 deletions.
22 changes: 11 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ GEM
faraday (~> 1.0)
globalid (1.0.0)
activesupport (>= 5.0)
google-apis-core (0.6.0)
google-apis-core (0.7.0)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
Expand All @@ -156,17 +156,17 @@ GEM
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-iamcredentials_v1 (0.12.0)
google-apis-core (>= 0.6, < 2.a)
google-apis-storage_v1 (0.16.0)
google-apis-core (>= 0.6, < 2.a)
google-apis-iamcredentials_v1 (0.13.0)
google-apis-core (>= 0.7, < 2.a)
google-apis-storage_v1 (0.18.0)
google-apis-core (>= 0.7, < 2.a)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.2.0)
google-cloud-storage (1.36.2)
google-cloud-storage (1.37.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
Expand All @@ -184,7 +184,7 @@ GEM
hashdiff (1.0.1)
hashie (4.1.0)
httpclient (2.8.3)
i18n (1.10.0)
i18n (1.11.0)
concurrent-ruby (~> 1.0)
jsonapi-renderer (0.2.2)
jwt (2.4.1)
Expand Down Expand Up @@ -214,13 +214,13 @@ GEM
memoist (0.16.2)
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.16.1)
minitest (5.16.2)
multi_json (1.15.0)
multipart-post (2.2.3)
mutations (0.9.1)
activesupport
nio4r (2.5.8)
nokogiri (1.13.6-x86_64-linux)
nokogiri (1.13.7-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
os (1.1.4)
Expand All @@ -241,7 +241,7 @@ GEM
hashie (~> 4.1)
multi_json (~> 1.15)
racc (1.6.0)
rack (2.2.3.1)
rack (2.2.4)
rack-attack (6.6.1)
rack (>= 1.0, < 3)
rack-cors (1.1.1)
Expand Down Expand Up @@ -281,7 +281,7 @@ GEM
thor (~> 1.0)
rake (13.0.6)
rbtree (0.4.5)
redis (4.7.0)
redis (4.7.1)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
Expand Down
14 changes: 5 additions & 9 deletions frontend/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ export namespace ToolTips {
every time, so the ordering shown below will only be representative.`);

export const CRITERIA_SELECTION_COUNT =
trim(`Filter additions can only be removed by changing filters.
Click and drag in the map to modify selection filters.
Filters will be applied at the time of sequence execution. The final
selection at that time may differ from the selection currently
displayed.`);
trim(`Manually add group members by clicking in the map. Group members
selected by filters can only be removed by changing the filters.
Filters will be applied at the time of sequence execution.
Group members at that time may differ from those currently displayed.`);

export const DOT_NOTATION_TIP =
trim(`Tip: Use dot notation (i.e., 'meta.color') to access meta fields.`);
Expand Down Expand Up @@ -1870,16 +1869,13 @@ export enum DeviceSetting {
osAutoUpdate = `auto update`,
farmbotOS = `Farmbot OS`,
bootSequence = `Boot Sequence`,

// Firmware
firmwareSection = `Firmware`,
firmware = `Firmware`,
firmwarePath = `Firmware path`,
restartFirmware = `Restart Firmware`,
flashFirmware = `Flash firmware`,

// Power and Reset
powerAndReset = `Power and Reset`,
restartFirmware = `Restart Firmware`,
restartFarmbot = `Restart Farmbot`,
shutdownFarmbot = `Shutdown Farmbot`,
softReset = `Soft Reset`,
Expand Down
20 changes: 19 additions & 1 deletion frontend/css/farm_designer/farm_designer_panels.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,20 @@ li {
}

.group-detail-panel {
.panel-header-icon-group {
display: flex;
float: right;
padding: 1.5rem;
.fa-sort {
margin-top: 0.25rem;
color: $white;
}
.fa-trash {
margin-top: 0.25rem;
margin-left: 2rem;
color: $white;
}
}
.panel-content {
max-height: calc(100vh - 14rem);
overflow-y: auto;
Expand Down Expand Up @@ -1915,6 +1929,7 @@ li {
.lt-gt-criteria,
.location-criteria {
display: inline-block;
position: relative;
.row {
margin-left: 0;
margin-right: -2.5rem;
Expand All @@ -1937,7 +1952,9 @@ li {
margin-top: 2rem !important;
}
.edit-in-map {
float: right;
position: absolute;
top: 0;
right: 0;
button {
margin: 1rem !important;
width: 5rem !important;
Expand Down Expand Up @@ -2440,6 +2457,7 @@ li {
}
}

.group-detail-panel,
.designer-regimen-editor-panel,
.designer-sequence-editor-panel {
.panel-header {
Expand Down
4 changes: 2 additions & 2 deletions frontend/point_groups/__tests__/actions_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("createGroup()", () => {
expect(init).toHaveBeenCalledWith("PointGroup", expect.objectContaining({
name: "Name123",
point_ids: [1, 2],
sort_type: "xy_ascending",
sort_type: "nn",
criteria: DEFAULT_CRITERIA,
}));
expect(save).toHaveBeenCalledWith("???");
Expand All @@ -62,7 +62,7 @@ describe("createGroup()", () => {
expect(init).toHaveBeenCalledWith("PointGroup", expect.objectContaining({
name: "Untitled Group",
point_ids: [4],
sort_type: "xy_ascending",
sort_type: "nn",
criteria: DEFAULT_CRITERIA,
}));
expect(save).toHaveBeenCalledWith("???");
Expand Down
77 changes: 20 additions & 57 deletions frontend/point_groups/__tests__/group_detail_active_test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
jest.mock("../../api/crud", () => ({
save: jest.fn(),
overwrite: jest.fn(),
edit: jest.fn(),
}));

jest.mock("../../farm_designer/map/actions", () => ({
setHoveredPlant: jest.fn(),
}));
Expand All @@ -15,26 +9,25 @@ jest.mock("../../plants/select_plants", () => ({
}));

jest.mock("../../ui/help", () => ({
Help: jest.fn(props => <p>{props.text}</p>),
Help: jest.fn(props => <p>{props.text}{props.customIcon}</p>),
}));

import React from "react";
import {
GroupDetailActive, GroupDetailActiveProps,
GroupDetailActive, GroupDetailActiveProps, GroupSortSelection,
GroupSortSelectionProps,
} from "../group_detail_active";
import { mount, shallow } from "enzyme";
import { mount } from "enzyme";
import {
fakePointGroup, fakePlant, fakePoint,
} from "../../__test_support__/fake_state/resources";
import { edit } from "../../api/crud";
import { SpecialStatus } from "farmbot";
import { DEFAULT_CRITERIA } from "../criteria/interfaces";
import { setSelectionPointType } from "../../plants/select_plants";
import { fakeToolTransformProps } from "../../__test_support__/fake_tool_info";
import { ToolTips } from "../../constants";
import { cloneDeep } from "lodash";

describe("<GroupDetailActive/>", () => {
describe("<GroupDetailActive />", () => {
const fakeProps = (): GroupDetailActiveProps => {
const plant = fakePlant();
plant.body.id = 1;
Expand Down Expand Up @@ -73,7 +66,6 @@ describe("<GroupDetailActive/>", () => {
const p = fakeProps();
p.group.specialStatus = SpecialStatus.SAVED;
const wrapper = mount(<GroupDetailActive {...p} />);
expect(wrapper.find("input").first().prop("defaultValue")).toContain("XYZ");
expect(wrapper.find(".group-member-display").length).toEqual(1);
});

Expand All @@ -85,58 +77,29 @@ describe("<GroupDetailActive/>", () => {
expect(setSelectionPointType).toHaveBeenCalledWith(undefined);
});

it("changes group name", () => {
const p = fakeProps();
const parentWrapper = shallow(<GroupDetailActive {...p} />);
const wrapper = shallow(parentWrapper.find("GroupNameInput").getElement());
wrapper.find("input").first().simulate("blur", {
currentTarget: { value: "new group name" }
});
expect(edit).toHaveBeenCalledWith(p.group, { name: "new group name" });
});

it("doesn't change group name", () => {
const p = fakeProps();
const parentWrapper = shallow(<GroupDetailActive {...p} />);
const wrapper = shallow(parentWrapper.find("GroupNameInput").getElement());
wrapper.find("input").first().simulate("blur", {
currentTarget: { value: "" }
});
expect(edit).not.toHaveBeenCalled();
});

it("shows paths", () => {
const p = fakeProps();
const wrapper = mount(<GroupDetailActive {...p} />);
expect(wrapper.text().toLowerCase()).toContain("0m");
});

it("shows random warning text", () => {
const p = fakeProps();
p.group.body.sort_type = "random";
const wrapper = mount(<GroupDetailActive {...p} />);
expect(wrapper.text()).toContain(ToolTips.SORT_DESCRIPTION);
});

it("doesn't show icons", () => {
const wrapper = mount(<GroupDetailActive {...fakeProps()} />);
wrapper.setState({ iconDisplay: false });
expect(wrapper.find(".groups-list-wrapper").length).toEqual(0);
});
});

describe("<GroupSortSelection />", () => {
const fakeProps = (): GroupSortSelectionProps => ({
group: fakePointGroup(),
dispatch: jest.fn(),
pointsSelectedByGroup: [fakePoint()],
});

it("doesn't show filters tooltip addition", () => {
const wrapper = mount(<GroupDetailActive {...fakeProps()} />);
expect(wrapper.text()).not.toContain(ToolTips.CRITERIA_SELECTION_COUNT);
it("renders", () => {
const wrapper = mount(<GroupSortSelection {...fakeProps()} />);
expect(wrapper.text().toLowerCase()).toContain("ascending");
});

it("shows filters tooltip addition", () => {
it("renders random notice", () => {
const p = fakeProps();
const point = fakePoint();
point.body.x = 0;
p.allPoints = [point];
p.group.body.point_ids = [];
p.group.body.criteria.number_eq = { x: [0] };
const wrapper = mount(<GroupDetailActive {...p} />);
expect(wrapper.text()).toContain(ToolTips.CRITERIA_SELECTION_COUNT);
p.group.body.sort_type = "random";
const wrapper = mount(<GroupSortSelection {...p} />);
expect(wrapper.html()).toContain("exclamation-triangle");
});
});
23 changes: 18 additions & 5 deletions frontend/point_groups/__tests__/group_detail_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ jest.mock("../../history", () => ({

jest.mock("../group_detail_active", () => ({
GroupDetailActive: () => <div />,
GroupSortSelection: () => <div />,
}));

jest.mock("../../api/crud", () => ({
destroy: jest.fn(),
}));

import React from "react";
Expand All @@ -27,6 +32,7 @@ import {
fakePointGroup, fakeWebAppConfig,
} from "../../__test_support__/fake_state/resources";
import { PointType } from "farmbot";
import { destroy } from "../../api/crud";

describe("<GroupDetail />", () => {
const fakeProps = (): GroupDetailProps => {
Expand Down Expand Up @@ -76,16 +82,23 @@ describe("<GroupDetail />", () => {
});

it.each<[string, PointType]>([
["plant", "Plant"],
["weed", "Weed"],
["point", "GenericPointer"],
["slot", "ToolSlot"],
["plants", "Plant"],
["weeds", "Weed"],
["points", "GenericPointer"],
["tools", "ToolSlot"],
])("renders %s group", (title, pointerType) => {
mockPath = Path.mock(Path.groups(1));
const p = fakeProps();
p.group && (p.group.body.criteria.string_eq = { pointer_type: [pointerType] });
const wrapper = mount(<GroupDetail {...p} />);
expect(wrapper.text().toLowerCase()).toContain(`edit ${title} group`);
expect(wrapper.html()).toContain("go back to " + title);
});

it("deletes group", () => {
mockPath = Path.mock(Path.groups(1));
const wrapper = mount(<GroupDetail {...fakeProps()} />);
wrapper.find(".fa-trash").first().simulate("click");
expect(destroy).toHaveBeenCalled();
});
});

Expand Down
2 changes: 1 addition & 1 deletion frontend/point_groups/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const createGroup = (props: CreateGroupProps) =>
const group: PointGroup = {
name: groupName || t("Untitled Group"),
point_ids,
sort_type: "xy_ascending",
sort_type: "nn",
criteria: criteria || DEFAULT_CRITERIA,
};
const action = init("PointGroup", group);
Expand Down
28 changes: 14 additions & 14 deletions frontend/point_groups/criteria/show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,20 @@ export const NumberLtGtInput = (props: NumberLtGtInputProps) => {
export const LocationSelection = (props: LocationSelectionProps) =>
<div className="location-criteria">
<p className={"category"}>{t("Location")}</p>
<div className={"edit-in-map"}>
<ToggleButton
title={props.editGroupAreaInMap
? t("map boxes will change location filter")
: t("map boxes will manually add plants")}
customText={{ textFalse: t("off"), textTrue: t("on") }}
toggleValue={props.editGroupAreaInMap}
toggleAction={() =>
props.dispatch({
type: Actions.EDIT_GROUP_AREA_IN_MAP,
payload: !props.editGroupAreaInMap
})} />
<label>{t("edit in map")}</label>
</div>
<ClearCategory
group={props.group}
criteriaCategories={["number_lt", "number_gt"]}
Expand All @@ -208,18 +222,4 @@ export const LocationSelection = (props: LocationSelectionProps) =>
criteriaKey={axis}
group={props.group}
dispatch={props.dispatch} />)}
<div className={"edit-in-map"}>
<ToggleButton
title={props.editGroupAreaInMap
? t("map boxes will change location filter")
: t("map boxes will manually add plants")}
customText={{ textFalse: t("off"), textTrue: t("on") }}
toggleValue={props.editGroupAreaInMap}
toggleAction={() =>
props.dispatch({
type: Actions.EDIT_GROUP_AREA_IN_MAP,
payload: !props.editGroupAreaInMap
})} />
<label>{t("edit in map")}</label>
</div>
</div>;
Loading

0 comments on commit 9dac273

Please sign in to comment.