]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11148 Fix bad use of scmAccount param in api/users/update
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Fri, 10 Aug 2018 13:53:11 +0000 (15:53 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 16 Aug 2018 07:45:57 +0000 (09:45 +0200)
server/sonar-web/src/main/js/api/users.ts
server/sonar-web/src/main/js/apps/users/components/UserForm.tsx
server/sonar-web/src/main/js/apps/users/components/UserScmAccountInput.tsx
server/sonar-web/src/main/js/apps/users/components/UserScmAccounts.tsx

index 055be31081f1c02c1d92906394ee94488171f18f..f266f79bd41ecfc5109e116f088bc524776984aa 100644 (file)
@@ -88,9 +88,12 @@ export function updateUser(data: {
   email?: string;
   login: string;
   name?: string;
-  scmAccount?: string;
+  scmAccount: string[];
 }): Promise<User> {
-  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<User> {
index c3c4e670af058d489e517a7ae9859d18e1fec6eb..75b581deea315c9e2738e682ab417ef42cf39aa6 100644 (file)
@@ -124,7 +124,7 @@ export default class UserForm extends React.PureComponent<Props, State> {
       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<Props, State> {
                 />
               ))}
               <div className="spacer-bottom">
-                <Button onClick={this.handleAddScmAccount} type="reset">
+                <Button className="js-scm-account-add" onClick={this.handleAddScmAccount}>
                   {translate('add_verb')}
                 </Button>
               </div>
index 6f93c423cd209f37a27d6da2463a680b0e20d34b..322a60c182fa21a26304efb24a5710a5f46d84ca 100644 (file)
@@ -35,7 +35,7 @@ export default class UserScmAccountInput extends React.PureComponent<Props> {
 
   render() {
     return (
-      <div>
+      <div className="js-scm-account">
         <input
           maxLength={255}
           onChange={this.handleChange}
index 67938f2e702732fe25f9ca2d72d7b591bd74a576..39a90cb2268ebea7f94d89c7c6df469b203ddda5 100644 (file)
@@ -42,7 +42,7 @@ export default class UserScmAccounts extends React.PureComponent<Props, State> {
     const { scmAccounts } = this.props;
     const limit = scmAccounts.length > SCM_LIMIT ? SCM_LIMIT - 1 : SCM_LIMIT;
     return (
-      <ul>
+      <ul className="js-scm-accounts">
         {scmAccounts.slice(0, limit).map((scmAccount, idx) => (
           <li className="little-spacer-bottom" key={idx}>
             {scmAccount}