Skip to content

Commit

Permalink
Show correct alert message
Browse files Browse the repository at this point in the history
  • Loading branch information
divyanshiGupta committed Dec 9, 2020
1 parent d464da4 commit 72e3d9e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
"No parameters are associated with this pipeline.": "No parameters are associated with this pipeline.",
"Description": "Description",
"Default value": "Default value",
"Save": "Save",
"Reload": "Reload",
"Add Pipeline resource": "Add Pipeline resource",
"No resources are associated with this pipeline.": "No resources are associated with this pipeline.",
"Resource type": "Resource type",
Expand Down Expand Up @@ -109,7 +111,6 @@
"Navigate back to the": "Navigate back to the",
"Pipelines page": "Pipelines page",
"Pipeline builder": "Pipeline builder",
"Save": "Save",
"Create": "Create",
"Cancel": "Cancel",
"Add parameters": "Add parameters",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { FormikProps, FormikValues, getIn } from 'formik';
import { useAccessReview } from '@console/internal/components/utils';
import { FormFooter } from '@console/shared';
import PipelineParameters from './PipelineParameters';
import { useTranslation } from 'react-i18next';

type PipelineParametersFormProps = FormikProps<FormikValues> & {
namespace: string;
Expand All @@ -25,6 +26,8 @@ const PipelineParametersForm: React.FC<PipelineParametersFormProps> = ({
namespace,
verb: 'update',
});
const { t } = useTranslation();
const disableSubmit = !dirty || !_.isEmpty(_.compact(getIn(errors, 'parameters')));
return (
<Form onSubmit={handleSubmit}>
<div className="co-m-pane__form">
Expand All @@ -36,8 +39,10 @@ const PipelineParametersForm: React.FC<PipelineParametersFormProps> = ({
isSubmitting={isSubmitting}
errorMessage={status && status.submitError}
successMessage={status && !dirty && status.success}
disableSubmit={!dirty || !_.isEmpty(_.compact(getIn(errors, 'parameters')))}
showAlert={dirty}
disableSubmit={disableSubmit}
showAlert={!disableSubmit}
submitLabel={t('pipelines-plugin~Save')}
resetLabel={t('pipelines-plugin~Reload')}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { FormikProps, FormikValues, getIn } from 'formik';
import { useAccessReview } from '@console/internal/components/utils';
import { FormFooter } from '@console/shared';
import PipelineResources from './PipelineResources';
import { useTranslation } from 'react-i18next';

type PipelineResourcesFormProps = FormikProps<FormikValues> & {
namespace: string;
Expand All @@ -25,6 +26,8 @@ const PipelineResourcesForm: React.FC<PipelineResourcesFormProps> = ({
namespace,
verb: 'update',
});
const { t } = useTranslation();
const disableSubmit = !dirty || !_.isEmpty(_.compact(getIn(errors, 'resources')));
return (
<Form onSubmit={handleSubmit}>
<div className="co-m-pane__form">
Expand All @@ -36,8 +39,10 @@ const PipelineResourcesForm: React.FC<PipelineResourcesFormProps> = ({
isSubmitting={isSubmitting}
errorMessage={status && status.submitError}
successMessage={status && !dirty && status.success}
disableSubmit={!dirty || !_.isEmpty(_.compact(getIn(errors, 'resources')))}
showAlert={dirty}
disableSubmit={disableSubmit}
showAlert={!disableSubmit}
submitLabel={t('pipelines-plugin~Save')}
resetLabel={t('pipelines-plugin~Reload')}
/>
)}
</div>
Expand Down

0 comments on commit 72e3d9e

Please sign in to comment.