Limit grids to 100 for now.

pull/1575/head
Rick Carlino 2019-11-15 07:45:22 -06:00
parent 55ed669de7
commit 47942fb9c8
2 changed files with 15 additions and 6 deletions

View File

@ -20,11 +20,11 @@ export const plantGridKeys: PlantGridKey[] =
export const EMPTY_PLANT_GRID: Omit<PlantGridState, "gridId"> = {
status: "clean",
grid: {
startX: 5,
startY: 5,
spacingH: 5,
spacingV: 5,
numPlantsH: 5,
numPlantsV: 5,
startX: 100,
startY: 100,
spacingH: 50,
spacingV: 50,
numPlantsH: 7,
numPlantsV: 7,
}
};

View File

@ -11,6 +11,8 @@ import { initPlantGrid } from "./generate_grid";
import { init } from "../../../api/crud";
import { uuid } from "farmbot";
import { saveGrid, stashGrid } from "./thunks";
import { error } from "../../../toast/toast";
import { t } from "../../../i18next_wrapper";
export class PlantGrid extends React.Component<PlantGridProps, PlantGridState> {
state: PlantGridState = {
@ -25,6 +27,13 @@ export class PlantGrid extends React.Component<PlantGridProps, PlantGridState> {
});
performPreview = () => {
const { numPlantsH, numPlantsV } = this.state.grid;
const total = numPlantsH * numPlantsV;
if (total > 100) {
error(t("Please make a grid with less than 100 plants"));
return;
}
const plants = initPlantGrid({
grid: this.state.grid,
openfarm_slug: this.props.openfarm_slug,