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
Rick Carlino 2017-11-28 18:01:35 -06:00 committed by GitHub
parent 0a76331b85
commit a8773ed475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 28 additions and 54 deletions

View File

@ -37,6 +37,7 @@ class SessionToken < AbstractJwtToken
mqtt_ws: MQTT_WS,
os_update_server: OS_RELEASE,
fw_update_server: "DEPRECATED",
interim_email: user.email, # Dont use this for anything ever -RC
bot: "device_#{user.device.id}",
vhost: VHOST }])
end

View File

@ -18,9 +18,6 @@ conf.output = {
[
new ExtractTextPlugin({
// Temporary hotfix for some issues on staging.
// - RC 12 MAY 17
// filename: "dist/styles.css",
filename: "dist/[name].[chunkhash].css",
disable: false,
allChunks: true

View File

@ -9,6 +9,7 @@
},
"scripts": {
"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",
"start": "echo 'use `rails api:start`'",
"heroku-postbuild": "webpack --config=./config/webpack.prod.js",

View File

@ -17,7 +17,8 @@
"strictNullChecks": true,
"sourceMap": true,
"allowJs": true,
"pretty": true
"pretty": true,
"removeComments": true
},
"exclude": [
"node_modules",

View File

@ -25,11 +25,8 @@ import { fakeSequence } from "../../__test_support__/fake_state/resources";
describe("<SequenceEditorMiddleActive/>", () => {
function fakeProps(): ActiveMiddleProps {
return {
slots: [],
dispatch: jest.fn(),
sequence: fakeSequence(),
sequences: [],
tools: [],
resources: buildResourceIndex(FAKE_RESOURCES).index,
syncStatus: "synced",
consistent: true,

View File

@ -8,11 +8,8 @@ import { fakeSequence } from "../../__test_support__/fake_state/resources";
describe("<SequenceEditorMiddle/>", () => {
function fakeProps(): SequenceEditorMiddleProps {
return {
slots: [],
dispatch: jest.fn(),
sequence: fakeSequence(),
sequences: [],
tools: [],
resources: buildResourceIndex(FAKE_RESOURCES).index,
syncStatus: "synced",
consistent: true,

View File

@ -14,11 +14,9 @@ import { ToolTips } from "../../constants";
describe("<Sequences/>", () => {
function fakeProps(): Props {
return {
slots: [],
dispatch: jest.fn(),
sequence: fakeSequence(),
sequences: [],
tools: [],
resources: buildResourceIndex(FAKE_RESOURCES).index,
syncStatus: "synced",
auth,

View File

@ -8,9 +8,7 @@ import {
} from "farmbot";
import { StepMoveDataXfer, StepSpliceDataXfer } from "../draggable/interfaces";
import {
TaggedSequence,
TaggedTool,
TaggedToolSlotPointer
TaggedSequence
} from "../resources/tagged_resources";
import { ResourceIndex } from "../resources/interfaces";
import { JSXChildren } from "../util";
@ -18,8 +16,6 @@ import { JSXChildren } from "../util";
export interface Props {
dispatch: Function;
sequences: TaggedSequence[];
tools: TaggedTool[];
slots: TaggedToolSlotPointer[];
sequence: TaggedSequence | undefined;
auth: AuthState | undefined;
resources: ResourceIndex;
@ -31,12 +27,6 @@ export interface Props {
export interface SequenceEditorMiddleProps {
dispatch: Function;
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;
syncStatus: SyncStatus;
consistent: boolean;

View File

@ -10,19 +10,13 @@ export class SequenceEditorMiddle
const {
dispatch,
sequence,
sequences,
tools,
slots,
resources,
syncStatus
} = this.props;
if (sequence && isTaggedSequence(sequence)) {
return <SequenceEditorMiddleActive
slots={slots}
dispatch={dispatch}
sequence={sequence}
sequences={sequences}
tools={tools}
resources={resources}
syncStatus={syncStatus}
consistent={true}

View File

@ -33,10 +33,7 @@ export class Sequences extends React.Component<Props, {}> {
<SequenceEditorMiddle
syncStatus={this.props.syncStatus}
dispatch={this.props.dispatch}
sequences={this.props.sequences}
sequence={this.props.sequence}
slots={this.props.slots}
tools={this.props.tools}
resources={this.props.resources}
consistent={this.props.consistent}
autoSyncEnabled={this.props.autoSyncEnabled} />

View File

@ -2,34 +2,26 @@ import { Everything } from "../interfaces";
import { Props } from "./interfaces";
import {
selectAllSequences,
selectAllTools,
findSequence,
selectAllToolSlotPointers
findSequence
} from "../resources/selectors";
import { getStepTag } from "../resources/sequence_tagging";
export function mapStateToProps(props: Everything): Props {
const uuid = props.resources.consumers.sequences.current;
const syncStatus =
props.bot.hardware.informational_settings.sync_status || "unknown";
const sequence =
(uuid) ? findSequence(props.resources.index, uuid) : undefined;
const sequence = uuid ? findSequence(props.resources.index, uuid) : undefined;
sequence && (sequence.body.body || []).map(x => getStepTag(x));
if (sequence) {
(sequence.body.body || [])
.map(x => {
getStepTag(x);
});
}
return {
dispatch: props.dispatch,
sequences: selectAllSequences(props.resources.index),
tools: selectAllTools(props.resources.index),
slots: selectAllToolSlotPointers(props.resources.index),
sequence: sequence,
auth: props.auth,
resources: props.resources.index,
syncStatus,
syncStatus: (props
.bot
.hardware
.informational_settings
.sync_status || "unknown"),
consistent: props.bot.consistent,
autoSyncEnabled: !!props.bot.hardware.configuration.auto_sync
};

View File

@ -1,25 +1,34 @@
import { ResourceIndex } from "../../../resources/interfaces";
import {
selectAllPoints,
selectAllTools,
mapToolIdToName
mapToolIdToName,
selectAllToolSlotPointers
} from "../../../resources/selectors";
import { CowardlyDictionary } from "../../../util";
import { CowardlyDictionary, betterCompact } from "../../../util";
import { PointerTypeName } from "../../../interfaces";
import { PointerType, TaggedTool } from "../../../resources/tagged_resources";
import { DropDownItem } from "../../../ui/index";
import { Vector3 } from "farmbot/dist";
import { TOOL } from "./interfaces";
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[] {
const toolNameById = mapToolIdToName(input);
const SORT_KEY: keyof DropDownItem = "headingId";
const points = selectAllPoints(input)
.filter(x => (x.body.pointer_type !== "ToolSlot"));
const toolDDI: DropDownItem[] = selectAllTools(input)
.filter((x: TaggedTool) => !!x.body.id)
.map(t => formatTools(t));
const toolDDI: DropDownItem[] = activeTools(input).map(t => formatTools(t));
return _(points)
.map(formatPoint(toolNameById))
.sortBy(SORT_KEY)