Skip to content

Commit a857020

Browse files
committed
fix(client): restrict task assignee dropdowns to User role only for management flows
1 parent e910364 commit a857020

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

src/app/features/projects/components/project-kanban/project-kanban.component.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,14 @@ export class ProjectKanbanComponent implements OnInit, OnDestroy {
746746
assignableUsers: UserSummaryDto[]
747747
): AssigneeOption[] {
748748
const options = new Map<string, AssigneeOption>();
749+
const canManageAssignments = this.canManageAllTasks;
750+
const assignableUserIds = new Set(assignableUsers.map((user) => user.id));
749751

750752
for (const member of members) {
753+
if (canManageAssignments && !assignableUserIds.has(member.userId)) {
754+
continue;
755+
}
756+
751757
if (!options.has(member.userId)) {
752758
options.set(member.userId, { label: member.displayName, value: member.userId });
753759
}
@@ -1000,7 +1006,7 @@ export class ProjectKanbanComponent implements OnInit, OnDestroy {
10001006
this.assigneeOptions = [
10011007
{ label: 'Unassigned', value: null },
10021008
{ label: 'Debug User', value: 'debug-user' },
1003-
{ label: 'Project Manager', value: 'pm-user' }
1009+
{ label: 'Alex Contributor', value: 'user-2' }
10041010
];
10051011
this.setAllTasks(this.createPreviewTasks(projectId));
10061012
this.pendingTaskIds.clear();
@@ -1036,14 +1042,14 @@ export class ProjectKanbanComponent implements OnInit, OnDestroy {
10361042
dueDate: now,
10371043
projectId,
10381044
projectName: 'Preview Project',
1039-
assignedUserId: 'pm-user',
1040-
assignedUserName: 'Project Manager',
1045+
assignedUserId: 'user-2',
1046+
assignedUserName: 'Alex Contributor',
10411047
createdAt: now,
1042-
createdByUserId: 'pm-user',
1043-
createdByUserName: 'Project Manager',
1048+
createdByUserId: 'debug-user',
1049+
createdByUserName: 'Debug User',
10441050
lastModifiedAt: now,
1045-
lastModifiedByUserId: 'pm-user',
1046-
lastModifiedByUserName: 'Project Manager'
1051+
lastModifiedByUserId: 'debug-user',
1052+
lastModifiedByUserName: 'Debug User'
10471053
},
10481054
{
10491055
id: `${projectId}-done-1`,

src/app/features/task-item/components/task-item-create/task-item-create.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,19 @@ export class TaskItemCreateComponent implements OnInit, OnDestroy {
331331
allUsers: UserSummaryDto[]
332332
): Array<{ label: string; value: string | null }> {
333333
const optionsByUserId = new Map<string, { label: string; value: string | null }>();
334+
const canManageAssignments = this.authService.hasAnyRole([...MANAGEMENT_ROLES]);
335+
const assignableUserIds = new Set(allUsers.map((user) => user.id));
334336
const projectManagerUserIds = new Set(
335337
allUsers
336338
.filter((user) => (user.roles ?? []).includes(AppRole.ProjectManager))
337339
.map((user) => user.id)
338340
);
339341

340342
for (const member of members) {
343+
if (canManageAssignments && !assignableUserIds.has(member.userId)) {
344+
continue;
345+
}
346+
341347
if (projectManagerUserIds.has(member.userId)) {
342348
continue;
343349
}

0 commit comments

Comments
 (0)