diff --git a/app/lib/session_token.rb b/app/lib/session_token.rb index 5f3e67df9..38baf4843 100644 --- a/app/lib/session_token.rb +++ b/app/lib/session_token.rb @@ -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 diff --git a/config/webpack.prod.js b/config/webpack.prod.js index e21866707..d38e2da26 100644 --- a/config/webpack.prod.js +++ b/config/webpack.prod.js @@ -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 diff --git a/package.json b/package.json index 9bb5a7ff1..617a64da4 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tsconfig.json b/tsconfig.json index dbb07e0ab..fbd42d6ad 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,7 +17,8 @@ "strictNullChecks": true, "sourceMap": true, "allowJs": true, - "pretty": true + "pretty": true, + "removeComments": true }, "exclude": [ "node_modules", diff --git a/webpack/sequences/__tests__/sequence_editor_middle_active_test.tsx b/webpack/sequences/__tests__/sequence_editor_middle_active_test.tsx index c9ad9d342..88bd2023d 100644 --- a/webpack/sequences/__tests__/sequence_editor_middle_active_test.tsx +++ b/webpack/sequences/__tests__/sequence_editor_middle_active_test.tsx @@ -25,11 +25,8 @@ import { fakeSequence } from "../../__test_support__/fake_state/resources"; describe("", () => { function fakeProps(): ActiveMiddleProps { return { - slots: [], dispatch: jest.fn(), sequence: fakeSequence(), - sequences: [], - tools: [], resources: buildResourceIndex(FAKE_RESOURCES).index, syncStatus: "synced", consistent: true, diff --git a/webpack/sequences/__tests__/sequence_editor_middle_test.tsx b/webpack/sequences/__tests__/sequence_editor_middle_test.tsx index 141e78d68..ccc58356f 100644 --- a/webpack/sequences/__tests__/sequence_editor_middle_test.tsx +++ b/webpack/sequences/__tests__/sequence_editor_middle_test.tsx @@ -8,11 +8,8 @@ import { fakeSequence } from "../../__test_support__/fake_state/resources"; describe("", () => { function fakeProps(): SequenceEditorMiddleProps { return { - slots: [], dispatch: jest.fn(), sequence: fakeSequence(), - sequences: [], - tools: [], resources: buildResourceIndex(FAKE_RESOURCES).index, syncStatus: "synced", consistent: true, diff --git a/webpack/sequences/__tests__/sequences_test.tsx b/webpack/sequences/__tests__/sequences_test.tsx index 95844fa00..70e529b1a 100644 --- a/webpack/sequences/__tests__/sequences_test.tsx +++ b/webpack/sequences/__tests__/sequences_test.tsx @@ -14,11 +14,9 @@ import { ToolTips } from "../../constants"; describe("", () => { function fakeProps(): Props { return { - slots: [], dispatch: jest.fn(), sequence: fakeSequence(), sequences: [], - tools: [], resources: buildResourceIndex(FAKE_RESOURCES).index, syncStatus: "synced", auth, diff --git a/webpack/sequences/interfaces.ts b/webpack/sequences/interfaces.ts index fd92ba559..2f1d0caca 100644 --- a/webpack/sequences/interfaces.ts +++ b/webpack/sequences/interfaces.ts @@ -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; diff --git a/webpack/sequences/sequence_editor_middle.tsx b/webpack/sequences/sequence_editor_middle.tsx index 15a912a2a..ebd36e3a3 100644 --- a/webpack/sequences/sequence_editor_middle.tsx +++ b/webpack/sequences/sequence_editor_middle.tsx @@ -10,19 +10,13 @@ export class SequenceEditorMiddle const { dispatch, sequence, - sequences, - tools, - slots, resources, syncStatus } = this.props; if (sequence && isTaggedSequence(sequence)) { return { diff --git a/webpack/sequences/state_to_props.ts b/webpack/sequences/state_to_props.ts index 7a300cda7..4c163b706 100644 --- a/webpack/sequences/state_to_props.ts +++ b/webpack/sequences/state_to_props.ts @@ -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 }; diff --git a/webpack/sequences/step_tiles/tile_move_absolute/generate_list.ts b/webpack/sequences/step_tiles/tile_move_absolute/generate_list.ts index bfd2822a3..dcfb33b00 100644 --- a/webpack/sequences/step_tiles/tile_move_absolute/generate_list.ts +++ b/webpack/sequences/step_tiles/tile_move_absolute/generate_list.ts @@ -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)