From e9e777bd04e35860cb2df85ec104dca795246c23 Mon Sep 17 00:00:00 2001 From: Celiant Date: Thu, 26 Mar 2026 23:51:12 +0400 Subject: [PATCH 1/7] feat: 4438 Add Worker Tasks to the permission modal --- api-gateway/src/api/service/worker-tasks.ts | 7 ++-- frontend/src/app/app-routing.module.ts | 16 +++++++- .../src/app/utils/permissions-interface.ts | 6 ++- .../new-header/new-header.component.html | 1 + .../worker-tasks/worker-tasks.component.html | 2 + .../worker-tasks/worker-tasks.component.ts | 22 ++++++---- interfaces/src/helpers/permissions-helper.ts | 13 ++++++ interfaces/src/type/permissions.type.ts | 40 ++++++++++++++++++- swagger.yaml | 8 ++++ 9 files changed, 100 insertions(+), 15 deletions(-) diff --git a/api-gateway/src/api/service/worker-tasks.ts b/api-gateway/src/api/service/worker-tasks.ts index 059016ada5..e9f2a745b8 100644 --- a/api-gateway/src/api/service/worker-tasks.ts +++ b/api-gateway/src/api/service/worker-tasks.ts @@ -3,6 +3,7 @@ import { ApiExtraModels, ApiInternalServerErrorResponse, ApiOkResponse, ApiOpera import { Auth, AuthUser } from '#auth'; import { Examples, InternalServerErrorDTO, pageHeader, WorkersTasksDTO } from '#middlewares'; import { IAuthUser } from '@guardian/common'; +import { Permissions } from '@guardian/interfaces'; import { Guardians, parseInteger } from '#helpers'; @Controller('worker-tasks') @@ -12,7 +13,7 @@ export class WorkerTasksController { * Get all notifications */ @Get('/') - @Auth() + @Auth(Permissions.WORKER_TASKS_READ) @ApiOperation({ summary: 'Get all worker tasks', description: 'Returns all worker tasks.', @@ -62,7 +63,7 @@ export class WorkerTasksController { res.header('X-Total-Count', count).send(tasks); } - @Auth() + @Auth(Permissions.WORKER_TASKS_EXECUTE) @ApiOperation({ summary: 'Restart task', description: 'Restart task' @@ -85,7 +86,7 @@ export class WorkerTasksController { await guardians.restartTask(body.taskId, user.id.toString()); } - @Auth() + @Auth(Permissions.WORKER_TASKS_DELETE) @ApiOperation({ summary: 'Delete task', description: 'Delete task' diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index d2af850598..62d4a8f143 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -132,8 +132,20 @@ const routes: Routes = [ { path: 'register', component: RegisterComponent }, { path: 'task/:id', component: AsyncProgressComponent }, { path: 'notifications', component: NotificationsComponent }, - { path: 'worker-tasks', component: WorkerTasksComponent }, - + { + path: 'worker-tasks', + component: WorkerTasksComponent, + canActivate: [PermissionsGuard], + data: { + roles: [ + UserRole.STANDARD_REGISTRY, + UserRole.USER + ], + permissions: [ + Permissions.WORKER_TASKS_READ + ] + } + }, { path: 'user-profile', component: UserProfileComponent, diff --git a/frontend/src/app/utils/permissions-interface.ts b/frontend/src/app/utils/permissions-interface.ts index 035b890650..04dab7f3e3 100644 --- a/frontend/src/app/utils/permissions-interface.ts +++ b/frontend/src/app/utils/permissions-interface.ts @@ -125,7 +125,8 @@ export const entityNames = new Map([ [PermissionEntities.ROLE, 'Role'], [PermissionEntities.STATISTIC, 'Statistic'], [PermissionEntities.LABEL, 'Label'], - [PermissionEntities.FORMULA, 'Formula'] + [PermissionEntities.FORMULA, 'Formula'], + [PermissionEntities.WORKER_TASK, 'Worker Task'] ]) export const actionIndexes = new Map([ @@ -171,7 +172,8 @@ export const categoryNames = new Map([ [PermissionCategories.PERMISSIONS, 'Permissions'], [PermissionCategories.STATISTICS, 'Policy Statistics'], [PermissionCategories.FORMULAS, 'Formulas'], - [PermissionCategories.ACCESS, 'Access'] + [PermissionCategories.ACCESS, 'Access'], + [PermissionCategories.WORKER_TASKS, 'Worker Tasks'], ]) export const actionName = [ diff --git a/frontend/src/app/views/new-header/new-header.component.html b/frontend/src/app/views/new-header/new-header.component.html index 566d79dc67..b19bcc42d1 100644 --- a/frontend/src/app/views/new-header/new-header.component.html +++ b/frontend/src/app/views/new-header/new-header.component.html @@ -92,6 +92,7 @@
Worker Tasks