Skip to content

Commit 4361335

Browse files
committed
feat: TT-190 Use add/remove groups endpoints in users section in UI
1 parent 5cae37f commit 4361335

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

src/app/modules/users/components/users-list/users-list.component.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<td class="col-4 text-break">{{ user.email }}</td>
2020
<td class="col-5 text-break">{{ user.name }}</td>
2121
<td class="col-3 text-center">
22+
<<<<<<< HEAD
2223
<div *ngIf="isUserGroupsToggleOn">
2324
<ui-switch
2425
size="small"
@@ -42,22 +43,49 @@
4243
[checked]="user.roles.includes('time-tracker-admin')"
4344
=======
4445
(change)="switchGroups(user.id, user.groups, 'admin', 'time-tracker-admin')"
46+
=======
47+
<div *ngIf="flakyToggle; else elseBlock">
48+
<ui-switch
49+
size="small"
50+
(change)="switchGroup(user.id, user.groups, 'time-tracker-admin')"
51+
>>>>>>> feat: TT-190 Use add/remove groups endpoints in users section in UI
4552
[checked]="user.groups.includes('time-tracker-admin')"
4653
>>>>>>> fix: TT-190 use add remove groups
4754
></ui-switch>
4855
admin
4956
<ui-switch
5057
size="small"
58+
<<<<<<< HEAD
5159
<<<<<<< HEAD
5260
(change)="switchRole(user.id, user.roles,'tester','time-tracker-tester')"
5361
[checked]="user.roles.includes('time-tracker-tester')"
5462
=======
5563
(change)="switchGroups(user.id, user.groups, 'test', 'time-tracker-tester')"
64+
=======
65+
(change)="switchGroup(user.id, user.groups, 'time-tracker-tester')"
66+
>>>>>>> feat: TT-190 Use add/remove groups endpoints in users section in UI
5667
[checked]="user.groups.includes('time-tracker-tester')"
5768
>>>>>>> fix: TT-190 use add remove groups
5869
></ui-switch>
5970
test
6071
</div>
72+
<ng-template #elseBlock>
73+
<div>
74+
<ui-switch
75+
size="small"
76+
(change)="switchRole(user.id, user.roles, 'admin','time-tracker-admin')"
77+
[checked]="user.roles.includes('time-tracker-admin')"
78+
></ui-switch>
79+
admin
80+
<ui-switch
81+
size="small"
82+
(change)="switchRole(user.id, user.roles,'tester','time-tracker-tester')"
83+
[checked]="user.roles.includes('time-tracker-tester')"
84+
></ui-switch>
85+
test
86+
</div>
87+
</ng-template>
88+
6189
</td>
6290
</tr>
6391
</tbody>

src/app/modules/users/components/users-list/users-list.component.ts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild } from '@angular
22
import { ActionsSubject, select, Store } from '@ngrx/store';
33
import { DataTableDirective } from 'angular-datatables';
44
<<<<<<< HEAD
5+
<<<<<<< HEAD
56
import { Observable, Subject, Subscription } from 'rxjs';
67
import { delay, filter, map } from 'rxjs/operators';
78
import { FeatureManagerService } from 'src/app/modules/shared/feature-toggles/feature-toggle-manager.service';
@@ -21,6 +22,20 @@ import { FeatureManagerService } from 'src/app/modules/shared/feature-toggles/fe
2122
import { User } from '../../models/users';
2223
import { GrantRoleUser, LoadUsers, RevokeRoleUser, UserActionTypes, AddUserToGroup, RemoveUserToGroup} from '../../store/user.actions';
2324
>>>>>>> fix: TT-190 use add remove groups
25+
=======
26+
import { Observable, Subject, Subscription } from 'rxjs';
27+
import { delay, filter, map } from 'rxjs/operators';
28+
import { FeatureManagerService } from 'src/app/modules/shared/feature-toggles/feature-toggle-manager.service';
29+
import { User } from '../../models/users';
30+
import {
31+
GrantRoleUser,
32+
LoadUsers,
33+
RevokeRoleUser,
34+
UserActionTypes,
35+
AddUserToGroup,
36+
RemoveUserToGroup,
37+
} from '../../store/user.actions';
38+
>>>>>>> feat: TT-190 Use add/remove groups endpoints in users section in UI
2439
import { getIsLoading } from '../../store/user.selectors';
2540

2641
@Component({
@@ -39,12 +54,17 @@ export class UsersListComponent implements OnInit, OnDestroy, AfterViewInit {
3954
dtOptions: any = {};
4055
switchGroupsSubscription: Subscription;
4156
isEnableToggleSubscription: Subscription;
57+
<<<<<<< HEAD
4258
isUserGroupsToggleOn: boolean;
59+
=======
60+
isUserGroupsToggleOn;
61+
flakyToggle: boolean = false; // borrar para implementar feature toggle
62+
>>>>>>> feat: TT-190 Use add/remove groups endpoints in users section in UI
4363

4464
constructor(
4565
private store: Store<User>,
4666
private actionsSubject$: ActionsSubject,
47-
private featureManagerService: FeatureManagerService
67+
//private featureManagerService: FeatureManagerService
4868
) {
4969
this.isLoading$ = store.pipe(delay(0), select(getIsLoading));
5070
}
@@ -58,9 +78,16 @@ export class UsersListComponent implements OnInit, OnDestroy, AfterViewInit {
5878
this.rerenderDataTable();
5979
});
6080

81+
<<<<<<< HEAD
6182
this.isEnableToggleSubscription = this.isFeatureToggleActivated().subscribe((flag) => {
6283
this.isUserGroupsToggleOn = flag;
6384
});
85+
=======
86+
/* this.isEnableToggleSubscription = this.isFeatureToggleActivated().subscribe((flag) => {
87+
this.isUserGroupsToggleOn = flag;
88+
console.log('in subscription', this.isUserGroupsToggleOn);
89+
});*/
90+
>>>>>>> feat: TT-190 Use add/remove groups endpoints in users section in UI
6491

6592
this.switchGroupsSubscription = this.actionsSubject$
6693
.pipe(
@@ -121,17 +148,32 @@ export class UsersListComponent implements OnInit, OnDestroy, AfterViewInit {
121148
: this.store.dispatch(new AddUserToGroup(userId, groupName));
122149
}
123150

151+
<<<<<<< HEAD
124152
isFeatureToggleActivated() {
125153
return this.featureManagerService.isToggleEnabledForUser('switch-group').pipe(
154+
=======
155+
switchGroup(userId: string, userGroups: string[], groupName: string) {
156+
userGroups.includes(groupName)
157+
? this.store.dispatch(new RemoveUserToGroup(userId, groupName))
158+
: this.store.dispatch(new AddUserToGroup(userId, groupName));
159+
}
160+
161+
/* isFeatureToggleActivated() {
162+
return this.featureManagerService.isToggleEnabledForUser('ui-list-technologies').pipe(
163+
>>>>>>> feat: TT-190 Use add/remove groups endpoints in users section in UI
126164
map((enabled) => {
127165
return enabled === true ? true : false;
128166
})
129167
);
168+
<<<<<<< HEAD
130169
}
131170
132171
switchGroups(userId: string, userGroups: string[], groupname: string, groupValue: string) {
133172
userGroups.includes(groupValue)
134173
? this.store.dispatch(new RemoveUserFromGroup(userId, groupname))
135174
: this.store.dispatch(new AddUserToGroup(userId, groupname));
136175
}
176+
=======
177+
}*/
178+
>>>>>>> feat: TT-190 Use add/remove groups endpoints in users section in UI
137179
}

0 commit comments

Comments
 (0)