Skip to content

Commit

Permalink
'Refresh' button functionality (Netgroups)
Browse files Browse the repository at this point in the history
The 'Refresh' button should refetch the
data related to the netgroups of a given
user. The solution has been implemented
taking the `refetch` functionality.

Signed-off-by: Carla Martinez <[email protected]>
  • Loading branch information
carma12 committed Apr 3, 2024
1 parent f9edf8e commit d042c4d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/MemberOf/MemberOfNetgroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ const memberOfNetgroups = (props: MemberOfNetroupsProps) => {
}
}, [netgroupsFullList]);

React.useEffect(() => {
netgroupsQuery.refetch();
}, [props.user]);

// Other states
const [netgroupsSelected, setNetgroupsSelected] = React.useState<string[]>(
[]
Expand All @@ -105,6 +109,11 @@ const memberOfNetgroups = (props: MemberOfNetroupsProps) => {
setShownNetgroups(paginate(netgroupsFromUser, page, perPage));
}, [netgroupsFromUser]);

// Buttons functionality
// - Refresh
const isRefreshButtonEnabled =
!netgroupsQuery.isFetching && !props.isUserDataLoading;

return (
<>
<alerts.ManagedAlerts />
Expand All @@ -113,7 +122,7 @@ const memberOfNetgroups = (props: MemberOfNetroupsProps) => {
onSearchTextChange={setSearchValue}
// eslint-disable-next-line @typescript-eslint/no-empty-function
onSearch={() => {}}
refreshButtonEnabled={true}
refreshButtonEnabled={isRefreshButtonEnabled}
onRefreshButtonClick={props.onRefreshUserData}
deleteButtonEnabled={someItemSelected}
// eslint-disable-next-line @typescript-eslint/no-empty-function
Expand Down

0 comments on commit d042c4d

Please sign in to comment.