Skip to content

Commit

Permalink
pinned sequence ui updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielburnworth committed Jan 12, 2021
1 parent 1c4d62b commit fc5565a
Show file tree
Hide file tree
Showing 28 changed files with 208 additions and 68 deletions.
6 changes: 5 additions & 1 deletion app/mutations/devices/seeders/sequence_fixtures.yml
Expand Up @@ -13,6 +13,7 @@
:args:
:tool_id: 0
:color: gray
:pinned: true
:name: Mount tool
:body:
- :kind: find_home
Expand Down Expand Up @@ -207,7 +208,8 @@
:x: 0
:y: 0
:z: 0
:color: gray
:color: pink
:pinned: true
:name: Take photo of plant
:body:
- :kind: move
Expand Down Expand Up @@ -263,6 +265,7 @@
:y: 0
:x: 0
:color: blue
:pinned: true
:name: Water plant
:body:
- :kind: move
Expand Down Expand Up @@ -740,6 +743,7 @@
:args:
:tool_id: 0
:color: gray
:pinned: true
:name: Unmount tool
:body:
- :kind: find_home
Expand Down
6 changes: 6 additions & 0 deletions frontend/constants.ts
Expand Up @@ -395,6 +395,9 @@ export namespace ToolTips {
If the sequence is ever run without the variable explicitly set to
another value, the default value will be used.`);

export const USING_DEFAULT_VARIABLE_VALUE =
trim(`No location selected. Using default value.`);

export const COMPUTED_MOVE =
trim(`The Move step instructs FarmBot to move to the specified
coordinate or distance from its current location.`);
Expand Down Expand Up @@ -979,6 +982,9 @@ export namespace Content {
export const INCLUDES_DEPRECATED_STEPS =
trim(`This sequence includes deprecated steps.`);

export const IS_PINNED =
trim(`This sequence is pinned.`);

// Regimens
export const NO_REGIMEN_SELECTED =
trim(`Click one in the Regimens panel to edit, or click "+" to create
Expand Down
3 changes: 3 additions & 0 deletions frontend/css/farm_designer/farm_designer_panels.scss
Expand Up @@ -2070,6 +2070,9 @@
@media screen and (max-width: 767px) {
padding: 0;
}
.fa-thumb-tack {
margin-left: -0.75rem;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions frontend/css/global.scss
Expand Up @@ -1920,6 +1920,7 @@ ul {
}

textarea {
width: 100%;
border: 0;
padding: 6px 8px;
box-shadow: 0 0 10px #ddd;
Expand Down
22 changes: 20 additions & 2 deletions frontend/css/sequences.scss
Expand Up @@ -19,7 +19,6 @@
overflow: hidden;
.bp3-popover-target .saucer {
float: left;
margin-top: 0.4rem;
}
@media screen and (max-width: 767px) {
h3,
Expand Down Expand Up @@ -104,6 +103,15 @@
overflow-y: auto;
overflow-x: hidden;
}
.fa-thumb-tack {
color: $placeholder_gray;
line-height: 3rem;
transform: rotate(45deg);
&.pinned {
transform: rotate(0deg);
color: $dark_gray;
}
}
}

.locals-list {
Expand All @@ -120,11 +128,17 @@
width: 100%;
background: darken($off_white, 5%);
padding: 1rem;
i {
.fa-caret-down,
.fa-caret-up {
float: right;
font-size: 2rem;
color: $dark_gray;
}
.bp3-popover-wrapper {
display: inline;
margin-left: 1rem;
font-size: 1.2rem;
}
}
>.location-form-content {
padding: 1rem;
Expand Down Expand Up @@ -421,6 +435,10 @@
width: 2rem;
color: $orange;
}
.fa-thumb-tack {
margin-right: 3rem;
width: 2rem;
}
}
button {
margin-left: 0.5rem;
Expand Down
19 changes: 18 additions & 1 deletion frontend/css/steps.scss
Expand Up @@ -51,6 +51,10 @@
padding: .75rem 1rem;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
&.pinned.no-inputs {
border-radius: 3px;
}
margin-bottom: -1px;
.bp3-popover-wrapper {
float: right;
margin-top: 0.1rem;
Expand Down Expand Up @@ -206,10 +210,20 @@
font-size: 2rem;
}

.step-control-icons i,
.step-control-icons .bp3-popover-wrapper,
.step-control {
margin-top: 0.3rem;
width: 1.2rem;
margin-top: 0.5rem;
margin-left: 2rem;
float: right;
.bp3-popover-target {
display: block;
margin-top: -0.5rem;
}
&.fa-external-link {
padding-top: 0.2rem;
}
}

.step-content {
Expand Down Expand Up @@ -292,6 +306,9 @@
}
}
}
&:empty {
display: none;
}
}
&.execute-script-step {
background: $light_magenta;
Expand Down
1 change: 1 addition & 0 deletions frontend/devices/interfaces.ts
Expand Up @@ -43,6 +43,7 @@ export enum Feature {
groups = "groups",
jest_feature = "jest_feature",
long_scaling_factor = "long_scaling_factor",
lua_step = "lua_step",
mark_as_step = "mark_as_step",
named_pins = "named_pins",
no_firmware_logs = "no_firmware_logs",
Expand Down
10 changes: 10 additions & 0 deletions frontend/folders/__tests__/component_test.tsx
Expand Up @@ -302,6 +302,16 @@ describe("<FolderListItem />", () => {
expect(wrapper.find(".fa-exclamation-triangle").length).toEqual(1);
});

it("renders: in use and pinned", () => {
const p = fakeProps();
p.inUse = true;
p.sequence.body.pinned = true;
const wrapper = mount(<FolderListItem {...p} />);
expect(wrapper.find(".in-use").length).toEqual(1);
expect(wrapper.find(".in-use").hasClass("two")).toBeTruthy();
expect(wrapper.find(".fa-thumb-tack").length).toEqual(1);
});

it("changes color", () => {
const p = fakeProps();
p.sequence.body.id = undefined;
Expand Down
5 changes: 4 additions & 1 deletion frontend/folders/component.tsx
Expand Up @@ -61,6 +61,7 @@ export const FolderListItem = (props: FolderItemProps) => {
const active = lastUrlChunk() === urlFriendly(seqName) ? "active" : "";
const deprecatedSteps = JSON.stringify(props.sequence.body.body)
.includes("resource_update");
const two = props.sequence.body.pinned || deprecatedSteps;
return <StepDragger
dispatch={props.dispatch}
step={{
Expand All @@ -81,10 +82,12 @@ export const FolderListItem = (props: FolderItemProps) => {
</Link>
<div className="sequence-list-item-icons">
{props.inUse &&
<i className={`in-use fa fa-hdd-o ${deprecatedSteps ? "two" : ""}`}
<i className={`in-use fa fa-hdd-o ${two ? "two" : ""}`}
title={t(Content.IN_USE)} />}
{deprecatedSteps && <i className="fa fa-exclamation-triangle"
title={t(Content.INCLUDES_DEPRECATED_STEPS)} />}
{props.sequence.body.pinned &&
<i className={"fa fa-thumb-tack"} title={t(Content.IS_PINNED)} />}
<i className="fa fa-arrows-v"
onMouseDown={() => props.startSequenceMove(sequence.uuid)}
onMouseUp={() => props.toggleSequenceMove(sequence.uuid)} />
Expand Down
23 changes: 12 additions & 11 deletions frontend/resources/sequence_meta.ts
Expand Up @@ -28,7 +28,7 @@ export interface SequenceMeta {
celeryNode: VariableNode;
dropdown: DropDownItem;
vector: Vector3 | Vector3Plus | undefined;
default?: boolean;
isDefault?: boolean;
}

/** Converts a "scope declaration body item" (AKA a CeleryScript variable) into
Expand Down Expand Up @@ -146,16 +146,17 @@ export const determineEditable = (node: VariableNode): boolean => {
export const createSequenceMeta =
(resources: ResourceIndex, sequence: TaggedSequence): VariableNameSet => {
const collection = sequence.body.args.locals.body || [];
const reducer = (acc: VariableNameSet, celeryNode: ScopeDeclarationBodyItem):
VariableNameSet =>
({
...acc,
[celeryNode.args.label]: {
celeryNode,
vector: determineVector(celeryNode, resources, sequence.uuid),
dropdown: determineDropdown(celeryNode, resources, sequence.uuid),
}
});
const reducer = (
acc: VariableNameSet,
celeryNode: ScopeDeclarationBodyItem,
): VariableNameSet => ({
...acc,
[celeryNode.args.label]: {
celeryNode,
vector: determineVector(celeryNode, resources, sequence.uuid),
dropdown: determineDropdown(celeryNode, resources, sequence.uuid),
}
});
return collection.reduce(reducer, {});
};

Expand Down
Expand Up @@ -256,7 +256,7 @@ describe("<SequenceEditorMiddleActive />", () => {
const p = fakeProps();
p.visualized = true;
const wrapper = mount(<SequenceEditorMiddleActive {...p} />);
wrapper.find(".fb-button.gray").at(1).simulate("click");
wrapper.find(".fb-button.gray").at(0).simulate("click");
expect(p.dispatch).toHaveBeenCalledWith({
type: Actions.VISUALIZE_SEQUENCE,
payload: undefined,
Expand All @@ -268,7 +268,7 @@ describe("<SequenceEditorMiddleActive />", () => {
const p = fakeProps();
p.sequence.body.pinned = false;
const wrapper = mount(<SequenceEditorMiddleActive {...p} />);
wrapper.find(".fb-button.gray").at(0).simulate("click");
wrapper.find(".fa-thumb-tack").simulate("click");
expect(pinSequenceToggle).toHaveBeenCalledWith(p.sequence);
});

Expand All @@ -277,7 +277,7 @@ describe("<SequenceEditorMiddleActive />", () => {
const p = fakeProps();
p.sequence.body.pinned = true;
const wrapper = mount(<SequenceEditorMiddleActive {...p} />);
wrapper.find(".fb-button.blue").at(0).simulate("click");
wrapper.find(".fa-thumb-tack").simulate("click");
expect(pinSequenceToggle).toHaveBeenCalledWith(p.sequence);
});
});
Expand Down
4 changes: 3 additions & 1 deletion frontend/sequences/__tests__/step_button_cluster_test.tsx
Expand Up @@ -12,6 +12,7 @@ import { push } from "../../history";
import { fakeSequence } from "../../__test_support__/fake_state/resources";
import { fakeFarmwareData } from "../../__test_support__/fake_sequence_step_data";
import { FarmwareName } from "../step_tiles/tile_execute_script";
import { buildResourceIndex } from "../../__test_support__/resource_index_builder";

describe("<StepButtonCluster />", () => {
const commands = ["move to", "move relative",
Expand All @@ -25,6 +26,7 @@ describe("<StepButtonCluster />", () => {
shouldDisplay: () => false,
stepIndex: undefined,
sequences: [],
resources: buildResourceIndex().index,
farmwareData: fakeFarmwareData(),
});

Expand All @@ -48,7 +50,7 @@ describe("<StepButtonCluster />", () => {
const p = fakeProps();
const wrapper = mount(<StepButtonCluster {...p} />);
const steps = wrapper.find(".step-dragger");
const stepButton = steps.at(steps.length - 3);
const stepButton = steps.at(steps.length - 2);
expect(stepButton.text().toLowerCase()).toEqual("take photo");
stepButton.simulate("dragStart", { dataTransfer: { setData: jest.fn() } });
expect(p.dispatch).toHaveBeenCalledWith(expect.objectContaining({
Expand Down
16 changes: 16 additions & 0 deletions frontend/sequences/__tests__/step_icon_group_test.tsx
Expand Up @@ -4,18 +4,26 @@ jest.mock("../step_tiles", () => ({
move: jest.fn(),
}));

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

import React from "react";
import { mount, shallow } from "enzyme";
import { StepIconGroup, StepIconBarProps } from "../step_icon_group";
import { fakeSequence } from "../../__test_support__/fake_state/resources";
import { splice, remove, move } from "../step_tiles";
import { push } from "../../history";

describe("<StepIconGroup />", () => {
const fakeProps = (): StepIconBarProps => ({
index: 0,
dispatch: jest.fn(),
step: { kind: "wait", args: { milliseconds: 100 } },
sequence: fakeSequence(),
executeSequenceName: undefined,
helpText: "helpful text",
confirmStepDeletion: false,
});
Expand Down Expand Up @@ -50,4 +58,12 @@ describe("<StepIconGroup />", () => {
step: fakeProps().step
}));
});

it("navigates to sequence", () => {
const p = fakeProps();
p.executeSequenceName = "My Sequence";
const wrapper = mount(<StepIconGroup {...p} />);
wrapper.find(".fa-external-link").simulate("click");
expect(push).toHaveBeenCalledWith("/app/sequences/my_sequence");
});
});
Expand Up @@ -60,6 +60,7 @@ describe("<LocationForm/>", () => {
dropdown
}));
expect(inputs.length).toBe(0);
expect(el.html()).not.toContain("fa-exclamation-triangle");
});

it("uses body variable data", () => {
Expand Down Expand Up @@ -148,4 +149,11 @@ describe("<LocationForm/>", () => {
const wrapper = shallow(<LocationForm {...p} />);
expect(wrapper.html()).toContain("fa-caret-down");
});

it("renders default value warning", () => {
const p = fakeProps();
p.variable.isDefault = true;
const wrapper = shallow(<LocationForm {...p} />);
expect(wrapper.html()).toContain("fa-exclamation-triangle");
});
});
2 changes: 1 addition & 1 deletion frontend/sequences/locals_list/locals_list.tsx
Expand Up @@ -82,6 +82,6 @@ const convertFormVariable =
celeryNode: converted,
dropdown: determineDropdown(converted, resources),
vector: determineVector(converted, resources),
default: true,
isDefault: true,
};
};

0 comments on commit fc5565a

Please sign in to comment.