mirror of
https://github.com/ansible/awx.git
synced 2026-05-16 13:57:39 -02:30
Add toast and delete modal messaging when removing/adding peers. (#14373)
This commit is contained in:
@@ -11,6 +11,7 @@ import DisassociateButton from 'components/DisassociateButton';
|
|||||||
import AssociateModal from 'components/AssociateModal';
|
import AssociateModal from 'components/AssociateModal';
|
||||||
import ErrorDetail from 'components/ErrorDetail';
|
import ErrorDetail from 'components/ErrorDetail';
|
||||||
import AlertModal from 'components/AlertModal';
|
import AlertModal from 'components/AlertModal';
|
||||||
|
import useToast, { AlertVariant } from 'hooks/useToast';
|
||||||
import { getQSConfig, parseQueryString, mergeParams } from 'util/qs';
|
import { getQSConfig, parseQueryString, mergeParams } from 'util/qs';
|
||||||
import { useLocation, useParams } from 'react-router-dom';
|
import { useLocation, useParams } from 'react-router-dom';
|
||||||
import useRequest, { useDismissableError } from 'hooks/useRequest';
|
import useRequest, { useDismissableError } from 'hooks/useRequest';
|
||||||
@@ -30,6 +31,7 @@ function InstancePeerList({ setBreadcrumb }) {
|
|||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||||
|
const { addToast, Toast, toastProps } = useToast();
|
||||||
const readInstancesOptions = useCallback(
|
const readInstancesOptions = useCallback(
|
||||||
() => InstancesAPI.readOptions(id),
|
() => InstancesAPI.readOptions(id),
|
||||||
[id]
|
[id]
|
||||||
@@ -114,8 +116,14 @@ function InstancePeerList({ setBreadcrumb }) {
|
|||||||
];
|
];
|
||||||
await InstancesAPI.update(instance.id, { peers: new_peers });
|
await InstancesAPI.update(instance.id, { peers: new_peers });
|
||||||
fetchPeers();
|
fetchPeers();
|
||||||
|
addToast({
|
||||||
|
id: instancesPeerToAssociate,
|
||||||
|
title: t`${selected_hostname} added as a peer. Please be sure to run the install bundle for ${instance.hostname} again in order to see changes take effect.`,
|
||||||
|
variant: AlertVariant.success,
|
||||||
|
hasTimeout: true,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
[instance, fetchPeers]
|
[instance, fetchPeers, addToast]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -134,7 +142,12 @@ function InstancePeerList({ setBreadcrumb }) {
|
|||||||
}
|
}
|
||||||
await InstancesAPI.update(instance.id, { peers: new_peers });
|
await InstancesAPI.update(instance.id, { peers: new_peers });
|
||||||
fetchPeers();
|
fetchPeers();
|
||||||
}, [instance, selected, fetchPeers])
|
addToast({
|
||||||
|
title: t`${selected_hostname} removed. Please be sure to run the install bundle for ${instance.hostname} again in order to see changes take effect.`,
|
||||||
|
variant: AlertVariant.success,
|
||||||
|
hasTimeout: true,
|
||||||
|
});
|
||||||
|
}, [instance, selected, fetchPeers, addToast])
|
||||||
);
|
);
|
||||||
|
|
||||||
const { error, dismissError } = useDismissableError(
|
const { error, dismissError } = useDismissableError(
|
||||||
@@ -239,6 +252,7 @@ function InstancePeerList({ setBreadcrumb }) {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
<Toast {...toastProps} />
|
||||||
{error && (
|
{error && (
|
||||||
<AlertModal
|
<AlertModal
|
||||||
isOpen={error}
|
isOpen={error}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ describe('<InstanceForm />', () => {
|
|||||||
expect(handleCancel).toBeCalled();
|
expect(handleCancel).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should call handleSubmit when Cancel button is clicked', async () => {
|
test('should call handleSubmit when Save button is clicked', async () => {
|
||||||
expect(handleSubmit).not.toHaveBeenCalled();
|
expect(handleSubmit).not.toHaveBeenCalled();
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
wrapper.find('input#hostname').simulate('change', {
|
wrapper.find('input#hostname').simulate('change', {
|
||||||
@@ -74,9 +74,6 @@ describe('<InstanceForm />', () => {
|
|||||||
wrapper.find('input#instance-description').simulate('change', {
|
wrapper.find('input#instance-description').simulate('change', {
|
||||||
target: { value: 'This is a repeat song', name: 'description' },
|
target: { value: 'This is a repeat song', name: 'description' },
|
||||||
});
|
});
|
||||||
wrapper.find('input#instance-port').simulate('change', {
|
|
||||||
target: { value: 'This is a repeat song', name: 'listener_port' },
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
expect(
|
expect(
|
||||||
@@ -91,10 +88,9 @@ describe('<InstanceForm />', () => {
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
managed_by_policy: true,
|
managed_by_policy: true,
|
||||||
hostname: 'new Foo',
|
hostname: 'new Foo',
|
||||||
listener_port: 'This is a repeat song',
|
|
||||||
node_state: 'installed',
|
node_state: 'installed',
|
||||||
node_type: 'execution',
|
node_type: 'execution',
|
||||||
peers_from_control_nodes: true,
|
peers_from_control_nodes: false,
|
||||||
peers: [],
|
peers: [],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ function RemoveInstanceButton({ itemsToRemove, onRemove, isK8s }) {
|
|||||||
</Button>,
|
</Button>,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<div>{t`This action will remove the following instances:`}</div>
|
<div>{t`This action will remove the following instance and you may need to rerun the install bundle for any instance that was previously connected to:`}</div>
|
||||||
{itemsToRemove.map((item) => (
|
{itemsToRemove.map((item) => (
|
||||||
<span key={item.id} id={`item-to-be-removed-${item.id}`}>
|
<span key={item.id} id={`item-to-be-removed-${item.id}`}>
|
||||||
<strong>{item.hostname}</strong>
|
<strong>{item.hostname}</strong>
|
||||||
|
|||||||
Reference in New Issue
Block a user