Skip to content

Commit 144904f

Browse files
authored
fix ux for keys permissions (#3280)
1 parent 963c8f1 commit 144904f

File tree

2 files changed

+50
-38
lines changed

2 files changed

+50
-38
lines changed

web-app/src/common/SecureComponent/permissions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,11 @@ export const IAM_PAGES_PERMISSIONS = {
444444
IAM_SCOPES.KMS_KEY_STATUS,
445445
],
446446
[IAM_PAGES.KMS_KEYS_ADD]: [
447-
IAM_SCOPES.KMS_ALL_ACTIONS,
447+
IAM_SCOPES.KMS_LIST_KEYS,
448448
IAM_SCOPES.KMS_CREATE_KEY,
449449
],
450450
[IAM_PAGES.KMS_KEYS_IMPORT]: [
451-
IAM_SCOPES.KMS_ALL_ACTIONS,
451+
IAM_SCOPES.KMS_LIST_KEYS,
452452
IAM_SCOPES.KMS_IMPORT_KEY,
453453
],
454454
[IAM_PAGES.IDP_LDAP_CONFIGURATIONS]: [

web-app/src/screens/Console/KMS/ListKeys.tsx

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ const ListKeys = () => {
6161
const deleteKey = hasPermission(CONSOLE_UI_RESOURCE, [
6262
IAM_SCOPES.KMS_DELETE_KEY,
6363
]);
64+
const createKey = hasPermission(CONSOLE_UI_RESOURCE, [
65+
IAM_SCOPES.KMS_CREATE_KEY,
66+
]);
67+
68+
const importKey = hasPermission(CONSOLE_UI_RESOURCE, [
69+
IAM_SCOPES.KMS_IMPORT_KEY,
70+
]);
6471

6572
const displayKeys = hasPermission(CONSOLE_UI_RESOURCE, [
6673
IAM_SCOPES.KMS_LIST_KEYS,
@@ -111,14 +118,15 @@ const ListKeys = () => {
111118
}
112119
};
113120

114-
const tableActions = [
115-
{
121+
const tableActions: any[] = [];
122+
if (deleteKey) {
123+
tableActions.push({
116124
type: "delete",
117125
onClick: confirmDeleteKey,
118126
sendOnlyId: true,
119127
disableButtonFunction: () => !deleteKey,
120-
},
121-
];
128+
});
129+
}
122130

123131
useEffect(() => {
124132
dispatch(setHelpName("list_keys"));
@@ -178,39 +186,43 @@ const ListKeys = () => {
178186
/>
179187
</TooltipWrapper>
180188
</SecureComponent>
181-
<SecureComponent
182-
scopes={[IAM_SCOPES.KMS_IMPORT_KEY]}
183-
resource={CONSOLE_UI_RESOURCE}
184-
errorProps={{ disabled: true }}
185-
>
186-
<TooltipWrapper tooltip={"Import Key"}>
187-
<Button
188-
id={"import-key"}
189-
variant={"regular"}
190-
icon={<UploadIcon />}
191-
onClick={() => {
192-
navigate(IAM_PAGES.KMS_KEYS_IMPORT);
193-
}}
194-
/>
195-
</TooltipWrapper>
196-
</SecureComponent>
197-
<SecureComponent
198-
scopes={[IAM_SCOPES.KMS_CREATE_KEY]}
199-
resource={CONSOLE_UI_RESOURCE}
200-
errorProps={{ disabled: true }}
201-
>
202-
<TooltipWrapper tooltip={"Create Key"}>
203-
<Button
204-
id={"create-key"}
205-
label={"Create Key"}
206-
variant={"callAction"}
207-
icon={<AddIcon />}
208-
onClick={() => navigate(IAM_PAGES.KMS_KEYS_ADD)}
209-
/>
210-
</TooltipWrapper>
211-
</SecureComponent>
189+
{importKey ? (
190+
<SecureComponent
191+
scopes={[IAM_SCOPES.KMS_IMPORT_KEY]}
192+
resource={CONSOLE_UI_RESOURCE}
193+
errorProps={{ disabled: true }}
194+
>
195+
<TooltipWrapper tooltip={"Import Key"}>
196+
<Button
197+
id={"import-key"}
198+
variant={"regular"}
199+
icon={<UploadIcon />}
200+
onClick={() => {
201+
navigate(IAM_PAGES.KMS_KEYS_IMPORT);
202+
}}
203+
/>
204+
</TooltipWrapper>
205+
</SecureComponent>
206+
) : null}
207+
{createKey ? (
208+
<SecureComponent
209+
scopes={[IAM_SCOPES.KMS_CREATE_KEY]}
210+
resource={CONSOLE_UI_RESOURCE}
211+
errorProps={{ disabled: true }}
212+
>
213+
<TooltipWrapper tooltip={"Create Key"}>
214+
<Button
215+
id={"create-key"}
216+
label={"Create Key"}
217+
variant={"callAction"}
218+
icon={<AddIcon />}
219+
onClick={() => navigate(IAM_PAGES.KMS_KEYS_ADD)}
220+
/>
221+
</TooltipWrapper>
222+
</SecureComponent>
223+
) : null}
212224
</Grid>
213-
<Grid item xs={12}>
225+
<Grid item xs={12} sx={{ marginTop: "5px" }}>
214226
<SecureComponent
215227
scopes={[IAM_SCOPES.KMS_LIST_KEYS]}
216228
resource={CONSOLE_UI_RESOURCE}

0 commit comments

Comments
 (0)