Skip to content

Commit de0d0d8

Browse files
Merge pull request #584 from IABTechLab/ans-UID2-4200-manage-participants-screen-improvements
manage participants screen improvements
2 parents c181bb8 + 4123220 commit de0d0d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+323
-1155
lines changed

README.md

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ This is the self-serve portal for UID2 participants. It enables a range of opera
1212

1313
Recommended VS Code extensions:
1414

15-
| Extension | Details | Required? |
16-
| --------- | ------- | --------- |
17-
| ESLint | Lints your code. We expect PRs to be free of linter errors, and preferably free of warnings as well. | Yes |
18-
| i18n Ally | Checks your front-end code for accessibility rules. We expect PRs to maintain a high standard of A11y. | Yes |
19-
| Prettier - Code formatter | Formats your code. We want PRs to contain functionality changes, not whitespace fixes and linebreak changes. Prettier makes us all use the same code style so we can focus on the things which matter. | Yes |
20-
| Stylelint | Same as ESLint, but for your style files. | Yes |
21-
| Code Spell Checker | Popular extension by Street Side Software - checks your spelling. | Yes, or similar alternative |
22-
| Wallaby.js | Live, in-your-IDE, as-you-type test runner. It is free for open source projects, but please read the license and satisfy yourself that you're in compliance if you use the free version. | No |
23-
| Docker | Helps you manage docker containers straight from VS Code. | No |
24-
| Auto Rename Tag | Fixes your closing tags as you edit opening tags | No |
25-
| Toggle Quotes | You can hit `ctrl-'` to cycle between quote styles (', ", and `) for the string you're editing. | No |
26-
| SonarLint | Detects and highlights issues that can lead to bugs, vulnerabilities, and code smells. | No |
15+
| Extension | Details | Required? |
16+
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------- |
17+
| ESLint | Lints your code. We expect PRs to be free of linter errors, and preferably free of warnings as well. | Yes |
18+
| i18n Ally | Checks your front-end code for accessibility rules. We expect PRs to maintain a high standard of A11y. | Yes |
19+
| Prettier - Code formatter | Formats your code. We want PRs to contain functionality changes, not whitespace fixes and linebreak changes. Prettier makes us all use the same code style so we can focus on the things which matter. | Yes |
20+
| Stylelint | Same as ESLint, but for your style files. | Yes |
21+
| Code Spell Checker | Popular extension by Street Side Software - checks your spelling. | Yes, or similar alternative |
22+
| Wallaby.js | Live, in-your-IDE, as-you-type test runner. It is free for open source projects, but please read the license and satisfy yourself that you're in compliance if you use the free version. | No |
23+
| Docker | Helps you manage docker containers straight from VS Code. | No |
24+
| Auto Rename Tag | Fixes your closing tags as you edit opening tags | No |
25+
| Toggle Quotes | You can hit `ctrl-'` to cycle between quote styles (', ", and `) for the string you're editing. | No |
26+
| SonarLint | Detects and highlights issues that can lead to bugs, vulnerabilities, and code smells. | No |
2727

2828
## Docker
2929

@@ -268,24 +268,6 @@ The following steps describe the minimal steps required to successfully log in t
268268
1. Fill in the form however you want and submit the form
269269
1. Connect to the database server `localhost,11433` using the credentials in [docker-compose.yml](docker-compose.yml) under `KC_DB_USERNAME` and `KC_DB_PASSWORD`
270270
1. In the `uid2_selfserve` database, observe that `dbo.users` now contains a row with with the details you just filled out.
271-
1. Approve your account by updating the `status` of the row in `dbo.participants` that corresponds to your new user, i.e.
272-
273-
```
274-
use [uid2_selfserve]
275-
276-
declare @email as nvarchar(256) = '<Enter your email here>'
277-
278-
update p
279-
set status = 'approved'
280-
from dbo.participants p
281-
where p.id in (
282-
select upr.participantId
283-
from dbo.users u
284-
join dbo.usersToParticipantRoles upr on u.id = upr.userId
285-
where u.email = @email
286-
);
287-
```
288-
289271
1. Assign yourself the `api-participant-member` role by following these steps: [Assign Role to a Particular User](./KeycloakAdvancedSetup.md#assign-role-to-a-particular-user)
290272
1. Run the Admin service locally by following [Connecting to local Admin service](#connecting-to-local-admin-service)
291273
1. Optionally give your user access to the [UID2 Support Screens/Routes](#uid2-support-screensroutes)

src/api/controllers/userController.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
} from 'inversify-express-utils';
1313

1414
import { TYPES } from '../constant/types';
15-
import { ParticipantStatus } from '../entities/Participant';
1615
import { UserRoleId } from '../entities/UserRole';
1716
import { getTraceId } from '../helpers/loggingHelpers';
1817
import { getKcAdminClient } from '../keycloakAdminClient';
@@ -56,12 +55,9 @@ export class UserController {
5655

5756
@httpPut('/current/acceptTerms')
5857
public async acceptTerms(@request() req: UserRequest, @response() res: Response): Promise<void> {
59-
const doesUserHaveAnApprovedParticipant =
60-
req.user?.participants?.some(
61-
(participant) => participant.status === ParticipantStatus.Approved
62-
) ?? false;
58+
const doesUserHaveAParticipant = (req.user?.participants?.length ?? 0) >= 1 ?? false;
6359

64-
if (!doesUserHaveAnApprovedParticipant) {
60+
if (!doesUserHaveAParticipant) {
6561
res.status(403).json({
6662
message: 'Unauthorized. You do not have the necessary permissions.',
6763
errorHash: req.headers.traceId,

src/api/entities/Participant.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ import { ParticipantType, ParticipantTypeDTO, ParticipantTypeSchema } from './Pa
88
import { type User, UserDTO, UserSchema } from './User';
99
import { UserToParticipantRole } from './UserToParticipantRole';
1010

11-
export enum ParticipantStatus {
12-
AwaitingSigning = 'awaitingSigning',
13-
AwaitingApproval = 'awaitingApproval',
14-
Approved = 'approved',
15-
}
16-
1711
export class Participant extends BaseModel {
1812
static get tableName() {
1913
return 'participants';
@@ -82,7 +76,6 @@ export class Participant extends BaseModel {
8276
};
8377
declare id: number;
8478
declare name: string;
85-
declare status: ParticipantStatus;
8679
declare allowSharing: boolean;
8780
declare completedRecommendations: boolean;
8881
declare siteId?: number;
@@ -107,7 +100,6 @@ export type ParticipantDTO = Omit<ModelObjectOpt<Participant>, 'types' | 'users'
107100
export const ParticipantSchema = z.object({
108101
id: z.number(),
109102
name: z.string(),
110-
status: z.nativeEnum(ParticipantStatus),
111103
types: z.array(ParticipantTypeSchema).optional(),
112104
apiRoles: z.array(ApiRoleSchema).optional(),
113105
users: z.array(UserSchema).optional(),

src/api/routers/participants/participants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Response } from 'express';
22

33
import { Participant } from '../../entities/Participant';
44
import {
5+
getAllParticipants,
56
ParticipantRequest,
67
updateParticipant,
78
UserParticipantRequest,
@@ -21,6 +22,12 @@ export const handleGetParticipant = async (req: ParticipantRequest, res: Respons
2122
return res.status(200).json(participant);
2223
};
2324

25+
export const handleGetAllParticipants = async (_req: ParticipantRequest, res: Response) => {
26+
const participants = await getAllParticipants();
27+
const result = participants.sort((a, b) => a.name.localeCompare(b.name));
28+
return res.status(200).json(result);
29+
};
30+
2431
export const handleCompleteRecommendations = async (req: ParticipantRequest, res: Response) => {
2532
const { participant } = req;
2633
const updatedParticipant = await Participant.query()

src/api/routers/participants/participantsApproval.ts

Lines changed: 0 additions & 98 deletions
This file was deleted.

src/api/routers/participants/participantsCreation.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { z } from 'zod';
44
import { getRoleNamesByIds } from '../../../web/utils/apiRoles';
55
import { ApiRole } from '../../entities/ApiRole';
66
import { AuditAction, AuditTrailEvents } from '../../entities/AuditTrail';
7-
import { Participant, ParticipantStatus } from '../../entities/Participant';
7+
import { Participant } from '../../entities/Participant';
88
import { User, UserCreationPartial } from '../../entities/User';
99
import { UserRoleId } from '../../entities/UserRole';
1010
import { UserToParticipantRole } from '../../entities/UserToParticipantRole';
@@ -136,7 +136,6 @@ async function createParticipant(
136136
await performAsyncOperationWithAuditTrail(auditTrailInsertObject, traceId, async () => {
137137
const participantData = {
138138
...parsedParticipantRequest,
139-
status: ParticipantStatus.Approved,
140139
approverId: requestingUser?.id,
141140
dateApproved: new Date(),
142141
};

src/api/routers/participants/participantsKeyPairs.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { http, HttpResponse } from 'msw';
44
import { setupServer } from 'msw/node';
55

66
import { createResponseObject } from '../../../testHelpers/apiTestHelpers';
7-
import { Participant, ParticipantStatus } from '../../entities/Participant';
7+
import { Participant } from '../../entities/Participant';
88
import { SSP_ADMIN_SERVICE_BASE_URL } from '../../envars';
99
import { KeyPairDTO } from '../../services/adminServiceHelpers';
1010
import { ParticipantRequest } from '../../services/participantsService';
@@ -96,7 +96,6 @@ describe('Get participant key pairs', () => {
9696
id: 5,
9797
allowSharing: true,
9898
completedRecommendations: true,
99-
status: ParticipantStatus.Approved,
10099
apiRoles: [],
101100
});
102101

@@ -122,7 +121,6 @@ describe('Get participant key pairs', () => {
122121
id: 5,
123122
allowSharing: true,
124123
completedRecommendations: true,
125-
status: ParticipantStatus.Approved,
126124
apiRoles: [],
127125
siteId,
128126
});

src/api/routers/participants/participantsRouter.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { createBusinessContactsRouter } from '../businessContactsRouter';
77
import { createParticipantUsersRouter } from '../participantUsersRouter';
88
import {
99
handleCompleteRecommendations,
10+
handleGetAllParticipants,
1011
handleGetParticipant,
1112
handleUpdateParticipant,
1213
} from './participants';
@@ -19,11 +20,6 @@ import {
1920
} from './participantsApiKeys';
2021
import { handleGetParticipantApiRoles } from './participantsApiRoles';
2122
import { handleGetParticipantAppNames, handleSetParticipantAppNames } from './participantsAppIds';
22-
import {
23-
handleApproveParticipant,
24-
handleGetApprovedParticipants,
25-
handleGetParticipantsAwaitingApproval,
26-
} from './participantsApproval';
2723
import { handleGetAuditTrail } from './participantsAuditTrail';
2824
import { handleCreateParticipant } from './participantsCreation';
2925
import {
@@ -50,12 +46,7 @@ export function createParticipantsRouter() {
5046

5147
participantsRouter.get('/signed', handleGetSignedParticipants);
5248

53-
participantsRouter.get(
54-
'/awaitingApproval',
55-
isUid2SupportCheck,
56-
handleGetParticipantsAwaitingApproval
57-
);
58-
participantsRouter.get('/approved', isUid2SupportCheck, handleGetApprovedParticipants);
49+
participantsRouter.get('/allParticipants', isUid2SupportCheck, handleGetAllParticipants);
5950

6051
participantsRouter.put('/', handleCreateParticipant);
6152

@@ -65,7 +56,6 @@ export function createParticipantsRouter() {
6556
participantsRouter.get('/:participantId/apiRoles', handleGetParticipantApiRoles);
6657
participantsRouter.put('/:participantId', handleUpdateParticipant);
6758
participantsRouter.put('/:participantId/completeRecommendations', handleCompleteRecommendations);
68-
participantsRouter.put('/:participantId/approve', handleApproveParticipant);
6959

7060
participantsRouter.post(
7161
'/:participantId/invite',

src/api/services/participantsService.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ import { z } from 'zod';
55
import { getRoleNamesByIds } from '../../web/utils/apiRoles';
66
import { ApiRole } from '../entities/ApiRole';
77
import { AuditAction, AuditTrailEvents } from '../entities/AuditTrail';
8-
import {
9-
Participant,
10-
ParticipantApprovalPartial,
11-
ParticipantDTO,
12-
ParticipantStatus,
13-
} from '../entities/Participant';
8+
import { Participant, ParticipantApprovalPartial, ParticipantDTO } from '../entities/Participant';
149
import { ParticipantType } from '../entities/ParticipantType';
1510
import { User, UserDTO } from '../entities/User';
1611
import { SSP_WEB_BASE_URL } from '../envars';
@@ -38,7 +33,7 @@ export interface UserParticipantRequest extends ParticipantRequest {
3833

3934
export type ParticipantRequestDTO = Pick<
4035
ParticipantDTO,
41-
'id' | 'name' | 'siteId' | 'types' | 'status' | 'apiRoles'
36+
'id' | 'name' | 'siteId' | 'types' | 'apiRoles'
4237
> & {
4338
requestingUser: Pick<UserDTO, 'email'> &
4439
Partial<Pick<UserDTO, 'jobFunction'>> & { fullName: string };
@@ -61,7 +56,6 @@ export const mapParticipantToApprovalRequest = (
6156
siteId: participant.siteId,
6257
types: participant.types,
6358
apiRoles: participant.apiRoles,
64-
status: participant.status,
6559
requestingUser: {
6660
email: firstUser ? firstUser.email : '',
6761
jobFunction: firstUser?.jobFunction,
@@ -72,13 +66,6 @@ export const mapParticipantToApprovalRequest = (
7266
};
7367
};
7468

75-
export const getParticipantsAwaitingApproval = async (): Promise<Participant[]> => {
76-
const participantsAwaitingApproval = await Participant.query()
77-
.withGraphFetched('[types, users]')
78-
.where('status', ParticipantStatus.AwaitingApproval);
79-
return participantsAwaitingApproval;
80-
};
81-
8269
type SiteIdType = NonNullable<ParticipantDTO['siteId']>;
8370
export const getAttachedSiteIDs = async (): Promise<SiteIdType[]> => {
8471
const sites = await Participant.query()
@@ -88,10 +75,8 @@ export const getAttachedSiteIDs = async (): Promise<SiteIdType[]> => {
8875
return sites.map((s) => s.siteId);
8976
};
9077

91-
export const getParticipantsApproved = async (): Promise<Participant[]> => {
92-
return Participant.query()
93-
.where('status', ParticipantStatus.Approved)
94-
.withGraphFetched('[apiRoles, approver, types, users]');
78+
export const getAllParticipants = async (): Promise<Participant[]> => {
79+
return Participant.query().withGraphFetched('[apiRoles, approver, types, users]');
9580
};
9681

9782
export const getParticipantsBySiteIds = async (siteIds: number[]) => {
@@ -166,7 +151,6 @@ export const updateParticipantApiRolesWithTransaction = async (
166151
export const updateParticipantAndTypesAndApiRoles = async (
167152
participant: Participant,
168153
participantApprovalPartial: z.infer<typeof ParticipantApprovalPartial> & {
169-
status: ParticipantStatus;
170154
approverId: number | undefined;
171155
dateApproved: Date;
172156
}
@@ -175,7 +159,6 @@ export const updateParticipantAndTypesAndApiRoles = async (
175159
await participant.$query(trx).patch({
176160
name: participantApprovalPartial.name,
177161
siteId: participantApprovalPartial.siteId,
178-
status: participantApprovalPartial.status,
179162
approverId: participantApprovalPartial.approverId,
180163
dateApproved: participantApprovalPartial.dateApproved,
181164
});

0 commit comments

Comments
 (0)