Skip to content

Commit

Permalink
Fixes #36469 - fix React tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ron-Lavi committed Jan 1, 2024
1 parent cb40128 commit cff3098
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const AnsibleVariableOverrides = ({ hostId, hostAttrs, history }) => {
const hostGlobalId = encodeId('Host', hostId);
const pagination = useCurrentPagination(history);
const [totalItems, setTotalItems] = useState(0);
const setTotalCount = totalCount => {
if (totalCount === 0) setTotalItems(totalCount);
}

Check failure on line 22 in webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js

View workflow job for this annotation

GitHub Actions / test_js (12)

Insert `;`

Check failure on line 22 in webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js

View workflow job for this annotation

GitHub Actions / test_js (14)

Insert `;`

const useFetchFn = () =>
useQuery(variableOverrides, {
Expand All @@ -31,7 +34,8 @@ const AnsibleVariableOverrides = ({ hostId, hostAttrs, history }) => {

const renameData = data => {
const { totalCount } = data.host.ansibleVariablesWithOverrides;
if (totalItems === 0) setTotalItems(totalCount);
// Moved into a seperate function after React complained on setstate-in-render issue.
setTotalCount(totalCount)

Check failure on line 38 in webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js

View workflow job for this annotation

GitHub Actions / test_js (12)

Insert `;`

Check failure on line 38 in webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js

View workflow job for this annotation

GitHub Actions / test_js (14)

Insert `;`
return {
variables: data.host.ansibleVariablesWithOverrides.nodes,
totalCount,
Expand Down

0 comments on commit cff3098

Please sign in to comment.