From b761e5dd04dfcd7e339fbfc188f866c78561dbed Mon Sep 17 00:00:00 2001 From: Abhishek Katiyar Date: Mon, 7 Dec 2020 21:54:57 +0530 Subject: [PATCH 1/2] INFRA-614 | Abhishek | Add changes to disable editing of name and environment while editing manifest --- src/coreform/BaseForm.tsx | 17 ++++++++--------- src/coreform/ManifestForm.tsx | 31 +++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/coreform/BaseForm.tsx b/src/coreform/BaseForm.tsx index a1cfd5a..26a083f 100644 --- a/src/coreform/BaseForm.tsx +++ b/src/coreform/BaseForm.tsx @@ -1,18 +1,17 @@ import * as React from 'react'; -import { makeStyles, Theme } from '@material-ui/core/styles'; +import {makeStyles, Theme} from '@material-ui/core/styles'; import Tabs from '@material-ui/core/Tabs'; import Tab from '@material-ui/core/Tab'; import ManifestForm from './ManifestForm' import DatabaseForm from './DatabaseForm' import * as _m from '../models/Manifest' -import { Formik, Form, FormikProps } from 'formik'; -import { manifestValidationSchema } from "../models/ManifestValidationSchema"; -import { tabA11yProps, TabPanel } from './FormUtil'; +import {Form, Formik, FormikProps} from 'formik'; +import {manifestValidationSchema} from "../models/ManifestValidationSchema"; +import {tabA11yProps, TabPanel} from './FormUtil'; import EnvironmentVariablesForm from './EnvironmentVariablesForm'; import S3BucketForm from './S3BucketForm'; -import _ from 'lodash' -import { Divider, Snackbar, Typography, Button } from '@material-ui/core'; -import { Alert } from "@material-ui/lab"; +import {Button, Divider, Snackbar, Typography} from '@material-ui/core'; +import {Alert} from "@material-ui/lab"; import DeploymentForm from './DeploymentForm'; import AWSAccessForm from './AWSAccessForm'; @@ -127,7 +126,7 @@ const BaseForm = (props: BaseFormProps) => { { props => (
- +
{ - {/* */} + ) diff --git a/src/coreform/ManifestForm.tsx b/src/coreform/ManifestForm.tsx index 4f0bb00..2618863 100644 --- a/src/coreform/ManifestForm.tsx +++ b/src/coreform/ManifestForm.tsx @@ -1,8 +1,7 @@ import * as React from 'react'; -import { Grid, Box } from '@material-ui/core'; -import { toMenuItems } from './FormUtil'; -import { FormikTextField } from '../components/common/FormikTextField'; -import { makeStyles } from '@material-ui/core'; +import {Box, Grid, makeStyles} from '@material-ui/core'; +import {toMenuItems} from './FormUtil'; +import {FormikTextField} from '../components/common/FormikTextField'; import * as _m from '../models/Manifest' const environments = ["dev", "qa", "prod"] @@ -22,16 +21,28 @@ const useStyles = makeStyles({ }); -const ManifestForm = () => { +const ManifestForm = (props: any) => { const classes = useStyles(); + const [id] = React.useState(props.id) return ( - - - {toMenuItems(environments)} - - + {id === undefined ? ( + + + + {toMenuItems(environments)} + + + ) + : + ( + + + + ) + } + {toMenuItems(_m.teams)} From 6425ae49d623a973da179ff47c431e8842935afc Mon Sep 17 00:00:00 2001 From: Abhishek Katiyar Date: Mon, 7 Dec 2020 22:14:45 +0530 Subject: [PATCH 2/2] INFRA-614 | Abhishek | Refactor code to remove duplication --- src/coreform/BaseForm.tsx | 2 +- src/coreform/ManifestForm.tsx | 25 +++++++++---------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/coreform/BaseForm.tsx b/src/coreform/BaseForm.tsx index 26a083f..926cefd 100644 --- a/src/coreform/BaseForm.tsx +++ b/src/coreform/BaseForm.tsx @@ -149,7 +149,7 @@ const BaseForm = (props: BaseFormProps) => { - + {/**/} ) diff --git a/src/coreform/ManifestForm.tsx b/src/coreform/ManifestForm.tsx index 2618863..c16042a 100644 --- a/src/coreform/ManifestForm.tsx +++ b/src/coreform/ManifestForm.tsx @@ -3,6 +3,7 @@ import {Box, Grid, makeStyles} from '@material-ui/core'; import {toMenuItems} from './FormUtil'; import {FormikTextField} from '../components/common/FormikTextField'; import * as _m from '../models/Manifest' +import {useEffect} from "react"; const environments = ["dev", "qa", "prod"] @@ -23,25 +24,17 @@ const useStyles = makeStyles({ const ManifestForm = (props: any) => { const classes = useStyles(); - const [id] = React.useState(props.id) + const [id] = React.useState(props.id); + const disableNameAndEnvironment = id !== undefined; return ( - {id === undefined ? ( - - - - {toMenuItems(environments)} - - - ) - : - ( - - - - ) - } + + + {toMenuItems(environments)} + {toMenuItems(_m.teams)}