Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'Clean up' button to Host Details page #1623

Merged
merged 16 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion assets/js/components/HostDetails/HostDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ function HostDetails() {

const cleanUpHost = (selectedHost) => {
setCleanUpModalOpen(false);
dispatch(deregisterHost({ ...selectedHost, navigate }));

const { id, hostname } = selectedHost;
dispatch(deregisterHost({ id, hostname, navigate }));
};

const getExportersStatus = async () => {
Expand Down
4 changes: 3 additions & 1 deletion assets/js/components/HostsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ function HostsList() {

const cleanUpHost = (host) => {
setCleanUpModalOpen(false);
dispatch(deregisterHost({ ...host, navigate }));

const { id, hostname } = host;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls destructure on the function argument level 👁️

dispatch(deregisterHost({ id, hostname, navigate }));
};

const config = {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/state/sagas/hosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function* hostDeregistered({ payload }) {

export function* deregisterHost({
payload,
payload: { hostname, id, navigate },
payload: { id, hostname, navigate },
}) {
yield put(setHostDeregistering(payload));
try {
Expand Down
22 changes: 10 additions & 12 deletions assets/js/state/sagas/hosts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,11 @@ describe('Hosts sagas', () => {
});

it('should send host deregister request', async () => {
const host = hostFactory.build();
const { id, hostname } = hostFactory.build();
const payload = { id, hostname, navigate: () => {} };

const mockNavigate = () => {};
axiosMock.onDelete(`/hosts/${host.id}`).reply(204, {});
axiosMock.onDelete(`/hosts/${id}`).reply(204, {});

const payload = { ...host, navigate: mockNavigate };
const dispatched = await recordSaga(deregisterHost, { payload });

expect(dispatched).toEqual([
Expand All @@ -97,21 +96,20 @@ describe('Hosts sagas', () => {
});

it('should notify error on host deregistration request', async () => {
const host = hostFactory.build();
const { id, hostname } = hostFactory.build();
const payload = { id, hostname, navigate: () => {} };

axiosMock.onDelete(`/hosts/${host.id}`).reply(404, {});
axiosMock.onDelete(`/hosts/${id}`).reply(404, {});

const dispatched = await recordSaga(deregisterHost, {
payload: host,
});
const dispatched = await recordSaga(deregisterHost, { payload });

expect(dispatched).toEqual([
setHostDeregistering(host),
setHostDeregistering(payload),
notify({
text: `Error deregistering host ${host.hostname}.`,
text: `Error deregistering host ${hostname}.`,
icon: '❌',
}),
setHostNotDeregistering(host),
setHostNotDeregistering(payload),
]);
});
});
Loading