Skip to content

Commit

Permalink
add disableSubmit property to Deploy image form initial values and us…
Browse files Browse the repository at this point in the history
…e it to disable submit button while the user types

fix unit test
  • Loading branch information
sahil143 committed May 7, 2020
1 parent 355ac27 commit fe8095b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ export const externalImageValues: DeployImageFormData = {
build: { env: [], triggers: {}, strategy: '' },
isSearchingForImage: false,
healthChecks: healthChecksProbeInitialData,
disableSubmit: false,
};

export const internalImageValues: DeployImageFormData = {
Expand Down Expand Up @@ -590,6 +591,7 @@ export const internalImageValues: DeployImageFormData = {
build: { env: [], triggers: {}, strategy: '' },
isSearchingForImage: false,
healthChecks: healthChecksProbeInitialData,
disableSubmit: false,
};

export const knAppResources: AppResources = {
Expand Down Expand Up @@ -669,6 +671,7 @@ export const knExternalImageValues: DeployImageFormData = {
searchTerm: 'openshift/hello-openshift',
serverless: { scaling: { concurrencylimit: '', concurrencytarget: '', maxpods: '', minpods: 0 } },
healthChecks: healthChecksProbeInitialData,
disableSubmit: false,
};

export const gitImportInitialValuesWithHealthChecksEnabled: GitImportFormData = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ const deployImageInitialValues = {
strategy: '',
},
isSearchingForImage: false,
disableSubmit: false,
};

export const getExternalImageInitialValues = (appResources: AppResources) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ const DeployImage: React.FC<Props> = ({
},
},
healthChecks: healthChecksProbeInitialData,
disableSubmit: true,
};

const handleSubmit = (values, actions) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const DeployImageForm: React.FC<FormikProps<FormikValues> & DeployImageFormProps
isSubmitting={isSubmitting}
submitLabel="Create"
sticky
disableSubmit={!dirty || !_.isEmpty(errors)}
disableSubmit={values.disableSubmit || !dirty || !_.isEmpty(errors)}
resetLabel="Cancel"
/>
</Form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const ImageSearch: React.FC = () => {
(!initialValues.route.targetPort || touched.searchTerm) && _.head(ports);
targetPort && setFieldValue('route.targetPort', makePortName(targetPort));
setValidated(ValidatedOptions.success);
setFieldValue('disableSubmit', false);
} else {
setFieldValue('isSearchingForImage', false);
setFieldValue('isi', {});
Expand Down Expand Up @@ -151,6 +152,7 @@ const ImageSearch: React.FC = () => {
helpTextInvalid={helpTextInvalid}
validated={validated}
onChange={(e: KeyboardEvent) => {
setFieldValue('disableSubmit', true);
debouncedHandleSearch((e.target as HTMLInputElement).value);
}}
data-test-id="deploy-image-search-term"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export interface DeployImageFormData {
deployment: DeploymentData;
limits: LimitsData;
healthChecks: HealthChecksData;
disableSubmit?: boolean;
}

export interface GitImportFormData {
Expand Down

0 comments on commit fe8095b

Please sign in to comment.