-
Notifications
You must be signed in to change notification settings - Fork 402
feat: [UIE-9357] - IAM Delegation: Default Roles table #12990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
26cc544
679bae0
a906373
87db233
4c7b9be
f240d78
116c374
5ace735
cfc7c1e
189e47f
d599b68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,15 +30,26 @@ export const useAccountRoles = (enabled = true) => { | |
| }); | ||
| }; | ||
|
|
||
| export const useUserRolesMutation = (username: string) => { | ||
| export const useUserRolesMutation = ( | ||
| username?: string, | ||
| enabled: boolean = true, | ||
| ) => { | ||
| const queryClient = useQueryClient(); | ||
|
|
||
| return useMutation<IamUserRoles, APIError[], IamUserRoles>({ | ||
| mutationFn: (data) => updateUserRoles(username, data), | ||
| mutationFn: (data) => { | ||
| if (!username) { | ||
| throw new Error('Username is required'); | ||
| } | ||
| return updateUserRoles(username, data); | ||
| }, | ||
| onSuccess: (role) => { | ||
| queryClient.setQueryData<IamUserRoles>( | ||
| iamQueries.user(username)._ctx.roles.queryKey, | ||
| role, | ||
| ); | ||
| if (username && enabled) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abailly-akamai , could you please check if that's what you mean? I haven't found anything similar to this in CM (might've missed something)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works but I would simplify: (sorry the conditional queries/mutations are tricky to handle. usually we tend to render different components but I think this should suffice. Maybe i am overthinking this and export const useUserRolesMutation = (username: string | undefined) => {
const queryClient = useQueryClient();
return useMutation<IamUserRoles, APIError[], IamUserRoles>({
mutationFn: (data) => {
if (!username) {
throw new Error('Username is required');
}
return updateUserRoles(username, data);
},
onSuccess: (role) => {
if (username) {
queryClient.setQueryData<IamUserRoles>(
iamQueries.user(username)._ctx.roles.queryKey,
role,
);
}
},
});
};
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated, thanks! |
||
| queryClient.setQueryData<IamUserRoles>( | ||
| iamQueries.user(username)._ctx.roles.queryKey, | ||
| role, | ||
| ); | ||
| } | ||
| }, | ||
| }); | ||
| }; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.