From 144904f0f63b13af55309a1c4b7f5af8d8174c85 Mon Sep 17 00:00:00 2001
From: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com>
Date: Fri, 5 Apr 2024 22:44:29 +0530
Subject: [PATCH] fix ux for keys permissions (#3280)
---
.../src/common/SecureComponent/permissions.ts | 4 +-
web-app/src/screens/Console/KMS/ListKeys.tsx | 84 +++++++++++--------
2 files changed, 50 insertions(+), 38 deletions(-)
diff --git a/web-app/src/common/SecureComponent/permissions.ts b/web-app/src/common/SecureComponent/permissions.ts
index 7094a1ed4..3ce03a638 100644
--- a/web-app/src/common/SecureComponent/permissions.ts
+++ b/web-app/src/common/SecureComponent/permissions.ts
@@ -444,11 +444,11 @@ export const IAM_PAGES_PERMISSIONS = {
IAM_SCOPES.KMS_KEY_STATUS,
],
[IAM_PAGES.KMS_KEYS_ADD]: [
- IAM_SCOPES.KMS_ALL_ACTIONS,
+ IAM_SCOPES.KMS_LIST_KEYS,
IAM_SCOPES.KMS_CREATE_KEY,
],
[IAM_PAGES.KMS_KEYS_IMPORT]: [
- IAM_SCOPES.KMS_ALL_ACTIONS,
+ IAM_SCOPES.KMS_LIST_KEYS,
IAM_SCOPES.KMS_IMPORT_KEY,
],
[IAM_PAGES.IDP_LDAP_CONFIGURATIONS]: [
diff --git a/web-app/src/screens/Console/KMS/ListKeys.tsx b/web-app/src/screens/Console/KMS/ListKeys.tsx
index 229017112..ddec0915e 100644
--- a/web-app/src/screens/Console/KMS/ListKeys.tsx
+++ b/web-app/src/screens/Console/KMS/ListKeys.tsx
@@ -61,6 +61,13 @@ const ListKeys = () => {
const deleteKey = hasPermission(CONSOLE_UI_RESOURCE, [
IAM_SCOPES.KMS_DELETE_KEY,
]);
+ const createKey = hasPermission(CONSOLE_UI_RESOURCE, [
+ IAM_SCOPES.KMS_CREATE_KEY,
+ ]);
+
+ const importKey = hasPermission(CONSOLE_UI_RESOURCE, [
+ IAM_SCOPES.KMS_IMPORT_KEY,
+ ]);
const displayKeys = hasPermission(CONSOLE_UI_RESOURCE, [
IAM_SCOPES.KMS_LIST_KEYS,
@@ -111,14 +118,15 @@ const ListKeys = () => {
}
};
- const tableActions = [
- {
+ const tableActions: any[] = [];
+ if (deleteKey) {
+ tableActions.push({
type: "delete",
onClick: confirmDeleteKey,
sendOnlyId: true,
disableButtonFunction: () => !deleteKey,
- },
- ];
+ });
+ }
useEffect(() => {
dispatch(setHelpName("list_keys"));
@@ -178,39 +186,43 @@ const ListKeys = () => {
/>
-
-
- }
- onClick={() => {
- navigate(IAM_PAGES.KMS_KEYS_IMPORT);
- }}
- />
-
-
-
-
- }
- onClick={() => navigate(IAM_PAGES.KMS_KEYS_ADD)}
- />
-
-
+ {importKey ? (
+
+
+ }
+ onClick={() => {
+ navigate(IAM_PAGES.KMS_KEYS_IMPORT);
+ }}
+ />
+
+
+ ) : null}
+ {createKey ? (
+
+
+ }
+ onClick={() => navigate(IAM_PAGES.KMS_KEYS_ADD)}
+ />
+
+
+ ) : null}
-
+