Skip to content

Fixes #39227 - Fix host delete toast disappearing before page refresh#10956

Merged
nofaralfasi merged 1 commit intotheforeman:developfrom
nofaralfasi:SAT-38950
May 3, 2026
Merged

Fixes #39227 - Fix host delete toast disappearing before page refresh#10956
nofaralfasi merged 1 commit intotheforeman:developfrom
nofaralfasi:SAT-38950

Conversation

@nofaralfasi
Copy link
Copy Markdown
Contributor

When deleting a host from the new hosts index page, the success toast notification would appear briefly then disappear because the page performed a full browser redirect, losing the Redux state.

Instead of redirecting after delete on the hosts index page, refresh the table data in-place. This preserves the Redux state so the toast remains visible. The host details page still redirects since the host no longer exists.

  • Add onDeleteSuccess callback option to deleteHost and bulkDeleteHosts
  • HostsIndex passes a refresh callback instead of relying on redirect
  • Clear selection after bulk delete before refreshing

Copy link
Copy Markdown
Member

@chris1984 chris1984 left a comment

Choose a reason for hiding this comment

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

Had one comment, tested and overall works great. Could you add a test for the new behavior?

@@ -209,9 +209,16 @@ const HostsIndex = () => {
const dispatch = useDispatch();
const { destroyVmOnHostDelete } = useForemanSettings();
const hostsIndexUrl = useForemanHostsPageUrl();
const refreshTableData = () =>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The same setAPIOptions({ ...apiOptions, params: { search: urlSearchQuery } }) pattern appears in refreshTableData (line 213-215) and again in the Table's refreshData prop (line
534-538). Could you reuse refreshTableData for the Table prop too:
refreshData={refreshTableData

Copy link
Copy Markdown
Member

@chris1984 chris1984 left a comment

Choose a reason for hiding this comment

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

Tested and looks good to me, thanks for adding the test and cleaning up the duplicated logic. Will let @jeremylenz take a second look incase I missed anything and provide a green ack if it looks good.

Copy link
Copy Markdown
Contributor

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

Thanks @nofaralfasi @chris1984!

ACK based on Chris's testing

@jeremylenz
Copy link
Copy Markdown
Contributor

jeremylenz commented Apr 29, 2026

@nofaralfasi Please squash

When deleting a host from the new hosts index page, the success toast
notification would appear briefly then disappear because the page
performed a full browser redirect, losing the Redux state.

Instead of redirecting after delete on the hosts index page, refresh
the table data in-place. This preserves the Redux state so the toast
remains visible. The host details page still redirects since the host
no longer exists.

- Add onDeleteSuccess callback option to deleteHost and bulkDeleteHosts
- HostsIndex passes a refresh callback instead of relying on redirect
- Clear selection after bulk delete before refreshing
- Add tests for host delete actions
- Refactor HostsIndex to reuse refreshTableData for Table's refreshData prop

Made-with: Cursor
@nofaralfasi nofaralfasi merged commit 9ae2ed6 into theforeman:develop May 3, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants