From 2f9b35b2f9347a8f0406de57b1a9782da7fe0d3b Mon Sep 17 00:00:00 2001 From: Akhil Mohan Date: Fri, 8 Sep 2023 20:43:37 +0530 Subject: [PATCH] feat(rbac): resolved submit button getting disabled --- .../src/views/DashboardPage/DashboardPage.tsx | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/frontend/src/views/DashboardPage/DashboardPage.tsx b/frontend/src/views/DashboardPage/DashboardPage.tsx index 5935d088f..81cbedf03 100644 --- a/frontend/src/views/DashboardPage/DashboardPage.tsx +++ b/frontend/src/views/DashboardPage/DashboardPage.tsx @@ -337,10 +337,21 @@ export const DashboardPage = () => { permission.cannot( ProjectPermissionActions.Create, subject(ProjectPermissionSub.Secrets, { environment, secretPath }) + ) && + permission.cannot( + ProjectPermissionActions.Delete, + subject(ProjectPermissionSub.Secrets, { environment, secretPath }) ); const canDoRollback = !isReadOnly; - const isSubmitDisabled = isReadOnly || (!isRollbackMode && !isDirty) || isSubmitting; + const isSubmitDisabled = + isReadOnly || + // not in rollback mode and no form has changed + (!isRollbackMode && !isDirty) || + // in rollback mode and don't have permission to do it + (isRollbackMode && + permission.cannot(ProjectPermissionActions.Create, ProjectPermissionSub.SecretRollback)) || + isSubmitting; useEffect(() => { if (!isSnapshotChanging && Boolean(snapshotId)) { @@ -455,7 +466,6 @@ export const DashboardPage = () => { await onSecretRollback(); return; } - console.log(userSec); // just closing this if save is triggered from drawer handlePopUpClose("secretDetails"); // encrypt and format the secrets to batch api format @@ -471,7 +481,6 @@ export const DashboardPage = () => { reset(); return; } - console.log(batchedSecret); try { await batchSecretOp({ requests: batchedSecret, @@ -990,35 +999,25 @@ export const DashboardPage = () => { Go back )} - - {(isAllowed) => ( - - )} - + +