From 5eda405f68aa270382a45ddd8a6c9e3da0ac58f4 Mon Sep 17 00:00:00 2001 From: PaulRC-ioet <73141380+PaulRC-ioet@users.noreply.github.com> Date: Wed, 27 Jan 2021 11:21:17 -0500 Subject: [PATCH 1/3] fix: TT-132 Remove Feature Toggle from User list (#630) --- .../users-list/users-list.component.html | 17 +++--- .../users-list/users-list.component.spec.ts | 54 +------------------ .../users-list/users-list.component.ts | 34 +----------- 3 files changed, 13 insertions(+), 92 deletions(-) diff --git a/src/app/modules/users/components/users-list/users-list.component.html b/src/app/modules/users/components/users-list/users-list.component.html index 71aa110da..b13c0206f 100644 --- a/src/app/modules/users/components/users-list/users-list.component.html +++ b/src/app/modules/users/components/users-list/users-list.component.html @@ -1,22 +1,23 @@ - - - + + + - + - - - + +
User EmailNamesRolesUser EmailNamesRoles
{{ user.email }}{{ user.name }} + {{ user.email }}{{ user.name }}
{ let component: UsersListComponent; let fixture: ComponentFixture; let store: MockStore; - let featureManagerService: FeatureManagerService; const actionSub: ActionsSubject = new ActionsSubject(); const state: UserState = { @@ -39,7 +36,6 @@ describe('UsersListComponent', () => { declarations: [UsersListComponent], providers: [provideMockStore({ initialState: state }), { provide: ActionsSubject, useValue: actionSub }], }).compileComponents(); - featureManagerService = TestBed.inject(FeatureManagerService); }) ); @@ -75,36 +71,6 @@ describe('UsersListComponent', () => { expect(component.users).toEqual(state.data); }); - it('When Component is created, should call the feature toggle method', () => { - spyOn(component, 'isFeatureToggleActivated').and.returnValue(of(true)); - - component.ngOnInit(); - - expect(component.isFeatureToggleActivated).toHaveBeenCalled(); - expect(component.isUserRoleToggleOn).toBe(true); - }); - - const actionsParams = [ - { actionType: UserActionTypes.GRANT_USER_ROLE_SUCCESS }, - { actionType: UserActionTypes.REVOKE_USER_ROLE_SUCCESS }, - ]; - - actionsParams.map((param) => { - it(`When action ${param.actionType} is dispatched should triggered load Users action`, () => { - spyOn(store, 'dispatch'); - - const actionSubject = TestBed.inject(ActionsSubject) as ActionsSubject; - const action = { - type: param.actionType, - payload: state.data, - }; - - actionSubject.next(action); - - expect(store.dispatch).toHaveBeenCalledWith(new LoadUsers()); - }); - }); - const grantRoleTypes = [ { roleId: 'admin', roleValue: 'time-tracker-admin' }, { roleId: 'test', roleValue: 'time-tracker-tester' }, @@ -190,23 +156,7 @@ describe('UsersListComponent', () => { }); }); - const toggleValues = [true, false]; - toggleValues.map((toggleValue) => { - it(`when FeatureToggle is ${toggleValue} should return ${toggleValue}`, () => { - spyOn(featureManagerService, 'isToggleEnabledForUser').and.returnValue(of(toggleValue)); - - const isFeatureToggleActivated: Observable = component.isFeatureToggleActivated(); - - expect(featureManagerService.isToggleEnabledForUser).toHaveBeenCalled(); - isFeatureToggleActivated.subscribe((value) => expect(value).toEqual(toggleValue)); - }); - }); - - /* - TODO: block commented on purpose so that when the tests pass and the Feature toggle is removed, - the table will be rendered again with dtInstance and not with dtOptions - - it('on success load users, the datatable should be reloaded', async () => { + it('on success load users, the datatable should be reloaded', async () => { const actionSubject = TestBed.inject(ActionsSubject); const action = { type: UserActionTypes.LOAD_USERS_SUCCESS, @@ -217,7 +167,7 @@ describe('UsersListComponent', () => { actionSubject.next(action); expect(component.dtElement.dtInstance.then).toHaveBeenCalled(); - });*/ + }); afterEach(() => { component.dtTrigger.unsubscribe(); diff --git a/src/app/modules/users/components/users-list/users-list.component.ts b/src/app/modules/users/components/users-list/users-list.component.ts index 91cfc2e23..bf4df91c4 100644 --- a/src/app/modules/users/components/users-list/users-list.component.ts +++ b/src/app/modules/users/components/users-list/users-list.component.ts @@ -2,11 +2,10 @@ import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild } from '@angular import { ActionsSubject, select, Store } from '@ngrx/store'; import { DataTableDirective } from 'angular-datatables'; import { Observable, Subject, Subscription } from 'rxjs'; -import { delay, filter, map } from 'rxjs/operators'; +import { delay, filter } from 'rxjs/operators'; import { User } from '../../models/users'; import { GrantRoleUser, LoadUsers, RevokeRoleUser, UserActionTypes } from '../../store/user.actions'; import { getIsLoading } from '../../store/user.selectors'; -import { FeatureManagerService } from 'src/app/modules/shared/feature-toggles/feature-toggle-manager.service'; @Component({ selector: 'app-users-list', @@ -22,20 +21,12 @@ export class UsersListComponent implements OnInit, OnDestroy, AfterViewInit { @ViewChild(DataTableDirective, { static: false }) dtElement: DataTableDirective; dtOptions: any = {}; - isUserRoleToggleOn; - constructor( - private store: Store, - private actionsSubject$: ActionsSubject, - private featureManagerService: FeatureManagerService - ) { + constructor(private store: Store, private actionsSubject$: ActionsSubject) { this.isLoading$ = store.pipe(delay(0), select(getIsLoading)); } ngOnInit(): void { - this.isFeatureToggleActivated().subscribe((flag) => { - this.isUserRoleToggleOn = flag; - }); this.store.dispatch(new LoadUsers()); this.loadUsersSubscription = this.actionsSubject$ .pipe(filter((action: any) => action.type === UserActionTypes.LOAD_USERS_SUCCESS)) @@ -43,19 +34,6 @@ export class UsersListComponent implements OnInit, OnDestroy, AfterViewInit { this.users = action.payload; this.rerenderDataTable(); }); - - this.switchRoleSubscription = this.actionsSubject$ - .pipe( - filter( - (action: any) => - action.type === UserActionTypes.GRANT_USER_ROLE_SUCCESS || - action.type === UserActionTypes.REVOKE_USER_ROLE_SUCCESS - ) - ) - .subscribe((action) => { - this.store.dispatch(new LoadUsers()); - this.rerenderDataTable(); - }); } ngAfterViewInit(): void { @@ -83,12 +61,4 @@ export class UsersListComponent implements OnInit, OnDestroy, AfterViewInit { ? this.store.dispatch(new RevokeRoleUser(userId, roleId)) : this.store.dispatch(new GrantRoleUser(userId, roleId)); } - - isFeatureToggleActivated() { - return this.featureManagerService.isToggleEnabledForUser('ui-list-test-users').pipe( - map((enabled) => { - return enabled === true ? true : false; - }) - ); - } } From 22d7a5cc348506262463edabe6368f494406a5a7 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 27 Jan 2021 16:22:45 +0000 Subject: [PATCH 2/3] chore(release): 1.31.7 [skip ci]nn --- package-lock.json | 32 ++++++++++++++++---------------- package.json | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5abb2b1c7..a8033c5e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "time-tracker", - "version": "1.31.6", + "version": "1.31.7", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -6077,6 +6077,15 @@ "p-try": "^2.0.0" } }, + "serialize-javascript": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-3.1.0.tgz", + "integrity": "sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, "ssri": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/ssri/-/ssri-8.0.0.tgz", @@ -18532,15 +18541,6 @@ } } }, - "serialize-javascript": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", - "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==", - "dev": true, - "requires": { - "randombytes": "^2.1.0" - } - }, "serve-index": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", @@ -20015,9 +20015,9 @@ } }, "serialize-javascript": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", - "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-3.1.0.tgz", + "integrity": "sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg==", "dev": true, "requires": { "randombytes": "^2.1.0" @@ -21250,9 +21250,9 @@ }, "dependencies": { "serialize-javascript": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", - "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-3.1.0.tgz", + "integrity": "sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg==", "dev": true, "requires": { "randombytes": "^2.1.0" diff --git a/package.json b/package.json index f5411847c..1ea6a7b0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "time-tracker", - "version": "1.31.6", + "version": "1.31.7", "scripts": { "preinstall": "npx npm-force-resolutions", "ng": "ng", From 498639b81401205735dfd45fd94f31e4bf5a0dc7 Mon Sep 17 00:00:00 2001 From: Sandro Castillo Date: Tue, 26 Jan 2021 19:28:21 -0500 Subject: [PATCH 3/3] fix: TT-117 two-entries-in-progress-bug --- .../components/details-fields/details-fields.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.ts b/src/app/modules/shared/components/details-fields/details-fields.component.ts index 566960acc..e6e5ee500 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.ts @@ -107,6 +107,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { .subscribe(() => { this.cleanForm(); }); + } onClearedComponent(event) { @@ -253,6 +254,6 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { end_hour: formatDate(get(this.entryToEdit, 'start_date', '00:00'), 'HH:mm', 'en'), }); } - this.shouldRestartEntry = !this.entryToEdit?.running && this.goingToWorkOnThis; + this.shouldRestartEntry = this.entryToEdit?.running && this.goingToWorkOnThis; } }