Skip to content

Commit

Permalink
Fixes #36469 - adjust also All Roles Modal
Browse files Browse the repository at this point in the history
  • Loading branch information
ronlavi2412 authored and nofaralfasi committed Mar 19, 2024
1 parent 6a9c68a commit 183e452
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { useQuery } from '@apollo/client';
import { translate as __ } from 'foremanReact/common/I18n';
Expand All @@ -14,6 +14,12 @@ import {
} from '../../../../../helpers/pageParamsHelper';

const AllRolesModal = ({ hostGlobalId, onClose, history }) => {
const [totalItems, setTotalItems] = useState(0);
const setTotalCount = data => {
if (!data) return;
const { totalCount } = data.host.allAnsibleRoles;
if (totalItems === 0) setTotalItems(totalCount);
};
const baseModalProps = {
ouiaId: 'modal-ansible-roles',
variant: ModalVariant.large,
Expand Down Expand Up @@ -44,9 +50,10 @@ const AllRolesModal = ({ hostGlobalId, onClose, history }) => {
useQuery(allAnsibleRolesQuery, {
variables: {
id: hostGlobalId,
...useParamsToVars(history),
...useParamsToVars(history, totalItems),
},
fetchPolicy: 'network-only',
onCompleted: setTotalCount,
});

const renameData = data => ({
Expand Down

0 comments on commit 183e452

Please sign in to comment.