fix ux for keys permissions (#3280)

This commit is contained in:
Prakash Senthil Vel
2024-04-05 22:44:29 +05:30
committed by GitHub
parent 963c8f1221
commit 144904f0f6
2 changed files with 50 additions and 38 deletions

View File

@@ -444,11 +444,11 @@ export const IAM_PAGES_PERMISSIONS = {
IAM_SCOPES.KMS_KEY_STATUS, IAM_SCOPES.KMS_KEY_STATUS,
], ],
[IAM_PAGES.KMS_KEYS_ADD]: [ [IAM_PAGES.KMS_KEYS_ADD]: [
IAM_SCOPES.KMS_ALL_ACTIONS, IAM_SCOPES.KMS_LIST_KEYS,
IAM_SCOPES.KMS_CREATE_KEY, IAM_SCOPES.KMS_CREATE_KEY,
], ],
[IAM_PAGES.KMS_KEYS_IMPORT]: [ [IAM_PAGES.KMS_KEYS_IMPORT]: [
IAM_SCOPES.KMS_ALL_ACTIONS, IAM_SCOPES.KMS_LIST_KEYS,
IAM_SCOPES.KMS_IMPORT_KEY, IAM_SCOPES.KMS_IMPORT_KEY,
], ],
[IAM_PAGES.IDP_LDAP_CONFIGURATIONS]: [ [IAM_PAGES.IDP_LDAP_CONFIGURATIONS]: [

View File

@@ -61,6 +61,13 @@ const ListKeys = () => {
const deleteKey = hasPermission(CONSOLE_UI_RESOURCE, [ const deleteKey = hasPermission(CONSOLE_UI_RESOURCE, [
IAM_SCOPES.KMS_DELETE_KEY, 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, [ const displayKeys = hasPermission(CONSOLE_UI_RESOURCE, [
IAM_SCOPES.KMS_LIST_KEYS, IAM_SCOPES.KMS_LIST_KEYS,
@@ -111,14 +118,15 @@ const ListKeys = () => {
} }
}; };
const tableActions = [ const tableActions: any[] = [];
{ if (deleteKey) {
tableActions.push({
type: "delete", type: "delete",
onClick: confirmDeleteKey, onClick: confirmDeleteKey,
sendOnlyId: true, sendOnlyId: true,
disableButtonFunction: () => !deleteKey, disableButtonFunction: () => !deleteKey,
}, });
]; }
useEffect(() => { useEffect(() => {
dispatch(setHelpName("list_keys")); dispatch(setHelpName("list_keys"));
@@ -178,39 +186,43 @@ const ListKeys = () => {
/> />
</TooltipWrapper> </TooltipWrapper>
</SecureComponent> </SecureComponent>
<SecureComponent {importKey ? (
scopes={[IAM_SCOPES.KMS_IMPORT_KEY]} <SecureComponent
resource={CONSOLE_UI_RESOURCE} scopes={[IAM_SCOPES.KMS_IMPORT_KEY]}
errorProps={{ disabled: true }} resource={CONSOLE_UI_RESOURCE}
> errorProps={{ disabled: true }}
<TooltipWrapper tooltip={"Import Key"}> >
<Button <TooltipWrapper tooltip={"Import Key"}>
id={"import-key"} <Button
variant={"regular"} id={"import-key"}
icon={<UploadIcon />} variant={"regular"}
onClick={() => { icon={<UploadIcon />}
navigate(IAM_PAGES.KMS_KEYS_IMPORT); onClick={() => {
}} navigate(IAM_PAGES.KMS_KEYS_IMPORT);
/> }}
</TooltipWrapper> />
</SecureComponent> </TooltipWrapper>
<SecureComponent </SecureComponent>
scopes={[IAM_SCOPES.KMS_CREATE_KEY]} ) : null}
resource={CONSOLE_UI_RESOURCE} {createKey ? (
errorProps={{ disabled: true }} <SecureComponent
> scopes={[IAM_SCOPES.KMS_CREATE_KEY]}
<TooltipWrapper tooltip={"Create Key"}> resource={CONSOLE_UI_RESOURCE}
<Button errorProps={{ disabled: true }}
id={"create-key"} >
label={"Create Key"} <TooltipWrapper tooltip={"Create Key"}>
variant={"callAction"} <Button
icon={<AddIcon />} id={"create-key"}
onClick={() => navigate(IAM_PAGES.KMS_KEYS_ADD)} label={"Create Key"}
/> variant={"callAction"}
</TooltipWrapper> icon={<AddIcon />}
</SecureComponent> onClick={() => navigate(IAM_PAGES.KMS_KEYS_ADD)}
/>
</TooltipWrapper>
</SecureComponent>
) : null}
</Grid> </Grid>
<Grid item xs={12}> <Grid item xs={12} sx={{ marginTop: "5px" }}>
<SecureComponent <SecureComponent
scopes={[IAM_SCOPES.KMS_LIST_KEYS]} scopes={[IAM_SCOPES.KMS_LIST_KEYS]}
resource={CONSOLE_UI_RESOURCE} resource={CONSOLE_UI_RESOURCE}