From 700c5409bf7cbb6d25d919b86593b35229583a63 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 16 Oct 2024 13:00:08 +0530 Subject: [PATCH] feat: resolved additional privilege not taking priority and dummy column miscalculation --- .../services/permission/permission-service.ts | 4 +- .../secret-v2-bridge-service.ts | 2 +- .../views/SecretMainPage/SecretMainPage.tsx | 27 ++++----- .../SecretListView/SecretNoAccessListView.tsx | 57 ++++++++++--------- .../SecretNoAccessOverviewTableRow.tsx | 18 ++++-- 5 files changed, 60 insertions(+), 48 deletions(-) diff --git a/backend/src/ee/services/permission/permission-service.ts b/backend/src/ee/services/permission/permission-service.ts index ea0289ab0..ccd896775 100644 --- a/backend/src/ee/services/permission/permission-service.ts +++ b/backend/src/ee/services/permission/permission-service.ts @@ -67,7 +67,7 @@ export const permissionServiceFactory = ({ throw new NotFoundError({ name: "OrgRoleInvalid", message: "Organization role not found" }); } }) - .reduce((curr, prev) => prev.concat(curr), []); + .reduce((prev, curr) => prev.concat(curr), []); return createMongoAbility(rules, { conditionsMatcher @@ -98,7 +98,7 @@ export const permissionServiceFactory = ({ }); } }) - .reduce((curr, prev) => prev.concat(curr), []); + .reduce((prev, curr) => prev.concat(curr), []); return rules; }; diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts index 5d715bbc0..380bbec1f 100644 --- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts +++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts @@ -394,7 +394,7 @@ export const secretV2BridgeServiceFactory = ({ subject(ProjectPermissionSub.Secrets, { environment, secretPath, - secretName: inputSecret.secretName, + secretName: inputSecret.newSecretName, secretTags: tags?.map((el) => el.slug) }) ); diff --git a/frontend/src/views/SecretMainPage/SecretMainPage.tsx b/frontend/src/views/SecretMainPage/SecretMainPage.tsx index 6c51584dc..7e34da254 100644 --- a/frontend/src/views/SecretMainPage/SecretMainPage.tsx +++ b/frontend/src/views/SecretMainPage/SecretMainPage.tsx @@ -210,8 +210,20 @@ export const SecretMainPage = () => { isPaused: !canDoReadRollback }); + const noAccessSecretCount = Math.max( + (page * perPage > totalCount ? totalCount % perPage : perPage) - + (imports?.length || 0) - + (folders?.length || 0) - + (secrets?.length || 0) - + (dynamicSecrets?.length || 0), + 0 + ); const isNotEmpty = Boolean( - secrets?.length || folders?.length || imports?.length || dynamicSecrets?.length + secrets?.length || + folders?.length || + imports?.length || + dynamicSecrets?.length || + noAccessSecretCount ); const handleSortToggle = () => @@ -405,18 +417,7 @@ export const SecretMainPage = () => { isProtectedBranch={isProtectedBranch} /> )} - {canReadSecret && ( - totalCount ? totalCount % perPage : perPage) - - (imports?.length || 0) - - (folders?.length || 0) - - (secrets?.length || 0) - - (dynamicSecrets?.length || 0), - 0 - )} - /> - )} + {canReadSecret && } {!canReadSecret && !canReadDynamicSecret && !canReadSecretImports && diff --git a/frontend/src/views/SecretMainPage/components/SecretListView/SecretNoAccessListView.tsx b/frontend/src/views/SecretMainPage/components/SecretListView/SecretNoAccessListView.tsx index 371b94bbe..a2353d778 100644 --- a/frontend/src/views/SecretMainPage/components/SecretListView/SecretNoAccessListView.tsx +++ b/frontend/src/views/SecretMainPage/components/SecretListView/SecretNoAccessListView.tsx @@ -1,4 +1,4 @@ -import { FontAwesomeSymbol, Input } from "@app/components/v2"; +import { FontAwesomeSymbol, Input, Tooltip } from "@app/components/v2"; import { FontAwesomeSpriteName } from "./SecretListView.utils"; @@ -10,34 +10,39 @@ export const SecretNoAccessListView = ({ count }: Props) => { return ( <> {Array.from(Array(count)).map((_, i) => ( -
-
- +
+
+ +
+ +
+ +
+
+ ******** +
-
- -
-
- ******** -
-
+ ))} ); diff --git a/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretNoAccessOverviewTableRow.tsx b/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretNoAccessOverviewTableRow.tsx index ef4ee2ce7..459c25ddc 100644 --- a/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretNoAccessOverviewTableRow.tsx +++ b/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretNoAccessOverviewTableRow.tsx @@ -2,7 +2,7 @@ import { faCircle } from "@fortawesome/free-regular-svg-icons"; import { faLock } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { Td, Tr } from "@app/components/v2"; +import { Td, Tooltip, Tr } from "@app/components/v2"; type Props = { environments: { name: string; slug: string }[]; @@ -16,12 +16,18 @@ export const SecretNoAccessOverviewTableRow = ({ environments = [], count }: Pro
-
-
- + +
+
+ +
+
NO ACCESS
-
NO ACCESS
-
+
{environments.map(({ slug }, i) => {