Skip to content

Commit

Permalink
Fixes #36469 - Fix it also for the Roles tab
Browse files Browse the repository at this point in the history
  • Loading branch information
ronlavi2412 committed Jan 1, 2024
1 parent a167f84 commit b486520
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,23 @@ const RolesTab = ({ hostId, history, canEditHost }) => {
const hostGlobalId = encodeId('Host', hostId);
const pagination = useCurrentPagination(history);
const [assignModal, setAssignModal] = useState(false);
const [totalItems, setTotalItems] = useState(0);
const setTotalCount = data => {
if (!data) return;
const { totalCount } = data.host.ownAnsibleRoles;
if (totalItems === 0) setTotalItems(totalCount);
};

const renameData = data => ({
ansibleRoles: data.host.ownAnsibleRoles.nodes,
totalCount: data.host.ownAnsibleRoles.totalCount,
});

const useFetchFn = () =>
useQuery(ansibleRolesQuery, {
variables: { id: hostGlobalId, ...useParamsToVars(history) },
variables: { id: hostGlobalId, ...useParamsToVars(history, totalItems) },
fetchPolicy: 'network-only',
onCompleted: setTotalCount,
});

const editBtn = canEditHost ? (
Expand Down

0 comments on commit b486520

Please sign in to comment.