Skip to content

Commit

Permalink
fix(RHINENG-2392): Show refresh link in group notifications (#2125)
Browse files Browse the repository at this point in the history
Fixes https://issues.redhat.com/browse/RHINENG-2392.

This adds a refresh link to the success notification when systems are added or removed from a group. The data is no longer reloaded automatically.
  • Loading branch information
gkarat authored Dec 19, 2023
1 parent 24c787d commit b732879
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
9 changes: 0 additions & 9 deletions src/components/GroupSystems/GroupImmutableSystems.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { TableVariant } from '@patternfly/react-table';
import PropTypes from 'prop-types';
import React, { useEffect, useRef, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { selectEntity } from '../../store/inventory-actions';
import AddSystemsToGroupModal from '../InventoryGroups/Modals/AddSystemsToGroupModal';
import InventoryTable from '../InventoryTable/InventoryTable';
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom';
Expand Down Expand Up @@ -222,14 +221,6 @@ const GroupImmutableSystems = ({ groupName, groupId, ...props }) => {
isModalOpen={removeHostsFromGroupModalOpen}
setIsModalOpen={setRemoveHostsFromGroupModalOpen}
modalState={currentSystem}
reloadTimeout={1000}
reloadData={() => {
if (calculateSelected() > 0) {
dispatch(selectEntity(-1, false));
}

inventory.current.onRefreshData({}, false, true);
}}
/>
)}
{updateDevice && (
Expand Down
1 change: 0 additions & 1 deletion src/components/GroupSystems/GroupSystems.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ describe('actions', () => {
cy.get('button[type="submit"]').click();
cy.wait('@request');
});
cy.wait('@getHosts'); // data must be reloaded
});
});

Expand Down
9 changes: 0 additions & 9 deletions src/components/GroupSystems/GroupSystems.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { TableVariant, fitContent } from '@patternfly/react-table';
import PropTypes from 'prop-types';
import React, { useEffect, useRef, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { selectEntity } from '../../store/inventory-actions';
import AddSystemsToGroupModal from '../InventoryGroups/Modals/AddSystemsToGroupModal';
import InventoryTable from '../InventoryTable/InventoryTable';
import { Link } from 'react-router-dom';
Expand Down Expand Up @@ -136,14 +135,6 @@ const GroupSystems = ({ groupName, groupId }) => {
isModalOpen={removeHostsFromGroupModalOpen}
setIsModalOpen={setRemoveHostsFromGroupModalOpen}
modalState={currentSystem}
reloadTimeout={1000}
reloadData={() => {
if (calculateSelected() > 0) {
dispatch(selectEntity(-1, false));
}

inventory.current.onRefreshData({}, false, true);
}}
/>
)}
{!addToGroupModalOpen && (
Expand Down
11 changes: 8 additions & 3 deletions src/components/InventoryGroups/Modals/AddSystemsToGroupModal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Alert,
AlertActionLink,
Button,
Flex,
FlexItem,
Expand Down Expand Up @@ -81,6 +82,11 @@ const AddSystemsToGroupModal = ({
description: `${hostIds.length > 1 ? 'Systems' : 'System'} added to ${
groupName || groupId
}`,
actionLinks: (
<AlertActionLink onClick={() => window.location.reload()}>
Refresh
</AlertActionLink>
),
},
onError: {
title: 'Error',
Expand Down Expand Up @@ -176,9 +182,8 @@ const AddSystemsToGroupModal = ({
{/** confirmation modal */}
<ConfirmSystemsAddModal
isModalOpen={confirmationModalOpen}
onSubmit={async () => {
await handleSystemAddition(overallSelectedKeys);
setTimeout(() => dispatch(fetchGroupDetail(groupId)), 500); // refetch data for this group
onSubmit={() => {
handleSystemAddition(overallSelectedKeys);
setIsModalOpen(false);
}}
onBack={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import apiWithToast from '../utils/apiWithToast';
import { useDispatch } from 'react-redux';
import { removeHostsFromGroup } from '../utils/api';
import componentTypes from '@data-driven-forms/react-form-renderer/component-types';
import { Text } from '@patternfly/react-core';
import { AlertActionLink, Text } from '@patternfly/react-core';

const schema = (hosts) => {
const hostsInGroup = hosts.filter(({ groups }) => groups.length > 0); // selection can contain ungroupped hosts
Expand Down Expand Up @@ -43,6 +43,11 @@ const statusMessages = (hosts) => {
? {
onSuccess: {
title: `1 system removed from ${groupName}`,
actionLinks: (
<AlertActionLink onClick={() => window.location.reload()}>
Refresh
</AlertActionLink>
),
},
onError: {
title: `Failed to remove 1 system from ${groupName}`,
Expand All @@ -51,6 +56,11 @@ const statusMessages = (hosts) => {
: {
onSuccess: {
title: `${hostsInGroup.length} systems removed from ${groupName}`,
actionLinks: (
<AlertActionLink onClick={() => window.location.reload()}>
Refresh
</AlertActionLink>
),
},
onError: {
title: `Failed to remove ${hostsInGroup.length} systems from ${groupName}`,
Expand Down

0 comments on commit b732879

Please sign in to comment.