INFRA-642 | Anoop | Add default values for environment variables

This commit is contained in:
anoop narang
2021-01-06 13:25:42 +05:30
parent bd45045e82
commit edcd5be4cc
2 changed files with 18 additions and 16 deletions

View File

@@ -3,7 +3,7 @@ import { FormikTable } from '../components/common/FormikTable';
import { FormikTextField } from '../components/common/FormikTextField';
import { toMenuItems } from './FormUtil';
import * as _m from '../models/Manifest'
import { TableCell, Grid, FormControlLabel, styled, makeStyles, Table, TableHead, TableContainer, Paper, TableRow, TableBody, MenuItem } from '@material-ui/core';
import { TableCell, Grid, FormControlLabel, styled, makeStyles, Table, TableHead, TableContainer, Paper, TableRow, TableBody, MenuItem, Tooltip } from '@material-ui/core';
import FormikMultiSelect from '../components/common/FormikMultiSelect';
import { cardStyles } from './Styles';
import { useField, useFormikContext } from 'formik';
@@ -11,7 +11,7 @@ import NotConfigured from './NotConfiguredPanel';
import { FormikCheckbox } from '../components/common/FormikCheckbox';
import AddRemoveButton from '../components/common/AddRemoveButton';
import CardLayout from '../components/common/CardLayout';
import { EnvironmentVariable, EnvironmentVariableTypes } from './Types';
import { EnvironmentVariable } from './Types';
const useStyles = makeStyles({
...cardStyles,
@@ -82,23 +82,25 @@ const toEnvironmentKeys = (environmentVariables: Array<EnvironmentVariable>) =>
))
}
const DatabaseConfiguration = () => {
const SecretSelectField = (props: { label: string, name: string }) => {
const [environmentVariables] = useField('environmentVariables')
return (
<Tooltip title="Add a SECRET environment variable to refer here">
<MarginedTextField select label={props.label} name={props.name} fullWidth >
{toEnvironmentKeys(environmentVariables.value)}
</MarginedTextField>
</Tooltip>
)
}
const DatabaseConfiguration = () => {
return (
<CardLayout heading="Configuration">
<MarginedTextField label="Instance Name" name="extraResources.database.instanceName" fullWidth />
<MarginedTextField select label="User" name="extraResources.database.user" fullWidth >
{toEnvironmentKeys(environmentVariables.value)}
</MarginedTextField>
<MarginedTextField select label="Password" name="extraResources.database.password" fullWidth >
{toEnvironmentKeys(environmentVariables.value)}
</MarginedTextField>
<MarginedTextField select label="Readonly User" name="extraResources.database.readonlyUser" fullWidth >
{toEnvironmentKeys(environmentVariables.value)}
</MarginedTextField>
<MarginedTextField select label="Readonly Password" name="extraResources.database.readonlyPassword" fullWidth >
{toEnvironmentKeys(environmentVariables.value)}
</MarginedTextField>
<SecretSelectField label="User" name="extraResources.database.user"/>
<SecretSelectField label="Password" name="extraResources.database.password"/>
<SecretSelectField label="Readonly User" name="extraResources.database.readonlyUser"/>
<SecretSelectField label="Readonly Password" name="extraResources.database.readonlyPassword"/>
<MarginedTextField label="Disk Size(in Gb)*" type="number" name="extraResources.database.sizeInGb" fullWidth />
<MarginedTextField select label="AWS Instance Class" name="extraResources.database.awsInstanceClass" fullWidth>
{toMenuItems(awsInstanceClasses)}

View File

@@ -41,7 +41,7 @@ const has = (manifest: any, pathStr: string) => {
// Public Methods
export const NewManifest = () => {
return { team: { name: '' }, environment: '', name: '' }
return { team: { name: '' }, environment: '', name: '', environmentVariables: [] }
}
export const newEnvironmentVariable = () => {