From 90adee65ca3c87d5bb11712085744272907ef466 Mon Sep 17 00:00:00 2001 From: Martin Krulis Date: Sat, 29 Jul 2023 14:33:07 +0200 Subject: [PATCH] Improving how some buttons (tests and runtime environments) are displayed on exercise config page. --- .../EditEnvironmentSimpleForm.js | 80 ++++++++++--------- .../forms/EditTestsForm/EditTestsForm.js | 36 +++++---- 2 files changed, 63 insertions(+), 53 deletions(-) diff --git a/src/components/forms/EditEnvironmentSimpleForm/EditEnvironmentSimpleForm.js b/src/components/forms/EditEnvironmentSimpleForm/EditEnvironmentSimpleForm.js index bcd0e82d3..0de7fd898 100644 --- a/src/components/forms/EditEnvironmentSimpleForm/EditEnvironmentSimpleForm.js +++ b/src/components/forms/EditEnvironmentSimpleForm/EditEnvironmentSimpleForm.js @@ -117,43 +117,49 @@ class EditEnvironmentSimpleForm extends Component { {error && {error}} -
- - {dirty && ( - - )} - - - ), - submitting: ( - - ), - success: ( - - ), - }} - /> - -
+ {(!invalid || dirty) && ( +
+ + {dirty && ( + + )} + + {!invalid && ( + + ), + submitting: ( + + ), + success: ( + + ), + }} + /> + )} + +
+ )} ) : ( <> diff --git a/src/components/forms/EditTestsForm/EditTestsForm.js b/src/components/forms/EditTestsForm/EditTestsForm.js index c833310f3..9a294ec43 100644 --- a/src/components/forms/EditTestsForm/EditTestsForm.js +++ b/src/components/forms/EditTestsForm/EditTestsForm.js @@ -122,6 +122,7 @@ class EditTestsForm extends Component { submitSucceeded, invalid, formValues, + initialValues, } = this.props; return ( @@ -188,6 +189,7 @@ class EditTestsForm extends Component { hasFailed={submitFailed} handleSubmit={handleSubmit} defaultIcon={} + disabled={formValues.tests.length === 0} messages={{ submit: , submitting: ( @@ -197,22 +199,24 @@ class EditTestsForm extends Component { }} /> - - } - hide={!dirty}> - - + {initialValues.tests.length > 0 && ( + + } + hide={!dirty}> + + + )}