From 028f84e225e141cf03e4bc997eea1f674a1b3e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maren=20S=C3=BCwer?= Date: Mon, 28 Jan 2019 15:02:08 +0100 Subject: [PATCH] only enable submit button user changed something at editing --- scm-ui/src/users/components/UserForm.js | 33 ++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/scm-ui/src/users/components/UserForm.js b/scm-ui/src/users/components/UserForm.js index 9e04160d3d..a241b583c3 100644 --- a/scm-ui/src/users/components/UserForm.js +++ b/scm-ui/src/users/components/UserForm.js @@ -61,17 +61,38 @@ class UserForm extends React.Component { return false; } - isValid = () => { + createUserComponentsAreValid = () => { const user = this.state.user; - - const createUserIsValid = !this.props.user - ? this.state.nameValidationError || + if (!this.props.user) { + return ( + this.state.nameValidationError || this.isFalsy(user.name) || !this.state.passwordValid - : false; + ); + } else { + return false; + } + }; + editUserComponentsAreChanged = () => { + const user = this.state.user; + if (this.props.user) { + return ( + this.props.user.displayName === user.displayName && + this.props.user.mail === user.mail && + this.props.user.admin === user.admin && + this.props.user.active === user.active + ); + } else { + return false; + } + }; + + isValid = () => { + const user = this.state.user; return !( - createUserIsValid || + this.createUserComponentsAreValid() || + this.editUserComponentsAreChanged() || this.state.mailValidationError || this.state.displayNameValidationError || this.isFalsy(user.displayName) ||