From 69a93c740f799cb3ab62620e8c301ac1ee1fe13e Mon Sep 17 00:00:00 2001 From: Andres Martinez Gotor Date: Mon, 14 Oct 2019 12:25:29 +0200 Subject: [PATCH] Add support for resource elements (#1214) --- .../BasicDeploymentForm.tsx | 49 ++++++++++++++++++- .../BasicDeploymentForm/Subsection.test.tsx | 3 ++ .../BasicDeploymentForm/Subsection.tsx | 18 +++++-- .../__snapshots__/Subsection.test.tsx.snap | 6 +++ dashboard/src/shared/schema.ts | 3 ++ 5 files changed, 74 insertions(+), 5 deletions(-) diff --git a/dashboard/src/components/DeploymentForm/BasicDeploymentForm/BasicDeploymentForm.tsx b/dashboard/src/components/DeploymentForm/BasicDeploymentForm/BasicDeploymentForm.tsx index 1143db87d4d..c3ec7769738 100644 --- a/dashboard/src/components/DeploymentForm/BasicDeploymentForm/BasicDeploymentForm.tsx +++ b/dashboard/src/components/DeploymentForm/BasicDeploymentForm/BasicDeploymentForm.tsx @@ -2,7 +2,14 @@ import * as React from "react"; import { IBasicFormParam } from "shared/types"; import TextParam from "./TextParam"; -import { DISK_SIZE, EXTERNAL_DB, USE_SELF_HOSTED_DB } from "../../../shared/schema"; +import { + CPU_REQUEST, + DISK_SIZE, + EXTERNAL_DB, + MEMORY_REQUEST, + RESOURCES, + USE_SELF_HOSTED_DB, +} from "../../../shared/schema"; import "./BasicDeploymentForm.css"; import BooleanParam from "./BooleanParam"; import SliderParam from "./SliderParam"; @@ -69,6 +76,46 @@ class BasicDeploymentForm extends React.Component { unit="Gi" /> ); + case RESOURCES: + return ( + + ); + case MEMORY_REQUEST: + return ( + + ); + case CPU_REQUEST: + return ( + + ); default: switch (param.type) { case "boolean": diff --git a/dashboard/src/components/DeploymentForm/BasicDeploymentForm/Subsection.test.tsx b/dashboard/src/components/DeploymentForm/BasicDeploymentForm/Subsection.test.tsx index 92c22c24ca5..cc9bbd1dcc3 100644 --- a/dashboard/src/components/DeploymentForm/BasicDeploymentForm/Subsection.test.tsx +++ b/dashboard/src/components/DeploymentForm/BasicDeploymentForm/Subsection.test.tsx @@ -32,6 +32,7 @@ const defaultProps = { }, path: "externalDatabase", title: "External Database Details", + description: "description of the param", type: "object", } as IBasicFormParam, handleBasicFormParamChange: jest.fn(), @@ -61,6 +62,8 @@ it("should hide/show the database params if the self-hosted database is enabled/ useSelfHostedDatabase: { path: "mariadb.enabled", value: false, type: "boolean" }, }, }, + enablerChildrenParam: "useSelfHostedDatabase", + enablerCondition: false, }); wrapper.update(); expect(wrapper.find("div").findWhere(d => d.prop("hidden"))).not.toExist(); diff --git a/dashboard/src/components/DeploymentForm/BasicDeploymentForm/Subsection.tsx b/dashboard/src/components/DeploymentForm/BasicDeploymentForm/Subsection.tsx index 6c2ab8cebfb..6ae4e8e45c2 100644 --- a/dashboard/src/components/DeploymentForm/BasicDeploymentForm/Subsection.tsx +++ b/dashboard/src/components/DeploymentForm/BasicDeploymentForm/Subsection.tsx @@ -8,8 +8,8 @@ export interface ISubsectionProps { label: string; param: IBasicFormParam; name: string; - enablerChildrenParam: string; - enablerCondition: boolean; + enablerChildrenParam?: string; + enablerCondition?: boolean; handleValuesChange: (value: string) => void; renderParam: ( name: string, @@ -28,7 +28,7 @@ class Subsection extends React.Component { const { label, param, name, enablerChildrenParam, enablerCondition } = this.props; return (
- {param.children && param.children[enablerChildrenParam] && ( + {param.children && enablerChildrenParam && param.children[enablerChildrenParam] && ( {
diff --git a/dashboard/src/shared/schema.ts b/dashboard/src/shared/schema.ts index b96caa0c534..9ef0aaa313e 100644 --- a/dashboard/src/shared/schema.ts +++ b/dashboard/src/shared/schema.ts @@ -15,6 +15,9 @@ nullOptions.nullStr = ""; export const EXTERNAL_DB = "externalDatabase"; export const USE_SELF_HOSTED_DB = "useSelfHostedDatabase"; export const DISK_SIZE = "diskSize"; +export const MEMORY_REQUEST = "memoryRequest"; +export const CPU_REQUEST = "cpuRequest"; +export const RESOURCES = "resources"; // retrieveBasicFormParams iterates over a JSON Schema properties looking for `form` keys // It uses the raw yaml to setup default values.