diff --git a/chaoscenter/web/src/components/SettingsWrapper/SettingsWrapper.tsx b/chaoscenter/web/src/components/SettingsWrapper/SettingsWrapper.tsx index 9bd37612ab1..8f5ba242793 100644 --- a/chaoscenter/web/src/components/SettingsWrapper/SettingsWrapper.tsx +++ b/chaoscenter/web/src/components/SettingsWrapper/SettingsWrapper.tsx @@ -45,8 +45,8 @@ export default function SettingsWrapper(props: SettingsWrapperProps): React.Reac void; - isEditOpen: boolean; } export default function EditEnvironmentController({ environmentID, handleClose, - isEditOpen, refetchEnvironments }: EditEnvironmentControllerProps & RefetchEnvironments): React.ReactElement { const { showError, showSuccess } = useToaster(); @@ -36,12 +34,11 @@ export default function EditEnvironmentController({ return ( { const setPage = (newPage: number): void => updateSearchParams({ page: newPage.toString() }); const setLimit = (newLimit: number): void => updateSearchParams({ limit: newLimit.toString() }); - // const resetPage = (): void => { - // page !== 0 && updateSearchParams({ page: '0' }); - // }; - const [isModalOpen, setIsModalOpen] = React.useState(false); const { data: envData, loading: listEnvironmentLoading, - refetch: refetchEnvironments + refetch: refetchEnvironments, + error: listEnvironmentError } = listEnvironment({ projectID: scope.projectID, environmentIDs: [], @@ -73,9 +70,7 @@ const EnvironmentController: React.FC = () => { return ( { - refetch(); + listInfrastructureRefetch(); setPage(0); showSuccess(getString('deleteSuccess')); }, @@ -78,8 +78,6 @@ export default function KubernetesChaosInfrastructureController(): React.ReactEl ); }; - //TODO pass down refetch() to call it in done buttons - return ( - + An environment is the place where you will deploy your cluster for chaos + testing environmentError: It seems there was an error fetching the Environment Details. +environmentNameIsRequired: Environment Name is a required field +environmentType: Environment Type environments: Environments error: Error errorApplyChanges: Error in Applying the Changes. Please enter correct input values. diff --git a/chaoscenter/web/src/strings/types.ts b/chaoscenter/web/src/strings/types.ts index f6819888ed8..bd45af1161b 100644 --- a/chaoscenter/web/src/strings/types.ts +++ b/chaoscenter/web/src/strings/types.ts @@ -275,7 +275,10 @@ export interface StringsMap { 'enterYourPassword': unknown 'enterYourUsername': unknown 'environment': unknown + 'environmentDescription': unknown 'environmentError': unknown + 'environmentNameIsRequired': unknown + 'environmentType': unknown 'environments': unknown 'error': unknown 'errorApplyChanges': unknown diff --git a/chaoscenter/web/src/views/Environments/EnvironmentList/CreateEnvironment.tsx b/chaoscenter/web/src/views/Environments/EnvironmentList/CreateEnvironment.tsx index 86e11b43146..4ab1b4c4df5 100644 --- a/chaoscenter/web/src/views/Environments/EnvironmentList/CreateEnvironment.tsx +++ b/chaoscenter/web/src/views/Environments/EnvironmentList/CreateEnvironment.tsx @@ -1,4 +1,4 @@ -import { Button, ButtonVariation, CardSelect, Container, Dialog, FormInput, Layout, Text } from '@harnessio/uicore'; +import { Button, ButtonVariation, CardSelect, Container, FormInput, Layout, Text } from '@harnessio/uicore'; import { FontVariation, Color } from '@harnessio/design-system'; import { Form, Formik } from 'formik'; import React from 'react'; @@ -25,11 +25,10 @@ interface CreateEnvironmentData { } interface CreateEnvironmentProps { - isOpen: boolean; editable?: boolean; environmentID?: string; existingEnvironment?: Environment; - setIsOpen: React.Dispatch>; + closeModal: () => void; mutation: { createEnvironment?: MutationFunction; updateEnvironment?: MutationFunction; @@ -40,13 +39,12 @@ interface CreateEnvironmentProps { } export default function CreateEnvironment({ - isOpen, editable, - setIsOpen, environmentID, mutation, existingEnvironment, - loading + loading, + closeModal }: CreateEnvironmentProps): React.ReactElement { const { getString } = useStrings(); const scope = getScope(); @@ -69,122 +67,106 @@ export default function CreateEnvironment({ ]; return ( - { - setIsOpen(false); - } - } - isCloseButtonShown - className={css.dialogStylesEnv} - > - - - - initialValues={initialValues} - onSubmit={data => { - !editable - ? mutation.createEnvironment && - mutation - .createEnvironment({ - variables: { - projectID: scope.projectID, - request: { - environmentID: data.id, - name: data.name, - description: data.description, - tags: data.tags, - type: data.type - } - } - }) - .then(() => setIsOpen(false)) - : mutation.updateEnvironment && - environmentID && - mutation.updateEnvironment({ + + + + initialValues={initialValues} + onSubmit={data => { + !editable + ? mutation.createEnvironment && + mutation + .createEnvironment({ variables: { projectID: scope.projectID, request: { - environmentID: environmentID, + environmentID: data.id, name: data.name, description: data.description, tags: data.tags, type: data.type } } - }); - }} - validationSchema={Yup.object().shape({ - name: Yup.string().trim().required('Environment Name is a required field') - })} - > - {formikProps => { - return ( -
- - - {editable ? 'Edit Environment' : 'New Environment'} - - - An environment is the place where you will deploy your cluster for chaos testing - -
- -
- - {/* */} - - - Environment Type - - objective._cardName === formikProps.values.type)} - data={environmentTypes} - onChange={key => { - formikProps.setFieldValue('type', key._cardName); + }) + .then(() => closeModal()) + : mutation.updateEnvironment && + environmentID && + mutation.updateEnvironment({ + variables: { + projectID: scope.projectID, + request: { + environmentID: environmentID, + name: data.name, + description: data.description, + tags: data.tags, + type: data.type + } + } + }); + }} + validationSchema={Yup.object().shape({ + name: Yup.string().trim().required(getString('environmentNameIsRequired')) + })} + > + {formikProps => { + return ( + + + + {editable ? 'Edit Environment' : 'New Environment'} + + + {getString('environmentDescription')} + +
+ ( - - {item.name} - - )} /> - -
+ + + + {getString('environmentType')} + + objective._cardName === formikProps.values.type)} + data={environmentTypes} + onChange={key => { + formikProps.setFieldValue('type', key._cardName); + }} + cornerSelected + className={css.cardContainer} + renderItem={item => ( + + {item.name} + + )} + /> + +