This is an automated email from the ASF dual-hosted git repository.

dgnatyshyn pushed a commit to branch DLAB-1942
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit f4911438892fe1ef1ebbe0f3bb117b2d36d84596
Author: Dmytro_Gnatyshyn <di1...@ukr.net>
AuthorDate: Wed Aug 26 13:54:38 2020 +0300

    [DLAB-1942]: Improved validation for user adding to the group
---
 .../src/app/administration/roles/roles.component.html       |  6 +++---
 .../webapp/src/app/administration/roles/roles.component.ts  | 13 +++++++------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git 
a/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.html
 
b/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.html
index 31199dc..ab1b7f5 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.html
+++ 
b/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.html
@@ -119,9 +119,9 @@
         <td mat-cell *matCellDef="let element" class="users-list ani">
           <mat-form-field class="chip-list">
             <input #user matInput placeholder="Enter user login" 
pattern="[@.-_0-9a-zA-Z]"
-              (keydown.enter)="addUser(user.value, element); user.value = ''" 
(keyup)="checkIfUserAdded(element, user.value)">
-            <button mat-icon-button matSuffix (click)="addUser(user.value, 
element); user.value = ''" [disabled]="element.isUserAdded">
-              <mat-icon matTooltip="User allready added to this group" 
matTooltipPosition="above" 
[matTooltipDisabled]="!element.isUserAdded">person_add</mat-icon>
+              (keydown.enter)="addUser(user, element);" 
(keyup)="checkIfUserAdded(element, user.value)">
+            <button mat-icon-button matSuffix (click)="addUser(user, element); 
user.value = ''" [disabled]="element.isUserAdded">
+              <mat-icon matTooltip="User is already added to this group" 
matTooltipPosition="above" 
[matTooltipDisabled]="!element.isUserAdded">person_add</mat-icon>
             </button>
           </mat-form-field>
           <div class="list-selected list-container ani">
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.ts
 
b/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.ts
index a80aae6..35318aa 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.ts
+++ 
b/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.ts
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-import { Component, OnInit, Output, EventEmitter, Inject } from 
'@angular/core';
+import {Component, OnInit, Output, EventEmitter, Inject, ViewChild} from 
'@angular/core';
 import { ValidatorFn, FormControl } from '@angular/forms';
 import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from 
'@angular/material/dialog';
 import { ToastrService } from 'ngx-toastr';
@@ -275,14 +275,15 @@ export class RolesComponent implements OnInit {
     list.splice(list.indexOf(item), 1);
   }
 
-  public addUser(value: string, item): void {
-    if (item.users.includes(value)) {
+  public addUser(user, item): void {
+    if (item.users.filter(v => v.toLowerCase() === 
user.value.toLowerCase()).length) {
+      if (!this.toastr.toasts.length) this.toastr.error('User is already added 
to this group', 'Oops!');
       return;
     }
-
-    if (value && value.trim()) {
-      item.users instanceof Array ? item.users.push(value.trim()) : item.users 
= [value.trim()];
+    if (user.value && user.value.trim()) {
+      item.users instanceof Array ? item.users.push(user.value.trim()) : 
item.users = [user.value.trim()];
     }
+    user.value = '';
   }
 
   private getEnvironmentHealthStatus() {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org
For additional commands, e-mail: commits-h...@dlab.apache.org

Reply via email to