From 50e7fe73a99cdd3e1ee522fb0085495df975b602 Mon Sep 17 00:00:00 2001 From: Elviani Huseyin Date: Thu, 10 Oct 2019 17:22:25 +0100 Subject: [PATCH 01/71] adding manage payments --- src/app/app.constants.ts | 3 ++- .../invite-user-form/invite-user-form.component.html | 8 +++++++- src/users/containers/invite-user/invite-user.component.ts | 3 ++- .../containers/user-details/user-details.component.html | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/app.constants.ts b/src/app/app.constants.ts index 1b700709a..efdca7819 100644 --- a/src/app/app.constants.ts +++ b/src/app/app.constants.ts @@ -65,7 +65,8 @@ const userRoles = [ { role: 'pui-organisation-manager', roleType: 'manageOrganisations'}, { role: 'pui-user-manager', roleType: 'manageUsers' }, - { role: 'pui-case-manager', roleType: 'manageCases'} + { role: 'pui-case-manager', roleType: 'manageCases'}, + { role: 'pui-finance-manager', roleType: 'managePayments'} ]; const jurisdictions = [ diff --git a/src/users/components/invite-user-form/invite-user-form.component.html b/src/users/components/invite-user-form/invite-user-form.component.html index 6dbf58d20..56c06d559 100644 --- a/src/users/components/invite-user-form/invite-user-form.component.html +++ b/src/users/components/invite-user-form/invite-user-form.component.html @@ -22,7 +22,7 @@
@@ -42,6 +42,12 @@ [config]="{value: 'pui-organisation-manager', label: 'Manage Organisation', name: 'roles', hint: 'View organisation name and addresses.'}"> + + +
diff --git a/src/users/containers/invite-user/invite-user.component.ts b/src/users/containers/invite-user/invite-user.component.ts index 214071c89..6af3525d0 100644 --- a/src/users/containers/invite-user/invite-user.component.ts +++ b/src/users/containers/invite-user/invite-user.component.ts @@ -46,7 +46,8 @@ export class InviteUserComponent implements OnInit, OnDestroy { roles: new FormGroup({ 'pui-case-manager': new FormControl(''), 'pui-user-manager': new FormControl(''), - 'pui-organisation-manager': new FormControl('') + 'pui-organisation-manager': new FormControl(''), + 'pui-finance-manager': new FormControl('') }, checkboxesBeCheckedValidator()) }); this.juridictionSubscription = this.store.pipe(select(fromAppStore.getAllJuridictions)) diff --git a/src/users/containers/user-details/user-details.component.html b/src/users/containers/user-details/user-details.component.html index f8ce8b77d..d74aea12f 100644 --- a/src/users/containers/user-details/user-details.component.html +++ b/src/users/containers/user-details/user-details.component.html @@ -25,6 +25,7 @@
Manage Organisations
Manage Users
Manage Cases
+
Manage Payments
From 5f377e34bffa9f240d7943d2b01c078261746403 Mon Sep 17 00:00:00 2001 From: Elviani Huseyin Date: Tue, 15 Oct 2019 16:02:24 +0100 Subject: [PATCH 02/71] adding the missing name on pending user --- .../src/lib/components/govuk-table/govuk-table.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/gov-ui/src/lib/components/govuk-table/govuk-table.component.html b/projects/gov-ui/src/lib/components/govuk-table/govuk-table.component.html index 615874ef5..520b29798 100644 --- a/projects/gov-ui/src/lib/components/govuk-table/govuk-table.component.html +++ b/projects/gov-ui/src/lib/components/govuk-table/govuk-table.component.html @@ -16,7 +16,7 @@ {{formatDate(r[col.key])}} - {{r[col.key]}} + {{r[col.key]}} {{r[col.key]}} From 22e20a5aec71ac1fd16a52b9ccbb2b639d86cc60 Mon Sep 17 00:00:00 2001 From: Elviani Huseyin Date: Wed, 16 Oct 2019 11:37:58 +0100 Subject: [PATCH 03/71] fixing the unit test --- src/users/store/reducers/users.reducer.spec.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/users/store/reducers/users.reducer.spec.ts b/src/users/store/reducers/users.reducer.spec.ts index f8bd56723..93122bd03 100644 --- a/src/users/store/reducers/users.reducer.spec.ts +++ b/src/users/store/reducers/users.reducer.spec.ts @@ -8,7 +8,7 @@ const mockUserList = [ email: 'somthing1@something', idamStatus: 'active', userIdentifier: 'userId1', - roles: ['pui-organisation-manager', 'pui-user-manager', 'pui-case-manager'] + roles: ['pui-organisation-manager', 'pui-user-manager', 'pui-case-manager', 'pui-finance-manager'] }, { firstName: 'Test2fggftfirstname', @@ -29,10 +29,11 @@ const resultUserList = [ userIdentifier: 'userId1', selected: false, status: 'Active', - roles: ['pui-organisation-manager', 'pui-user-manager', 'pui-case-manager'], + roles: ['pui-organisation-manager', 'pui-user-manager', 'pui-case-manager', 'pui-finance-manager'], manageOrganisations: 'Yes', manageUsers: 'Yes', - manageCases: 'Yes' + manageCases: 'Yes', + managePayments: 'Yes' }, { firstName: 'Test2fggftfirstname', @@ -45,7 +46,8 @@ const resultUserList = [ roles: ['pui-organisation-manager', 'pui-user-manager'], manageOrganisations: 'Yes', manageUsers: 'Yes', - manageCases: 'No' + manageCases: 'No', + managePayments: 'No' } ]; From 793c629c55774f8d377d45049f469586b16c5232 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Thu, 17 Oct 2019 15:38:33 +0100 Subject: [PATCH 04/71] Adding User Permissions --- src/users/components/index.ts | 4 ++- .../invite-user-form.component.html | 7 +++-- .../invite-user-permission.component.html | 27 +++++++++++++++++++ .../invite-user-permission.component.ts | 12 +++++++++ 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 src/users/components/invite-user-permissions/invite-user-permission.component.html create mode 100644 src/users/components/invite-user-permissions/invite-user-permission.component.ts diff --git a/src/users/components/index.ts b/src/users/components/index.ts index 0c8ed203e..18cb91c30 100644 --- a/src/users/components/index.ts +++ b/src/users/components/index.ts @@ -1,5 +1,7 @@ import {InviteUserFormComponent} from './invite-user-form/invite-user-form.component'; +import { InviteUserPermissionComponent } from './invite-user-permissions/invite-user-permission.component'; -export const components: any[] = [InviteUserFormComponent]; +export const components: any[] = [InviteUserFormComponent, InviteUserPermissionComponent]; export * from './invite-user-form/invite-user-form.component'; +export * from './invite-user-permissions/invite-user-permission.component'; diff --git a/src/users/components/invite-user-form/invite-user-form.component.html b/src/users/components/invite-user-form/invite-user-form.component.html index 6dbf58d20..a45ac3c0e 100644 --- a/src/users/components/invite-user-form/invite-user-form.component.html +++ b/src/users/components/invite-user-form/invite-user-form.component.html @@ -19,8 +19,11 @@ [group]="inviteUserForm"> + + + - @@ -44,7 +47,7 @@ - + --> diff --git a/src/users/components/invite-user-permissions/invite-user-permission.component.html b/src/users/components/invite-user-permissions/invite-user-permission.component.html index fb635246a..4072a2fab 100644 --- a/src/users/components/invite-user-permissions/invite-user-permission.component.html +++ b/src/users/components/invite-user-permissions/invite-user-permission.component.html @@ -1,6 +1,7 @@ diff --git a/src/users/components/invite-user-permissions/invite-user-permission.component.ts b/src/users/components/invite-user-permissions/invite-user-permission.component.ts index 66aeacc8d..13351ee14 100644 --- a/src/users/components/invite-user-permissions/invite-user-permission.component.ts +++ b/src/users/components/invite-user-permissions/invite-user-permission.component.ts @@ -8,5 +8,5 @@ import { FormGroup } from '@angular/forms'; export class InviteUserPermissionComponent { @Input() inviteUserForm: FormGroup; - // @Input() isInvalid; + @Input() isInvalid; } From 3414cae4d9ed13d9709e80faff65631c6a60caed Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Fri, 18 Oct 2019 14:11:45 +0100 Subject: [PATCH 06/71] Adding edit user permission and link with router --- .../edit-user-permission.component.html | 0 .../edit-user-permission.component.ts | 9 ++++ src/users/containers/index.ts | 5 +- .../user-details/user-details.component.html | 47 +++++++++++-------- src/users/users.routing.ts | 6 ++- 5 files changed, 45 insertions(+), 22 deletions(-) create mode 100644 src/users/containers/edit-user-permissions/edit-user-permission.component.html create mode 100644 src/users/containers/edit-user-permissions/edit-user-permission.component.ts diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.html b/src/users/containers/edit-user-permissions/edit-user-permission.component.html new file mode 100644 index 000000000..e69de29bb diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts new file mode 100644 index 000000000..bd5f6338e --- /dev/null +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts @@ -0,0 +1,9 @@ +import {Component, Input, Output, EventEmitter} from '@angular/core'; + +@Component({ + selector: 'edit-user-permission', + templateUrl: './edit-user-permission.component.html', + }) + export class EditUserPermissionComponent { + + } diff --git a/src/users/containers/index.ts b/src/users/containers/index.ts index 61cfefc12..09bdb35b1 100644 --- a/src/users/containers/index.ts +++ b/src/users/containers/index.ts @@ -2,11 +2,14 @@ import { UsersComponent } from './users/users.component'; import { InviteUserComponent } from './invite-user/invite-user.component'; import { InviteUserSuccessComponent } from './invite-user-success/invite-user-success.component'; import { UserDetailsComponent } from './user-details/user-details.component'; +import { EditUserPermissionComponent } from './edit-user-permissions/edit-user-permission.component'; -export const containers: any[] = [UsersComponent, InviteUserComponent, InviteUserSuccessComponent, UserDetailsComponent]; +export const containers: any[] = [UsersComponent, InviteUserComponent, InviteUserSuccessComponent, UserDetailsComponent, + EditUserPermissionComponent]; export * from './users/users.component'; export * from './invite-user/invite-user.component'; export * from './invite-user-success/invite-user-success.component'; export * from './user-details/user-details.component'; +export * from './edit-user-permissions/edit-user-permission.component'; diff --git a/src/users/containers/user-details/user-details.component.html b/src/users/containers/user-details/user-details.component.html index f8ce8b77d..cc4d7dcee 100644 --- a/src/users/containers/user-details/user-details.component.html +++ b/src/users/containers/user-details/user-details.component.html @@ -9,26 +9,33 @@ This user's account has been suspended. - - - - - - - - - - - - - - - -
Name{{user.fullName}}
Email address{{user.email}}
Permissions -
Manage Organisations
-
Manage Users
-
Manage Cases
-
+
+
+ + + + + + + + + + + + + + + + + + +
Name{{user.fullName}}
Email address{{user.email}}
Permissions +
Manage Organisations
+
Manage Users
+
Manage Cases
+
Change
+
+

Contact service-desk@hmcts.gov.uk to reactivate this account.

diff --git a/src/users/users.routing.ts b/src/users/users.routing.ts index 0cd8fb0ba..15c82061e 100644 --- a/src/users/users.routing.ts +++ b/src/users/users.routing.ts @@ -1,7 +1,7 @@ // routes import { RouterModule, Routes } from '@angular/router'; import { ModuleWithProviders } from '@angular/core'; -import { UsersComponent, UserDetailsComponent } from './containers'; +import { UsersComponent, UserDetailsComponent, EditUserPermissionComponent } from './containers'; import { InviteUserComponent } from './containers/invite-user/invite-user.component'; import { InviteUserSuccessComponent } from './containers/invite-user-success/invite-user-success.component'; import { InviteUserSuccessGuard } from './guards/invite-user-success.guard'; @@ -26,6 +26,10 @@ export const ROUTES: Routes = [ path: 'invite-user-success', component: InviteUserSuccessComponent, canActivate: [InviteUserSuccessGuard], + }, + { + path: 'user/:userId/editpermission', + component: EditUserPermissionComponent, } ]; From 0c55b7f43ef4d602ade137a8832bec33c92cb4c9 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Mon, 21 Oct 2019 09:48:38 +0100 Subject: [PATCH 07/71] Edit user permissions --- .../invite-user-permission.component.html | 1 - .../edit-user-permission.component.html | 3 +++ .../edit-user-permission.component.ts | 18 +++++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/users/components/invite-user-permissions/invite-user-permission.component.html b/src/users/components/invite-user-permissions/invite-user-permission.component.html index 4072a2fab..fb635246a 100644 --- a/src/users/components/invite-user-permissions/invite-user-permission.component.html +++ b/src/users/components/invite-user-permissions/invite-user-permission.component.html @@ -1,7 +1,6 @@ diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.html b/src/users/containers/edit-user-permissions/edit-user-permission.component.html index e69de29bb..7b719eea6 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.html +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts index bd5f6338e..301d0326b 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts @@ -1,9 +1,21 @@ -import {Component, Input, Output, EventEmitter} from '@angular/core'; +import {Component, Input, Output, EventEmitter, OnInit} from '@angular/core'; +import { FormGroup, FormControl } from '@angular/forms'; +import { checkboxesBeCheckedValidator } from 'src/custom-validators/checkboxes-be-checked.validator'; @Component({ selector: 'edit-user-permission', templateUrl: './edit-user-permission.component.html', }) - export class EditUserPermissionComponent { - + export class EditUserPermissionComponent implements OnInit { + inviteUserForm: FormGroup; + isInvalid; + ngOnInit(): void { + this.inviteUserForm = new FormGroup({ + roles: new FormGroup({ + 'pui-case-manager': new FormControl(''), + 'pui-user-manager': new FormControl(''), + 'pui-organisation-manager': new FormControl('') + }, checkboxesBeCheckedValidator()) + }); + } } From 8cfb5cc75ee4bf20d2e1a2161704893c0e87dfe2 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Mon, 21 Oct 2019 14:45:37 +0100 Subject: [PATCH 08/71] Adding isChecked to gov-uk-checkbox to take the default Value --- .../gov-uk-checkbox.component.ts | 3 +- .../invite-user-permission.component.html | 3 + .../invite-user-permission.component.ts | 3 + .../edit-user-permission.component.html | 10 ++- .../edit-user-permission.component.ts | 69 ++++++++++++++++++- 5 files changed, 83 insertions(+), 5 deletions(-) diff --git a/projects/gov-ui/src/lib/components/gov-uk-checkbox/gov-uk-checkbox.component.ts b/projects/gov-ui/src/lib/components/gov-uk-checkbox/gov-uk-checkbox.component.ts index 59cb024a2..20f3093c8 100644 --- a/projects/gov-ui/src/lib/components/gov-uk-checkbox/gov-uk-checkbox.component.ts +++ b/projects/gov-ui/src/lib/components/gov-uk-checkbox/gov-uk-checkbox.component.ts @@ -10,7 +10,7 @@ import {FormGroup} from '@angular/forms'; template: `
+ [id]="config.id" [name]="config.name" [formControlName]="config.value" [checked]="isChecked"> {{config.hint}} @@ -22,6 +22,7 @@ export class GovUkCheckboxComponent implements OnInit { constructor() { } @Input() group: FormGroup; @Input() config: {value: string, label: string, hint: string; name: string; focusOn: string; id: string; classes: string}; + @Input() isChecked: boolean = false; id: string; /** diff --git a/src/users/components/invite-user-permissions/invite-user-permission.component.html b/src/users/components/invite-user-permissions/invite-user-permission.component.html index fb635246a..815fef79c 100644 --- a/src/users/components/invite-user-permissions/invite-user-permission.component.html +++ b/src/users/components/invite-user-permissions/invite-user-permission.component.html @@ -7,17 +7,20 @@
diff --git a/src/users/components/invite-user-permissions/invite-user-permission.component.ts b/src/users/components/invite-user-permissions/invite-user-permission.component.ts index 13351ee14..69eecd77f 100644 --- a/src/users/components/invite-user-permissions/invite-user-permission.component.ts +++ b/src/users/components/invite-user-permissions/invite-user-permission.component.ts @@ -9,4 +9,7 @@ import { FormGroup } from '@angular/forms'; export class InviteUserPermissionComponent { @Input() inviteUserForm: FormGroup; @Input() isInvalid; + @Input() isPuiCaseManager: boolean = false; + @Input() isPuiUserManager: boolean = false; + @Input() isPuiOrganisationManager: boolean = false; } diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.html b/src/users/containers/edit-user-permissions/edit-user-permission.component.html index 7b719eea6..cb5bc3a45 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.html +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.html @@ -1,3 +1,9 @@ - - \ No newline at end of file +
+ + + +
\ No newline at end of file diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts index 301d0326b..8670c7da6 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts @@ -1,14 +1,34 @@ -import {Component, Input, Output, EventEmitter, OnInit} from '@angular/core'; +import {Component, OnInit, OnDestroy} from '@angular/core'; import { FormGroup, FormControl } from '@angular/forms'; import { checkboxesBeCheckedValidator } from 'src/custom-validators/checkboxes-be-checked.validator'; +import { Store, select } from '@ngrx/store'; +import * as fromStore from '../../store'; +import * as fromRoot from '../../../app/store'; +import { Observable, Subscription, combineLatest } from 'rxjs'; @Component({ selector: 'edit-user-permission', templateUrl: './edit-user-permission.component.html', }) - export class EditUserPermissionComponent implements OnInit { + export class EditUserPermissionComponent implements OnInit, OnDestroy { inviteUserForm: FormGroup; isInvalid; + + user$: Observable; + isLoading$: Observable; + user: any; + isPuiCaseManager: boolean; + isPuiOrganisationManager: boolean; + isPuiUserManager: boolean; + + userSubscription: Subscription; + dependanciesSubscription: Subscription; + + constructor( + private userStore: Store, + private routerStore: Store, + ) { } + ngOnInit(): void { this.inviteUserForm = new FormGroup({ roles: new FormGroup({ @@ -17,5 +37,50 @@ import { checkboxesBeCheckedValidator } from 'src/custom-validators/checkboxes-b 'pui-organisation-manager': new FormControl('') }, checkboxesBeCheckedValidator()) }); + this.isLoading$ = this.userStore.pipe(select(fromStore.getGetUserLoading)); + + this.dependanciesSubscription = combineLatest([ + this.routerStore.pipe(select(fromRoot.getRouterState)), + this.userStore.pipe(select(fromStore.getGetUserLoaded)) + ]).subscribe(([route, users]) => { + if (users === false) { + this.userStore.dispatch(new fromStore.LoadUsers()); + } + const userId = route.state.params.userId; + this.user$ = this.userStore.pipe(select(fromStore.getGetSingleUser, { userIdentifier: userId })); + }); + + this.userSubscription = this.user$.subscribe((user) => { + this.user = user; + this.isPuiCaseManager = this.getIsPuiCaseManager(user); + this.isPuiOrganisationManager = this.getIsPuiOrganisationManager(user); + this.isPuiUserManager = this.getIsPuiUserManager(user); + }); + } + + getIsPuiCaseManager(user: any): boolean { + return user && user.manageCases === 'Yes'; + } + + getIsPuiOrganisationManager(user: any): boolean { + return user && user.manageOrganisations === 'Yes'; + } + + getIsPuiUserManager(user: any): boolean { + return user && user.manageUsers === 'Yes'; + } + + unsubscribe(subscription: Subscription) { + if (subscription) { + subscription.unsubscribe(); + } + } + + ngOnDestroy() { + this.unsubscribe(this.userSubscription); + this.unsubscribe(this.dependanciesSubscription); + } + + onSubmit() { } } From 527c15e90ed2f34bce07589d800531d7c16ea71d Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Mon, 21 Oct 2019 16:42:18 +0100 Subject: [PATCH 09/71] Setting up router for the Edit user permissions --- api/editUserPermissions/index.ts | 48 ++++++++++++++++++++++++++++++++ api/routes.ts | 2 ++ 2 files changed, 50 insertions(+) create mode 100644 api/editUserPermissions/index.ts diff --git a/api/editUserPermissions/index.ts b/api/editUserPermissions/index.ts new file mode 100644 index 000000000..04cfe3415 --- /dev/null +++ b/api/editUserPermissions/index.ts @@ -0,0 +1,48 @@ +import * as express from 'express' +import { config } from '../lib/config' +import { http } from '../lib/http' +import * as log4jui from '../lib/log4jui' + +export const router = express.Router({ mergeParams: true }) +const logger = log4jui.getLogger('outgoing') + +router.put('/', inviteUserRoute) + +async function inviteUserRoute(req, res) { + let errReport: any + if (!req.params.userId) { + errReport = getErrorReport('UserId is missing', '400', 'User Permissions route error') + res.status(500).send(errReport) + return + } + if (!req.params.orgId) { + errReport = getErrorReport('OrgId is missing', '400', 'User Permissions route error') + res.status(500).send(errReport) + return + } + const payload = req.body + try { + const response = await http.put(getEditPermissionsUrl(config.services.rdProfessionalApi, req.params.userId, req.params.orgId), payload) + logger.info('response::', response.data) + res.send(response.data) + } catch (error) { + logger.info('error', error) + errReport = getErrorReport(getErrorMessage(error), error.status, getErrorMessage(error)) + res.status(error.status).send(errReport) + } +} + +function getErrorMessage(error: any): string { + return error && error.data ? error.data.message : '' +} +function getErrorReport(apiError: string, apiStatusCode: string, message: string): any { + return { + apiError, + apiStatusCode, + message, + } +} +function getEditPermissionsUrl(rdProfessionalApiUrl: string, userId: string, orgId: string): string { + return `${rdProfessionalApiUrl}/refdata/internal/v1/organisations/${orgId}/users/${userId}` +} +export default router diff --git a/api/routes.ts b/api/routes.ts index ab08dc1cb..463ee8984 100644 --- a/api/routes.ts +++ b/api/routes.ts @@ -1,6 +1,7 @@ import * as express from 'express' import accountsRouter from './accounts' import * as auth from './auth' +import editUserPermissions from './editUserPermissions' import healthCheck from './healthCheck' import inviteUser from './inviteUser' import getJurisdictions from './jurisdictions' @@ -23,4 +24,5 @@ router.use('/userDetails', getUserList) router.use('/jurisdictions', getJurisdictions) router.use('/payments/:account', payments) +router.use('/editUserPermissions/:orgId/users/:userId', editUserPermissions) export default router From 0cba49ca0a44172e87457c639250197ccdbdf843 Mon Sep 17 00:00:00 2001 From: Adnan Akgun Date: Tue, 22 Oct 2019 11:31:53 +0100 Subject: [PATCH 10/71] EUI-639 squashed commits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EUI-628 Moved logic to the front end EUI-628 unfinished - broken EUI-628 some more on the store logic remains EUI-628 all working and refactoring EUI-628 tests EUI-628 reverted karma config EUI-628 requested changes EUI-639 added suspend button - unfinished EUI-639 back function needs to taken care of EUI-639 done EUI-639 tests messed up EUI-639 more progress needed EUI-639 tests #!"£$%^&* EUI-639 test for user details EUI-639 Elviani's fix EUI-871 waiting for endpoint confirmation EUI-871 removed console.log EUI-871 really removed console.log EUI-871 fixing experiments EUI-871 tests done --- api/routes.ts | 2 + api/suspendUser/index.ts | 27 ++++ .../govuk-table/govuk-table.component.html | 2 +- .../hmcts-main-wrapper.component.ts | 25 +++- .../user-details/user-details.component.html | 49 ++++++- .../user-details.component.spec.ts | 134 ++++++++++++++++++ .../user-details/user-details.component.ts | 76 ++++++++-- src/users/services/users.service.spec.ts | 20 +++ src/users/services/users.service.ts | 31 ++-- src/users/store/actions/user.actions.ts | 25 +++- src/users/store/effects/users.effects.spec.ts | 55 ++++++- src/users/store/effects/users.effects.ts | 12 ++ 12 files changed, 409 insertions(+), 49 deletions(-) create mode 100644 api/suspendUser/index.ts create mode 100644 src/users/containers/user-details/user-details.component.spec.ts create mode 100644 src/users/services/users.service.spec.ts diff --git a/api/routes.ts b/api/routes.ts index ab08dc1cb..d07bd7961 100644 --- a/api/routes.ts +++ b/api/routes.ts @@ -6,6 +6,7 @@ import inviteUser from './inviteUser' import getJurisdictions from './jurisdictions' import organisationRouter from './organisation' import payments from './payments' +import suspendUser from './suspendUser' import userDetailsRouter from './user' import getUserList from './userList' @@ -22,5 +23,6 @@ router.use('/userList', getUserList) router.use('/userDetails', getUserList) router.use('/jurisdictions', getJurisdictions) router.use('/payments/:account', payments) +router.use('/user/:userId/suspend', suspendUser) export default router diff --git a/api/suspendUser/index.ts b/api/suspendUser/index.ts new file mode 100644 index 000000000..1f448780d --- /dev/null +++ b/api/suspendUser/index.ts @@ -0,0 +1,27 @@ +import * as express from 'express' +import { config } from '../lib/config' +import { http } from '../lib/http' +import * as log4jui from '../lib/log4jui' + +export const router = express.Router({ mergeParams: true }) +const logger = log4jui.getLogger('outgoing') + +router.put('/', suspendUser) + +async function suspendUser(req, res) { + const payload = req.body + try { + const response = await http.put(`${config.services.rdProfessionalApi}/refdata/external/v1/organisations/users/${req.params.userId}`, payload) + logger.info('response::', response.data) + res.send(response.data) + } catch (error) { + logger.info('error', error) + const errReport = { + apiError: error.data.message, + apiStatusCode: error.status, + message: error.data.message, + } + res.status(error.status).send(errReport) + } +} +export default router diff --git a/projects/gov-ui/src/lib/components/govuk-table/govuk-table.component.html b/projects/gov-ui/src/lib/components/govuk-table/govuk-table.component.html index 615874ef5..520b29798 100644 --- a/projects/gov-ui/src/lib/components/govuk-table/govuk-table.component.html +++ b/projects/gov-ui/src/lib/components/govuk-table/govuk-table.component.html @@ -16,7 +16,7 @@ {{formatDate(r[col.key])}} - {{r[col.key]}} + {{r[col.key]}} {{r[col.key]}} diff --git a/src/shared/components/hmcts-main-wrapper/hmcts-main-wrapper.component.ts b/src/shared/components/hmcts-main-wrapper/hmcts-main-wrapper.component.ts index 89cf67b65..8a4107a92 100644 --- a/src/shared/components/hmcts-main-wrapper/hmcts-main-wrapper.component.ts +++ b/src/shared/components/hmcts-main-wrapper/hmcts-main-wrapper.component.ts @@ -3,15 +3,18 @@ import {Component, Input} from '@angular/core'; * Main Content wrapper * Responsible for: * Wrapping content within the gov-uk html elements bellow - * @prop showBackLink - switch for back link + * @prop backLink - switch for back link + * @prop backAction - switch for back action * @prop title = title * @prop summaryErrors list of errors -* @prop back link, title (title), summaryErrors (array of errors) + * @prop actionButtons list of buttons + * @prop back link, back action, title (title), summaryErrors (array of errors), action buttons (array of buttons) * */ @Component({ selector: 'app-hmcts-main-wrapper', template: ` - Back + Back + Back
@@ -23,15 +26,29 @@ import {Component, Input} from '@angular/core';

{{title}}

+
- ` + `, + styles: [`.govuk-back-link { cursor: pointer }`] }) export class HmctsMainWrapperComponent { @Input() backLink: string; + @Input() backAction: () => {}; @Input() title: string; @Input() summaryErrors: {isFromValid: boolean; items: { id: string; message: any; }[]}; + @Input() actionButtons: {name: string, class: string, action: () => {}}[]; constructor() { } diff --git a/src/users/containers/user-details/user-details.component.html b/src/users/containers/user-details/user-details.component.html index f8ce8b77d..3d65602e9 100644 --- a/src/users/containers/user-details/user-details.component.html +++ b/src/users/containers/user-details/user-details.component.html @@ -1,9 +1,11 @@ -
+
! This user's account has been suspended. @@ -29,10 +31,49 @@ -

Contact service-desk@hmcts.gov.uk to reactivate this account.

+

Contact service-desk@hmcts.gov.uk to reactivate this account.

-
Loading...
-
+
Loading...
+ + + + + +
+ ! + + If you suspend this user’s account, they’ll no longer be able to access MyHMCTS services. You will need to contact the service desk to reactivate this account. + +
+ + + + + + + + + + + + + + + +
Name{{user.fullName}}
Email address{{user.email}}
Permissions +
Manage Organisations
+
Manage Users
+
Manage Cases
+
+ + +
\ No newline at end of file diff --git a/src/users/containers/user-details/user-details.component.spec.ts b/src/users/containers/user-details/user-details.component.spec.ts new file mode 100644 index 000000000..36e92570c --- /dev/null +++ b/src/users/containers/user-details/user-details.component.spec.ts @@ -0,0 +1,134 @@ +import { UserDetailsComponent } from './user-details.component'; +import { Observable } from 'rxjs'; + +describe('User Details Component', () => { + + let component: UserDetailsComponent; + let userStoreSpyObject; + let routerStoreSpyObject; + + beforeEach(() => { + userStoreSpyObject = jasmine.createSpyObj('Store', ['pipe', 'select', 'dispatch']); + routerStoreSpyObject = jasmine.createSpyObj('Store', ['pipe', 'select', 'dispatch']); + component = new UserDetailsComponent(userStoreSpyObject, routerStoreSpyObject); + }); + + describe('ngOnInit', () => { + it('should create subscriptions', () => { + component.ngOnInit(); + expect(component.dependanciesSubscription).toBeDefined(); + expect(component.userSubscription).toBeDefined(); + }); + }); + + describe('dispatchGetUsers', () => { + it('should load users when there are none', () => { + component.dispatchGetUsers(false, userStoreSpyObject); + expect(userStoreSpyObject.dispatch).toHaveBeenCalled(); + }); + + it('should not load users when they exist', () => { + component.dispatchGetUsers(true, userStoreSpyObject); + expect(userStoreSpyObject.dispatch).not.toHaveBeenCalled(); + }); + }); + + describe('getUserObservable', () => { + it('should return user', () => { + component.getUserObservable('user', userStoreSpyObject); + expect(userStoreSpyObject.pipe).toHaveBeenCalled(); + }); + }); + + describe('getDependancyObservables', () => { + it('should return Observable', () => { + component.getDependancyObservables(routerStoreSpyObject, userStoreSpyObject).subscribe(([route, users]) => { + expect(users).toBe(false); + }); + }); + }); + + describe('isSuspended', () => { + it('should return suspended state', () => { + expect(component.isSuspended('Suspended')).toBe(true); + }); + }); + + describe('isSuspendView', () => { + it('should return state of suspended state flag', () => { + expect(component.isSuspendView()).toBe(false); + }); + }); + + describe('hideSuspendView', () => { + it('should set state of suspended state flag to false', () => { + component.setSuspendViewFunctions(); + component.hideSuspendView(); + expect(component.suspendViewFlag).toBe(false); + }); + }); + + describe('showSuspendView', () => { + it('should set state of suspended state flag to true', () => { + component.setSuspendViewFunctions(); + component.showSuspendView(); + expect(component.suspendViewFlag).toBe(true); + }); + }); + + describe('handleUserSubscription', () => { + it('should set actionButtons when user is Active', () => { + component.handleUserSubscription({ status: 'Active' }); + expect(component.actionButtons.length).toBe(1); + }); + + it('should not set actionButtons when user is Suspended', () => { + component.handleUserSubscription({ status: 'Suspended' }); + expect(component.actionButtons.length).toBe(0); + }); + }); + + describe('handleDependanciesSubscription', () => { + it('should load users when there are none', () => { + component.handleDependanciesSubscription(false, { state: { params: { userId: 'user' } } }); + expect(userStoreSpyObject.dispatch).toHaveBeenCalled(); + }); + + it('should not load users when they exist', () => { + component.handleDependanciesSubscription(true, { state: { params: { userId: 'user' } } }); + expect(userStoreSpyObject.dispatch).not.toHaveBeenCalled(); + }); + }); + + describe('ngOnDestroy', () => { + it('should unsubscribe from observables when subscribed', () => { + component.dependanciesSubscription = new Observable().subscribe(); + component.userSubscription = new Observable().subscribe(); + const componentDependanciesSubscriptionUnsubscribeSpy = spyOn(component.dependanciesSubscription, 'unsubscribe'); + const componentUserSubscriptionUnsubscribeSpy = spyOn(component.userSubscription, 'unsubscribe'); + component.ngOnDestroy(); + expect(componentDependanciesSubscriptionUnsubscribeSpy).toHaveBeenCalled(); + expect(componentUserSubscriptionUnsubscribeSpy).toHaveBeenCalled(); + }); + + it('should not unsubscribe from observables when not subscribed', () => { + component.dependanciesSubscription = new Observable().subscribe(); + component.userSubscription = new Observable().subscribe(); + const componentDependanciesSubscriptionUnsubscribeSpy = spyOn(component.dependanciesSubscription, 'unsubscribe'); + const componentUserSubscriptionUnsubscribeSpy = spyOn(component.userSubscription, 'unsubscribe'); + component.dependanciesSubscription = undefined; + component.userSubscription = undefined; + component.ngOnDestroy(); + expect(componentDependanciesSubscriptionUnsubscribeSpy).not.toHaveBeenCalled(); + expect(componentUserSubscriptionUnsubscribeSpy).not.toHaveBeenCalled(); + }); + }); + + describe('suspendUser', () => { + it('should dispatch an action', () => { + component.suspendUser(); + expect(userStoreSpyObject.dispatch).toHaveBeenCalled(); + }); + }); + +}); diff --git a/src/users/containers/user-details/user-details.component.ts b/src/users/containers/user-details/user-details.component.ts index 79ddd6699..64df3efd3 100644 --- a/src/users/containers/user-details/user-details.component.ts +++ b/src/users/containers/user-details/user-details.component.ts @@ -3,15 +3,13 @@ import { select, Store } from '@ngrx/store'; import * as fromStore from '../../store'; import * as fromRoot from '../../../app/store'; import { Observable, Subscription, combineLatest } from 'rxjs'; -import { ActivatedRoute } from '@angular/router'; -import { map } from 'rxjs/internal/operators'; @Component({ selector: 'app-prd-user-details-component', templateUrl: './user-details.component.html', styleUrls: ['./user-details.component.scss'] }) -export class UserDetailsComponent implements OnInit { +export class UserDetailsComponent implements OnInit, OnDestroy { user$: Observable; isLoading$: Observable; @@ -20,27 +18,70 @@ export class UserDetailsComponent implements OnInit { userSubscription: Subscription; dependanciesSubscription: Subscription; + actionButtons: { name: string, class: string, action: () => {} }[] = []; + + suspendViewFlag: boolean = false; + + showSuspendView: () => {}; + hideSuspendView: () => {}; + constructor( private userStore: Store, private routerStore: Store, ) { } ngOnInit(): void { + this.user$ = new Observable(); + this.setSuspendViewFunctions(); + this.isLoading$ = this.userStore.pipe(select(fromStore.getGetUserLoading)); - this.dependanciesSubscription = combineLatest([ - this.routerStore.pipe(select(fromRoot.getRouterState)), - this.userStore.pipe(select(fromStore.getGetUserLoaded)) - ]).subscribe(([route, users]) => { - if (users === false) { - this.userStore.dispatch(new fromStore.LoadUsers()); - } - const userId = route.state.params.userId; - this.user$ = this.userStore.pipe(select(fromStore.getGetSingleUser, { userIdentifier: userId })); + this.dependanciesSubscription = this.getDependancyObservables(this.userStore, this.routerStore).subscribe(([route, users]) => { + this.handleDependanciesSubscription(users, route); }); - this.userSubscription = this.user$.subscribe((user) => this.user = user); + this.userSubscription = this.user$.subscribe((user) => this.handleUserSubscription(user)); + } + + getDependancyObservables(routerStore: Store, userStore: Store) { + return combineLatest([ + routerStore.pipe(select(fromRoot.getRouterState)), + userStore.pipe(select(fromStore.getGetUserLoaded)) + ]); + } + + dispatchGetUsers(users, userStore) { + if (!users) { + userStore.dispatch(new fromStore.LoadUsers()); + } + } + + getUserObservable(userId, userStore) { + return userStore.pipe(select(fromStore.getGetSingleUser, { userIdentifier: userId })); + } + setSuspendViewFunctions() { + this.hideSuspendView = () => this.suspendViewFlag = false; + this.showSuspendView = () => this.suspendViewFlag = true; + } + + handleUserSubscription(user) { + this.user = user; + if (this.user && this.user.status === 'Active') { + + this.actionButtons = [ + { + name: 'Suspend account', + class: 'hmcts-button--secondary', + action: this.showSuspendView + } + ]; + } + } + + handleDependanciesSubscription(users, route) { + this.dispatchGetUsers(users, this.userStore); + this.user$ = this.getUserObservable(route.state.params.userId, this.userStore); } ngOnDestroy() { @@ -58,5 +99,12 @@ export class UserDetailsComponent implements OnInit { return status === 'Suspended'; } -} + isSuspendView() { + return this.suspendViewFlag; + } + suspendUser() { + this.userStore.dispatch(new fromStore.SuspendUser(this.user)); + } + +} diff --git a/src/users/services/users.service.spec.ts b/src/users/services/users.service.spec.ts new file mode 100644 index 000000000..94e2784d7 --- /dev/null +++ b/src/users/services/users.service.spec.ts @@ -0,0 +1,20 @@ +import { UsersService } from './users.service'; +import { of } from 'rxjs'; + +describe('Users service', () => { + const mockedHttpClient = jasmine.createSpyObj('mockedHttpClient', ['get', 'put']); + + it('should call getListOfUsers', () => { + const service = new UsersService(mockedHttpClient); + mockedHttpClient.get.and.returnValue(of()); + service.getListOfUsers(); + expect(mockedHttpClient.get).toHaveBeenCalledWith('/api/userList'); + }); + + it('should call getJurisdictions', () => { + const service = new UsersService(mockedHttpClient); + mockedHttpClient.put.and.returnValue(of()); + service.suspendUser({payload: { userIdentifier: 'dummy' }}); + expect(mockedHttpClient.put).toHaveBeenCalledWith('/api/user/dummy/suspend', { userIdentifier: 'dummy', idamStatus: 'Suspend' }); + }); +}); diff --git a/src/users/services/users.service.ts b/src/users/services/users.service.ts index 140559af7..d58b6f7ed 100644 --- a/src/users/services/users.service.ts +++ b/src/users/services/users.service.ts @@ -4,26 +4,6 @@ import { HttpClient } from '@angular/common/http'; import {Observable, of, throwError} from 'rxjs'; import {catchError} from 'rxjs/operators'; -/* -const dummy = [ - { - email: 'somthing@something', - manageCases: 'All', - manageOrganisation: 'Yes', - manageUsers: 'yes', - manageFeeAcc: 'yes', - status: 'active' - }, - { - email: 'xyz@something', - manageCases: 'All', - manageOrganisation: 'Yes', - manageUsers: 'no', - manageFeeAcc: 'no', - status: 'active' - } -]; -*/ @Injectable() export class UsersService { constructor(private http: HttpClient) { } @@ -32,8 +12,17 @@ export class UsersService { return this.http .get(`/api/userList`) .pipe(catchError((error: any) => throwError(error.json()))); - // return of(dummy); } + suspendUser(param): Observable { + let user = param.payload; + user = { + ...user, + idamStatus: 'Suspend' + }; + return this.http + .put(`/api/user/${user.userIdentifier}/suspend`, user) + .pipe(catchError((error: any) => throwError(error.json()))); + } } diff --git a/src/users/store/actions/user.actions.ts b/src/users/store/actions/user.actions.ts index aec443624..449d4b873 100644 --- a/src/users/store/actions/user.actions.ts +++ b/src/users/store/actions/user.actions.ts @@ -4,11 +4,14 @@ import { Action } from '@ngrx/store'; export const LOAD_USERS = '[User] Load Users'; export const LOAD_USERS_SUCCESS = '[User] Load Users Success'; export const LOAD_USERS_FAIL = '[User] Load Users Fail'; +export const SUSPEND_USER = '[User] Suspend User'; +export const SUSPEND_USER_SUCCESS = '[User] Suspend User Success'; +export const SUSPEND_USER_FAIL = '[User] Suspend User Fail'; export class LoadUsers { readonly type = LOAD_USERS; - constructor() {} + constructor() { } } export class LoadUsersSuccess implements Action { @@ -21,7 +24,25 @@ export class LoadUsersFail implements Action { constructor(public payload: any) { } } +export class SuspendUser { + readonly type = SUSPEND_USER; + constructor(public payload: any) { } +} + +export class SuspendUserSuccess implements Action { + readonly type = SUSPEND_USER_SUCCESS; + constructor(public payload: any) { } +} + +export class SuspendUserFail implements Action { + readonly type = SUSPEND_USER_FAIL; + constructor(public payload: any) { } +} + export type UserActions = | LoadUsers | LoadUsersSuccess - | LoadUsersFail; + | LoadUsersFail + | SuspendUser + | SuspendUserSuccess + | SuspendUserFail; diff --git a/src/users/store/effects/users.effects.spec.ts b/src/users/store/effects/users.effects.spec.ts index 32207f0ed..03e2e3b3f 100644 --- a/src/users/store/effects/users.effects.spec.ts +++ b/src/users/store/effects/users.effects.spec.ts @@ -5,14 +5,14 @@ import { of, throwError } from 'rxjs'; import { provideMockActions } from '@ngrx/effects/testing'; import * as fromUsersEffects from './users.effects'; import { UsersEffects } from './users.effects'; -import { LoadUsersSuccess, LoadUsersFail, LoadUsers } from '../actions/user.actions'; +import { LoadUsersSuccess, LoadUsersFail, LoadUsers, SuspendUser, SuspendUserSuccess, SuspendUserFail } from '../actions/user.actions'; import { UsersService } from '../../services/users.service'; describe('Users Effects', () => { let actions$; let effects: UsersEffects; const UsersServiceMock = jasmine.createSpyObj('UsersService', [ - 'getListOfUsers', + 'getListOfUsers', 'suspendUser', ]); @@ -35,7 +35,7 @@ describe('Users Effects', () => { describe('loadUsers$', () => { it('should return a collection from loadUsers$ - LoadUsersSuccess', () => { - const payload = {users: [{ payload: 'something' }]}; + const payload = { users: [{ payload: 'something' }] }; UsersServiceMock.getListOfUsers.and.returnValue(of(payload)); const action = new LoadUsers(); const completion = new LoadUsersSuccess({ @@ -47,6 +47,20 @@ describe('Users Effects', () => { const expected = cold('-b', { b: completion }); expect(effects.loadUsers$).toBeObservable(expected); }); + + it('should return a collection from loadUsers$ when status pending - LoadUsersSuccess', () => { + const payload = { users: [{ idamStatus: 'PENDING' }] }; + UsersServiceMock.getListOfUsers.and.returnValue(of(payload)); + const action = new LoadUsers(); + const completion = new LoadUsersSuccess({ + users: [ + { idamStatus: 'PENDING', fullName: 'undefined undefined' } + ] + }); + actions$ = hot('-a', { a: action }); + const expected = cold('-b', { b: completion }); + expect(effects.loadUsers$).toBeObservable(expected); + }); }); describe('loadUsers$ error', () => { @@ -60,4 +74,39 @@ describe('Users Effects', () => { }); }); + describe('suspendUser$', () => { + it('should return a collection from suspendUser$ - SuspendUserSuccess', () => { + const user = { + userIdentifier: 'cfeba78e-ff81-49d5-8a65-55fa2a9c2424', + firstName: 'Humpty', + lastName: 'Dumpty', + email: 'aa@aa.com', + idamStatus: 'Suspend', + idamStatusCode: '', + idamMessage: '19 No call made to SIDAM to get the user roles as user status is ‘Pending’', + fullName: 'Humpty Dumpty', + routerLink: 'user/cfeba78e-ff81-49d5-8a65-55fa2a9c2424', + selected: false, + status: 'Active' + }; + UsersServiceMock.suspendUser.and.returnValue(of({})); + const action = new SuspendUser({payload: user}); + const completion = new SuspendUserSuccess({response: {}}); + actions$ = hot('-a', { a: action }); + const expected = cold('-b', { b: completion }); + expect(effects.suspendUser$).toBeObservable(expected); + }); + }); + + describe('suspendUser$ error', () => { + it('should return LoadUsersFail', () => { + UsersServiceMock.suspendUser.and.returnValue(throwError(new Error())); + const action = new SuspendUser({}); + const completion = new SuspendUserFail(new Error()); + actions$ = hot('-a', { a: action }); + const expected = cold('-b', { b: completion }); + expect(effects.suspendUser$).toBeObservable(expected); + }); + }); + }); diff --git a/src/users/store/effects/users.effects.ts b/src/users/store/effects/users.effects.ts index b6f59b3d3..d18352b1e 100644 --- a/src/users/store/effects/users.effects.ts +++ b/src/users/store/effects/users.effects.ts @@ -38,4 +38,16 @@ export class UsersEffects { ); }) ); + + + @Effect() + suspendUser$ = this.actions$.pipe( + ofType(usersActions.SUSPEND_USER), + switchMap((user) => { + return this.usersService.suspendUser(user).pipe( + map(res => new usersActions.SuspendUserSuccess({response: res})), + catchError(error => of(new usersActions.SuspendUserFail(error))) + ); + }) + ); } From b1053d4c05e4c4cc16dd7acc27bf8c30278aceb2 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Tue, 22 Oct 2019 12:18:27 +0100 Subject: [PATCH 11/71] fix the endpoint and put working --- api/editUserPermissions/index.ts | 13 ++++--------- api/routes.ts | 2 +- .../edit-user-permission.component.html | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/api/editUserPermissions/index.ts b/api/editUserPermissions/index.ts index 04cfe3415..f3d7de78c 100644 --- a/api/editUserPermissions/index.ts +++ b/api/editUserPermissions/index.ts @@ -6,7 +6,7 @@ import * as log4jui from '../lib/log4jui' export const router = express.Router({ mergeParams: true }) const logger = log4jui.getLogger('outgoing') -router.put('/', inviteUserRoute) +router.put('', inviteUserRoute) async function inviteUserRoute(req, res) { let errReport: any @@ -15,14 +15,9 @@ async function inviteUserRoute(req, res) { res.status(500).send(errReport) return } - if (!req.params.orgId) { - errReport = getErrorReport('OrgId is missing', '400', 'User Permissions route error') - res.status(500).send(errReport) - return - } const payload = req.body try { - const response = await http.put(getEditPermissionsUrl(config.services.rdProfessionalApi, req.params.userId, req.params.orgId), payload) + const response = await http.put(getEditPermissionsUrl(config.services.rdProfessionalApi, req.params.userId), payload) logger.info('response::', response.data) res.send(response.data) } catch (error) { @@ -42,7 +37,7 @@ function getErrorReport(apiError: string, apiStatusCode: string, message: string message, } } -function getEditPermissionsUrl(rdProfessionalApiUrl: string, userId: string, orgId: string): string { - return `${rdProfessionalApiUrl}/refdata/internal/v1/organisations/${orgId}/users/${userId}` +function getEditPermissionsUrl(rdProfessionalApiUrl: string, userId: string): string { + return `${rdProfessionalApiUrl}/refdata/external/v1/organisations/users/${userId}` } export default router diff --git a/api/routes.ts b/api/routes.ts index 463ee8984..a1def043a 100644 --- a/api/routes.ts +++ b/api/routes.ts @@ -24,5 +24,5 @@ router.use('/userDetails', getUserList) router.use('/jurisdictions', getJurisdictions) router.use('/payments/:account', payments) -router.use('/editUserPermissions/:orgId/users/:userId', editUserPermissions) +router.use('/editUserPermissions/users/:userId', editUserPermissions) export default router diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.html b/src/users/containers/edit-user-permissions/edit-user-permission.component.html index cb5bc3a45..478411426 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.html +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.html @@ -1,4 +1,4 @@ - +

{{user.firstName}}, {{user.lastName}}

From 286c5ba36c765066e0e680f755a0835fa03b345f Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Tue, 22 Oct 2019 15:07:31 +0100 Subject: [PATCH 12/71] Changes for Edit permissions to work --- .../edit-user-permission.component.html | 6 +-- .../edit-user-permission.component.ts | 54 +++++++++++++------ src/users/containers/utils/user-roles-util.ts | 46 ++++++++++++++++ 3 files changed, 88 insertions(+), 18 deletions(-) create mode 100644 src/users/containers/utils/user-roles-util.ts diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.html b/src/users/containers/edit-user-permissions/edit-user-permission.component.html index 478411426..20c0c9da5 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.html +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.html @@ -1,6 +1,6 @@ -

{{user.firstName}}, {{user.lastName}}

- - {{user ? user.firstName : ''}}, {{user ? user.lastName : ''}} + + - \ No newline at end of file +Back +
+

{{user ? user.firstName : ''}}, {{user ? user.lastName : ''}}

+
+ + + +
+
\ No newline at end of file diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts index 0a96e5c0b..d62185be3 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts @@ -27,6 +27,7 @@ import { UserRolesUtil } from '../utils/user-roles-util'; userSubscription: Subscription; dependanciesSubscription: Subscription; + backUrl: string; constructor( private userStore: Store, @@ -45,6 +46,7 @@ import { UserRolesUtil } from '../utils/user-roles-util'; } this.userId = route.state.params.userId; this.user$ = this.userStore.pipe(select(fromStore.getGetSingleUser, { userIdentifier: this.userId })); + this.backUrl = `/users/user/${this.userId}`; }); this.userSubscription = this.user$.subscribe((user) => { @@ -94,7 +96,6 @@ import { UserRolesUtil } from '../utils/user-roles-util'; const rolesDeleted = UserRolesUtil.getRolesDeleted(this.user, permissions); const editUserRolesObj = UserRolesUtil.mapEditUserRoles(this.user, rolesAdded, rolesDeleted); this.userStore.dispatch(new fromStore.EditUser({editUserRolesObj, userId: this.userId})); - console.log(editUserRolesObj); } else { const formValidationData = { isInvalid: { diff --git a/src/users/containers/utils/user-roles-util.ts b/src/users/containers/utils/user-roles-util.ts index ba2981f3b..2cb216897 100644 --- a/src/users/containers/utils/user-roles-util.ts +++ b/src/users/containers/utils/user-roles-util.ts @@ -43,4 +43,15 @@ export class UserRolesUtil { } }); } + static isAddingRoleSuccessful(response: any): boolean { + return response.addRolesResponse && + response.addRolesResponse.idamStatusCode && + response.addRolesResponse.idamStatusCode === '201'; + } + + static isDeletingRoleSuccessful(result: any): boolean { + return result.deleteRolesResponse && + result.deleteRolesResponse[0].idamStatusCode && + result.deleteRolesResponse[0].idamStatusCode === '204'; + } } diff --git a/src/users/store/actions/user.actions.ts b/src/users/store/actions/user.actions.ts index 1dd01795f..c31ba5889 100644 --- a/src/users/store/actions/user.actions.ts +++ b/src/users/store/actions/user.actions.ts @@ -6,6 +6,7 @@ export const LOAD_USERS_SUCCESS = '[User] Load Users Success'; export const LOAD_USERS_FAIL = '[User] Load Users Fail'; export const EDIT_USER = '[User] Edit User'; export const EDIT_USER_SUCCESS = '[User] Edit User Success'; +export const EDIT_USER_FAILURE = '[User] Edit User Failure'; export class LoadUsers { readonly type = LOAD_USERS; @@ -29,6 +30,12 @@ export class EditUserSuccess implements Action { } } +export class EditUserFailure implements Action { + readonly type = EDIT_USER_FAILURE; + constructor(public payload: any) { + } +} + export class LoadUsersFail implements Action { readonly type = LOAD_USERS_FAIL; constructor(public payload: any) { } @@ -38,4 +45,5 @@ export type UserActions = | LoadUsers | LoadUsersSuccess | LoadUsersFail - | EditUser; + | EditUser + | EditUserFailure; diff --git a/src/users/store/effects/invite-user.effects.ts b/src/users/store/effects/invite-user.effects.ts index ec9dafdc2..430b6c1b1 100644 --- a/src/users/store/effects/invite-user.effects.ts +++ b/src/users/store/effects/invite-user.effects.ts @@ -8,7 +8,7 @@ import {InviteUserService, JurisdictionService } from '../../services'; import * as fromRoot from '../../../app/store'; import { LoggerService } from 'src/shared/services/logger.service'; import { UserService } from 'src/user-profile/services/user.service'; - +import { UserRolesUtil } from '../../containers/utils/user-roles-util'; @Injectable() export class InviteUserEffects { @@ -47,11 +47,11 @@ export class InviteUserEffects { switchMap((user) => { console.log(user); return this.userService.editUserPermissions(user).pipe( - map( result => { - if (result.addRolesResponse && result.addRolesResponse.idamStatusCode && result.addRolesResponse.idamStatusCode === '201') { + map( response => { + if (UserRolesUtil.isAddingRoleSuccessful(response) || UserRolesUtil.isDeletingRoleSuccessful(response)) { return new usersActions.EditUserSuccess(user.userId); } else { - // return new usersActions.EditUserSuccess(user.userId); + return new usersActions.EditUserFailure(user.userId); } }) ); @@ -62,7 +62,11 @@ export class InviteUserEffects { confirmEditUser$ = this.actions$.pipe( ofType(usersActions.EDIT_USER_SUCCESS), map((user: any) => { - return new fromRoot.Go({ path: [`users/user/${user.payload}`] }); - }) + return user.payload; // this is the userId + }), + switchMap(userId => [ + new usersActions.LoadUsers(), + new fromRoot.Go({ path: [`users/user/${userId}`] }) + ]) ); } From 27eec43a02b175728aa7f7b4e42cf9eb35ccb881 Mon Sep 17 00:00:00 2001 From: Adnan Akgun Date: Wed, 23 Oct 2019 14:24:17 +0100 Subject: [PATCH 16/71] EUI-643 partial error handling --- src/users/store/reducers/users.reducer.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/users/store/reducers/users.reducer.ts b/src/users/store/reducers/users.reducer.ts index e9eb5bc36..7a849e086 100644 --- a/src/users/store/reducers/users.reducer.ts +++ b/src/users/store/reducers/users.reducer.ts @@ -77,6 +77,14 @@ export function reducer( }; } + case fromUsers.SUSPEND_USER_FAIL: { + return { + ...state, + loading: false, + loaded: true + }; + } + case fromUsers.SUSPEND_USER_SUCCESS: { const user = action.payload ? action.payload : null; const amendedUserList = []; From a0a5c078346edebdaa1c330c92aa80a2ab37500c Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Wed, 23 Oct 2019 14:37:48 +0100 Subject: [PATCH 17/71] Clean up of code --- .../edit-user-permission.component.ts | 45 ++++++++++--------- .../store/effects/invite-user.effects.ts | 1 - 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts index d62185be3..f5c51d30c 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts @@ -1,5 +1,5 @@ import {Component, OnInit, OnDestroy} from '@angular/core'; -import { FormGroup, FormControl } from '@angular/forms'; +import { FormGroup, FormControl, Validator, ValidatorFn } from '@angular/forms'; import { checkboxesBeCheckedValidator } from 'src/custom-validators/checkboxes-be-checked.validator'; import { Store, select } from '@ngrx/store'; import * as fromStore from '../../store'; @@ -46,7 +46,7 @@ import { UserRolesUtil } from '../utils/user-roles-util'; } this.userId = route.state.params.userId; this.user$ = this.userStore.pipe(select(fromStore.getGetSingleUser, { userIdentifier: this.userId })); - this.backUrl = `/users/user/${this.userId}`; + this.backUrl = this.getBackurl(this.userId); }); this.userSubscription = this.user$.subscribe((user) => { @@ -55,16 +55,25 @@ import { UserRolesUtil } from '../utils/user-roles-util'; this.isPuiOrganisationManager = this.getIsPuiOrganisationManager(user); this.isPuiUserManager = this.getIsPuiUserManager(user); - this.editUserForm = new FormGroup({ - roles: new FormGroup({ - 'pui-case-manager': new FormControl(this.isPuiCaseManager), - 'pui-user-manager': new FormControl(this.isPuiUserManager), - 'pui-organisation-manager': new FormControl(this.isPuiOrganisationManager) - }, checkboxesBeCheckedValidator(1)) - }); + this.editUserForm = this.getFormGroup(this.isPuiCaseManager, + this.isPuiUserManager, this.isPuiOrganisationManager, checkboxesBeCheckedValidator); }); } + getBackurl(userId: string) { + return `/users/user/${userId}`; + } + + getFormGroup(isPuiCaseManager, isPuiUserManager, isPuiOrganisationManager, validator: any): FormGroup { + return new FormGroup({ + roles: new FormGroup({ + 'pui-case-manager': new FormControl(isPuiCaseManager), + 'pui-user-manager': new FormControl(isPuiUserManager), + 'pui-organisation-manager': new FormControl(isPuiOrganisationManager) + }, validator(1)) + }); + } + getIsPuiCaseManager(user: any): boolean { return user && user.manageCases === 'Yes'; } @@ -95,19 +104,13 @@ import { UserRolesUtil } from '../utils/user-roles-util'; const rolesAdded = UserRolesUtil.getRolesAdded(this.user, permissions); const rolesDeleted = UserRolesUtil.getRolesDeleted(this.user, permissions); const editUserRolesObj = UserRolesUtil.mapEditUserRoles(this.user, rolesAdded, rolesDeleted); - this.userStore.dispatch(new fromStore.EditUser({editUserRolesObj, userId: this.userId})); + if (rolesAdded.length > 0 || rolesDeleted.length > 0) { + this.userStore.dispatch(new fromStore.EditUser({editUserRolesObj, userId: this.userId})); + } else { + return this.userStore.dispatch(new fromStore.EditUserFailure('No changes done.')); + } } else { - const formValidationData = { - isInvalid: { - roles: [(this.f.roles.errors && this.f.roles.errors.requireOneCheckboxToBeChecked)], - }, - errorMessages: this.errorMessages, - isSubmitted: true - }; - this.userStore.dispatch(new fromStore.UpdateErrorMessages(formValidationData)); + this.userStore.dispatch(new fromStore.EditUserFailure('Please select at least 1 checkbox')); } } - - get f() { return this.editUserForm.controls; } - } diff --git a/src/users/store/effects/invite-user.effects.ts b/src/users/store/effects/invite-user.effects.ts index 430b6c1b1..2404208e4 100644 --- a/src/users/store/effects/invite-user.effects.ts +++ b/src/users/store/effects/invite-user.effects.ts @@ -45,7 +45,6 @@ export class InviteUserEffects { ofType(usersActions.EDIT_USER), map((action: usersActions.EditUser) => action.payload), switchMap((user) => { - console.log(user); return this.userService.editUserPermissions(user).pipe( map( response => { if (UserRolesUtil.isAddingRoleSuccessful(response) || UserRolesUtil.isDeletingRoleSuccessful(response)) { From 79c6e36133843317f052ff5e9b3391abc726075d Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Wed, 23 Oct 2019 15:29:21 +0100 Subject: [PATCH 18/71] Adding unit test cases for Edit User permission --- .../edit-user-permission.component.spec.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/users/containers/edit-user-permissions/edit-user-permission.component.spec.ts diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.spec.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.spec.ts new file mode 100644 index 000000000..c0f9b8693 --- /dev/null +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.spec.ts @@ -0,0 +1,56 @@ +import { EditUserPermissionComponent } from './edit-user-permission.component'; +import { Observable, of } from 'rxjs'; + +describe('Edit User Permission Component Component', () => { + + let component: EditUserPermissionComponent; + let userStoreSpyObject; + let routerStoreSpyObject; + + beforeEach(() => { + userStoreSpyObject = jasmine.createSpyObj('Store', ['pipe', 'select', 'dispatch']); + routerStoreSpyObject = jasmine.createSpyObj('Store', ['pipe', 'select', 'dispatch']); + component = new EditUserPermissionComponent(userStoreSpyObject, routerStoreSpyObject); + }); + + describe('EditUserPermissionComponent is Truthy', () => { + it('should create', () => { + expect(component).toBeTruthy(); + }); + }); + + describe('EditUserPermissionComponent', () => { + it('getbackUrl', () => { + expect(component.getBackurl('1234')).toEqual('/users/user/1234'); + }); + }); + + describe('EditUserPermissionComponent', () => { + it('getIsPuiCaseManager', () => { + const user = {manageCases: 'Yes'}; + expect(component.getIsPuiCaseManager(user)).toEqual(true); + }); + }); + + describe('EditUserPermissionComponent', () => { + it('getIsPuiOrganisationManager', () => { + const user = {manageOrganisations: 'Yes'}; + expect(component.getIsPuiOrganisationManager(user)).toEqual(true); + }); + }); + + describe('EditUserPermissionComponent', () => { + it('getIsPuiUserManager', () => { + const user = {manageUsers: 'Yes'}; + expect(component.getIsPuiUserManager(user)).toEqual(true); + }); + }); + + describe('EditUserPermissionComponent', () => { + it('unsubscribe', () => { + const subscription = jasmine.createSpyObj('subscription', ['unsubscribe']); + expect(component.unsubscribe(subscription)); + expect(subscription.unsubscribe).toHaveBeenCalled(); + }); + }); +}); From edc98015e41e7a0b46d326ca435c8f9f7fe8c00a Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Wed, 23 Oct 2019 16:41:14 +0100 Subject: [PATCH 19/71] removing noop --- src/user-profile/services/user.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/user-profile/services/user.service.ts b/src/user-profile/services/user.service.ts index 8e315c700..f6a8fb775 100644 --- a/src/user-profile/services/user.service.ts +++ b/src/user-profile/services/user.service.ts @@ -1,6 +1,6 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { Observable, noop } from 'rxjs'; +import { Observable } from 'rxjs'; import { UserInterface} from '../models/user.model'; @Injectable({ From 8c4acf83021f2e60c58edfcaafd736a73827c3dc Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Wed, 23 Oct 2019 17:02:32 +0100 Subject: [PATCH 20/71] Moving to the User.effects --- .../store/effects/user.effects.ts | 37 +++++++++++++++++-- .../store/effects/invite-user.effects.ts | 31 +--------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/user-profile/store/effects/user.effects.ts b/src/user-profile/store/effects/user.effects.ts index a66cdd066..842ea0720 100644 --- a/src/user-profile/store/effects/user.effects.ts +++ b/src/user-profile/store/effects/user.effects.ts @@ -8,19 +8,22 @@ import {AuthActionTypes} from '../actions/'; import {UserInterface} from '../../models/user.model'; import {HttpErrorResponse} from '@angular/common/http'; import config from '../../../../api/lib/config'; +import * as usersActions from '../../../users/store/actions/user.actions'; +import { UserRolesUtil } from 'src/users/containers/utils/user-roles-util'; +import * as fromRoot from '../../../app/store'; @Injectable() export class UserEffects { constructor( private actions$: Actions, - private authService: UserService + private userService: UserService, ) { } @Effect() getUser$ = this.actions$.pipe( ofType(AuthActionTypes.GET_USER_DETAILS), switchMap(() => { - return this.authService.getUserDetails() + return this.userService.getUserDetails() .pipe( map((userDetails: UserInterface) => new authActions.GetUserDetailsSuccess(userDetails)), catchError((error: HttpErrorResponse) => of(new authActions.GetUserDetailsFailure(error))) @@ -48,6 +51,32 @@ export class UserEffects { }) ); -} - + @Effect() + editUser$ = this.actions$.pipe( + ofType(usersActions.EDIT_USER), + map((action: usersActions.EditUser) => action.payload), + switchMap((user) => { + return this.userService.editUserPermissions(user).pipe( + map( response => { + if (UserRolesUtil.isAddingRoleSuccessful(response) || UserRolesUtil.isDeletingRoleSuccessful(response)) { + return new usersActions.EditUserSuccess(user.userId); + } else { + return new usersActions.EditUserFailure(user.userId); + } + }) + ); + }) + ); + @Effect() + confirmEditUser$ = this.actions$.pipe( + ofType(usersActions.EDIT_USER_SUCCESS), + map((user: any) => { + return user.payload; // this is the userId + }), + switchMap(userId => [ + new usersActions.LoadUsers(), + new fromRoot.Go({ path: [`users/user/${userId}`] }) + ]) + ); +} diff --git a/src/users/store/effects/invite-user.effects.ts b/src/users/store/effects/invite-user.effects.ts index 2404208e4..d4c84a8dd 100644 --- a/src/users/store/effects/invite-user.effects.ts +++ b/src/users/store/effects/invite-user.effects.ts @@ -4,18 +4,16 @@ import {Actions, Effect, ofType} from '@ngrx/effects'; import * as usersActions from '../actions'; import {catchError, map, switchMap, tap} from 'rxjs/operators'; import {of} from 'rxjs'; -import {InviteUserService, JurisdictionService } from '../../services'; +import {InviteUserService } from '../../services'; import * as fromRoot from '../../../app/store'; import { LoggerService } from 'src/shared/services/logger.service'; import { UserService } from 'src/user-profile/services/user.service'; -import { UserRolesUtil } from '../../containers/utils/user-roles-util'; @Injectable() export class InviteUserEffects { constructor( private actions$: Actions, private inviteUserSevice: InviteUserService, - private userService: UserService, private loggerService: LoggerService ) {} @@ -40,32 +38,5 @@ export class InviteUserEffects { }) ); - @Effect() - editUser$ = this.actions$.pipe( - ofType(usersActions.EDIT_USER), - map((action: usersActions.EditUser) => action.payload), - switchMap((user) => { - return this.userService.editUserPermissions(user).pipe( - map( response => { - if (UserRolesUtil.isAddingRoleSuccessful(response) || UserRolesUtil.isDeletingRoleSuccessful(response)) { - return new usersActions.EditUserSuccess(user.userId); - } else { - return new usersActions.EditUserFailure(user.userId); - } - }) - ); - }) - ); - @Effect() - confirmEditUser$ = this.actions$.pipe( - ofType(usersActions.EDIT_USER_SUCCESS), - map((user: any) => { - return user.payload; // this is the userId - }), - switchMap(userId => [ - new usersActions.LoadUsers(), - new fromRoot.Go({ path: [`users/user/${userId}`] }) - ]) - ); } From 273c1dd1198c8c4bb90f3dab37d79ae9506f3104 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Thu, 24 Oct 2019 11:05:01 +0100 Subject: [PATCH 21/71] Adding User roles Edit --- .../containers/utils/user-roles-util.spec.ts | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/users/containers/utils/user-roles-util.spec.ts diff --git a/src/users/containers/utils/user-roles-util.spec.ts b/src/users/containers/utils/user-roles-util.spec.ts new file mode 100644 index 000000000..de6a32173 --- /dev/null +++ b/src/users/containers/utils/user-roles-util.spec.ts @@ -0,0 +1,54 @@ +import { UserRolesUtil } from './user-roles-util'; + +describe('UserRolesUtil class ', () => { + it('should get rolesAdded', () => { + const user = { roles: ['permission1', 'permission3']}; + const rolesAdded = UserRolesUtil.getRolesAdded(user, ['permission1', 'permission2']); + expect(rolesAdded).toEqual([{name: 'permission2'}]); + }); + + it('should get rolesDeleted', () => { + const user = { roles: ['permission1', 'permission2', 'permission3']}; + const rolesDeleted = UserRolesUtil.getRolesDeleted(user, ['permission1', 'permission2']); + expect(rolesDeleted).toEqual([{name: 'permission3'}]); + }); + + it('should mapEditUserRoles', () => { + const user = { + email: 'email', + lastName: 'last', + firstName: 'first', + idamStatus: 'idam', + roles: ['permission1', 'permission2'] + }; + const userEditObj = UserRolesUtil.mapEditUserRoles(user, ['permission3', 'permission4'], ['permission1', 'permission2']); + expect(userEditObj).toEqual({ email: 'email', + lastName: 'last', + firstName: 'first', + idamStatus: 'idam', + rolesAdd: ['permission3', 'permission4'], + rolesDelete: ['permission1', 'permission2'] + } + ); + }); + + it('should get isAddingRoleSuccessful', () => { + let response = {}; + let isAddingSuccessful = UserRolesUtil.isAddingRoleSuccessful(response); + expect(isAddingSuccessful).toEqual(undefined); + + response = {addRolesResponse: {idamStatusCode: '201'}}; + isAddingSuccessful = UserRolesUtil.isAddingRoleSuccessful(response); + expect(isAddingSuccessful).toEqual(true); + }); + + it('should get isDeletingRoleSuccessful', () => { + let response = {}; + let isDeletingSuccessful = UserRolesUtil.isDeletingRoleSuccessful(response); + expect(isDeletingSuccessful).toEqual(undefined); + + response = {deleteRolesResponse: [{idamStatusCode: '204'}]}; + isDeletingSuccessful = UserRolesUtil.isDeletingRoleSuccessful(response); + expect(isDeletingSuccessful).toEqual(true); + }); +}); From 2937e985a228848d0ed2b45882a91a929c349d52 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Thu, 24 Oct 2019 11:06:33 +0100 Subject: [PATCH 22/71] Refactor for ! --- .../edit-user-permissions/edit-user-permission.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts index f5c51d30c..c6800713b 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts @@ -41,7 +41,7 @@ import { UserRolesUtil } from '../utils/user-roles-util'; this.routerStore.pipe(select(fromRoot.getRouterState)), this.userStore.pipe(select(fromStore.getGetUserLoaded)) ]).subscribe(([route, users]) => { - if (users === false) { + if (!users) { this.userStore.dispatch(new fromStore.LoadUsers()); } this.userId = route.state.params.userId; From 23478d31523c143e2415736974784e57d3d377a4 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Thu, 24 Oct 2019 11:09:41 +0100 Subject: [PATCH 23/71] JS early return --- .../edit-user-permission.component.ts | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts index c6800713b..43c4a65e4 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts @@ -98,19 +98,20 @@ import { UserRolesUtil } from '../utils/user-roles-util'; } onSubmit() { - if (this.editUserForm.valid) { - const {value} = this.editUserForm; - const permissions = UserRolesUtil.mapPermissions(value); - const rolesAdded = UserRolesUtil.getRolesAdded(this.user, permissions); - const rolesDeleted = UserRolesUtil.getRolesDeleted(this.user, permissions); - const editUserRolesObj = UserRolesUtil.mapEditUserRoles(this.user, rolesAdded, rolesDeleted); - if (rolesAdded.length > 0 || rolesDeleted.length > 0) { - this.userStore.dispatch(new fromStore.EditUser({editUserRolesObj, userId: this.userId})); - } else { - return this.userStore.dispatch(new fromStore.EditUserFailure('No changes done.')); - } - } else { + if (!this.editUserForm.valid) { this.userStore.dispatch(new fromStore.EditUserFailure('Please select at least 1 checkbox')); + return; + } + + const {value} = this.editUserForm; + const permissions = UserRolesUtil.mapPermissions(value); + const rolesAdded = UserRolesUtil.getRolesAdded(this.user, permissions); + const rolesDeleted = UserRolesUtil.getRolesDeleted(this.user, permissions); + const editUserRolesObj = UserRolesUtil.mapEditUserRoles(this.user, rolesAdded, rolesDeleted); + if (rolesAdded.length > 0 || rolesDeleted.length > 0) { + this.userStore.dispatch(new fromStore.EditUser({editUserRolesObj, userId: this.userId})); + } else { + return this.userStore.dispatch(new fromStore.EditUserFailure('No changes done.')); } } } From af132054f6fb82ae7ceb4cb7a197b0eb017006ba Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Thu, 24 Oct 2019 11:11:31 +0100 Subject: [PATCH 24/71] Fix the error codes --- api/editUserPermissions/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/editUserPermissions/index.ts b/api/editUserPermissions/index.ts index f3d7de78c..9a0d67b6c 100644 --- a/api/editUserPermissions/index.ts +++ b/api/editUserPermissions/index.ts @@ -11,7 +11,7 @@ router.put('', inviteUserRoute) async function inviteUserRoute(req, res) { let errReport: any if (!req.params.userId) { - errReport = getErrorReport('UserId is missing', '400', 'User Permissions route error') + errReport = getErrorReport('UserId is missing', '500', 'User Permissions route error') res.status(500).send(errReport) return } From 24fea36c9162e38c164930d94fe2e5afc97a8eac Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Thu, 24 Oct 2019 11:20:15 +0100 Subject: [PATCH 25/71] Adding ErrorReportInterface --- api/editUserPermissions/index.ts | 5 +++-- api/interfaces/errorReport.ts | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 api/interfaces/errorReport.ts diff --git a/api/editUserPermissions/index.ts b/api/editUserPermissions/index.ts index 9a0d67b6c..05162bd95 100644 --- a/api/editUserPermissions/index.ts +++ b/api/editUserPermissions/index.ts @@ -1,4 +1,5 @@ import * as express from 'express' +import { ErrorReport } from '../interfaces/errorReport' import { config } from '../lib/config' import { http } from '../lib/http' import * as log4jui from '../lib/log4jui' @@ -9,7 +10,7 @@ const logger = log4jui.getLogger('outgoing') router.put('', inviteUserRoute) async function inviteUserRoute(req, res) { - let errReport: any + let errReport: ErrorReport if (!req.params.userId) { errReport = getErrorReport('UserId is missing', '500', 'User Permissions route error') res.status(500).send(errReport) @@ -30,7 +31,7 @@ async function inviteUserRoute(req, res) { function getErrorMessage(error: any): string { return error && error.data ? error.data.message : '' } -function getErrorReport(apiError: string, apiStatusCode: string, message: string): any { +function getErrorReport(apiError: string, apiStatusCode: string, message: string): ErrorReport { return { apiError, apiStatusCode, diff --git a/api/interfaces/errorReport.ts b/api/interfaces/errorReport.ts new file mode 100644 index 000000000..4f3765da7 --- /dev/null +++ b/api/interfaces/errorReport.ts @@ -0,0 +1,5 @@ +export interface ErrorReport { + apiError: string + apiStatusCode: string + message: string +} From 596496bbf66e948a934980da146a2ad3249b9999 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Thu, 24 Oct 2019 11:45:42 +0100 Subject: [PATCH 26/71] Adding Unit tests to user.service --- src/user-profile/services/user.service.spec.ts | 17 +++++++++++++++++ src/user-profile/services/user.service.ts | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/user-profile/services/user.service.spec.ts diff --git a/src/user-profile/services/user.service.spec.ts b/src/user-profile/services/user.service.spec.ts new file mode 100644 index 000000000..0830d5480 --- /dev/null +++ b/src/user-profile/services/user.service.spec.ts @@ -0,0 +1,17 @@ +import { UserService } from './user.service'; + +describe('User service', () => { + const mockHttpService = jasmine.createSpyObj('mockHttpService', ['put', 'get']); + + it('should be Truthy', () => { + const userService = new UserService(mockHttpService); + expect(userService).toBeTruthy(); + }); + + it('editUser Permissions', () => { + const userService = new UserService(mockHttpService); + const editUser = {userId: '123', editUserRolesObj: {}}; + userService.editUserPermissions(editUser); + expect(mockHttpService.put).toHaveBeenCalledWith('/api/editUserPermissions/users/123', {}); + }); +}); diff --git a/src/user-profile/services/user.service.ts b/src/user-profile/services/user.service.ts index f6a8fb775..a5e7ee5de 100644 --- a/src/user-profile/services/user.service.ts +++ b/src/user-profile/services/user.service.ts @@ -8,10 +8,11 @@ import { UserInterface} from '../models/user.model'; }) export class UserService { + constructor(private http: HttpClient) {} + editUserPermissions(editUser): Observable { return this.http.put(`/api/editUserPermissions/users/${editUser.userId}`, editUser.editUserRolesObj); } - constructor(private http: HttpClient) {} getUserDetails(): Observable { return this.http.get(`/api/user/details`); From d07bbe00115d950f3100b33810e7a583db7c9247 Mon Sep 17 00:00:00 2001 From: VAMSHI MUNIGANTI Date: Thu, 24 Oct 2019 12:30:51 +0100 Subject: [PATCH 27/71] demo configs change --- api/lib/config/environments/demo.config.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/api/lib/config/environments/demo.config.ts b/api/lib/config/environments/demo.config.ts index a76d102c6..35a68d61c 100644 --- a/api/lib/config/environments/demo.config.ts +++ b/api/lib/config/environments/demo.config.ts @@ -2,19 +2,19 @@ export default { services: { ccdDataApi: 'http://ccd-data-store-api-demo.service.core-compute-demo.internal', ccdDefApi: 'http://ccd-definition-store-api-demo.service.core-compute-demo.internal', - idamWeb: 'https://idam-web-public.aat.platform.hmcts.net', - idamApi: 'https://idam-api.aat.platform.hmcts.net', - s2s: 'http://rpe-service-auth-provider-aat.service.core-compute-aat.internal', - rdProfessionalApi: 'http://rd-professional-api-aat.service.core-compute-aat.internal', + idamWeb: 'https://idam-web-public.demo.platform.hmcts.net', + idamApi: 'https://idam-api.demo.platform.hmcts.net', + s2s: 'http://rpe-service-auth-provider-demo.service.core-compute-demo.internal', + rdProfessionalApi: 'http://rd-professional-api-demo.service.core-compute-demo.internal', feeAndPayApi: 'https://payment-api-demo.service.core-compute-demo.internal', }, health: { ccdDataApi: 'http://ccd-data-store-api-demo.service.core-compute-demo.internal/health', ccdDefApi: 'http://ccd-definition-store-api-demo.service.core-compute-demo.internal/health', - idamWeb: 'https://idam-web-public.aat.platform.hmcts.net/health', - idamApi: 'https://idam-api.aat.platform.hmcts.net/health', - s2s: 'http://rpe-service-auth-provider-aat.service.core-compute-aat.internal/health', - rdProfessionalApi: 'http://rd-professional-api-aat.service.core-compute-aat.internal/health', + idamWeb: 'https://idam-web-public.demo.platform.hmcts.net/health', + idamApi: 'https://idam-api.demo.platform.hmcts.net/health', + s2s: 'http://rpe-service-auth-provider-demo.service.core-compute-demo.internal/health', + rdProfessionalApi: 'http://rd-professional-api-demo.service.core-compute-demo.internal/health', feeAndPayApi: 'https://payment-api-demo.service.core-compute-demo.internal/health', }, @@ -39,4 +39,4 @@ export default { {id: 'EMPLOYMENT'}, {id: 'CMC'}, ], -} \ No newline at end of file +} From 7b03c7b3044f039c655a9d78a67ab89ca145486e Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Fri, 25 Oct 2019 15:35:28 +0100 Subject: [PATCH 28/71] Fix for the warning for circular effects references --- src/user-profile/store/effects/user.effects.ts | 3 +-- .../edit-user-permission.component.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/user-profile/store/effects/user.effects.ts b/src/user-profile/store/effects/user.effects.ts index 842ea0720..ea0465643 100644 --- a/src/user-profile/store/effects/user.effects.ts +++ b/src/user-profile/store/effects/user.effects.ts @@ -75,8 +75,7 @@ export class UserEffects { return user.payload; // this is the userId }), switchMap(userId => [ - new usersActions.LoadUsers(), - new fromRoot.Go({ path: [`users/user/${userId}`] }) + new usersActions.LoadUsers() ]) ); } diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts index a6c8b8bf8..31b85a609 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts @@ -6,6 +6,7 @@ import * as fromStore from '../../store'; import * as fromRoot from '../../../app/store'; import { Observable, Subscription, combineLatest } from 'rxjs'; import { UserRolesUtil } from '../utils/user-roles-util'; +import { Actions, ofType } from '@ngrx/effects'; @Component({ selector: 'edit-user-permission', @@ -28,14 +29,21 @@ import { UserRolesUtil } from '../utils/user-roles-util'; userSubscription: Subscription; dependanciesSubscription: Subscription; + editPermissionSuccessSubscription: Subscription; backUrl: string; constructor( private userStore: Store, - private routerStore: Store + private routerStore: Store, + private actions$: Actions ) { } ngOnInit(): void { + + this.editPermissionSuccessSubscription = this.actions$.pipe(ofType(fromStore.EDIT_USER_SUCCESS)).subscribe(() => { + this.routerStore.dispatch(new fromRoot.Go({ path: [`users/user/${this.userId}`] })); + }); + this.isLoading$ = this.userStore.pipe(select(fromStore.getGetUserLoading)); this.dependanciesSubscription = combineLatest([ From f10d064d70eba7988c2925939d46bb9bcaed7354 Mon Sep 17 00:00:00 2001 From: Elviani Huseyin Date: Tue, 29 Oct 2019 14:24:41 +0000 Subject: [PATCH 29/71] adding edit users error messages --- .../invite-user-form.component.html | 2 +- .../invite-user-permission.component.html | 3 ++- .../invite-user-permission.component.ts | 2 +- .../edit-user-permission.component.html | 10 ++++++---- .../edit-user-permission.component.ts | 18 ++++++++++++++---- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/users/components/invite-user-form/invite-user-form.component.html b/src/users/components/invite-user-form/invite-user-form.component.html index 0d3d10a61..1ada69eed 100644 --- a/src/users/components/invite-user-form/invite-user-form.component.html +++ b/src/users/components/invite-user-form/invite-user-form.component.html @@ -19,7 +19,7 @@ [group]="inviteUserForm"> - + - \ No newline at end of file + \ No newline at end of file diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts index 31b85a609..23b74af30 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts @@ -14,9 +14,9 @@ import { Actions, ofType } from '@ngrx/effects'; }) export class EditUserPermissionComponent implements OnInit, OnDestroy { editUserForm: FormGroup; - isInvalid; errorMessages = { - roles: ['Select at least one option'], + header: 'There is a problem', + roles: ['You must select at least one action'], }; user$: Observable; isLoading$: Observable; @@ -32,6 +32,9 @@ import { Actions, ofType } from '@ngrx/effects'; editPermissionSuccessSubscription: Subscription; backUrl: string; + summaryErrors: {isFromValid: boolean; items: { id: string; message: any; }[]; header: string}; + permissionErrors: {isInvalid: boolean; messages: string[] }; + constructor( private userStore: Store, private routerStore: Store, @@ -69,6 +72,7 @@ import { Actions, ofType } from '@ngrx/effects'; this.isPuiUserManager, this.isPuiOrganisationManager, this.isPuiFinanceManager, checkboxesBeCheckedValidator); }); + } getBackurl(userId: string) { @@ -82,7 +86,7 @@ import { Actions, ofType } from '@ngrx/effects'; 'pui-user-manager': new FormControl(isPuiUserManager), 'pui-organisation-manager': new FormControl(isPuiOrganisationManager), 'pui-finance-manager': new FormControl(isPuiFinanceManager) - }, validator(1)) + }, checkboxesBeCheckedValidator()) }); } @@ -115,7 +119,10 @@ import { Actions, ofType } from '@ngrx/effects'; onSubmit() { if (!this.editUserForm.valid) { - this.userStore.dispatch(new fromStore.EditUserFailure('Please select at least 1 checkbox')); + this.summaryErrors = { isFromValid: false, items: [{id: 'roles', + message: this.errorMessages.roles[0] }], header: this.errorMessages.header}; + this.permissionErrors = { isInvalid: true, messages: [this.errorMessages.roles[0]]}; + this.userStore.dispatch(new fromStore.EditUserFailure(this.errorMessages.roles[0])); return; } @@ -127,6 +134,9 @@ import { Actions, ofType } from '@ngrx/effects'; if (rolesAdded.length > 0 || rolesDeleted.length > 0) { this.userStore.dispatch(new fromStore.EditUser({editUserRolesObj, userId: this.userId})); } else { + this.summaryErrors = { isFromValid: false, items: [{id: 'roles', message: 'No changes done.' }], + header: this.errorMessages.header}; + this.permissionErrors = { isInvalid: true, messages: ['No changes done.' ]}; return this.userStore.dispatch(new fromStore.EditUserFailure('No changes done.')); } } From ca02a3d58862de4fa42e6c848fdfc8b6c09ca099 Mon Sep 17 00:00:00 2001 From: Elviani Huseyin Date: Wed, 30 Oct 2019 11:59:10 +0000 Subject: [PATCH 30/71] fixing the test failure --- .../edit-user-permission.component.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.spec.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.spec.ts index c0f9b8693..7606d204c 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.spec.ts +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.spec.ts @@ -1,16 +1,19 @@ import { EditUserPermissionComponent } from './edit-user-permission.component'; import { Observable, of } from 'rxjs'; +import { Actions } from '@ngrx/effects'; describe('Edit User Permission Component Component', () => { let component: EditUserPermissionComponent; let userStoreSpyObject; let routerStoreSpyObject; + let actionsObject; beforeEach(() => { userStoreSpyObject = jasmine.createSpyObj('Store', ['pipe', 'select', 'dispatch']); routerStoreSpyObject = jasmine.createSpyObj('Store', ['pipe', 'select', 'dispatch']); - component = new EditUserPermissionComponent(userStoreSpyObject, routerStoreSpyObject); + actionsObject = jasmine.createSpyObj('Actions', ['pipe']); + component = new EditUserPermissionComponent(userStoreSpyObject, routerStoreSpyObject, actionsObject); }); describe('EditUserPermissionComponent is Truthy', () => { From e0c22cb27339761a0d50c163f9b6f0c3ccafe106 Mon Sep 17 00:00:00 2001 From: VAMSHI MUNIGANTI Date: Wed, 6 Nov 2019 15:15:33 +0000 Subject: [PATCH 31/71] user status changed to suspended --- src/users/services/users.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/users/services/users.service.ts b/src/users/services/users.service.ts index d58b6f7ed..9d60f750f 100644 --- a/src/users/services/users.service.ts +++ b/src/users/services/users.service.ts @@ -18,7 +18,7 @@ export class UsersService { let user = param.payload; user = { ...user, - idamStatus: 'Suspend' + idamStatus: 'SUSPENDED' }; return this.http .put(`/api/user/${user.userIdentifier}/suspend`, user) From 0fb1776ade213dd9a632234668d60d8071170b43 Mon Sep 17 00:00:00 2001 From: Adnan Akgun Date: Wed, 6 Nov 2019 16:16:39 +0000 Subject: [PATCH 32/71] Update users.service.spec.ts --- src/users/services/users.service.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/users/services/users.service.spec.ts b/src/users/services/users.service.spec.ts index 94e2784d7..65e3e4763 100644 --- a/src/users/services/users.service.spec.ts +++ b/src/users/services/users.service.spec.ts @@ -11,10 +11,10 @@ describe('Users service', () => { expect(mockedHttpClient.get).toHaveBeenCalledWith('/api/userList'); }); - it('should call getJurisdictions', () => { + it('should suspend account', () => { const service = new UsersService(mockedHttpClient); mockedHttpClient.put.and.returnValue(of()); service.suspendUser({payload: { userIdentifier: 'dummy' }}); - expect(mockedHttpClient.put).toHaveBeenCalledWith('/api/user/dummy/suspend', { userIdentifier: 'dummy', idamStatus: 'Suspend' }); + expect(mockedHttpClient.put).toHaveBeenCalledWith('/api/user/dummy/suspend', { userIdentifier: 'dummy', idamStatus: 'SUSPENDED' }); }); }); From fc0b740f188f005a4d651525bbba7a0c22e3f618 Mon Sep 17 00:00:00 2001 From: VAMSHI MUNIGANTI Date: Wed, 20 Nov 2019 13:53:59 +0000 Subject: [PATCH 33/71] latest changes from AAT --- test/e2e/config/conf.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/e2e/config/conf.js b/test/e2e/config/conf.js index dc6aea337..bece508cb 100644 --- a/test/e2e/config/conf.js +++ b/test/e2e/config/conf.js @@ -53,6 +53,9 @@ const config = { onPrepare() { browser.waitForAngularEnabled(false); + browser.executeScript('window.localStorage.clear();'); + browser.executeScript('window.sessionStorage.clear();'); + browser.driver.manage().deleteAllCookies(); global.expect = chai.expect; global.assert = chai.assert; global.should = chai.should; From a570e7a92a2e5506ba38cc3ebc96ed890bcf5578 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Tue, 19 Nov 2019 17:07:10 +0000 Subject: [PATCH 34/71] Add/Display the Fee and Account tab --- src/app/app.constants.ts | 16 +++++++--------- src/fee-accounts/guards/accounts.guard.ts | 2 -- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/app/app.constants.ts b/src/app/app.constants.ts index 3789df509..d827cf0a5 100644 --- a/src/app/app.constants.ts +++ b/src/app/app.constants.ts @@ -15,20 +15,18 @@ const navItemsArray: NavItemModel[] = [ active: false, orderId: 2 }, - // Hiding the Tab for the Fee And Accounts - // { - // text: 'Fee Accounts', - // href: '/fee-accounts', - // active: false, - // orderId: 3 - // } + { + text: 'Fee Accounts', + href: '/fee-accounts', + active: false, + orderId: 3 + } ]; const roleBasedNav = { 'pui-organisation-manager': navItemsArray[0], 'pui-user-manager': navItemsArray[1], - // Hiding the role - // 'pui-finance-manager': navItemsArray[2], + 'pui-finance-manager': navItemsArray[2], }; const userNav: UserNavModel = { diff --git a/src/fee-accounts/guards/accounts.guard.ts b/src/fee-accounts/guards/accounts.guard.ts index 209c3ee82..85f276cec 100644 --- a/src/fee-accounts/guards/accounts.guard.ts +++ b/src/fee-accounts/guards/accounts.guard.ts @@ -11,8 +11,6 @@ export class AccountsGuard implements CanActivate { constructor(private store: Store) { } canActivate(): Observable { - // purposefully not allowing the user to hit Fee and Accounts tab - return of(false); return this.checkStore().pipe( switchMap(() => of(true)), catchError(() => of(false)) From 82fec7598cdaaeea58c236f9d45d041514decba6 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Wed, 20 Nov 2019 12:15:24 +0000 Subject: [PATCH 35/71] new account wrapper component that navigates the overview component --- src/fee-accounts/containers/index.ts | 3 +++ .../account-overview-container.component.html | 16 +++++++++++++ .../account-overview-container.component.ts | 23 +++++++++++++++++++ .../overview/account-overview.component.html | 9 ++++---- .../overview/account-overview.component.ts | 19 ++++++++++++--- 5 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 src/fee-accounts/containers/overview-container/account-overview-container.component.html create mode 100644 src/fee-accounts/containers/overview-container/account-overview-container.component.ts diff --git a/src/fee-accounts/containers/index.ts b/src/fee-accounts/containers/index.ts index 91413ac4d..6959f66e3 100644 --- a/src/fee-accounts/containers/index.ts +++ b/src/fee-accounts/containers/index.ts @@ -1,13 +1,16 @@ import { OrganisationAccountsComponent } from './overview/account-overview.component'; import { TransactionsComponent } from '../components/transactions/transactions.component'; import { SummaryComponent } from '../components/summary/summary.component'; +import { OrganisationAccountsOverviewContainerComponent } from './overview-container/account-overview-container.component'; export const containers: any[] = [ OrganisationAccountsComponent, + OrganisationAccountsOverviewContainerComponent, TransactionsComponent, SummaryComponent ]; export * from './overview/account-overview.component'; +export * from './overview-container/account-overview-container.component'; export * from '../components/transactions/transactions.component'; export * from '../components/summary/summary.component'; diff --git a/src/fee-accounts/containers/overview-container/account-overview-container.component.html b/src/fee-accounts/containers/overview-container/account-overview-container.component.html new file mode 100644 index 000000000..530bbfe08 --- /dev/null +++ b/src/fee-accounts/containers/overview-container/account-overview-container.component.html @@ -0,0 +1,16 @@ + + + + +
+ + + + You won’t be able to view your transactions until you’ve added one or more payment by account (PBA) numbers. + +
+

Adding a PBA number

+

Contact your service representative to add a PBA number.

+
\ No newline at end of file diff --git a/src/fee-accounts/containers/overview-container/account-overview-container.component.ts b/src/fee-accounts/containers/overview-container/account-overview-container.component.ts new file mode 100644 index 000000000..0090ef2d4 --- /dev/null +++ b/src/fee-accounts/containers/overview-container/account-overview-container.component.ts @@ -0,0 +1,23 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { GovukTableColumnConfig } from 'projects/gov-ui/src/lib/components/govuk-table/govuk-table.component'; + +@Component({ + selector: 'account-overview-container', + templateUrl: './account-overview-container.component.html' +}) + +export class OrganisationAccountsOverviewContainerComponent { + + @Input() classes = ''; + + @Input() caption = 'Dates and amounts'; + @Input() firstCellIsHeader = true; + + @Input() rows; + + @Input() columnConfig: any; + @Input() isAccountAvailableForOrg = true; + + constructor() { + } +} diff --git a/src/fee-accounts/containers/overview/account-overview.component.html b/src/fee-accounts/containers/overview/account-overview.component.html index 46b03da4a..7084f61d1 100644 --- a/src/fee-accounts/containers/overview/account-overview.component.html +++ b/src/fee-accounts/containers/overview/account-overview.component.html @@ -1,8 +1,9 @@ - +
Loading...
diff --git a/src/fee-accounts/containers/overview/account-overview.component.ts b/src/fee-accounts/containers/overview/account-overview.component.ts index 5e27f9bca..7fe8a5128 100644 --- a/src/fee-accounts/containers/overview/account-overview.component.ts +++ b/src/fee-accounts/containers/overview/account-overview.component.ts @@ -1,8 +1,8 @@ import {Component, OnInit, OnDestroy} from '@angular/core'; -import { Store, select } from '@ngrx/store'; +import { Store, select, Action } from '@ngrx/store'; import * as fromAccountStore from '../../../fee-accounts/store'; import { GovukTableColumnConfig } from 'projects/gov-ui/src/lib/components/govuk-table/govuk-table.component'; -import {Observable, Subscription, combineLatest} from 'rxjs'; +import {Observable, Subscription, combineLatest, of} from 'rxjs'; import {FeeAccount} from '../../models/pba-accounts'; import * as fromOrgStore from '../../../organisation/store/index'; import { Organisation } from 'src/organisation/organisation.model'; @@ -18,6 +18,7 @@ export class OrganisationAccountsComponent implements OnInit, OnDestroy { loading$: Observable; orgData: Organisation; org$: Observable; + isOrgAccountAvailable$: Observable; organisationSubscription: Subscription; dependanciesSubscription: Subscription; constructor(private feeStore: Store, @@ -36,7 +37,8 @@ export class OrganisationAccountsComponent implements OnInit, OnDestroy { if (this.org$) { this.organisationSubscription = this.org$.subscribe(( data) => { this.orgData = data; - this.feeStore.dispatch(new fromAccountStore.LoadFeeAccounts(data.paymentAccount)); + const anyAccountForOrg = this.dispatchLoadFeeAccount(data); + this.isOrgAccountAvailable$ = of(anyAccountForOrg); }); } this.accounts$ = this.feeStore.pipe(select(fromAccountStore.feeAccounts)); @@ -46,6 +48,17 @@ export class OrganisationAccountsComponent implements OnInit, OnDestroy { { header: 'Account name', key: 'account_name' } ]; } + dispatchLoadFeeAccount(organisation: Organisation): boolean { + const anyAccountForOrg = organisation.paymentAccount.length > 0; + anyAccountForOrg ? this.dispatchAction(this.feeStore, new fromAccountStore.LoadFeeAccounts(organisation.paymentAccount)) : + this.dispatchAction(this.feeStore, new fromAccountStore.LoadFeeAccountsSuccess([])); + return anyAccountForOrg; + } + + dispatchAction(feeStore: Store, action: Action) { + feeStore.dispatch(action); + } + ngOnDestroy(): void { if (this.organisationSubscription) { this.organisationSubscription.unsubscribe(); From 628c670a75a04c710a28b5f4461673bfe13a5672 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Wed, 20 Nov 2019 13:22:30 +0000 Subject: [PATCH 36/71] Add tests for the fee-accounts --- src/app/store/reducers/app.reducer.spec.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/app/store/reducers/app.reducer.spec.ts b/src/app/store/reducers/app.reducer.spec.ts index c4ed51570..f2a510f41 100644 --- a/src/app/store/reducers/app.reducer.spec.ts +++ b/src/app/store/reducers/app.reducer.spec.ts @@ -72,13 +72,12 @@ describe('AppReducer', () => { active: false, orderId: 2 }, - // Fix the failing test - // { - // href: '/fee-accounts', - // text: 'Fee Accounts', - // active: false, - // orderId: 3 - // } + { + href: '/fee-accounts', + text: 'Fee Accounts', + active: false, + orderId: 3 + } ]; const action = new fromAppActions.SetUserRoles(payload); const state = fromApp.reducer(initialState, action); From e25de2eca56e41d40dbb7780837018684269ba4e Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Thu, 21 Nov 2019 12:04:50 +0000 Subject: [PATCH 37/71] Clicking summary should not take user to home page rather stay on Summary --- .../containers/account-summary/account-summary.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fee-accounts/containers/account-summary/account-summary.component.ts b/src/fee-accounts/containers/account-summary/account-summary.component.ts index defceadef..c6f71d96f 100644 --- a/src/fee-accounts/containers/account-summary/account-summary.component.ts +++ b/src/fee-accounts/containers/account-summary/account-summary.component.ts @@ -21,7 +21,7 @@ export class AccountSummaryComponent implements OnInit, OnDestroy { navItems = [ { text: 'Summary', - href: `/`, + href: `./`, active: true }, { From 1661ca2d34ffb9a58da87590faa1ef85e0fc3749 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Thu, 21 Nov 2019 17:13:35 +0000 Subject: [PATCH 38/71] Changes when PBA number is missing and 404 is returned by Fee & Pay is handled gracefully --- api/accounts/accountUtil.ts | 29 ++++++++++++++ api/accounts/index.ts | 39 ++++++++++--------- api/interfaces/feeAccountPayload.ts | 8 ++++ .../store/actions/fee-accounts.actions.ts | 9 ++++- .../store/effects/fee-accounts.effects.ts | 5 ++- .../store/reducers/fee-accounts.reducer.ts | 19 +++++++++ 6 files changed, 89 insertions(+), 20 deletions(-) create mode 100644 api/accounts/accountUtil.ts create mode 100644 api/interfaces/feeAccountPayload.ts diff --git a/api/accounts/accountUtil.ts b/api/accounts/accountUtil.ts new file mode 100644 index 000000000..d8cb64941 --- /dev/null +++ b/api/accounts/accountUtil.ts @@ -0,0 +1,29 @@ +import { FeeAccount } from "../../src/fee-accounts/models/pba-accounts" +import { http } from '../lib/http' + +export function getAccountUrl(baseUrl: string, accountName: string) { + return `${baseUrl}/accounts/${accountName}` +} + +export function getAccount(accountNumber: string, url: string): Promise { + return new Promise((resolve, reject) => { + http.get(url) + .then(account => { + resolve(account) + }) + .catch(err => { + err && err.status && err.status === 404 ? resolve({data: getMissingFeeAccount(accountNumber), status: 404}) : reject(err) + }) + }) +} + +export function getMissingFeeAccount(accountNumber: string): FeeAccount { + return { + account_number: accountNumber, + account_name: '', + credit_limit: 0, + available_balance: 0, + status: '', + effective_date: '', + } +} \ No newline at end of file diff --git a/api/accounts/index.ts b/api/accounts/index.ts index bd2474ce8..eb2566008 100644 --- a/api/accounts/index.ts +++ b/api/accounts/index.ts @@ -1,7 +1,8 @@ import { AxiosPromise } from 'axios' import * as express from 'express' +import { FeeAccount } from '../../src/fee-accounts/models/pba-accounts' import { config } from '../lib/config' -import { http } from '../lib/http' +import { getAccount, getAccountUrl } from './accountUtil' async function handleAddressRoute(req, res) { let errReport: any @@ -14,38 +15,40 @@ async function handleAddressRoute(req, res) { res.status(500).send(errReport) } const accountNames = req.query.accountNames.split(',') - console.log('accountNames', accountNames) - const accounts = new Array() + const accounts = new Array() const accountPromises = new Array>() - accountNames.forEach((accountName: string) => accountPromises.push(getAccount(accountName))) + accountNames.forEach((accountNumber: string) => { + const url = getAccountUrl(config.services.feeAndPayApi, accountNumber) + accountPromises.push(getAccount(accountNumber, url)) + }) + let responseStatusCode try { - await Promise.all(accountPromises).then(allAccounts => { - allAccounts.forEach(account => { - accounts.push(account.data) + await Promise.all(accountPromises).then(allAccounts => { + allAccounts.forEach(account => { + if (account.status === 404) { + responseStatusCode = 404 + } + accounts.push(account.data) + }) }) - }) } catch (error) { - console.error(error) errReport = { apiError: error && error.data && error.data.message ? error.data.message : error, apiStatusCode: error && error.status ? error.status : '', message: `Fee And Pay route error `, } - res.status(500).send(errReport) + res.status(error.status).send(errReport) return } - res.send(accounts) -} -function getAccount(accountName: string): AxiosPromise { - const url = `${config.services.feeAndPayApi}/accounts/${accountName}` - const promise = http.get(url) - return promise + if (responseStatusCode) { + res.status(responseStatusCode).send(accounts) + } else { + res.send(accounts) } +} export const router = express.Router({ mergeParams: true }) - router.get('', handleAddressRoute) - export default router diff --git a/api/interfaces/feeAccountPayload.ts b/api/interfaces/feeAccountPayload.ts new file mode 100644 index 000000000..f69772ae9 --- /dev/null +++ b/api/interfaces/feeAccountPayload.ts @@ -0,0 +1,8 @@ +export interface FeeAccount { + account_number: string + account_name: string + credit_limit: number + available_balance: number + status: string + effective_date: Date +} diff --git a/src/fee-accounts/store/actions/fee-accounts.actions.ts b/src/fee-accounts/store/actions/fee-accounts.actions.ts index d3ac57841..7c0d26f44 100644 --- a/src/fee-accounts/store/actions/fee-accounts.actions.ts +++ b/src/fee-accounts/store/actions/fee-accounts.actions.ts @@ -3,6 +3,7 @@ import {Action} from '@ngrx/store'; export const LOAD_FEE_ACCOUNTS = '[Fee Accounts] Load Fee Accounts'; export const LOAD_FEE_ACCOUNTS_SUCCESS = '[Fee Accounts] Load Fee Accounts Success'; export const LOAD_FEE_ACCOUNTS_FAIL = '[Fee Accounts] Load Fee Accounts Fail'; +export const LOAD_FEE_ONE_OR_MORE_ACCOUNTS_FAIL = '[Fee Accounts] Load Fee One or more Accounts Fail'; export class LoadFeeAccounts { constructor(public paymentAccounts: string[]) { @@ -20,8 +21,14 @@ export class LoadFeeAccountsFail implements Action { constructor(public payload: any) {} } +export class LoadFeeOneOrMoreAccountsFail implements Action { + readonly type = LOAD_FEE_ONE_OR_MORE_ACCOUNTS_FAIL; + constructor(public payload: any) {} +} + export type FeeAccountsActions = | LoadFeeAccounts | LoadFeeAccountsSuccess - | LoadFeeAccountsFail; + | LoadFeeAccountsFail + | LoadFeeOneOrMoreAccountsFail; diff --git a/src/fee-accounts/store/effects/fee-accounts.effects.ts b/src/fee-accounts/store/effects/fee-accounts.effects.ts index d7eed712f..cfdc37b9e 100644 --- a/src/fee-accounts/store/effects/fee-accounts.effects.ts +++ b/src/fee-accounts/store/effects/fee-accounts.effects.ts @@ -21,7 +21,10 @@ export class FeeAccountsEffects { switchMap((payload: any) => { return this.feeAccountsService.fetchFeeAccounts(payload.paymentAccounts).pipe( map(feeAccountsDetails => new feeAccountsActions.LoadFeeAccountsSuccess(feeAccountsDetails)), - catchError(error => of(new feeAccountsActions.LoadFeeAccountsFail(error))) + catchError(errorResponse => { + return errorResponse.status === 404 ? of(new feeAccountsActions.LoadFeeOneOrMoreAccountsFail(errorResponse.error)) : + of(new feeAccountsActions.LoadFeeAccountsFail(errorResponse)); + }) ); }) ); diff --git a/src/fee-accounts/store/reducers/fee-accounts.reducer.ts b/src/fee-accounts/store/reducers/fee-accounts.reducer.ts index 669c7e3ed..4102558b0 100644 --- a/src/fee-accounts/store/reducers/fee-accounts.reducer.ts +++ b/src/fee-accounts/store/reducers/fee-accounts.reducer.ts @@ -45,6 +45,25 @@ export function reducer( loaded: true, loading: false }; + } + case fromFeeAccountActions.LOAD_FEE_ONE_OR_MORE_ACCOUNTS_FAIL: { + const payload = action.payload; + let feeAccounts = payload; + if (feeAccounts.length !== 0) { + feeAccounts = payload.map((entity: FeeAccount) => { + const element: FeeAccountSummary = { + ...entity, + routerLink: entity.account_number ? `/fee-accounts/account/${entity.account_number}/` : '' + }; + return element; + }); + } + return { + ...state, + feeAccounts, + loaded: true, + loading: false + }; } } From 0f1418dea6d0ac114c69f0d6b70557b4c8c518cf Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Fri, 22 Nov 2019 14:31:20 +0000 Subject: [PATCH 39/71] Handle missing PBA account gracefully and show it in different style --- .../account-missing.component.html | 9 ++++ .../account-missing.component.ts | 9 ++++ src/fee-accounts/containers/index.ts | 3 ++ .../account-overview-container.component.html | 47 ++++++++++++++----- .../account-overview-container.component.ts | 1 + .../overview/account-overview.component.html | 1 + .../overview/account-overview.component.ts | 2 + src/fee-accounts/models/pba-accounts.ts | 1 + .../store/reducers/fee-accounts.reducer.ts | 13 +++-- .../store/selectors/fee-accounts.selectors.ts | 1 + 10 files changed, 72 insertions(+), 15 deletions(-) create mode 100644 src/fee-accounts/containers/account-missing/account-missing.component.html create mode 100644 src/fee-accounts/containers/account-missing/account-missing.component.ts diff --git a/src/fee-accounts/containers/account-missing/account-missing.component.html b/src/fee-accounts/containers/account-missing/account-missing.component.html new file mode 100644 index 000000000..b91e42976 --- /dev/null +++ b/src/fee-accounts/containers/account-missing/account-missing.component.html @@ -0,0 +1,9 @@ +
+ + + + You won’t be able to view your transactions until you’ve added one or more payment by account (PBA) numbers. + +
+

Adding a PBA number

+

Contact your service representative to add a PBA number.

\ No newline at end of file diff --git a/src/fee-accounts/containers/account-missing/account-missing.component.ts b/src/fee-accounts/containers/account-missing/account-missing.component.ts new file mode 100644 index 000000000..6515f3ad4 --- /dev/null +++ b/src/fee-accounts/containers/account-missing/account-missing.component.ts @@ -0,0 +1,9 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'organisation-account-missing', + templateUrl: './account-missing.component.html' +}) + +export class OrganisationAccountMissingComponent { +} diff --git a/src/fee-accounts/containers/index.ts b/src/fee-accounts/containers/index.ts index 6959f66e3..dc9c6a9b8 100644 --- a/src/fee-accounts/containers/index.ts +++ b/src/fee-accounts/containers/index.ts @@ -2,15 +2,18 @@ import { OrganisationAccountsComponent } from './overview/account-overview.compo import { TransactionsComponent } from '../components/transactions/transactions.component'; import { SummaryComponent } from '../components/summary/summary.component'; import { OrganisationAccountsOverviewContainerComponent } from './overview-container/account-overview-container.component'; +import { OrganisationAccountMissingComponent } from './account-missing/account-missing.component'; export const containers: any[] = [ OrganisationAccountsComponent, OrganisationAccountsOverviewContainerComponent, + OrganisationAccountMissingComponent, TransactionsComponent, SummaryComponent ]; export * from './overview/account-overview.component'; +export * from './account-missing/account-missing.component'; export * from './overview-container/account-overview-container.component'; export * from '../components/transactions/transactions.component'; export * from '../components/summary/summary.component'; diff --git a/src/fee-accounts/containers/overview-container/account-overview-container.component.html b/src/fee-accounts/containers/overview-container/account-overview-container.component.html index 530bbfe08..db107cdb2 100644 --- a/src/fee-accounts/containers/overview-container/account-overview-container.component.html +++ b/src/fee-accounts/containers/overview-container/account-overview-container.component.html @@ -1,16 +1,39 @@ - +
+ + Error: PBA number not found + + + + + + + + + + + + + + + + + +
-
- - - - You won’t be able to view your transactions until you’ve added one or more payment by account (PBA) numbers. - -
-

Adding a PBA number

-

Contact your service representative to add a PBA number.

+
\ No newline at end of file diff --git a/src/fee-accounts/containers/overview-container/account-overview-container.component.ts b/src/fee-accounts/containers/overview-container/account-overview-container.component.ts index 0090ef2d4..64c786f2c 100644 --- a/src/fee-accounts/containers/overview-container/account-overview-container.component.ts +++ b/src/fee-accounts/containers/overview-container/account-overview-container.component.ts @@ -17,6 +17,7 @@ export class OrganisationAccountsOverviewContainerComponent { @Input() columnConfig: any; @Input() isAccountAvailableForOrg = true; + @Input() oneOrMoreAccountInfoMissing = false; constructor() { } diff --git a/src/fee-accounts/containers/overview/account-overview.component.html b/src/fee-accounts/containers/overview/account-overview.component.html index 7084f61d1..82b53edc2 100644 --- a/src/fee-accounts/containers/overview/account-overview.component.html +++ b/src/fee-accounts/containers/overview/account-overview.component.html @@ -2,6 +2,7 @@ diff --git a/src/fee-accounts/containers/overview/account-overview.component.ts b/src/fee-accounts/containers/overview/account-overview.component.ts index 7fe8a5128..441d5c6ec 100644 --- a/src/fee-accounts/containers/overview/account-overview.component.ts +++ b/src/fee-accounts/containers/overview/account-overview.component.ts @@ -21,6 +21,7 @@ export class OrganisationAccountsComponent implements OnInit, OnDestroy { isOrgAccountAvailable$: Observable; organisationSubscription: Subscription; dependanciesSubscription: Subscription; + oneOrMoreAccountMissing$: Observable; constructor(private feeStore: Store, private organisationStore: Store) {} @@ -39,6 +40,7 @@ export class OrganisationAccountsComponent implements OnInit, OnDestroy { this.orgData = data; const anyAccountForOrg = this.dispatchLoadFeeAccount(data); this.isOrgAccountAvailable$ = of(anyAccountForOrg); + this.oneOrMoreAccountMissing$ = this.feeStore.pipe(select(fromAccountStore.isOneOrMorefeeAccountsMissing)); }); } this.accounts$ = this.feeStore.pipe(select(fromAccountStore.feeAccounts)); diff --git a/src/fee-accounts/models/pba-accounts.ts b/src/fee-accounts/models/pba-accounts.ts index 748724bd5..8fba77ea7 100644 --- a/src/fee-accounts/models/pba-accounts.ts +++ b/src/fee-accounts/models/pba-accounts.ts @@ -18,4 +18,5 @@ effective_date: Date; export interface FeeAccountSummary extends FeeAccount { routerLink: string; + isAccountInfoMissing: boolean; } diff --git a/src/fee-accounts/store/reducers/fee-accounts.reducer.ts b/src/fee-accounts/store/reducers/fee-accounts.reducer.ts index 4102558b0..9812176a6 100644 --- a/src/fee-accounts/store/reducers/fee-accounts.reducer.ts +++ b/src/fee-accounts/store/reducers/fee-accounts.reducer.ts @@ -1,14 +1,16 @@ import * as fromFeeAccountActions from '../actions/fee-accounts.actions'; -import {PbaAccounts, PbaAccountsSummary, FeeAccount, FeeAccountSummary} from '../../models/pba-accounts'; +import {FeeAccount, FeeAccountSummary} from '../../models/pba-accounts'; export interface FeeAccountsState { feeAccounts: Array | null; + oneOrMoreAccountMissing: boolean; loaded: boolean; loading: boolean; } export const initialState: FeeAccountsState = { feeAccounts: null, + oneOrMoreAccountMissing: false, loaded: false, loading: false, }; @@ -33,7 +35,8 @@ export function reducer( feeAccounts = payload.map((entity: FeeAccount) => { const element: FeeAccountSummary = { ...entity, - routerLink: `/fee-accounts/account/${entity.account_number}/` + routerLink: `/fee-accounts/account/${entity.account_number}/`, + isAccountInfoMissing: false }; return element; }); @@ -42,6 +45,7 @@ export function reducer( return { ...state, feeAccounts, + oneOrMoreAccountMissing: false, loaded: true, loading: false }; @@ -53,7 +57,8 @@ export function reducer( feeAccounts = payload.map((entity: FeeAccount) => { const element: FeeAccountSummary = { ...entity, - routerLink: entity.account_number ? `/fee-accounts/account/${entity.account_number}/` : '' + routerLink: entity.account_name ? `/fee-accounts/account/${entity.account_number}/` : '', + isAccountInfoMissing: entity.account_name === null || entity.account_name === undefined || entity.account_name === '' }; return element; }); @@ -61,6 +66,7 @@ export function reducer( return { ...state, feeAccounts, + oneOrMoreAccountMissing: true, loaded: true, loading: false }; @@ -74,3 +80,4 @@ export function reducer( export const getFeeAccounts = (state: FeeAccountsState) => state.feeAccounts; export const getFeeAccountsLoading = (state: FeeAccountsState) => state.loading; export const getFeeAccountsLoaded = (state: FeeAccountsState) => state.loaded; +export const getOneOrMoreAccountMissingLoaded = (state: FeeAccountsState) => state.oneOrMoreAccountMissing; diff --git a/src/fee-accounts/store/selectors/fee-accounts.selectors.ts b/src/fee-accounts/store/selectors/fee-accounts.selectors.ts index 4acc1eeb9..6e21e2ea2 100644 --- a/src/fee-accounts/store/selectors/fee-accounts.selectors.ts +++ b/src/fee-accounts/store/selectors/fee-accounts.selectors.ts @@ -8,3 +8,4 @@ export const getFeeAccountsState = createSelector( selectFeatureFee, (state: any export const feeAccounts = createSelector( getFeeAccountsState, fromFeeAccounts.getFeeAccounts); export const feeAccountsLoading = createSelector( getFeeAccountsState, fromFeeAccounts.getFeeAccountsLoading); export const feeAccountsLoaded = createSelector( getFeeAccountsState, fromFeeAccounts.getFeeAccountsLoaded); +export const isOneOrMorefeeAccountsMissing = createSelector(getFeeAccountsState, fromFeeAccounts.getOneOrMoreAccountMissingLoaded); From 4cad35184b2d495c21e119a66e8154a7e9df2ffc Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Fri, 22 Nov 2019 16:52:45 +0000 Subject: [PATCH 40/71] Displaying error messages using the notification component --- .../overview/account-overview.component.html | 3 +++ .../overview/account-overview.component.ts | 2 ++ src/fee-accounts/fee-accounts.module.ts | 3 ++- .../store/reducers/fee-accounts.reducer.ts | 15 +++++++++++++-- .../store/selectors/fee-accounts.selectors.ts | 1 + 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/fee-accounts/containers/overview/account-overview.component.html b/src/fee-accounts/containers/overview/account-overview.component.html index 82b53edc2..01145d5f3 100644 --- a/src/fee-accounts/containers/overview/account-overview.component.html +++ b/src/fee-accounts/containers/overview/account-overview.component.html @@ -1,3 +1,6 @@ + + {{errorMessages$ | async }} + ; + errorMessages$: Observable>; constructor(private feeStore: Store, private organisationStore: Store) {} ngOnInit(): void { + this.errorMessages$ = this.feeStore.pipe(select(fromAccountStore.getErrorMessages)); const isOrgLoaded$ = this.organisationStore.pipe(select(fromOrgStore.getOrganisationLoaded)); if (isOrgLoaded$) { this.dependanciesSubscription = isOrgLoaded$.subscribe((org) => { diff --git a/src/fee-accounts/fee-accounts.module.ts b/src/fee-accounts/fee-accounts.module.ts index 8e10a10fa..4c353e0b7 100644 --- a/src/fee-accounts/fee-accounts.module.ts +++ b/src/fee-accounts/fee-accounts.module.ts @@ -21,6 +21,7 @@ import { AccountTransactionsComponent } from './containers/account-transactions/ import {AccountsGuard} from './guards/accounts.guard'; import {AccountSummaryGuard} from './guards/acccounts-summary.guards'; import { OrganisationService } from 'src/organisation/services'; +import { NotificationBannerComponent } from 'src/register/components'; export const GUARDS = [AccountsGuard, AccountSummaryGuard]; export const COMPONENTS = [ AccountOverviewComponent, AccountSummaryComponent, AccountTransactionsComponent]; @@ -37,7 +38,7 @@ export const COMPONENTS = [ AccountOverviewComponent, AccountSummaryComponent, A EffectsModule.forFeature(orgEffects), ], exports: [...fromContainers.containers], - declarations: [...fromContainers.containers, ...COMPONENTS], + declarations: [...fromContainers.containers, ...COMPONENTS, NotificationBannerComponent], providers: [...fromServices.services, ...GUARDS, OrganisationService] }) diff --git a/src/fee-accounts/store/reducers/fee-accounts.reducer.ts b/src/fee-accounts/store/reducers/fee-accounts.reducer.ts index 9812176a6..91a16a1ad 100644 --- a/src/fee-accounts/store/reducers/fee-accounts.reducer.ts +++ b/src/fee-accounts/store/reducers/fee-accounts.reducer.ts @@ -6,6 +6,7 @@ export interface FeeAccountsState { oneOrMoreAccountMissing: boolean; loaded: boolean; loading: boolean; + errorMessages: string[]; } export const initialState: FeeAccountsState = { @@ -13,6 +14,7 @@ export const initialState: FeeAccountsState = { oneOrMoreAccountMissing: false, loaded: false, loading: false, + errorMessages: null }; export function reducer( @@ -47,12 +49,14 @@ export function reducer( feeAccounts, oneOrMoreAccountMissing: false, loaded: true, - loading: false + loading: false, + errorMessages: [] }; } case fromFeeAccountActions.LOAD_FEE_ONE_OR_MORE_ACCOUNTS_FAIL: { const payload = action.payload; let feeAccounts = payload; + let errorMessages = new Array(); if (feeAccounts.length !== 0) { feeAccounts = payload.map((entity: FeeAccount) => { const element: FeeAccountSummary = { @@ -60,6 +64,11 @@ export function reducer( routerLink: entity.account_name ? `/fee-accounts/account/${entity.account_number}/` : '', isAccountInfoMissing: entity.account_name === null || entity.account_name === undefined || entity.account_name === '' }; + if (element.isAccountInfoMissing) { + // errorMessages.push(`Account number ${entity.account_number} not found. Contact your service representative for help`); + errorMessages = [...errorMessages, + `Account number ${entity.account_number} not found. Contact your service representative for help`]; + } return element; }); } @@ -68,7 +77,8 @@ export function reducer( feeAccounts, oneOrMoreAccountMissing: true, loaded: true, - loading: false + loading: false, + errorMessages }; } @@ -81,3 +91,4 @@ export const getFeeAccounts = (state: FeeAccountsState) => state.feeAccounts; export const getFeeAccountsLoading = (state: FeeAccountsState) => state.loading; export const getFeeAccountsLoaded = (state: FeeAccountsState) => state.loaded; export const getOneOrMoreAccountMissingLoaded = (state: FeeAccountsState) => state.oneOrMoreAccountMissing; +export const getFeeAccountErrorMessages = (state: FeeAccountsState) => state.errorMessages; diff --git a/src/fee-accounts/store/selectors/fee-accounts.selectors.ts b/src/fee-accounts/store/selectors/fee-accounts.selectors.ts index 6e21e2ea2..da5aeb4b6 100644 --- a/src/fee-accounts/store/selectors/fee-accounts.selectors.ts +++ b/src/fee-accounts/store/selectors/fee-accounts.selectors.ts @@ -9,3 +9,4 @@ export const feeAccounts = createSelector( getFeeAccountsState, fromFeeAccounts. export const feeAccountsLoading = createSelector( getFeeAccountsState, fromFeeAccounts.getFeeAccountsLoading); export const feeAccountsLoaded = createSelector( getFeeAccountsState, fromFeeAccounts.getFeeAccountsLoaded); export const isOneOrMorefeeAccountsMissing = createSelector(getFeeAccountsState, fromFeeAccounts.getOneOrMoreAccountMissingLoaded); +export const getErrorMessages = createSelector(getFeeAccountsState, fromFeeAccounts.getFeeAccountErrorMessages); From b1068911855503a04dd3ca1473afa7a9f7df1673 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Mon, 25 Nov 2019 11:22:46 +0000 Subject: [PATCH 41/71] Displaying error messages in different lines. Adding a new notification component for Fee and error --- .../fee-account-error-notification.component.html | 14 ++++++++++++++ .../fee-account-error-notification.component.ts | 14 ++++++++++++++ src/fee-accounts/containers/index.ts | 5 ++++- .../overview/account-overview.component.html | 7 ++++--- 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 src/fee-accounts/components/notifications/fee-account-error-notification.component.html create mode 100644 src/fee-accounts/components/notifications/fee-account-error-notification.component.ts diff --git a/src/fee-accounts/components/notifications/fee-account-error-notification.component.html b/src/fee-accounts/components/notifications/fee-account-error-notification.component.html new file mode 100644 index 000000000..038b0c0cc --- /dev/null +++ b/src/fee-accounts/components/notifications/fee-account-error-notification.component.html @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/src/fee-accounts/components/notifications/fee-account-error-notification.component.ts b/src/fee-accounts/components/notifications/fee-account-error-notification.component.ts new file mode 100644 index 000000000..18c5d0948 --- /dev/null +++ b/src/fee-accounts/components/notifications/fee-account-error-notification.component.ts @@ -0,0 +1,14 @@ +import {Component, OnInit, Input} from '@angular/core'; +@Component({ + selector: 'fee-account-notification-banner', + templateUrl: './fee-account-error-notification.component.html', +}) + +export class FeeAccountErrorNotificationComponent implements OnInit { + constructor() {} +@Input() errorMessages: Array; + ngOnInit(): void { + + } + +} diff --git a/src/fee-accounts/containers/index.ts b/src/fee-accounts/containers/index.ts index dc9c6a9b8..d4bb42ed7 100644 --- a/src/fee-accounts/containers/index.ts +++ b/src/fee-accounts/containers/index.ts @@ -3,13 +3,15 @@ import { TransactionsComponent } from '../components/transactions/transactions.c import { SummaryComponent } from '../components/summary/summary.component'; import { OrganisationAccountsOverviewContainerComponent } from './overview-container/account-overview-container.component'; import { OrganisationAccountMissingComponent } from './account-missing/account-missing.component'; +import { FeeAccountErrorNotificationComponent } from '../components/notifications/fee-account-error-notification.component'; export const containers: any[] = [ OrganisationAccountsComponent, OrganisationAccountsOverviewContainerComponent, OrganisationAccountMissingComponent, TransactionsComponent, - SummaryComponent + SummaryComponent, + FeeAccountErrorNotificationComponent ]; export * from './overview/account-overview.component'; @@ -17,3 +19,4 @@ export * from './account-missing/account-missing.component'; export * from './overview-container/account-overview-container.component'; export * from '../components/transactions/transactions.component'; export * from '../components/summary/summary.component'; +export * from '../components/notifications/fee-account-error-notification.component'; diff --git a/src/fee-accounts/containers/overview/account-overview.component.html b/src/fee-accounts/containers/overview/account-overview.component.html index 01145d5f3..e0b17422c 100644 --- a/src/fee-accounts/containers/overview/account-overview.component.html +++ b/src/fee-accounts/containers/overview/account-overview.component.html @@ -1,6 +1,7 @@ - - {{errorMessages$ | async }} - + + + + Date: Mon, 25 Nov 2019 13:40:36 +0000 Subject: [PATCH 42/71] Showing an error message --- api/accounts/index.ts | 2 +- .../containers/overview/account-overview.component.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/api/accounts/index.ts b/api/accounts/index.ts index eb2566008..d02a25e1b 100644 --- a/api/accounts/index.ts +++ b/api/accounts/index.ts @@ -12,7 +12,7 @@ async function handleAddressRoute(req, res) { apiStatusCode: '400', message: 'Fee And Pay route error', } - res.status(500).send(errReport) + res.status(errReport.apiStatusCode).send(errReport) } const accountNames = req.query.accountNames.split(',') const accounts = new Array() diff --git a/src/fee-accounts/containers/overview/account-overview.component.ts b/src/fee-accounts/containers/overview/account-overview.component.ts index 720b51e6e..c566f34bd 100644 --- a/src/fee-accounts/containers/overview/account-overview.component.ts +++ b/src/fee-accounts/containers/overview/account-overview.component.ts @@ -6,6 +6,8 @@ import {Observable, Subscription, combineLatest, of} from 'rxjs'; import {FeeAccount} from '../../models/pba-accounts'; import * as fromOrgStore from '../../../organisation/store/index'; import { Organisation } from 'src/organisation/organisation.model'; +import { Actions, ofType } from '@ngrx/effects'; +import * as fromRoot from '../../../app/store'; @Component({ selector: 'app-prd-fee-accounts-component', templateUrl: './account-overview.component.html', @@ -24,7 +26,9 @@ export class OrganisationAccountsComponent implements OnInit, OnDestroy { oneOrMoreAccountMissing$: Observable; errorMessages$: Observable>; constructor(private feeStore: Store, - private organisationStore: Store) {} + private organisationStore: Store, + private actions$: Actions, + private routerStore: Store) {} ngOnInit(): void { this.errorMessages$ = this.feeStore.pipe(select(fromAccountStore.getErrorMessages)); @@ -51,6 +55,9 @@ export class OrganisationAccountsComponent implements OnInit, OnDestroy { { header: 'Account number', key: 'account_number', type: 'link' }, { header: 'Account name', key: 'account_name' } ]; + this.actions$.pipe(ofType(fromAccountStore.LOAD_FEE_ACCOUNTS_FAIL)).subscribe(() => { + this.routerStore.dispatch(new fromRoot.Go({ path: ['service-down'] })); + }); } dispatchLoadFeeAccount(organisation: Organisation): boolean { const anyAccountForOrg = organisation.paymentAccount.length > 0; From d2e937316309c42b0613684453b9368f03ccc1c6 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Mon, 25 Nov 2019 16:32:19 +0000 Subject: [PATCH 43/71] If no transactions are available then show a message that no transactions are available --- api/payments/index.ts | 4 +-- ...-account-error-notification.component.html | 30 ++++++++++--------- .../transactions/transactions.component.html | 9 +++++- .../transactions/transactions.component.ts | 13 ++++---- .../account-transactions.component.html | 8 +---- .../account-overview-container.component.html | 5 +++- 6 files changed, 36 insertions(+), 33 deletions(-) diff --git a/api/payments/index.ts b/api/payments/index.ts index d307ec7d9..38412cf24 100644 --- a/api/payments/index.ts +++ b/api/payments/index.ts @@ -10,7 +10,7 @@ async function handleAddressRoute(req, res) { apiStatusCode: '400', message: 'Fee And Pay route error', } - res.status(500).send(errReport) + res.status(errReport.apiStatusCode).send(errReport) } try { const response = await http.get( @@ -23,7 +23,7 @@ async function handleAddressRoute(req, res) { apiStatusCode: error.status, message: 'Fee And Pay route error', } - res.status(500).send(errReport) + res.status(errReport.apiStatusCode).send(errReport) } } diff --git a/src/fee-accounts/components/notifications/fee-account-error-notification.component.html b/src/fee-accounts/components/notifications/fee-account-error-notification.component.html index 038b0c0cc..03c20ff36 100644 --- a/src/fee-accounts/components/notifications/fee-account-error-notification.component.html +++ b/src/fee-accounts/components/notifications/fee-account-error-notification.component.html @@ -1,14 +1,16 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/src/fee-accounts/components/transactions/transactions.component.html b/src/fee-accounts/components/transactions/transactions.component.html index f450909da..667714d11 100644 --- a/src/fee-accounts/components/transactions/transactions.component.html +++ b/src/fee-accounts/components/transactions/transactions.component.html @@ -1 +1,8 @@ - + + + + +

No transactions found.

+
\ No newline at end of file diff --git a/src/fee-accounts/components/transactions/transactions.component.ts b/src/fee-accounts/components/transactions/transactions.component.ts index 7f384e19b..618c7d839 100644 --- a/src/fee-accounts/components/transactions/transactions.component.ts +++ b/src/fee-accounts/components/transactions/transactions.component.ts @@ -14,22 +14,19 @@ export class TransactionsComponent implements OnChanges { @Input() transactions; columnConfig: GovukTableColumnConfig[]; - tableRows: {}[]; constructor() {} ngOnChanges(): void { this.columnConfig = [ - { header: 'Payment reference', key: 'paymentReference' }, - { header: 'Case', key: 'case' }, - { header: 'Reference', key: 'reference' }, - { header: 'Submitted by', key: 'submittedBy' }, + { header: 'Payment reference', key: 'payment_reference' }, + { header: 'Case', key: 'ccd_case_number' }, + { header: 'Your reference', key: 'payment_reference' }, { header: 'Status', key: 'status' }, - { header: 'Date created', key: 'dateCreated' }, + { header: 'Date created', key: 'date_created', type: 'date' }, + { header: 'Last updated', key: 'date_updated', type: 'date' }, { header: 'Amount', key: 'amount' } ]; - - this.tableRows = this.transactions; } } diff --git a/src/fee-accounts/containers/account-transactions/account-transactions.component.html b/src/fee-accounts/containers/account-transactions/account-transactions.component.html index 9d249286f..4214a5d62 100644 --- a/src/fee-accounts/containers/account-transactions/account-transactions.component.html +++ b/src/fee-accounts/containers/account-transactions/account-transactions.component.html @@ -14,11 +14,5 @@

Last updated on {{accounts && accounts[0] ? (accounts[0].effective_date | date:"dd MMM yyyy hh:mm a") : ''}}

- - -
Loading...
-
+ diff --git a/src/fee-accounts/containers/overview-container/account-overview-container.component.html b/src/fee-accounts/containers/overview-container/account-overview-container.component.html index db107cdb2..38e75e55e 100644 --- a/src/fee-accounts/containers/overview-container/account-overview-container.component.html +++ b/src/fee-accounts/containers/overview-container/account-overview-container.component.html @@ -25,7 +25,10 @@ {{r[col.key]}} - {{r[col.key]}} + {{r[col.key]}} + + {{r[col.key]}} + From 013cc3d2fa5c983374eeeadb81de65548f53f294 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Tue, 26 Nov 2019 11:09:05 +0000 Subject: [PATCH 44/71] Fix build errors --- api/accounts/accountUtil.ts | 4 ++-- src/fee-accounts/fee-accounts.module.ts | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/api/accounts/accountUtil.ts b/api/accounts/accountUtil.ts index d8cb64941..7ecc7422b 100644 --- a/api/accounts/accountUtil.ts +++ b/api/accounts/accountUtil.ts @@ -24,6 +24,6 @@ export function getMissingFeeAccount(accountNumber: string): FeeAccount { credit_limit: 0, available_balance: 0, status: '', - effective_date: '', + effective_date: new Date(2017, 1, 1), } -} \ No newline at end of file +} diff --git a/src/fee-accounts/fee-accounts.module.ts b/src/fee-accounts/fee-accounts.module.ts index 4c353e0b7..8e10a10fa 100644 --- a/src/fee-accounts/fee-accounts.module.ts +++ b/src/fee-accounts/fee-accounts.module.ts @@ -21,7 +21,6 @@ import { AccountTransactionsComponent } from './containers/account-transactions/ import {AccountsGuard} from './guards/accounts.guard'; import {AccountSummaryGuard} from './guards/acccounts-summary.guards'; import { OrganisationService } from 'src/organisation/services'; -import { NotificationBannerComponent } from 'src/register/components'; export const GUARDS = [AccountsGuard, AccountSummaryGuard]; export const COMPONENTS = [ AccountOverviewComponent, AccountSummaryComponent, AccountTransactionsComponent]; @@ -38,7 +37,7 @@ export const COMPONENTS = [ AccountOverviewComponent, AccountSummaryComponent, A EffectsModule.forFeature(orgEffects), ], exports: [...fromContainers.containers], - declarations: [...fromContainers.containers, ...COMPONENTS, NotificationBannerComponent], + declarations: [...fromContainers.containers, ...COMPONENTS], providers: [...fromServices.services, ...GUARDS, OrganisationService] }) From 6dc17137a049b8560d1c938d2673ac25e386f6ad Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Tue, 26 Nov 2019 13:13:31 +0000 Subject: [PATCH 45/71] update the IDAM response changes --- src/users/containers/utils/user-roles-util.spec.ts | 4 ++-- src/users/containers/utils/user-roles-util.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/users/containers/utils/user-roles-util.spec.ts b/src/users/containers/utils/user-roles-util.spec.ts index de6a32173..f041faf5e 100644 --- a/src/users/containers/utils/user-roles-util.spec.ts +++ b/src/users/containers/utils/user-roles-util.spec.ts @@ -37,7 +37,7 @@ describe('UserRolesUtil class ', () => { let isAddingSuccessful = UserRolesUtil.isAddingRoleSuccessful(response); expect(isAddingSuccessful).toEqual(undefined); - response = {addRolesResponse: {idamStatusCode: '201'}}; + response = {roleAdditionResponse: {idamStatusCode: '201'}}; isAddingSuccessful = UserRolesUtil.isAddingRoleSuccessful(response); expect(isAddingSuccessful).toEqual(true); }); @@ -47,7 +47,7 @@ describe('UserRolesUtil class ', () => { let isDeletingSuccessful = UserRolesUtil.isDeletingRoleSuccessful(response); expect(isDeletingSuccessful).toEqual(undefined); - response = {deleteRolesResponse: [{idamStatusCode: '204'}]}; + response = {roleDeletionResponse: [{idamStatusCode: '204'}]}; isDeletingSuccessful = UserRolesUtil.isDeletingRoleSuccessful(response); expect(isDeletingSuccessful).toEqual(true); }); diff --git a/src/users/containers/utils/user-roles-util.ts b/src/users/containers/utils/user-roles-util.ts index 2cb216897..91d834c33 100644 --- a/src/users/containers/utils/user-roles-util.ts +++ b/src/users/containers/utils/user-roles-util.ts @@ -44,14 +44,14 @@ export class UserRolesUtil { }); } static isAddingRoleSuccessful(response: any): boolean { - return response.addRolesResponse && - response.addRolesResponse.idamStatusCode && - response.addRolesResponse.idamStatusCode === '201'; + return response.roleAdditionResponse && + response.roleAdditionResponse.idamStatusCode && + response.roleAdditionResponse.idamStatusCode === '201'; } static isDeletingRoleSuccessful(result: any): boolean { - return result.deleteRolesResponse && - result.deleteRolesResponse[0].idamStatusCode && - result.deleteRolesResponse[0].idamStatusCode === '204'; + return result.roleDeletionResponse && + result.roleDeletionResponse[0].idamStatusCode && + result.roleDeletionResponse[0].idamStatusCode === '204'; } } From fa70a1045bd9f0cd2d8d4c88ce4d3c46eb03112c Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Tue, 26 Nov 2019 14:22:47 +0000 Subject: [PATCH 46/71] fix the response object name of the IDAM --- src/users/containers/utils/user-roles-util.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/users/containers/utils/user-roles-util.ts b/src/users/containers/utils/user-roles-util.ts index 2cb216897..91d834c33 100644 --- a/src/users/containers/utils/user-roles-util.ts +++ b/src/users/containers/utils/user-roles-util.ts @@ -44,14 +44,14 @@ export class UserRolesUtil { }); } static isAddingRoleSuccessful(response: any): boolean { - return response.addRolesResponse && - response.addRolesResponse.idamStatusCode && - response.addRolesResponse.idamStatusCode === '201'; + return response.roleAdditionResponse && + response.roleAdditionResponse.idamStatusCode && + response.roleAdditionResponse.idamStatusCode === '201'; } static isDeletingRoleSuccessful(result: any): boolean { - return result.deleteRolesResponse && - result.deleteRolesResponse[0].idamStatusCode && - result.deleteRolesResponse[0].idamStatusCode === '204'; + return result.roleDeletionResponse && + result.roleDeletionResponse[0].idamStatusCode && + result.roleDeletionResponse[0].idamStatusCode === '204'; } } From ecd253066ee740bb16069bf685230680e692c867 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Tue, 26 Nov 2019 14:56:47 +0000 Subject: [PATCH 47/71] fixing the failing tests --- .../transactions.component.spec.ts | 6 --- .../transactions/transactions.component.ts | 2 +- .../account-overview.component.spec.ts | 43 +++---------------- .../reducers/fee-accounts.reducer.spec.ts | 3 +- .../selectors/fee-accounts.selectors.spec.ts | 5 ++- 5 files changed, 11 insertions(+), 48 deletions(-) diff --git a/src/fee-accounts/components/transactions/transactions.component.spec.ts b/src/fee-accounts/components/transactions/transactions.component.spec.ts index 07442f0f5..eeb016fb7 100644 --- a/src/fee-accounts/components/transactions/transactions.component.spec.ts +++ b/src/fee-accounts/components/transactions/transactions.component.spec.ts @@ -28,10 +28,4 @@ describe('TransactionsComponent', () => { expect(component).toBeTruthy(); }); - it('should fill tableRows', () => { - component.transactions = [{dummy: 'something'}]; - component.ngOnChanges(); - expect(component.tableRows).toBeTruthy([{dummy: 'something'}]); - }); - }); diff --git a/src/fee-accounts/components/transactions/transactions.component.ts b/src/fee-accounts/components/transactions/transactions.component.ts index 618c7d839..97504a5be 100644 --- a/src/fee-accounts/components/transactions/transactions.component.ts +++ b/src/fee-accounts/components/transactions/transactions.component.ts @@ -11,7 +11,7 @@ import { GovukTableColumnConfig } from 'projects/gov-ui/src/lib/components/govuk }) export class TransactionsComponent implements OnChanges { - @Input() transactions; + @Input() transactions = []; columnConfig: GovukTableColumnConfig[]; diff --git a/src/fee-accounts/containers/overview/account-overview.component.spec.ts b/src/fee-accounts/containers/overview/account-overview.component.spec.ts index 4ebbc2a20..e8fb4c4ab 100644 --- a/src/fee-accounts/containers/overview/account-overview.component.spec.ts +++ b/src/fee-accounts/containers/overview/account-overview.component.spec.ts @@ -1,48 +1,15 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { OrganisationAccountsComponent } from './account-overview.component'; -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { StoreModule } from '@ngrx/store'; -import { reducers } from 'src/fee-accounts/store/reducers'; -import { of } from 'rxjs'; -import { APP_BASE_HREF } from '@angular/common'; -import { ActivatedRoute } from '@angular/router'; describe('OrganisationAccountsComponent', () => { let component: OrganisationAccountsComponent; - let fixture: ComponentFixture; + const feeStore = jasmine.createSpyObj('feeStore', ['pipe']); + const organisationStore = jasmine.createSpyObj('feeStore', ['pipe']); + const actions = jasmine.createSpyObj('feeStore', ['pipe']); + const routerStore = jasmine.createSpyObj('feeStore', ['pipe']); - let activatedRoute: any; - - beforeEach(async(() => { - activatedRoute = { - parent: { - params: of({}) - } - }; - TestBed.configureTestingModule({ - declarations: [OrganisationAccountsComponent], - imports: [ - StoreModule.forRoot({}), - StoreModule.forFeature('feeAccounts', reducers), - StoreModule.forFeature('org', reducers), - ], - schemas: [CUSTOM_ELEMENTS_SCHEMA], - providers: [ - { provide: APP_BASE_HREF, useValue: '/' }, - { provide: ActivatedRoute, useValue: activatedRoute }, - ] - }) - .compileComponents(); - })); beforeEach(() => { - fixture = TestBed.createComponent(OrganisationAccountsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - afterEach(() => { - TestBed.resetTestingModule(); + component = new OrganisationAccountsComponent(feeStore, organisationStore, actions, routerStore); }); it('should create', () => { diff --git a/src/fee-accounts/store/reducers/fee-accounts.reducer.spec.ts b/src/fee-accounts/store/reducers/fee-accounts.reducer.spec.ts index 26cf7fcdf..1d5dbed9d 100644 --- a/src/fee-accounts/store/reducers/fee-accounts.reducer.spec.ts +++ b/src/fee-accounts/store/reducers/fee-accounts.reducer.spec.ts @@ -31,7 +31,8 @@ describe('FeeAccountsReducer', () => { available_balance: null, status: null, effective_date: null, - routerLink: `/fee-accounts/account/123/` + routerLink: `/fee-accounts/account/123/`, + isAccountInfoMissing: false }; expect(state.feeAccounts).toEqual([expected]); }); diff --git a/src/fee-accounts/store/selectors/fee-accounts.selectors.spec.ts b/src/fee-accounts/store/selectors/fee-accounts.selectors.spec.ts index 25b4dd35e..2ad5f6663 100644 --- a/src/fee-accounts/store/selectors/fee-accounts.selectors.spec.ts +++ b/src/fee-accounts/store/selectors/fee-accounts.selectors.spec.ts @@ -25,7 +25,7 @@ describe('Fee accounts selectors', () => { result = value; }); - expect(result).toEqual({ feeAccounts: null, loaded: false, loading: false }); + expect(result).toEqual({ feeAccounts: null, loaded: false, loading: false, oneOrMoreAccountMissing: false, errorMessages: null }); }); }); @@ -42,7 +42,8 @@ describe('Fee accounts selectors', () => { expect(result).toEqual([ { payload: 'something', - routerLink: '/fee-accounts/account/undefined/' + routerLink: '/fee-accounts/account/undefined/', + isAccountInfoMissing: false } ]); }); From bb3a23ef355f1fc877b8c6a1cbd7a830d4fab04f Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Tue, 26 Nov 2019 15:31:42 +0000 Subject: [PATCH 48/71] Fix the account util --- api/accounts/accountUtil.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/accounts/accountUtil.ts b/api/accounts/accountUtil.ts index 7ecc7422b..827df5d5f 100644 --- a/api/accounts/accountUtil.ts +++ b/api/accounts/accountUtil.ts @@ -20,10 +20,10 @@ export function getAccount(accountNumber: string, url: string): Promise { export function getMissingFeeAccount(accountNumber: string): FeeAccount { return { account_number: accountNumber, - account_name: '', - credit_limit: 0, + account_name: null, + credit_limit: null, available_balance: 0, - status: '', - effective_date: new Date(2017, 1, 1), + status: null, + effective_date: new Date(), } } From e7aa662567ee03f02dc45ca55dee1801be3fab6f Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Fri, 29 Nov 2019 11:15:29 +0000 Subject: [PATCH 49/71] reset error state. Clean up after minor issue raised by QA --- .../containers/overview/account-overview.component.ts | 1 + src/fee-accounts/store/actions/fee-accounts.actions.ts | 8 +++++++- src/fee-accounts/store/reducers/fee-accounts.reducer.ts | 9 +++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/fee-accounts/containers/overview/account-overview.component.ts b/src/fee-accounts/containers/overview/account-overview.component.ts index c566f34bd..750981d23 100644 --- a/src/fee-accounts/containers/overview/account-overview.component.ts +++ b/src/fee-accounts/containers/overview/account-overview.component.ts @@ -77,5 +77,6 @@ export class OrganisationAccountsComponent implements OnInit, OnDestroy { if (this.dependanciesSubscription) { this.dependanciesSubscription.unsubscribe(); } + this.dispatchAction(this.feeStore, new fromAccountStore.LoadFeeAccountResetState()); } } diff --git a/src/fee-accounts/store/actions/fee-accounts.actions.ts b/src/fee-accounts/store/actions/fee-accounts.actions.ts index 7c0d26f44..dd67ccd0e 100644 --- a/src/fee-accounts/store/actions/fee-accounts.actions.ts +++ b/src/fee-accounts/store/actions/fee-accounts.actions.ts @@ -4,6 +4,7 @@ export const LOAD_FEE_ACCOUNTS = '[Fee Accounts] Load Fee Accounts'; export const LOAD_FEE_ACCOUNTS_SUCCESS = '[Fee Accounts] Load Fee Accounts Success'; export const LOAD_FEE_ACCOUNTS_FAIL = '[Fee Accounts] Load Fee Accounts Fail'; export const LOAD_FEE_ONE_OR_MORE_ACCOUNTS_FAIL = '[Fee Accounts] Load Fee One or more Accounts Fail'; +export const LOAD_FEE_RESET_STATE = '[Fee Accounts] Reset State'; export class LoadFeeAccounts { constructor(public paymentAccounts: string[]) { @@ -26,9 +27,14 @@ export class LoadFeeOneOrMoreAccountsFail implements Action { constructor(public payload: any) {} } +export class LoadFeeAccountResetState implements Action { + readonly type = LOAD_FEE_RESET_STATE; +} + export type FeeAccountsActions = | LoadFeeAccounts | LoadFeeAccountsSuccess | LoadFeeAccountsFail - | LoadFeeOneOrMoreAccountsFail; + | LoadFeeOneOrMoreAccountsFail + | LoadFeeAccountResetState; diff --git a/src/fee-accounts/store/reducers/fee-accounts.reducer.ts b/src/fee-accounts/store/reducers/fee-accounts.reducer.ts index 91a16a1ad..656984c9a 100644 --- a/src/fee-accounts/store/reducers/fee-accounts.reducer.ts +++ b/src/fee-accounts/store/reducers/fee-accounts.reducer.ts @@ -82,7 +82,16 @@ export function reducer( }; } + case fromFeeAccountActions.LOAD_FEE_RESET_STATE: { + const errorMessages = []; + return { + ...state, + loaded: false, + loading: false, + errorMessages + }; } +} return state; } From ce8833faf98ce9f03a8e149860c3762522e0e84f Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Mon, 2 Dec 2019 16:41:54 +0000 Subject: [PATCH 50/71] Handling server errors and redirecting user to the error page --- api/editUserPermissions/index.ts | 4 ++-- src/user-profile/store/effects/user.effects.spec.ts | 7 +++++++ src/user-profile/store/effects/user.effects.ts | 10 ++++++++-- .../edit-user-permission.component.ts | 5 +++++ src/users/store/actions/user.actions.ts | 10 +++++++++- 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/api/editUserPermissions/index.ts b/api/editUserPermissions/index.ts index 05162bd95..df85a401a 100644 --- a/api/editUserPermissions/index.ts +++ b/api/editUserPermissions/index.ts @@ -12,8 +12,8 @@ router.put('', inviteUserRoute) async function inviteUserRoute(req, res) { let errReport: ErrorReport if (!req.params.userId) { - errReport = getErrorReport('UserId is missing', '500', 'User Permissions route error') - res.status(500).send(errReport) + errReport = getErrorReport('UserId is missing', '400', 'User Permissions route error') + res.status(400).send(errReport) return } const payload = req.body diff --git a/src/user-profile/store/effects/user.effects.spec.ts b/src/user-profile/store/effects/user.effects.spec.ts index 862e8bcbf..05996ad8a 100644 --- a/src/user-profile/store/effects/user.effects.spec.ts +++ b/src/user-profile/store/effects/user.effects.spec.ts @@ -8,6 +8,7 @@ import { UserEffects } from './user.effects'; import { GetUserDetails, GetUserDetailsFailure, GetUserDetailsSuccess } from '../actions'; import { UserService } from '../../services/user.service'; import { HttpErrorResponse } from '@angular/common/http'; +import { LoggerService } from 'src/shared/services/logger.service'; describe('Fee accounts Effects', () => { let actions$; @@ -16,6 +17,8 @@ describe('Fee accounts Effects', () => { 'getUserDetails', ]); + const LoggerServiceMock = jasmine.createSpyObj('LoggerService', ['log', 'error']); + beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], @@ -24,6 +27,10 @@ describe('Fee accounts Effects', () => { provide: UserService, useValue: UserServiceMock, }, + { + provide: LoggerService, + useValue: LoggerServiceMock + }, fromUserEffects.UserEffects, provideMockActions(() => actions$) ] diff --git a/src/user-profile/store/effects/user.effects.ts b/src/user-profile/store/effects/user.effects.ts index ea0465643..463faa82a 100644 --- a/src/user-profile/store/effects/user.effects.ts +++ b/src/user-profile/store/effects/user.effects.ts @@ -7,16 +7,16 @@ import {UserService} from '../../services/user.service'; import {AuthActionTypes} from '../actions/'; import {UserInterface} from '../../models/user.model'; import {HttpErrorResponse} from '@angular/common/http'; -import config from '../../../../api/lib/config'; import * as usersActions from '../../../users/store/actions/user.actions'; import { UserRolesUtil } from 'src/users/containers/utils/user-roles-util'; -import * as fromRoot from '../../../app/store'; +import { LoggerService } from 'src/shared/services/logger.service'; @Injectable() export class UserEffects { constructor( private actions$: Actions, private userService: UserService, + private loggerService: LoggerService ) { } @Effect() @@ -59,10 +59,16 @@ export class UserEffects { return this.userService.editUserPermissions(user).pipe( map( response => { if (UserRolesUtil.isAddingRoleSuccessful(response) || UserRolesUtil.isDeletingRoleSuccessful(response)) { + this.loggerService.info('User permissions modified'); return new usersActions.EditUserSuccess(user.userId); } else { + this.loggerService.error('user permissions failed'); return new usersActions.EditUserFailure(user.userId); } + }), + catchError(error => { + this.loggerService.error(error); + return of(new usersActions.EditUserServerError({userId: user.userId, errorCode: error.apiStatusCode})); }) ); }) diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts index 23b74af30..90631cc3e 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts @@ -30,6 +30,7 @@ import { Actions, ofType } from '@ngrx/effects'; userSubscription: Subscription; dependanciesSubscription: Subscription; editPermissionSuccessSubscription: Subscription; + editPermissionServerErrorSubscription: Subscription; backUrl: string; summaryErrors: {isFromValid: boolean; items: { id: string; message: any; }[]; header: string}; @@ -47,6 +48,10 @@ import { Actions, ofType } from '@ngrx/effects'; this.routerStore.dispatch(new fromRoot.Go({ path: [`users/user/${this.userId}`] })); }); + this.editPermissionServerErrorSubscription = this.actions$.pipe(ofType(fromStore.EDIT_USER_SERVER_ERROR)).subscribe(() => { + this.routerStore.dispatch(new fromRoot.Go({ path: [`service-down`] })); + }); + this.isLoading$ = this.userStore.pipe(select(fromStore.getGetUserLoading)); this.dependanciesSubscription = combineLatest([ diff --git a/src/users/store/actions/user.actions.ts b/src/users/store/actions/user.actions.ts index 349113030..4d17d552c 100644 --- a/src/users/store/actions/user.actions.ts +++ b/src/users/store/actions/user.actions.ts @@ -7,6 +7,7 @@ export const LOAD_USERS_FAIL = '[User] Load Users Fail'; export const EDIT_USER = '[User] Edit User'; export const EDIT_USER_SUCCESS = '[User] Edit User Success'; export const EDIT_USER_FAILURE = '[User] Edit User Failure'; +export const EDIT_USER_SERVER_ERROR = '[User] Edit User Server Error'; export const SUSPEND_USER = '[User] Suspend User'; export const SUSPEND_USER_SUCCESS = '[User] Suspend User Success'; export const SUSPEND_USER_FAIL = '[User] Suspend User Fail'; @@ -33,6 +34,12 @@ export class EditUserSuccess implements Action { } } +export class EditUserServerError implements Action { + readonly type = EDIT_USER_SERVER_ERROR; + constructor(public payload: any) { + } +} + export class EditUserFailure implements Action { readonly type = EDIT_USER_FAILURE; constructor(public payload: any) { @@ -67,4 +74,5 @@ export type UserActions = | EditUserFailure | SuspendUser | SuspendUserSuccess - | SuspendUserFail; + | SuspendUserFail + | EditUserServerError; From 050d168a7ece89ec7c189ee023fd89ece00390a4 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Tue, 3 Dec 2019 16:00:08 +0000 Subject: [PATCH 51/71] Fix for the error page to appear --- .../containers/user-details/user-details.component.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/users/containers/user-details/user-details.component.ts b/src/users/containers/user-details/user-details.component.ts index 35c07c5de..ad57acd1c 100644 --- a/src/users/containers/user-details/user-details.component.ts +++ b/src/users/containers/user-details/user-details.component.ts @@ -18,6 +18,7 @@ export class UserDetailsComponent implements OnInit, OnDestroy { userSubscription: Subscription; dependanciesSubscription: Subscription; + suspendUserServerErrorSubscription: Subscription; actionButtons: { name: string, class: string, action: () => {} }[] = []; @@ -49,6 +50,10 @@ export class UserDetailsComponent implements OnInit, OnDestroy { this.suspendSuccessSubscription = this.actions$.pipe(ofType(fromStore.SUSPEND_USER_SUCCESS)).subscribe(() => { this.hideSuspendView(); }); + + this.suspendUserServerErrorSubscription = this.actions$.pipe(ofType(fromStore.SUSPEND_USER_FAIL)).subscribe(() => { + this.routerStore.dispatch(new fromRoot.Go({ path: [`service-down`] })); + }); } getDependancyObservables(routerStore: Store, userStore: Store) { @@ -107,6 +112,10 @@ export class UserDetailsComponent implements OnInit, OnDestroy { if (this.suspendSuccessSubscription) { this.suspendSuccessSubscription.unsubscribe(); } + + if (this.suspendUserServerErrorSubscription) { + this.suspendUserServerErrorSubscription.unsubscribe(); + } } isSuspended(status) { From 10ed29e709d9cb3bebd35e09a78d8565fe9f885d Mon Sep 17 00:00:00 2001 From: VAMSHI MUNIGANTI Date: Wed, 4 Dec 2019 16:00:25 +0000 Subject: [PATCH 52/71] added UI functional tests --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 586f2d15a..a4d636d8d 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "start:node": "cd api && yarn watch", "start:node:docker": "PUI_ENV=ldocker;cd api && yarn watch", "test:node": "cd api && yarn test", - "test:smoke": "sh whitelist.sh && ts-node ./test/integration/tests/test.ts", + "test:smoke": "sh whitelist.sh && && webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/functional.conf.js --local", "test:smoke:functional": "sh whitelist.sh && webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/smoke.conf.js --local", "test:functional": "webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/conf.js --local", "test:coverage": "echo 'not implemented'", From b1c8c579d9ba53542fb735094335561f3c251ac7 Mon Sep 17 00:00:00 2001 From: VAMSHI MUNIGANTI Date: Wed, 4 Dec 2019 16:27:59 +0000 Subject: [PATCH 53/71] fix syntax error --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a4d636d8d..affe9808f 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "start:node": "cd api && yarn watch", "start:node:docker": "PUI_ENV=ldocker;cd api && yarn watch", "test:node": "cd api && yarn test", - "test:smoke": "sh whitelist.sh && && webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/functional.conf.js --local", + "test:smoke": "sh whitelist.sh && webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/functional.conf.js --local", "test:smoke:functional": "sh whitelist.sh && webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/smoke.conf.js --local", "test:functional": "webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/conf.js --local", "test:coverage": "echo 'not implemented'", From e318e9bf9017a36112fea814aeef38397a3439d8 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Thu, 5 Dec 2019 10:02:28 +0000 Subject: [PATCH 54/71] Fix the failing tests --- src/users/containers/utils/user-roles-util.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/users/containers/utils/user-roles-util.spec.ts b/src/users/containers/utils/user-roles-util.spec.ts index de6a32173..f041faf5e 100644 --- a/src/users/containers/utils/user-roles-util.spec.ts +++ b/src/users/containers/utils/user-roles-util.spec.ts @@ -37,7 +37,7 @@ describe('UserRolesUtil class ', () => { let isAddingSuccessful = UserRolesUtil.isAddingRoleSuccessful(response); expect(isAddingSuccessful).toEqual(undefined); - response = {addRolesResponse: {idamStatusCode: '201'}}; + response = {roleAdditionResponse: {idamStatusCode: '201'}}; isAddingSuccessful = UserRolesUtil.isAddingRoleSuccessful(response); expect(isAddingSuccessful).toEqual(true); }); @@ -47,7 +47,7 @@ describe('UserRolesUtil class ', () => { let isDeletingSuccessful = UserRolesUtil.isDeletingRoleSuccessful(response); expect(isDeletingSuccessful).toEqual(undefined); - response = {deleteRolesResponse: [{idamStatusCode: '204'}]}; + response = {roleDeletionResponse: [{idamStatusCode: '204'}]}; isDeletingSuccessful = UserRolesUtil.isDeletingRoleSuccessful(response); expect(isDeletingSuccessful).toEqual(true); }); From 37cd7350ced0cd445e3586cfecdf6bc962d00431 Mon Sep 17 00:00:00 2001 From: ernestman28 Date: Thu, 5 Dec 2019 11:48:31 +0000 Subject: [PATCH 55/71] update demo config --- api/lib/config/environments/demo.config.ts | 40 ++++++++++------------ 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/api/lib/config/environments/demo.config.ts b/api/lib/config/environments/demo.config.ts index 21df1f1fd..eab0fdd65 100644 --- a/api/lib/config/environments/demo.config.ts +++ b/api/lib/config/environments/demo.config.ts @@ -6,7 +6,7 @@ export default { idamApi: 'https://idam-api.demo.platform.hmcts.net', s2s: 'http://rpe-service-auth-provider-demo.service.core-compute-demo.internal', rdProfessionalApi: 'http://rd-professional-api-demo.service.core-compute-demo.internal', - feeAndPayApi: 'https://payment-api-demo.service.core-compute-demo.internal', + feeAndPayApi: 'http://payment-api-demo.service.core-compute-demo.internal', }, health: { ccdDataApi: 'http://ccd-data-store-api-demo.service.core-compute-demo.internal/health', @@ -15,27 +15,23 @@ export default { idamApi: 'https://idam-api.demo.platform.hmcts.net/health', s2s: 'http://rpe-service-auth-provider-demo.service.core-compute-demo.internal/health', rdProfessionalApi: 'http://rd-professional-api-demo.service.core-compute-demo.internal/health', - feeAndPayApi: 'https://payment-api-demo.service.core-compute-demo.internal/health', + feeAndPayApi: 'http://payment-api-demo.service.core-compute-demo.internal/health', }, - proxy: { - host: '172.16.0.7', - port: 8080, - }, - protocol: 'http', - secureCookie: false, - sessionSecret: 'secretSauce', - logging: 'debug', - jurisdictions: [ - {id: 'SSCS'}, - {id: 'AUTOTEST1'}, - {id: 'DIVORCE'}, - {id: 'PROBATE'}, - {id: 'PUBLICLAW'}, - {id: 'bulkscan'}, - {id: 'BULKSCAN'}, - {id: 'IA'}, - {id: 'EMPLOYMENT'}, - {id: 'CMC'}, - ], + useProxy: false, + secureCookie: false, + sessionSecret: 'secretSauce', + logging: 'debug', + jurisdictions: [ + {id: 'SSCS'}, + {id: 'AUTOTEST1'}, + {id: 'DIVORCE'}, + {id: 'PROBATE'}, + {id: 'PUBLICLAW'}, + {id: 'bulkscan'}, + {id: 'BULKSCAN'}, + {id: 'IA'}, + {id: 'EMPLOYMENT'}, + {id: 'CMC'} + ], } From 5fd88ab62731270d793bea8dd669d4cdb44212d6 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Thu, 5 Dec 2019 15:41:46 +0000 Subject: [PATCH 56/71] fix the dependancy of FeeAccountPayload --- api/accounts/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/accounts/index.ts b/api/accounts/index.ts index d02a25e1b..35fb453c5 100644 --- a/api/accounts/index.ts +++ b/api/accounts/index.ts @@ -1,6 +1,6 @@ import { AxiosPromise } from 'axios' import * as express from 'express' -import { FeeAccount } from '../../src/fee-accounts/models/pba-accounts' +import { FeeAccount } from '../interfaces/feeAccountPayload' import { config } from '../lib/config' import { getAccount, getAccountUrl } from './accountUtil' From 6cff7f13307137a845eec9f85695103e3c2c053d Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Thu, 5 Dec 2019 15:50:56 +0000 Subject: [PATCH 57/71] fix the path --- api/accounts/accountUtil.ts | 2 +- .../edit-user-permissions/edit-user-permission.component.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/accounts/accountUtil.ts b/api/accounts/accountUtil.ts index 827df5d5f..ab053d010 100644 --- a/api/accounts/accountUtil.ts +++ b/api/accounts/accountUtil.ts @@ -1,4 +1,4 @@ -import { FeeAccount } from "../../src/fee-accounts/models/pba-accounts" +import { FeeAccount } from "../interfaces/feeAccountPayload" import { http } from '../lib/http' export function getAccountUrl(baseUrl: string, accountName: string) { diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts index 23b74af30..c1260d179 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts @@ -1,12 +1,12 @@ import {Component, OnInit, OnDestroy} from '@angular/core'; -import { FormGroup, FormControl, Validator, ValidatorFn } from '@angular/forms'; -import { checkboxesBeCheckedValidator } from 'src/custom-validators/checkboxes-be-checked.validator'; +import { FormGroup, FormControl } from '@angular/forms'; import { Store, select } from '@ngrx/store'; import * as fromStore from '../../store'; import * as fromRoot from '../../../app/store'; import { Observable, Subscription, combineLatest } from 'rxjs'; import { UserRolesUtil } from '../utils/user-roles-util'; import { Actions, ofType } from '@ngrx/effects'; +import { checkboxesBeCheckedValidator } from '../../../custom-validators/checkboxes-be-checked.validator'; @Component({ selector: 'edit-user-permission', From 9a0c4be29cfc698c74306a2cb4efe42000056cb0 Mon Sep 17 00:00:00 2001 From: VAMSHI MUNIGANTI Date: Thu, 5 Dec 2019 16:29:49 +0000 Subject: [PATCH 58/71] tests disbaled --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index affe9808f..8dddd32b9 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "start:node": "cd api && yarn watch", "start:node:docker": "PUI_ENV=ldocker;cd api && yarn watch", "test:node": "cd api && yarn test", - "test:smoke": "sh whitelist.sh && webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/functional.conf.js --local", + "test:smoke": "", "test:smoke:functional": "sh whitelist.sh && webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/smoke.conf.js --local", "test:functional": "webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/conf.js --local", "test:coverage": "echo 'not implemented'", From ff4b4a4bfed5e6d44d9badcb548ccbd5d86bbef5 Mon Sep 17 00:00:00 2001 From: VAMSHI MUNIGANTI Date: Thu, 5 Dec 2019 16:53:17 +0000 Subject: [PATCH 59/71] added some script' --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8dddd32b9..03f1f16b8 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "start:node": "cd api && yarn watch", "start:node:docker": "PUI_ENV=ldocker;cd api && yarn watch", "test:node": "cd api && yarn test", - "test:smoke": "", + "test:smoke": "sh whitelist.sh", "test:smoke:functional": "sh whitelist.sh && webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/smoke.conf.js --local", "test:functional": "webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/conf.js --local", "test:coverage": "echo 'not implemented'", From 54fa27150fefb277d37cec9fd1d91b625e5b72f3 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Mon, 9 Dec 2019 09:41:26 +0000 Subject: [PATCH 60/71] update CCD roles --- src/app/app.constants.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/app.constants.ts b/src/app/app.constants.ts index 2a5829e3a..a70e0349c 100644 --- a/src/app/app.constants.ts +++ b/src/app/app.constants.ts @@ -95,12 +95,16 @@ const jurisdictions = [ const ccdRoles = [ 'caseworker', + 'caseworker-ia', 'caseworker-divorce', 'caseworker-divorce-solicitor', 'caseworker-divorce-financialremedy', 'caseworker-divorce-financialremedy-solicitor', 'caseworker-probate', - 'caseworker-probate-solicitor' + 'caseworker-probate-solicitor', + 'caseworker-publiclaw', + 'caseworker-ia-legalrep-solicitor', + 'caseworker-publiclaw-solicitor' ]; const redirectUrl = { From 59967f9c3de1329cf16ab8a08136e13f61231870 Mon Sep 17 00:00:00 2001 From: Borislav Petrov Date: Tue, 10 Dec 2019 15:50:55 +0000 Subject: [PATCH 61/71] add and remove ccd roles when updating pui-case-manager role, update error message content --- .../edit-user-permission.component.ts | 9 +++-- .../containers/utils/user-roles-util.spec.ts | 14 ++++++++ src/users/containers/utils/user-roles-util.ts | 33 +++++++++++++++++-- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts index 90631cc3e..b950d25d0 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts @@ -139,10 +139,13 @@ import { Actions, ofType } from '@ngrx/effects'; if (rolesAdded.length > 0 || rolesDeleted.length > 0) { this.userStore.dispatch(new fromStore.EditUser({editUserRolesObj, userId: this.userId})); } else { - this.summaryErrors = { isFromValid: false, items: [{id: 'roles', message: 'No changes done.' }], + /* tslint:disable-next-line */ + this.summaryErrors = { isFromValid: false, items: [{id: 'roles', message: 'You need to make a change before submitting. If you don\'t make a change, these permissions will stay the same' }], header: this.errorMessages.header}; - this.permissionErrors = { isInvalid: true, messages: ['No changes done.' ]}; - return this.userStore.dispatch(new fromStore.EditUserFailure('No changes done.')); + /* tslint:disable-next-line */ + this.permissionErrors = { isInvalid: true, messages: ['You need to make a change before submitting. If you don\'t make a change, these permissions will stay the same' ]}; + /* tslint:disable-next-line */ + return this.userStore.dispatch(new fromStore.EditUserFailure('You need to make a change before submitting. If you don\'t make a change, these permissions will stay the same')); } } } diff --git a/src/users/containers/utils/user-roles-util.spec.ts b/src/users/containers/utils/user-roles-util.spec.ts index f041faf5e..4e3fe04e9 100644 --- a/src/users/containers/utils/user-roles-util.spec.ts +++ b/src/users/containers/utils/user-roles-util.spec.ts @@ -51,4 +51,18 @@ describe('UserRolesUtil class ', () => { isDeletingSuccessful = UserRolesUtil.isDeletingRoleSuccessful(response); expect(isDeletingSuccessful).toEqual(true); }); + + it('should get deletable roles GetCCDRoles', () => { + const user = {roles: ['Perm1', 'caseworker', 'caseworker-divorce']}; + const roles = ['caseworker', 'caseworker-divorce']; + const result = UserRolesUtil.GetRemovableRolesForUser(user, roles); + expect(result).toEqual([{ name: 'caseworker' }, {name: 'caseworker-divorce'}]); + }); + + it('should get roles ccd roles to add GetCCDRoles', () => { + const user = {roles: ['role-1', 'role-2']}; + const roles = ['caseworker', 'caseworker-divorce']; + const result = UserRolesUtil.GetRolesToBeAddedForUser(user, roles); + expect(result).toEqual([{name: 'caseworker'}, {name: 'caseworker-divorce'}]); + }); }); diff --git a/src/users/containers/utils/user-roles-util.ts b/src/users/containers/utils/user-roles-util.ts index 91d834c33..5119b302b 100644 --- a/src/users/containers/utils/user-roles-util.ts +++ b/src/users/containers/utils/user-roles-util.ts @@ -1,4 +1,5 @@ import { AppConstants } from '../../../app/app.constants'; +import {boolean} from '@pact-foundation/pact/dsl/matchers'; export class UserRolesUtil { static getRolesAdded(user: any, permissions: string[]): any[] { @@ -8,6 +9,10 @@ export class UserRolesUtil { roles.push({ name: permission }); + if (permission === 'pui-case-manager') { + const ccdRolesTobeAdded = UserRolesUtil.GetRolesToBeAddedForUser(user, AppConstants.CCD_ROLES); + ccdRolesTobeAdded.forEach(newRole => roles.push(newRole)); + } } }); return roles; @@ -17,9 +22,13 @@ export class UserRolesUtil { const roles = []; user.roles.forEach( (permission) => { if (!permissions.includes(permission) && !AppConstants.CCD_ROLES.includes(permission)) { - roles.push({ - name: permission - }); + roles.push({ + name: permission + }); + if (permission === 'pui-case-manager') { + const ccdRolesTobeRemoved = UserRolesUtil.GetRemovableRolesForUser(user, AppConstants.CCD_ROLES); + ccdRolesTobeRemoved.forEach(newRole => roles.push(newRole)); + } } }); return roles; @@ -54,4 +63,22 @@ export class UserRolesUtil { result.roleDeletionResponse[0].idamStatusCode && result.roleDeletionResponse[0].idamStatusCode === '204'; } + + static GetRemovableRolesForUser(user: any, roles: Array): Array { + const rolesTobeRemoved = new Array(); + roles.forEach(role => { + if (user.roles.includes(role)) { + rolesTobeRemoved.push({name: role}); + } + }); + return rolesTobeRemoved; + } + + static GetRolesToBeAddedForUser(user: any, roles: Array): Array { + const rolesTobeAdded = new Array(); + roles.forEach(role => { + rolesTobeAdded.push({name: role}); + }); + return rolesTobeAdded; + } } From 2610260d41039f5506446d5666d3a1d448b2a809 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Wed, 11 Dec 2019 10:38:27 +0000 Subject: [PATCH 62/71] Remove duplicate caseworker-ia in constants file --- src/app/app.constants.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/app.constants.ts b/src/app/app.constants.ts index 088ff2d3b..c6ca3f2d1 100644 --- a/src/app/app.constants.ts +++ b/src/app/app.constants.ts @@ -95,7 +95,6 @@ const jurisdictions = [ const ccdRoles = [ 'caseworker', - 'caseworker-ia', 'caseworker-divorce', 'caseworker-divorce-solicitor', 'caseworker-divorce-financialremedy', From 56ac6b413457f7e56d1cf51e7c8372ac32fcb377 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Wed, 11 Dec 2019 11:13:15 +0000 Subject: [PATCH 63/71] Changes to the Manage Payments to fee account --- .../invite-user-permission.component.html | 4 ++-- src/users/containers/user-details/user-details.component.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/users/components/invite-user-permissions/invite-user-permission.component.html b/src/users/components/invite-user-permissions/invite-user-permission.component.html index 05d65fd30..158611c79 100644 --- a/src/users/components/invite-user-permissions/invite-user-permission.component.html +++ b/src/users/components/invite-user-permissions/invite-user-permission.component.html @@ -29,8 +29,8 @@ + [config]="{value: 'pui-finance-manager', label: 'Manage fee accounts', name: 'roles', + hint: 'View payments, account balances, available credit and transactions.'}">
diff --git a/src/users/containers/user-details/user-details.component.html b/src/users/containers/user-details/user-details.component.html index f843def8f..a27737a54 100644 --- a/src/users/containers/user-details/user-details.component.html +++ b/src/users/containers/user-details/user-details.component.html @@ -31,7 +31,7 @@
Manage Organisations
Manage Users
Manage Cases
-
Manage Payments
+
Manage fee accounts
Change From f03bd8d4caa16089269d2666e7db46db1ef32dd3 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Fri, 24 Jan 2020 12:02:27 +0000 Subject: [PATCH 64/71] hide accounts for now --- src/app/app.constants.ts | 14 +++++++------- src/fee-accounts/guards/accounts.guard.ts | 3 ++- .../invite-user-permission.component.html | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/app/app.constants.ts b/src/app/app.constants.ts index f208df635..d1e991e95 100644 --- a/src/app/app.constants.ts +++ b/src/app/app.constants.ts @@ -15,18 +15,18 @@ const navItemsArray: NavItemModel[] = [ active: false, orderId: 2 }, - { - text: 'Fee Accounts', - href: '/fee-accounts', - active: false, - orderId: 3 - } + // { + // text: 'Fee Accounts', + // href: '/fee-accounts', + // active: false, + // orderId: 3 + // } ]; const roleBasedNav = { 'pui-organisation-manager': navItemsArray[0], 'pui-user-manager': navItemsArray[1], - 'pui-finance-manager': navItemsArray[2], + // 'pui-finance-manager': navItemsArray[2], }; const userNav: UserNavModel = { diff --git a/src/fee-accounts/guards/accounts.guard.ts b/src/fee-accounts/guards/accounts.guard.ts index 85f276cec..aa93c5309 100644 --- a/src/fee-accounts/guards/accounts.guard.ts +++ b/src/fee-accounts/guards/accounts.guard.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { CanActivate } from '@angular/router'; import { take, filter, tap, catchError, switchMap } from 'rxjs/operators'; -import { Observable, of } from 'rxjs'; +import { Observable, of, observable } from 'rxjs'; import { select, Store } from '@ngrx/store'; import * as fromStore from '../../organisation/store'; @@ -11,6 +11,7 @@ export class AccountsGuard implements CanActivate { constructor(private store: Store) { } canActivate(): Observable { + return of(false); return this.checkStore().pipe( switchMap(() => of(true)), catchError(() => of(false)) diff --git a/src/users/components/invite-user-permissions/invite-user-permission.component.html b/src/users/components/invite-user-permissions/invite-user-permission.component.html index 05d65fd30..905faade0 100644 --- a/src/users/components/invite-user-permissions/invite-user-permission.component.html +++ b/src/users/components/invite-user-permissions/invite-user-permission.component.html @@ -26,12 +26,12 @@ hint: 'View organisation name and addresses.'}"> - - + -->
From a73a5db1353a0ac58c881579664731dd57a94f63 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Fri, 24 Jan 2020 14:14:53 +0000 Subject: [PATCH 65/71] Fix merge conflicts --- .../store/effects/fee-accounts.effects.ts | 12 ------- .../store/effects/user.effects.ts | 31 +++++-------------- .../store/effects/invite-user.effects.ts | 21 +++---------- src/users/store/effects/users.effects.ts | 18 +++-------- 4 files changed, 16 insertions(+), 66 deletions(-) diff --git a/src/fee-accounts/store/effects/fee-accounts.effects.ts b/src/fee-accounts/store/effects/fee-accounts.effects.ts index 4a79b25e1..204cef6b4 100644 --- a/src/fee-accounts/store/effects/fee-accounts.effects.ts +++ b/src/fee-accounts/store/effects/fee-accounts.effects.ts @@ -23,22 +23,10 @@ export class FeeAccountsEffects { switchMap((payload: any) => { return this.feeAccountsService.fetchFeeAccounts(payload.paymentAccounts).pipe( map(feeAccountsDetails => new feeAccountsActions.LoadFeeAccountsSuccess(feeAccountsDetails)), -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> f1619da3f05cd26213bcc03e8f3d299e1997f3d8 catchError(errorResponse => { this.loggerService.error(errorResponse); return errorResponse.status === 404 ? of(new feeAccountsActions.LoadFeeOneOrMoreAccountsFail(errorResponse.error)) : of(new feeAccountsActions.LoadFeeAccountsFail(errorResponse)); -<<<<<<< HEAD -======= - catchError(error => { - this.loggerService.error(error.message); - return of(new feeAccountsActions.LoadFeeAccountsFail(error)); ->>>>>>> 5c7f86a1f0b68ad3a23c6ab8a0e2496080c7e850 -======= ->>>>>>> f1619da3f05cd26213bcc03e8f3d299e1997f3d8 }) ); }) diff --git a/src/user-profile/store/effects/user.effects.ts b/src/user-profile/store/effects/user.effects.ts index e6abf7f43..91411ca18 100644 --- a/src/user-profile/store/effects/user.effects.ts +++ b/src/user-profile/store/effects/user.effects.ts @@ -1,40 +1,25 @@ +import {HttpErrorResponse} from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Actions, Effect, ofType } from '@ngrx/effects'; -import * as authActions from '../actions'; -import { catchError, map, switchMap } from 'rxjs/operators'; import { of } from 'rxjs'; -import {UserService} from '../../services/user.service'; -import {AuthActionTypes} from '../actions/'; -import {UserInterface} from '../../models/user.model'; -import {HttpErrorResponse} from '@angular/common/http'; -<<<<<<< HEAD -<<<<<<< HEAD -import config from '../../../../api/lib/config'; -import * as usersActions from '../../../users/store/actions/user.actions'; +import { catchError, map, switchMap } from 'rxjs/operators'; import { UserRolesUtil } from 'src/users/containers/utils/user-roles-util'; +import config from '../../../../api/lib/config'; import * as fromRoot from '../../../app/store'; -======= -import { LoggerService } from '../../../shared/services/logger.service'; ->>>>>>> 5c7f86a1f0b68ad3a23c6ab8a0e2496080c7e850 -======= import { LoggerService } from '../../../shared/services/logger.service'; ->>>>>>> f1619da3f05cd26213bcc03e8f3d299e1997f3d8 +import * as usersActions from '../../../users/store/actions/user.actions'; +import {UserInterface} from '../../models/user.model'; +import {UserService} from '../../services/user.service'; +import * as authActions from '../actions'; +import {AuthActionTypes} from '../actions/'; @Injectable() export class UserEffects { constructor( private actions$: Actions, -<<<<<<< HEAD -<<<<<<< HEAD private userService: UserService, -======= - private authService: UserService, - private loggerService: LoggerService ->>>>>>> 5c7f86a1f0b68ad3a23c6ab8a0e2496080c7e850 -======= private authService: UserService, private loggerService: LoggerService ->>>>>>> f1619da3f05cd26213bcc03e8f3d299e1997f3d8 ) { } @Effect() diff --git a/src/users/store/effects/invite-user.effects.ts b/src/users/store/effects/invite-user.effects.ts index 415f7de1c..481271024 100644 --- a/src/users/store/effects/invite-user.effects.ts +++ b/src/users/store/effects/invite-user.effects.ts @@ -1,24 +1,13 @@ import {Injectable} from '@angular/core'; import {Actions, Effect, ofType} from '@ngrx/effects'; -import * as usersActions from '../actions'; -import {catchError, map, switchMap, tap} from 'rxjs/operators'; import {of} from 'rxjs'; -import {InviteUserService } from '../../services'; -import * as fromRoot from '../../../app/store'; -<<<<<<< HEAD -<<<<<<< HEAD +import {catchError, map, switchMap, tap} from 'rxjs/operators'; import { LoggerService } from 'src/shared/services/logger.service'; -import { UserService } from 'src/user-profile/services/user.service'; -======= -import { LoggerService } from '../../../shared/services/logger.service'; - ->>>>>>> 5c7f86a1f0b68ad3a23c6ab8a0e2496080c7e850 - -======= -import { LoggerService } from '../../../shared/services/logger.service'; +import * as fromRoot from '../../../app/store'; +import {InviteUserService } from '../../services'; +import * as usersActions from '../actions'; ->>>>>>> f1619da3f05cd26213bcc03e8f3d299e1997f3d8 @Injectable() export class InviteUserEffects { constructor( @@ -51,6 +40,4 @@ export class InviteUserEffects { return new fromRoot.Go({ path: ['users/invite-user-success'] }); }) ); - - } diff --git a/src/users/store/effects/users.effects.ts b/src/users/store/effects/users.effects.ts index 86312ba61..ee742e2ae 100644 --- a/src/users/store/effects/users.effects.ts +++ b/src/users/store/effects/users.effects.ts @@ -1,21 +1,11 @@ import { Injectable } from '@angular/core'; import { Actions, Effect, ofType } from '@ngrx/effects'; -import * as usersActions from '../actions'; -import { catchError, map, switchMap } from 'rxjs/operators'; import { of } from 'rxjs'; -import { UsersService } from '../../services'; -<<<<<<< HEAD -<<<<<<< HEAD -import { SuspendUser } from '../actions'; -======= -import { LoggerService } from '../../../shared/services/logger.service'; ->>>>>>> 5c7f86a1f0b68ad3a23c6ab8a0e2496080c7e850 -======= +import { catchError, map, switchMap } from 'rxjs/operators'; import { LoggerService } from '../../../shared/services/logger.service'; ->>>>>>> f1619da3f05cd26213bcc03e8f3d299e1997f3d8 - - +import { UsersService } from '../../services'; +import * as usersActions from '../actions'; @Injectable() export class UsersEffects { @@ -56,7 +46,7 @@ export class UsersEffects { @Effect() suspendUser$ = this.actions$.pipe( ofType(usersActions.SUSPEND_USER), - switchMap((user: SuspendUser) => { + switchMap((user: usersActions.SuspendUser) => { return this.usersService.suspendUser(user).pipe( map(res => new usersActions.SuspendUserSuccess(user.payload)), catchError(error => of(new usersActions.SuspendUserFail(error))) From f3fd1e85b2536874e417953ce123b9aabbc38306 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Fri, 24 Jan 2020 14:32:01 +0000 Subject: [PATCH 66/71] Fix the Lint errors --- .../fee-account-error-notification.component.ts | 2 +- .../account-missing/account-missing.component.ts | 2 +- .../account-overview-container.component.html | 2 +- .../account-overview-container.component.ts | 2 +- .../containers/overview/account-overview.component.html | 8 ++++---- .../edit-user-permission.component.ts | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/fee-accounts/components/notifications/fee-account-error-notification.component.ts b/src/fee-accounts/components/notifications/fee-account-error-notification.component.ts index 18c5d0948..f2c0a367c 100644 --- a/src/fee-accounts/components/notifications/fee-account-error-notification.component.ts +++ b/src/fee-accounts/components/notifications/fee-account-error-notification.component.ts @@ -1,6 +1,6 @@ import {Component, OnInit, Input} from '@angular/core'; @Component({ - selector: 'fee-account-notification-banner', + selector: 'app-fee-account-notification-banner', templateUrl: './fee-account-error-notification.component.html', }) diff --git a/src/fee-accounts/containers/account-missing/account-missing.component.ts b/src/fee-accounts/containers/account-missing/account-missing.component.ts index 6515f3ad4..c11d22f09 100644 --- a/src/fee-accounts/containers/account-missing/account-missing.component.ts +++ b/src/fee-accounts/containers/account-missing/account-missing.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; @Component({ - selector: 'organisation-account-missing', + selector: 'app-organisation-account-missing', templateUrl: './account-missing.component.html' }) diff --git a/src/fee-accounts/containers/overview-container/account-overview-container.component.html b/src/fee-accounts/containers/overview-container/account-overview-container.component.html index 38e75e55e..546c18082 100644 --- a/src/fee-accounts/containers/overview-container/account-overview-container.component.html +++ b/src/fee-accounts/containers/overview-container/account-overview-container.component.html @@ -38,5 +38,5 @@
- + \ No newline at end of file diff --git a/src/fee-accounts/containers/overview-container/account-overview-container.component.ts b/src/fee-accounts/containers/overview-container/account-overview-container.component.ts index 64c786f2c..53a520633 100644 --- a/src/fee-accounts/containers/overview-container/account-overview-container.component.ts +++ b/src/fee-accounts/containers/overview-container/account-overview-container.component.ts @@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core'; import { GovukTableColumnConfig } from 'projects/gov-ui/src/lib/components/govuk-table/govuk-table.component'; @Component({ - selector: 'account-overview-container', + selector: 'app-account-overview-container', templateUrl: './account-overview-container.component.html' }) diff --git a/src/fee-accounts/containers/overview/account-overview.component.html b/src/fee-accounts/containers/overview/account-overview.component.html index e0b17422c..a1b2f6c58 100644 --- a/src/fee-accounts/containers/overview/account-overview.component.html +++ b/src/fee-accounts/containers/overview/account-overview.component.html @@ -1,14 +1,14 @@ - - + + - +>
Loading...
diff --git a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts index a7683a225..b18bf336e 100644 --- a/src/users/containers/edit-user-permissions/edit-user-permission.component.ts +++ b/src/users/containers/edit-user-permissions/edit-user-permission.component.ts @@ -9,7 +9,7 @@ import { Actions, ofType } from '@ngrx/effects'; import { checkboxesBeCheckedValidator } from '../../../custom-validators/checkboxes-be-checked.validator'; @Component({ - selector: 'edit-user-permission', + selector: 'app-edit-user-permission', templateUrl: './edit-user-permission.component.html', }) export class EditUserPermissionComponent implements OnInit, OnDestroy { From 7cacca597d036b9cc54fd37ca600999d6fe2c22e Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Fri, 24 Jan 2020 14:53:03 +0000 Subject: [PATCH 67/71] fix the tests for removing fee-account --- src/app/store/reducers/app.reducer.spec.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/store/reducers/app.reducer.spec.ts b/src/app/store/reducers/app.reducer.spec.ts index f2a510f41..e2222476b 100644 --- a/src/app/store/reducers/app.reducer.spec.ts +++ b/src/app/store/reducers/app.reducer.spec.ts @@ -72,12 +72,12 @@ describe('AppReducer', () => { active: false, orderId: 2 }, - { - href: '/fee-accounts', - text: 'Fee Accounts', - active: false, - orderId: 3 - } + // { + // href: '/fee-accounts', + // text: 'Fee Accounts', + // active: false, + // orderId: 3 + // } ]; const action = new fromAppActions.SetUserRoles(payload); const state = fromApp.reducer(initialState, action); From cde4cde52d937bb8101cf53f444680505c6201dd Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Tue, 28 Jan 2020 10:09:14 +0000 Subject: [PATCH 68/71] apiStatusCode to number from string --- api/accounts/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/accounts/index.ts b/api/accounts/index.ts index 35fb453c5..94a328deb 100644 --- a/api/accounts/index.ts +++ b/api/accounts/index.ts @@ -9,7 +9,7 @@ async function handleAddressRoute(req, res) { if (!req.query.accountNames) { errReport = { apiError: 'Account is missing', - apiStatusCode: '400', + apiStatusCode: 400, message: 'Fee And Pay route error', } res.status(errReport.apiStatusCode).send(errReport) From e114964b46db53c92c59f98958160fdab43edd14 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Tue, 28 Jan 2020 10:13:37 +0000 Subject: [PATCH 69/71] code review comment to use string[] instead of Array --- .../notifications/fee-account-error-notification.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fee-accounts/components/notifications/fee-account-error-notification.component.ts b/src/fee-accounts/components/notifications/fee-account-error-notification.component.ts index f2c0a367c..e337cbfe6 100644 --- a/src/fee-accounts/components/notifications/fee-account-error-notification.component.ts +++ b/src/fee-accounts/components/notifications/fee-account-error-notification.component.ts @@ -6,8 +6,8 @@ import {Component, OnInit, Input} from '@angular/core'; export class FeeAccountErrorNotificationComponent implements OnInit { constructor() {} -@Input() errorMessages: Array; - ngOnInit(): void { +@Input() public errorMessages: string[]; + public ngOnInit(): void { } From 50f39d5230d7fc0c93aa551ccd9106dc22a00eeb Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Tue, 28 Jan 2020 11:22:11 +0000 Subject: [PATCH 70/71] hide the manage payment --- src/users/containers/user-details/user-details.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/users/containers/user-details/user-details.component.html b/src/users/containers/user-details/user-details.component.html index a27737a54..f63dbaa0e 100644 --- a/src/users/containers/user-details/user-details.component.html +++ b/src/users/containers/user-details/user-details.component.html @@ -31,7 +31,7 @@
Manage Organisations
Manage Users
Manage Cases
-
Manage fee accounts
+ Change From f504dd9da6e738a69d63aa907db1accfe3f62937 Mon Sep 17 00:00:00 2001 From: Uday Denduluri Date: Tue, 28 Jan 2020 13:46:30 +0000 Subject: [PATCH 71/71] strongly typing the transactions --- .../components/transactions/transactions.component.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fee-accounts/components/transactions/transactions.component.ts b/src/fee-accounts/components/transactions/transactions.component.ts index 97504a5be..229bd412f 100644 --- a/src/fee-accounts/components/transactions/transactions.component.ts +++ b/src/fee-accounts/components/transactions/transactions.component.ts @@ -1,6 +1,6 @@ import {Component, OnChanges, Input} from '@angular/core'; import { GovukTableColumnConfig } from 'projects/gov-ui/src/lib/components/govuk-table/govuk-table.component'; - +import { Payment } from '../../models/pba-transactions'; /** * Bootstraps the Transactions Components */ @@ -11,13 +11,13 @@ import { GovukTableColumnConfig } from 'projects/gov-ui/src/lib/components/govuk }) export class TransactionsComponent implements OnChanges { - @Input() transactions = []; + @Input() public transactions = Array(); - columnConfig: GovukTableColumnConfig[]; + public columnConfig: GovukTableColumnConfig[]; constructor() {} - ngOnChanges(): void { + public ngOnChanges(): void { this.columnConfig = [ { header: 'Payment reference', key: 'payment_reference' }, { header: 'Case', key: 'ccd_case_number' },