From 9a2ff164731ca7795e25a69650184574571eddf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Dombya?= <135591453+hervedombya@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:05:46 +0200 Subject: [PATCH] ARTESCA-13607 // filter out iam storage manager role Refactor SelectAccountIAMRole component and utils/hooks.ts --- src/react/ui-elements/SelectAccountIAMRole.tsx | 12 +++--------- src/react/utils/hooks.ts | 5 +++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/react/ui-elements/SelectAccountIAMRole.tsx b/src/react/ui-elements/SelectAccountIAMRole.tsx index 1a1a88ec2..5a636818c 100644 --- a/src/react/ui-elements/SelectAccountIAMRole.tsx +++ b/src/react/ui-elements/SelectAccountIAMRole.tsx @@ -1,10 +1,4 @@ -import { - Form, - FormGroup, - FormSection, - Stack, - useToast, -} from '@scality/core-ui'; +import { Form, FormGroup, FormSection, useToast } from '@scality/core-ui'; import { Select } from '@scality/core-ui/dist/next'; import { IAM } from 'aws-sdk'; import { Bucket } from 'aws-sdk/clients/s3'; @@ -26,7 +20,7 @@ import { } from '../next-architecture/ui/AccessibleAccountsAdapterProvider'; import { AccountsLocationsEndpointsAdapterProvider } from '../next-architecture/ui/AccountsLocationsEndpointsAdapterProvider'; import { getListRolesQuery } from '../queries'; -import { SCALITY_INTERNAL_ROLES, regexArn } from '../utils/hooks'; +import { SCALITY_IAM_ROLES, regexArn } from '../utils/hooks'; class NoOpMetricsAdapter implements IMetricsAdapter { async listBucketsLatestUsedCapacity( @@ -234,7 +228,7 @@ const SelectAccountIAMRoleWithAccount = ( const roles = props.filterOutInternalRoles ? allRolesExceptHiddenOnes.filter((role) => { return ( - SCALITY_INTERNAL_ROLES.includes(role.RoleName) || + SCALITY_IAM_ROLES.includes(role.RoleName) || !role.Arn.includes('role/scality-internal') ); }) diff --git a/src/react/utils/hooks.ts b/src/react/utils/hooks.ts index 588caed7a..7b9388187 100644 --- a/src/react/utils/hooks.ts +++ b/src/react/utils/hooks.ts @@ -161,6 +161,11 @@ export const SCALITY_INTERNAL_ROLES = [ DATA_CONSUMER_ROLE, DATA_ACCESSOR_ROLE, ]; +export const SCALITY_IAM_ROLES = [ + STORAGE_ACCOUNT_OWNER_ROLE, + DATA_CONSUMER_ROLE, + DATA_ACCESSOR_ROLE, +]; const reduxBasedEventDispatcher = () => { const dispatch = useDispatch();