From c0fc74b62a9bad6d13e90bb465defe0f9d48a8ce Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Mon, 30 Jan 2023 19:22:38 -0800 Subject: [PATCH] Add write permission status --- backend/src/controllers/v2/environmentController.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/src/controllers/v2/environmentController.ts b/backend/src/controllers/v2/environmentController.ts index d92ec8264..4cc702eec 100644 --- a/backend/src/controllers/v2/environmentController.ts +++ b/backend/src/controllers/v2/environmentController.ts @@ -11,7 +11,7 @@ import { import { SecretVersion } from '../../ee/models'; import { BadRequestError } from '../../utils/errors'; import _ from 'lodash'; -import { ABILITY_READ } from '../../variables/organization'; +import { ABILITY_READ, ABILITY_WRITE } from '../../variables/organization'; /** * Create new workspace environment named [environmentName] under workspace with id @@ -236,7 +236,7 @@ export const getAllAccessibleEnvironmentsOfWorkspace = async ( throw BadRequestError() } - const accessibleEnvironments: { name: string; slug: string; }[] = [] + const accessibleEnvironments: any = [] const deniedPermission = workspacesUserIsMemberOf.deniedPermissions const relatedWorkspace = await Workspace.findById(workspaceId) @@ -245,11 +245,15 @@ export const getAllAccessibleEnvironmentsOfWorkspace = async ( } relatedWorkspace.environments.forEach(environment => { const isReadBlocked = _.some(deniedPermission, { environmentSlug: environment.slug, ability: ABILITY_READ }) - // const isWriteBlocked = _.some(deniedPermission, { environmentSlug: environment.slug, ability: ABILITY_WRITE }) + const isWriteBlocked = _.some(deniedPermission, { environmentSlug: environment.slug, ability: ABILITY_WRITE }) if (isReadBlocked) { return } else { - accessibleEnvironments.push(environment) + accessibleEnvironments.push({ + environment: environment, + // readDenied: isReadBlocked, + isWriteDenied: isWriteBlocked + }) } })