Skip to content

Commit

Permalink
Add on Error toast when failing to retrieve the role description
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWatenbergScality committed Sep 25, 2024
1 parent 09c6135 commit c49413e
Show file tree
Hide file tree
Showing 2 changed files with 263 additions and 187 deletions.
18 changes: 17 additions & 1 deletion src/react/ui-elements/SelectAccountIAMRole.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Form, FormGroup, FormSection, Stack } from '@scality/core-ui';
import {
Form,
FormGroup,
FormSection,
Stack,
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';
Expand Down Expand Up @@ -175,11 +181,21 @@ const SelectAccountIAMRoleWithAccount = (
const [account, setAccount] = useState<Account | null>(defaultAccount);
const [role, setRole] = useState<IAM.Role | null>(null);
const assumedRole = useAssumedRole();
const { showToast } = useToast();

const getIAMRoleMutation = useMutation({
mutationFn: (roleName: string) => {
return IAMClient.getRole(roleName);
},
onError: () => {
showToast({
status: 'error',
open: true,
autoDismiss: false,
message:
"An error occured on our side while fetching the role's policy.",
});
},
});

const accountName = account ? account.name : '';
Expand Down
Loading

0 comments on commit c49413e

Please sign in to comment.