Restrict move_abs tool selection to active tools only (#544)
* Debugging webpack config part I
* Debugging webpack config part II
* interim_email claim
* Update `clean` npm task
* ¯\_(ツ)_/¯
* TODO: Move generateList() into mapStateToProps
* 👏 remove deprecated props
* Restrict move_abs to active tools
pull/546/head
parent
0a76331b85
commit
a8773ed475
|
@ -37,6 +37,7 @@ class SessionToken < AbstractJwtToken
|
||||||
mqtt_ws: MQTT_WS,
|
mqtt_ws: MQTT_WS,
|
||||||
os_update_server: OS_RELEASE,
|
os_update_server: OS_RELEASE,
|
||||||
fw_update_server: "DEPRECATED",
|
fw_update_server: "DEPRECATED",
|
||||||
|
interim_email: user.email, # Dont use this for anything ever -RC
|
||||||
bot: "device_#{user.device.id}",
|
bot: "device_#{user.device.id}",
|
||||||
vhost: VHOST }])
|
vhost: VHOST }])
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,9 +18,6 @@ conf.output = {
|
||||||
|
|
||||||
[
|
[
|
||||||
new ExtractTextPlugin({
|
new ExtractTextPlugin({
|
||||||
// Temporary hotfix for some issues on staging.
|
|
||||||
// - RC 12 MAY 17
|
|
||||||
// filename: "dist/styles.css",
|
|
||||||
filename: "dist/[name].[chunkhash].css",
|
filename: "dist/[name].[chunkhash].css",
|
||||||
disable: false,
|
disable: false,
|
||||||
allChunks: true
|
allChunks: true
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"coverage": "cat **/*lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
"coverage": "cat **/*lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
||||||
|
"clean": "rm -rf public/dist && rm -rf public/webpack",
|
||||||
"build": "TARGET=production bundle exec rake webpack:compile",
|
"build": "TARGET=production bundle exec rake webpack:compile",
|
||||||
"start": "echo 'use `rails api:start`'",
|
"start": "echo 'use `rails api:start`'",
|
||||||
"heroku-postbuild": "webpack --config=./config/webpack.prod.js",
|
"heroku-postbuild": "webpack --config=./config/webpack.prod.js",
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"pretty": true
|
"pretty": true,
|
||||||
|
"removeComments": true
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules",
|
"node_modules",
|
||||||
|
|
|
@ -25,11 +25,8 @@ import { fakeSequence } from "../../__test_support__/fake_state/resources";
|
||||||
describe("<SequenceEditorMiddleActive/>", () => {
|
describe("<SequenceEditorMiddleActive/>", () => {
|
||||||
function fakeProps(): ActiveMiddleProps {
|
function fakeProps(): ActiveMiddleProps {
|
||||||
return {
|
return {
|
||||||
slots: [],
|
|
||||||
dispatch: jest.fn(),
|
dispatch: jest.fn(),
|
||||||
sequence: fakeSequence(),
|
sequence: fakeSequence(),
|
||||||
sequences: [],
|
|
||||||
tools: [],
|
|
||||||
resources: buildResourceIndex(FAKE_RESOURCES).index,
|
resources: buildResourceIndex(FAKE_RESOURCES).index,
|
||||||
syncStatus: "synced",
|
syncStatus: "synced",
|
||||||
consistent: true,
|
consistent: true,
|
||||||
|
|
|
@ -8,11 +8,8 @@ import { fakeSequence } from "../../__test_support__/fake_state/resources";
|
||||||
describe("<SequenceEditorMiddle/>", () => {
|
describe("<SequenceEditorMiddle/>", () => {
|
||||||
function fakeProps(): SequenceEditorMiddleProps {
|
function fakeProps(): SequenceEditorMiddleProps {
|
||||||
return {
|
return {
|
||||||
slots: [],
|
|
||||||
dispatch: jest.fn(),
|
dispatch: jest.fn(),
|
||||||
sequence: fakeSequence(),
|
sequence: fakeSequence(),
|
||||||
sequences: [],
|
|
||||||
tools: [],
|
|
||||||
resources: buildResourceIndex(FAKE_RESOURCES).index,
|
resources: buildResourceIndex(FAKE_RESOURCES).index,
|
||||||
syncStatus: "synced",
|
syncStatus: "synced",
|
||||||
consistent: true,
|
consistent: true,
|
||||||
|
|
|
@ -14,11 +14,9 @@ import { ToolTips } from "../../constants";
|
||||||
describe("<Sequences/>", () => {
|
describe("<Sequences/>", () => {
|
||||||
function fakeProps(): Props {
|
function fakeProps(): Props {
|
||||||
return {
|
return {
|
||||||
slots: [],
|
|
||||||
dispatch: jest.fn(),
|
dispatch: jest.fn(),
|
||||||
sequence: fakeSequence(),
|
sequence: fakeSequence(),
|
||||||
sequences: [],
|
sequences: [],
|
||||||
tools: [],
|
|
||||||
resources: buildResourceIndex(FAKE_RESOURCES).index,
|
resources: buildResourceIndex(FAKE_RESOURCES).index,
|
||||||
syncStatus: "synced",
|
syncStatus: "synced",
|
||||||
auth,
|
auth,
|
||||||
|
|
|
@ -8,9 +8,7 @@ import {
|
||||||
} from "farmbot";
|
} from "farmbot";
|
||||||
import { StepMoveDataXfer, StepSpliceDataXfer } from "../draggable/interfaces";
|
import { StepMoveDataXfer, StepSpliceDataXfer } from "../draggable/interfaces";
|
||||||
import {
|
import {
|
||||||
TaggedSequence,
|
TaggedSequence
|
||||||
TaggedTool,
|
|
||||||
TaggedToolSlotPointer
|
|
||||||
} from "../resources/tagged_resources";
|
} from "../resources/tagged_resources";
|
||||||
import { ResourceIndex } from "../resources/interfaces";
|
import { ResourceIndex } from "../resources/interfaces";
|
||||||
import { JSXChildren } from "../util";
|
import { JSXChildren } from "../util";
|
||||||
|
@ -18,8 +16,6 @@ import { JSXChildren } from "../util";
|
||||||
export interface Props {
|
export interface Props {
|
||||||
dispatch: Function;
|
dispatch: Function;
|
||||||
sequences: TaggedSequence[];
|
sequences: TaggedSequence[];
|
||||||
tools: TaggedTool[];
|
|
||||||
slots: TaggedToolSlotPointer[];
|
|
||||||
sequence: TaggedSequence | undefined;
|
sequence: TaggedSequence | undefined;
|
||||||
auth: AuthState | undefined;
|
auth: AuthState | undefined;
|
||||||
resources: ResourceIndex;
|
resources: ResourceIndex;
|
||||||
|
@ -31,12 +27,6 @@ export interface Props {
|
||||||
export interface SequenceEditorMiddleProps {
|
export interface SequenceEditorMiddleProps {
|
||||||
dispatch: Function;
|
dispatch: Function;
|
||||||
sequence: TaggedSequence | undefined;
|
sequence: TaggedSequence | undefined;
|
||||||
/** @deprecated Use props.resources now. */
|
|
||||||
sequences: TaggedSequence[];
|
|
||||||
/** @deprecated Use props.resources now. */
|
|
||||||
tools: TaggedTool[];
|
|
||||||
/** @deprecated Use props.resources now. */
|
|
||||||
slots: TaggedToolSlotPointer[];
|
|
||||||
resources: ResourceIndex;
|
resources: ResourceIndex;
|
||||||
syncStatus: SyncStatus;
|
syncStatus: SyncStatus;
|
||||||
consistent: boolean;
|
consistent: boolean;
|
||||||
|
|
|
@ -10,19 +10,13 @@ export class SequenceEditorMiddle
|
||||||
const {
|
const {
|
||||||
dispatch,
|
dispatch,
|
||||||
sequence,
|
sequence,
|
||||||
sequences,
|
|
||||||
tools,
|
|
||||||
slots,
|
|
||||||
resources,
|
resources,
|
||||||
syncStatus
|
syncStatus
|
||||||
} = this.props;
|
} = this.props;
|
||||||
if (sequence && isTaggedSequence(sequence)) {
|
if (sequence && isTaggedSequence(sequence)) {
|
||||||
return <SequenceEditorMiddleActive
|
return <SequenceEditorMiddleActive
|
||||||
slots={slots}
|
|
||||||
dispatch={dispatch}
|
dispatch={dispatch}
|
||||||
sequence={sequence}
|
sequence={sequence}
|
||||||
sequences={sequences}
|
|
||||||
tools={tools}
|
|
||||||
resources={resources}
|
resources={resources}
|
||||||
syncStatus={syncStatus}
|
syncStatus={syncStatus}
|
||||||
consistent={true}
|
consistent={true}
|
||||||
|
|
|
@ -33,10 +33,7 @@ export class Sequences extends React.Component<Props, {}> {
|
||||||
<SequenceEditorMiddle
|
<SequenceEditorMiddle
|
||||||
syncStatus={this.props.syncStatus}
|
syncStatus={this.props.syncStatus}
|
||||||
dispatch={this.props.dispatch}
|
dispatch={this.props.dispatch}
|
||||||
sequences={this.props.sequences}
|
|
||||||
sequence={this.props.sequence}
|
sequence={this.props.sequence}
|
||||||
slots={this.props.slots}
|
|
||||||
tools={this.props.tools}
|
|
||||||
resources={this.props.resources}
|
resources={this.props.resources}
|
||||||
consistent={this.props.consistent}
|
consistent={this.props.consistent}
|
||||||
autoSyncEnabled={this.props.autoSyncEnabled} />
|
autoSyncEnabled={this.props.autoSyncEnabled} />
|
||||||
|
|
|
@ -2,34 +2,26 @@ import { Everything } from "../interfaces";
|
||||||
import { Props } from "./interfaces";
|
import { Props } from "./interfaces";
|
||||||
import {
|
import {
|
||||||
selectAllSequences,
|
selectAllSequences,
|
||||||
selectAllTools,
|
findSequence
|
||||||
findSequence,
|
|
||||||
selectAllToolSlotPointers
|
|
||||||
} from "../resources/selectors";
|
} from "../resources/selectors";
|
||||||
import { getStepTag } from "../resources/sequence_tagging";
|
import { getStepTag } from "../resources/sequence_tagging";
|
||||||
|
|
||||||
export function mapStateToProps(props: Everything): Props {
|
export function mapStateToProps(props: Everything): Props {
|
||||||
const uuid = props.resources.consumers.sequences.current;
|
const uuid = props.resources.consumers.sequences.current;
|
||||||
const syncStatus =
|
const sequence = uuid ? findSequence(props.resources.index, uuid) : undefined;
|
||||||
props.bot.hardware.informational_settings.sync_status || "unknown";
|
sequence && (sequence.body.body || []).map(x => getStepTag(x));
|
||||||
const sequence =
|
|
||||||
(uuid) ? findSequence(props.resources.index, uuid) : undefined;
|
|
||||||
|
|
||||||
if (sequence) {
|
|
||||||
(sequence.body.body || [])
|
|
||||||
.map(x => {
|
|
||||||
getStepTag(x);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
dispatch: props.dispatch,
|
dispatch: props.dispatch,
|
||||||
sequences: selectAllSequences(props.resources.index),
|
sequences: selectAllSequences(props.resources.index),
|
||||||
tools: selectAllTools(props.resources.index),
|
|
||||||
slots: selectAllToolSlotPointers(props.resources.index),
|
|
||||||
sequence: sequence,
|
sequence: sequence,
|
||||||
auth: props.auth,
|
auth: props.auth,
|
||||||
resources: props.resources.index,
|
resources: props.resources.index,
|
||||||
syncStatus,
|
syncStatus: (props
|
||||||
|
.bot
|
||||||
|
.hardware
|
||||||
|
.informational_settings
|
||||||
|
.sync_status || "unknown"),
|
||||||
consistent: props.bot.consistent,
|
consistent: props.bot.consistent,
|
||||||
autoSyncEnabled: !!props.bot.hardware.configuration.auto_sync
|
autoSyncEnabled: !!props.bot.hardware.configuration.auto_sync
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,25 +1,34 @@
|
||||||
import { ResourceIndex } from "../../../resources/interfaces";
|
import { ResourceIndex } from "../../../resources/interfaces";
|
||||||
import {
|
import {
|
||||||
selectAllPoints,
|
selectAllPoints,
|
||||||
selectAllTools,
|
mapToolIdToName,
|
||||||
mapToolIdToName
|
selectAllToolSlotPointers
|
||||||
} from "../../../resources/selectors";
|
} from "../../../resources/selectors";
|
||||||
import { CowardlyDictionary } from "../../../util";
|
import { CowardlyDictionary, betterCompact } from "../../../util";
|
||||||
import { PointerTypeName } from "../../../interfaces";
|
import { PointerTypeName } from "../../../interfaces";
|
||||||
import { PointerType, TaggedTool } from "../../../resources/tagged_resources";
|
import { PointerType, TaggedTool } from "../../../resources/tagged_resources";
|
||||||
import { DropDownItem } from "../../../ui/index";
|
import { DropDownItem } from "../../../ui/index";
|
||||||
import { Vector3 } from "farmbot/dist";
|
import { Vector3 } from "farmbot/dist";
|
||||||
import { TOOL } from "./interfaces";
|
import { TOOL } from "./interfaces";
|
||||||
import * as _ from "lodash";
|
import * as _ from "lodash";
|
||||||
|
import { joinKindAndId } from "../../../resources/reducer";
|
||||||
|
|
||||||
|
export function activeTools(resources: ResourceIndex) {
|
||||||
|
const Tool: TaggedTool["kind"] = "Tool";
|
||||||
|
const slots = selectAllToolSlotPointers(resources);
|
||||||
|
|
||||||
|
const { byKindAndId, references } = resources;
|
||||||
|
return betterCompact(slots
|
||||||
|
.map(x => references[byKindAndId[joinKindAndId(Tool, x.body.tool_id)] || ""])
|
||||||
|
.map(tool => (tool && tool.kind === "Tool") ? tool : undefined));
|
||||||
|
}
|
||||||
|
|
||||||
export function generateList(input: ResourceIndex): DropDownItem[] {
|
export function generateList(input: ResourceIndex): DropDownItem[] {
|
||||||
const toolNameById = mapToolIdToName(input);
|
const toolNameById = mapToolIdToName(input);
|
||||||
const SORT_KEY: keyof DropDownItem = "headingId";
|
const SORT_KEY: keyof DropDownItem = "headingId";
|
||||||
const points = selectAllPoints(input)
|
const points = selectAllPoints(input)
|
||||||
.filter(x => (x.body.pointer_type !== "ToolSlot"));
|
.filter(x => (x.body.pointer_type !== "ToolSlot"));
|
||||||
const toolDDI: DropDownItem[] = selectAllTools(input)
|
const toolDDI: DropDownItem[] = activeTools(input).map(t => formatTools(t));
|
||||||
.filter((x: TaggedTool) => !!x.body.id)
|
|
||||||
.map(t => formatTools(t));
|
|
||||||
return _(points)
|
return _(points)
|
||||||
.map(formatPoint(toolNameById))
|
.map(formatPoint(toolNameById))
|
||||||
.sortBy(SORT_KEY)
|
.sortBy(SORT_KEY)
|
||||||
|
|
Loading…
Reference in New Issue