From 3ee7baceba601526f60ea2a78decfc0b6c8feb8e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Fri, 10 Aug 2018 15:53:11 +0200 Subject: [PATCH] SONAR-11148 Fix bad use of scmAccount param in api/users/update --- server/sonar-web/src/main/js/api/users.ts | 7 +++++-- .../src/main/js/apps/users/components/UserForm.tsx | 4 ++-- .../main/js/apps/users/components/UserScmAccountInput.tsx | 2 +- .../src/main/js/apps/users/components/UserScmAccounts.tsx | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/server/sonar-web/src/main/js/api/users.ts b/server/sonar-web/src/main/js/api/users.ts index 055be31081f..f266f79bd41 100644 --- a/server/sonar-web/src/main/js/api/users.ts +++ b/server/sonar-web/src/main/js/api/users.ts @@ -88,9 +88,12 @@ export function updateUser(data: { email?: string; login: string; name?: string; - scmAccount?: string; + scmAccount: string[]; }): Promise { - return postJSON('/api/users/update', data); + return postJSON('/api/users/update', { + ...data, + scmAccount: data.scmAccount.length > 0 ? data.scmAccount : '' + }); } export function deactivateUser(data: { login: string }): Promise { diff --git a/server/sonar-web/src/main/js/apps/users/components/UserForm.tsx b/server/sonar-web/src/main/js/apps/users/components/UserForm.tsx index c3c4e670af0..75b581deea3 100644 --- a/server/sonar-web/src/main/js/apps/users/components/UserForm.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/UserForm.tsx @@ -124,7 +124,7 @@ export default class UserForm extends React.PureComponent { email: this.state.email, login: this.state.login, name: this.state.name, - scmAccount: uniq(this.state.scmAccounts).join(',') + scmAccount: uniq(this.state.scmAccounts) }).then(() => { this.props.onUpdateUsers(); this.props.onClose(); @@ -249,7 +249,7 @@ export default class UserForm extends React.PureComponent { /> ))}
-
diff --git a/server/sonar-web/src/main/js/apps/users/components/UserScmAccountInput.tsx b/server/sonar-web/src/main/js/apps/users/components/UserScmAccountInput.tsx index 6f93c423cd2..322a60c182f 100644 --- a/server/sonar-web/src/main/js/apps/users/components/UserScmAccountInput.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/UserScmAccountInput.tsx @@ -35,7 +35,7 @@ export default class UserScmAccountInput extends React.PureComponent { render() { return ( -
+
{ const { scmAccounts } = this.props; const limit = scmAccounts.length > SCM_LIMIT ? SCM_LIMIT - 1 : SCM_LIMIT; return ( -
    +
      {scmAccounts.slice(0, limit).map((scmAccount, idx) => (
    • {scmAccount} -- 2.39.5