diff --git a/frontend/farm_designer/__tests__/index_test.tsx b/frontend/farm_designer/__tests__/index_test.tsx index 19e743bd6..26acd1746 100644 --- a/frontend/farm_designer/__tests__/index_test.tsx +++ b/frontend/farm_designer/__tests__/index_test.tsx @@ -126,7 +126,7 @@ describe("", () => { it("renders saved garden indicator", () => { const p = fakeProps(); - p.designer.openedSavedGarden = "SavedGardenUuid"; + p.designer.openedSavedGarden = 1; const wrapper = mount(); expect(wrapper.text().toLowerCase()).toContain("viewing saved garden"); }); diff --git a/frontend/farm_designer/__tests__/reducer_test.ts b/frontend/farm_designer/__tests__/reducer_test.ts index f95dbc4b8..71ac71edd 100644 --- a/frontend/farm_designer/__tests__/reducer_test.ts +++ b/frontend/farm_designer/__tests__/reducer_test.ts @@ -256,10 +256,10 @@ describe("designer reducer", () => { }); it("sets opened saved garden", () => { - const payload = "savedGardenUuid"; - const action: ReduxAction = { + const payload = 1; + const action: ReduxAction = { type: Actions.CHOOSE_SAVED_GARDEN, - payload + payload, }; const newState = designer(oldState(), action); expect(newState.openedSavedGarden).toEqual(payload); diff --git a/frontend/farm_designer/__tests__/state_to_props_test.ts b/frontend/farm_designer/__tests__/state_to_props_test.ts index 2be33fa70..ee1d4bf7d 100644 --- a/frontend/farm_designer/__tests__/state_to_props_test.ts +++ b/frontend/farm_designer/__tests__/state_to_props_test.ts @@ -167,8 +167,8 @@ describe("getPlants()", () => { it("returns plant templates", () => { const resources = fakeResources(); - const savedGardenUuid = Object.keys(resources.index.byKind["SavedGarden"])[0]; - resources.consumers.farm_designer.openedSavedGarden = savedGardenUuid; + const savedGardenId = 1; + resources.consumers.farm_designer.openedSavedGarden = savedGardenId; expect(getPlants(resources).length).toEqual(1); }); diff --git a/frontend/farm_designer/interfaces.ts b/frontend/farm_designer/interfaces.ts index 119de9742..bbf966016 100644 --- a/frontend/farm_designer/interfaces.ts +++ b/frontend/farm_designer/interfaces.ts @@ -165,7 +165,7 @@ export interface DesignerState { chosenLocation: BotPosition; drawnPoint: DrawnPointPayl | undefined; drawnWeed: DrawnWeedPayl | undefined; - openedSavedGarden: string | undefined; + openedSavedGarden: number | undefined; tryGroupSortType: ExtendedPointGroupSortType | undefined; editGroupAreaInMap: boolean; visualizedSequence: UUID | undefined; @@ -311,7 +311,7 @@ export type PlantOptions = Partial; export interface EditPlantInfoProps { dispatch: Function; findPlant(stringyID: string | undefined): TaggedPlant | undefined; - openedSavedGarden: string | undefined; + openedSavedGarden: number | undefined; timeSettings: TimeSettings; getConfigValue: GetWebAppConfigValue; soilHeightPoints: TaggedGenericPointer[]; diff --git a/frontend/farm_designer/map/layers/plants/__tests__/plant_actions_test.ts b/frontend/farm_designer/map/layers/plants/__tests__/plant_actions_test.ts index 1851ab2ad..ef84ef644 100644 --- a/frontend/farm_designer/map/layers/plants/__tests__/plant_actions_test.ts +++ b/frontend/farm_designer/map/layers/plants/__tests__/plant_actions_test.ts @@ -54,7 +54,7 @@ describe("newPlantKindAndBody()", () => { y: 0, slug: "mint", cropName: "Mint", - openedSavedGarden: "SavedGarden.1.1", + openedSavedGarden: 1, depth: 0, designer: fakeDesignerState(), }; diff --git a/frontend/farm_designer/map/layers/plants/plant_actions.ts b/frontend/farm_designer/map/layers/plants/plant_actions.ts index d3ff4979b..184616c6e 100644 --- a/frontend/farm_designer/map/layers/plants/plant_actions.ts +++ b/frontend/farm_designer/map/layers/plants/plant_actions.ts @@ -4,8 +4,7 @@ import { AxisNumberProperty, TaggedPlant, MapTransformProps, } from "../../interfaces"; import { Plant, DEFAULT_PLANT_RADIUS } from "../../../plant"; -import { unpackUUID } from "../../../../util"; -import { isNumber, isString } from "lodash"; +import { isNumber } from "lodash"; import { DesignerState, GardenMapState, MovePointsProps, } from "../../../interfaces"; @@ -25,7 +24,7 @@ export interface NewPlantKindAndBodyProps { y: number; slug: string; cropName: string; - openedSavedGarden: string | undefined; + openedSavedGarden: number | undefined; depth: number; designer: DesignerState; } @@ -35,9 +34,7 @@ export const newPlantKindAndBody = (props: NewPlantKindAndBodyProps): { kind: TaggedPlant["kind"], body: TaggedPlant["body"], } => { - const savedGardenId = isString(props.openedSavedGarden) - ? unpackUUID(props.openedSavedGarden).remoteId - : undefined; + const savedGardenId = props.openedSavedGarden || undefined; return isNumber(savedGardenId) ? { kind: "PlantTemplate", @@ -75,7 +72,7 @@ export interface CreatePlantProps { gardenCoords: AxisNumberProperty; gridSize: AxisNumberProperty | undefined; dispatch: Function; - openedSavedGarden: string | undefined; + openedSavedGarden: number | undefined; depth: number; designer: DesignerState; } diff --git a/frontend/farm_designer/reducer.ts b/frontend/farm_designer/reducer.ts index e4a1b088b..a71d8648d 100644 --- a/frontend/farm_designer/reducer.ts +++ b/frontend/farm_designer/reducer.ts @@ -188,7 +188,7 @@ export const designer = generateReducer(initialState) push(Path.location({ x: payload.x, y: payload.y })); return s; }) - .add(Actions.CHOOSE_SAVED_GARDEN, (s, { payload }) => { + .add(Actions.CHOOSE_SAVED_GARDEN, (s, { payload }) => { s.openedSavedGarden = payload; return s; }) diff --git a/frontend/farm_designer/state_to_props.ts b/frontend/farm_designer/state_to_props.ts index da327ae91..3c2b6cc8e 100644 --- a/frontend/farm_designer/state_to_props.ts +++ b/frontend/farm_designer/state_to_props.ts @@ -22,13 +22,13 @@ import { selectAllFarmwareEnvs, selectAllCurves, } from "../resources/selectors"; -import { validFwConfig, unpackUUID, validFbosConfig } from "../util"; +import { validFwConfig, validFbosConfig } from "../util"; import { validBotLocationData } from "../util/location"; import { getWebAppConfigValue } from "../config_storage/actions"; import { FarmDesignerProps, CameraCalibrationData } from "./interfaces"; import { TaggedPlant, BotSize } from "./map/interfaces"; import { RestResources } from "../resources/interfaces"; -import { isString, uniq, chain } from "lodash"; +import { isFinite, uniq, chain } from "lodash"; import { BooleanSetting } from "../session_keys"; import { getEnv } from "../farmware/state_to_props"; import { getFirmwareConfig, getFbosConfig } from "../resources/getters"; @@ -50,9 +50,9 @@ export const getPlants = (resources: RestResources) => { const onlyPlants = selectAllPlantPointers(resources.index); const plantTemplates = selectAllPlantTemplates(resources.index); const { openedSavedGarden } = resources.consumers.farm_designer; - return isString(openedSavedGarden) + return isFinite(openedSavedGarden) ? plantTemplates.filter(x => - x.body.saved_garden_id === unpackUUID(openedSavedGarden).remoteId) + x.body.saved_garden_id === openedSavedGarden) : onlyPlants; }; diff --git a/frontend/plants/__tests__/map_state_to_props_test.ts b/frontend/plants/__tests__/map_state_to_props_test.ts index 62ef2bd72..bef6a75df 100644 --- a/frontend/plants/__tests__/map_state_to_props_test.ts +++ b/frontend/plants/__tests__/map_state_to_props_test.ts @@ -29,7 +29,7 @@ describe("mapStateToProps()", () => { template.body.id = 10; state.resources = buildResourceIndex([template]); const uuid = Object.keys(state.resources.index.all)[0]; - state.resources.consumers.farm_designer.openedSavedGarden = "uuid"; + state.resources.consumers.farm_designer.openedSavedGarden = 1; const result = mapStateToProps(state); expect(result.findPlant("10")).toEqual( expect.objectContaining({ uuid })); diff --git a/frontend/plants/__tests__/plant_info_test.tsx b/frontend/plants/__tests__/plant_info_test.tsx index 5073da687..c0f1f760e 100644 --- a/frontend/plants/__tests__/plant_info_test.tsx +++ b/frontend/plants/__tests__/plant_info_test.tsx @@ -98,7 +98,7 @@ describe("", () => { it("gets template id", () => { mockPath = Path.mock(Path.plantTemplates(2)); const p = fakeProps(); - p.openedSavedGarden = "uuid"; + p.openedSavedGarden = 1; const wrapper = mount(); expect(wrapper.instance().stringyID).toEqual("2"); }); diff --git a/frontend/plants/__tests__/plant_inventory_test.tsx b/frontend/plants/__tests__/plant_inventory_test.tsx index aa8f072b6..0e19613ee 100644 --- a/frontend/plants/__tests__/plant_inventory_test.tsx +++ b/frontend/plants/__tests__/plant_inventory_test.tsx @@ -158,7 +158,7 @@ describe("", () => { window.confirm = () => true; const p = fakeProps(); p.plantsPanelState.plants = true; - p.openedSavedGarden = "fake"; + p.openedSavedGarden = 1; const wrapper = mount(); const plantsSection = wrapper.find(PanelSection).at(2); expect(plantsSection.text().toLowerCase()).not.toContain("delete all"); diff --git a/frontend/plants/__tests__/select_plants_test.tsx b/frontend/plants/__tests__/select_plants_test.tsx index 39bdf2b46..cf9c5ec95 100644 --- a/frontend/plants/__tests__/select_plants_test.tsx +++ b/frontend/plants/__tests__/select_plants_test.tsx @@ -63,7 +63,7 @@ describe("", () => { getConfigValue: () => true, plants: [plant1, plant2], dispatch: jest.fn(x => x), - gardenOpen: undefined, + gardenOpenId: undefined, allPoints: [], toolTransformProps: fakeToolTransformProps(), isActive: () => false, @@ -377,7 +377,7 @@ describe("", () => { it("doesn't create group", () => { const p = fakeProps(); - p.gardenOpen = "uuid"; + p.gardenOpenId = 1; const wrapper = mount(); wrapper.find(".dark-blue").simulate("click"); expect(createGroup).not.toHaveBeenCalled(); diff --git a/frontend/plants/crop_info.tsx b/frontend/plants/crop_info.tsx index 510dc3b3a..af975467f 100644 --- a/frontend/plants/crop_info.tsx +++ b/frontend/plants/crop_info.tsx @@ -204,7 +204,7 @@ const Companions = (props: CropInfoListProps) => { interface AddPlantHereButtonProps { botPosition: BotPosition; - openedSavedGarden: string | undefined; + openedSavedGarden: number | undefined; cropName: string; slug: string; dispatch: Function; diff --git a/frontend/plants/plant_info.tsx b/frontend/plants/plant_info.tsx index ee74842b4..2372f5670 100644 --- a/frontend/plants/plant_info.tsx +++ b/frontend/plants/plant_info.tsx @@ -9,7 +9,7 @@ import { } from "../farm_designer/designer_panel"; import { t } from "../i18next_wrapper"; import { EditPlantInfoProps, PlantOptions } from "../farm_designer/interfaces"; -import { isString } from "lodash"; +import { isFinite } from "lodash"; import { push } from "../history"; import { destroy, edit, save } from "../api/crud"; import { BooleanSetting } from "../session_keys"; @@ -20,7 +20,7 @@ import { validGoButtonAxes } from "../farm_designer/move_to"; export type UpdatePlant = (uuid: string, update: PlantOptions) => void; export class RawPlantInfo extends React.Component { - get templates() { return isString(this.props.openedSavedGarden); } + get templates() { return isFinite(this.props.openedSavedGarden); } get stringyID() { return Path.getSlug((this.templates ? Path.plantTemplates diff --git a/frontend/plants/plant_inventory.tsx b/frontend/plants/plant_inventory.tsx index 1058ddb37..7315fac02 100644 --- a/frontend/plants/plant_inventory.tsx +++ b/frontend/plants/plant_inventory.tsx @@ -48,7 +48,7 @@ export interface PlantInventoryProps { allPoints: TaggedPoint[]; plantTemplates: TaggedPlantTemplate[]; plantPointerCount: number; - openedSavedGarden: string | undefined; + openedSavedGarden: number | undefined; plantsPanelState: PlantsPanelState; getConfigValue: GetWebAppConfigValue; } diff --git a/frontend/plants/select_plants.tsx b/frontend/plants/select_plants.tsx index 8055cbd23..8553d6e98 100644 --- a/frontend/plants/select_plants.tsx +++ b/frontend/plants/select_plants.tsx @@ -116,7 +116,7 @@ export const mapStateToProps = (props: Everything): SelectPlantsProps => { plants: getPlants(props.resources), allPoints: selectAllActivePoints(props.resources.index), dispatch: props.dispatch, - gardenOpen: openedSavedGarden, + gardenOpenId: openedSavedGarden, tools: selectAllTools(props.resources.index), groups: selectAllPointGroups(props.resources.index), isActive: isActive(selectAllToolSlotPointers(props.resources.index)), @@ -135,7 +135,7 @@ export interface SelectPlantsProps { selected: UUID[] | undefined; selectionPointType: PointType[] | undefined; getConfigValue: GetWebAppConfigValue; - gardenOpen: string | undefined; + gardenOpenId: number | undefined; toolTransformProps: ToolTransformProps; isActive(id: number | undefined): boolean; tools: TaggedTool[]; @@ -288,7 +288,7 @@ export class RawSelectPlants