From 3ac125f9c787534db1b9cbe04a42bed64100a09b Mon Sep 17 00:00:00 2001 From: = Date: Fri, 27 Sep 2024 20:59:33 +0530 Subject: [PATCH] feat: fixed test, resolved another edgecase in dashboard and added label to conditions in secrets --- backend/e2e-test/routes/v3/secrets.spec.ts | 2 + .../ee/services/permission/permission-dal.ts | 2 +- .../src/server/routes/v1/dashboard-router.ts | 4 +- .../components/GeneralPermissionOptions.tsx | 1 + .../components/SecretPermissionConditions.tsx | 167 ++++++++++-------- .../SecretOverviewPage/SecretOverviewPage.tsx | 1 + 6 files changed, 96 insertions(+), 81 deletions(-) diff --git a/backend/e2e-test/routes/v3/secrets.spec.ts b/backend/e2e-test/routes/v3/secrets.spec.ts index c035692ed..3a4bf255a 100644 --- a/backend/e2e-test/routes/v3/secrets.spec.ts +++ b/backend/e2e-test/routes/v3/secrets.spec.ts @@ -812,6 +812,8 @@ describe.each([{ auth: AuthMode.JWT }, { auth: AuthMode.IDENTITY_ACCESS_TOKEN }] }, body: createSecretReqBody }); + console.log(">>>>>>>>>>"); + console.log(createSecRes.payload); expect(createSecRes.statusCode).toBe(200); const createdSecretPayload = JSON.parse(createSecRes.payload); expect(createdSecretPayload).toHaveProperty("secret"); diff --git a/backend/src/ee/services/permission/permission-dal.ts b/backend/src/ee/services/permission/permission-dal.ts index 0a7abf704..8ad58f528 100644 --- a/backend/src/ee/services/permission/permission-dal.ts +++ b/backend/src/ee/services/permission/permission-dal.ts @@ -441,7 +441,7 @@ export const permissionDALFactory = (db: TDbClient) => { .on(`${TableName.Identity}.id`, `${TableName.IdentityMetadata}.identityId`) .andOn(`${TableName.Project}.orgId`, `${TableName.IdentityMetadata}.orgId`); }) - .where("identityId", identityId) + .where(`${TableName.IdentityProjectMembership}.identityId`, identityId) .where(`${TableName.IdentityProjectMembership}.projectId`, projectId) .select(selectAllTableCols(TableName.IdentityProjectMembershipRole)) .select( diff --git a/backend/src/server/routes/v1/dashboard-router.ts b/backend/src/server/routes/v1/dashboard-router.ts index 303c58621..f8e02365a 100644 --- a/backend/src/server/routes/v1/dashboard-router.ts +++ b/backend/src/server/routes/v1/dashboard-router.ts @@ -200,7 +200,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => { ) ); - if (includeDynamicSecrets) { + if (includeDynamicSecrets && permissiveEnvs.length) { // this is the unique count, ie duplicate secrets across envs only count as 1 totalDynamicSecretCount = await server.services.dynamicSecret.getCountMultiEnv({ actor: req.permission.type, @@ -241,7 +241,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => { } } - if (includeSecrets) { + if (includeSecrets && permissiveEnvs.length) { // this is the unique count, ie duplicate secrets across envs only count as 1 totalSecretCount = await server.services.secret.getSecretsCountMultiEnv({ actorId: req.permission.id, diff --git a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/GeneralPermissionOptions.tsx b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/GeneralPermissionOptions.tsx index be3404dfe..5e9220458 100644 --- a/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/GeneralPermissionOptions.tsx +++ b/frontend/src/views/Project/RolePage/components/RolePermissionsSection/components/GeneralPermissionOptions.tsx @@ -93,6 +93,7 @@ export const GeneralPermissionOptions = (
{ + if (type === "environment") return "Environment slug"; + if (type === "secretPath") return "Folder path"; + return ""; +}; + export const SecretPermissionConditions = ({ position = 0, isDisabled }: Props) => { - const { control } = useFormContext(); + const { control, watch } = useFormContext(); const items = useFieldArray({ control, name: `permissions.secrets.${position}.conditions` @@ -22,86 +28,91 @@ export const SecretPermissionConditions = ({ position = 0, isDisabled }: Props) return (
- {items.fields.map((el, index) => ( -
-
- ( - - - - )} - /> -
-
- ( - - field.onChange(e)} + className="w-full" + > + Environment + Secret Path + + + )} + /> +
+
+ ( + - Equal - Not Equal - Glob Match - Contains - - - )} - /> + + + )} + /> +
+
+ ( + + + + )} + /> +
+
+ items.remove(index)} + > + + +
-
- ( - - - - )} - /> -
-
- items.remove(index)} - > - - -
-
- ))} + ); + })}