history.push(`/app/designer/tool-slots/${id}`)}
onMouseEnter={() => props.dispatch(setToolHover(props.toolSlot.uuid))}
onMouseLeave={() => props.dispatch(setToolHover(undefined))}>
-
- {props.getToolName(tool_id) || t("No tool")}
+
+
-
+
+ e.stopPropagation()}>
+ tool.body.id == tool_id)[0]}
+ onChange={update => {
+ props.dispatch(edit(props.toolSlot, update));
+ props.dispatch(save(props.toolSlot.uuid));
+ }}
+ isActive={props.isActive}
+ filterSelectedTool={false}
+ filterActiveTools={true} />
+
+
+
- {botPositionLabel({ x, y, z }, gantry_mounted)}
+ {botPositionLabel({ x, y, z }, gantry_mounted)}
@@ -230,16 +298,28 @@ const ToolSlotInventoryItem = (props: ToolSlotInventoryItemProps) => {
interface ToolInventoryItemProps {
toolName: string;
toolId: number | undefined;
+ mounted: boolean;
+ active: boolean;
}
-const ToolInventoryItem = (props: ToolInventoryItemProps) =>
-
{
+ const activeText = props.active ? t("in slot") : t("inactive");
+ return
history.push(`/app/designer/tools/${props.toolId}`)}>
-
+
+
+
+
{t(props.toolName)}
+
+
+ {props.mounted ? t("mounted") : activeText}
+
+
;
+};
export const Tools = connect(mapStateToProps)(RawTools);
diff --git a/frontend/farm_designer/tools/map_to_props_add_edit.ts b/frontend/farm_designer/tools/map_to_props_add_edit.ts
new file mode 100644
index 000000000..444d71e2e
--- /dev/null
+++ b/frontend/farm_designer/tools/map_to_props_add_edit.ts
@@ -0,0 +1,67 @@
+import { Everything } from "../../interfaces";
+import { TaggedTool, TaggedToolSlotPointer, FirmwareHardware } from "farmbot";
+import {
+ selectAllTools, maybeFindToolById, maybeGetToolSlot, maybeFindToolSlotById,
+ selectAllToolSlotPointers,
+} from "../../resources/selectors";
+import { BotPosition } from "../../devices/interfaces";
+import { validBotLocationData } from "../../util";
+import { UUID } from "../../resources/interfaces";
+import {
+ getFwHardwareValue,
+} from "../../devices/components/firmware_hardware_support";
+import { getFbosConfig } from "../../resources/getters";
+import { getWebAppConfigValue } from "../../config_storage/actions";
+import { BooleanSetting, NumericSetting } from "../../session_keys";
+import { BotOriginQuadrant, isBotOriginQuadrant } from "../interfaces";
+import { isActive } from "./edit_tool";
+
+export interface AddEditToolSlotPropsBase {
+ tools: TaggedTool[];
+ dispatch: Function;
+ botPosition: BotPosition;
+ findTool(id: number): TaggedTool | undefined;
+ firmwareHardware: FirmwareHardware | undefined;
+ xySwap: boolean;
+ quadrant: BotOriginQuadrant;
+ isActive(id: number | undefined): boolean;
+}
+
+export const mapStateToPropsBase = (props: Everything): AddEditToolSlotPropsBase => {
+ const getWebAppConfig = getWebAppConfigValue(() => props);
+ const xySwap = !!getWebAppConfig(BooleanSetting.xy_swap);
+ const rawQuadrant = getWebAppConfig(NumericSetting.bot_origin_quadrant);
+ const quadrant = isBotOriginQuadrant(rawQuadrant) ? rawQuadrant : 2;
+ return {
+ tools: selectAllTools(props.resources.index),
+ dispatch: props.dispatch,
+ botPosition: validBotLocationData(props.bot.hardware.location_data).position,
+ findTool: (id: number) => maybeFindToolById(props.resources.index, id),
+ firmwareHardware: getFwHardwareValue(getFbosConfig(props.resources.index)),
+ xySwap,
+ quadrant,
+ isActive: isActive(selectAllToolSlotPointers(props.resources.index)),
+ };
+};
+
+export interface AddToolSlotProps extends AddEditToolSlotPropsBase {
+ findToolSlot(uuid: UUID | undefined): TaggedToolSlotPointer | undefined;
+}
+
+export const mapStateToPropsAdd = (props: Everything): AddToolSlotProps => {
+ const mapStateToProps = mapStateToPropsBase(props) as AddToolSlotProps;
+ mapStateToProps.findToolSlot = (uuid: UUID | undefined) =>
+ maybeGetToolSlot(props.resources.index, uuid);
+ return mapStateToProps;
+};
+
+export interface EditToolSlotProps extends AddEditToolSlotPropsBase {
+ findToolSlot(id: string): TaggedToolSlotPointer | undefined;
+}
+
+export const mapStateToPropsEdit = (props: Everything): EditToolSlotProps => {
+ const mapStateToProps = mapStateToPropsBase(props) as EditToolSlotProps;
+ mapStateToProps.findToolSlot = (id: string) =>
+ maybeFindToolSlotById(props.resources.index, parseInt(id));
+ return mapStateToProps;
+};
diff --git a/frontend/farm_designer/tools/tool_slot_edit_components.tsx b/frontend/farm_designer/tools/tool_slot_edit_components.tsx
index 9a2fc0f86..702537376 100644
--- a/frontend/farm_designer/tools/tool_slot_edit_components.tsx
+++ b/frontend/farm_designer/tools/tool_slot_edit_components.tsx
@@ -1,15 +1,15 @@
import React from "react";
import { t } from "../../i18next_wrapper";
import { Xyz, TaggedTool, TaggedToolSlotPointer } from "farmbot";
-import { Row, Col, BlurableInput, FBSelect, NULL_CHOICE } from "../../ui";
import {
- directionIconClass, positionButtonTitle, newSlotDirection, positionIsDefined
-} from "../../tools/components/toolbay_slot_menu";
-import {
- DIRECTION_CHOICES, DIRECTION_CHOICES_DDI
-} from "../../tools/components/toolbay_slot_direction_selection";
+ Row, Col, BlurableInput, FBSelect, NULL_CHOICE, DropDownItem,
+} from "../../ui";
import { BotPosition } from "../../devices/interfaces";
import { ToolPulloutDirection } from "farmbot/dist/resources/api_resources";
+import { Popover } from "@blueprintjs/core";
+import { ToolSlotSVG } from "../map/layers/tool_slots/tool_graphics";
+import { BotOriginQuadrant } from "../interfaces";
+import { isNumber } from "lodash";
export interface GantryMountedInputProps {
gantryMounted: boolean;
@@ -19,30 +19,11 @@ export interface GantryMountedInputProps {
export const GantryMountedInput = (props: GantryMountedInputProps) =>
;
-export interface UseCurrentLocationInputRowProps {
- botPosition: BotPosition;
- onChange(botPosition: BotPosition): void;
-}
-
-export const UseCurrentLocationInputRow =
- (props: UseCurrentLocationInputRowProps) =>
-
;
-
export interface SlotDirectionInputRowProps {
toolPulloutDirection: ToolPulloutDirection;
onChange(update: { pullout_direction: ToolPulloutDirection }): void;
@@ -51,7 +32,7 @@ export interface SlotDirectionInputRowProps {
export const SlotDirectionInputRow = (props: SlotDirectionInputRowProps) =>