Skip to content

Fixes #39538 - Host actions are disabled after bulk action#11110

Open
MariaAga wants to merge 1 commit into
theforeman:developfrom
MariaAga:39538
Open

Fixes #39538 - Host actions are disabled after bulk action#11110
MariaAga wants to merge 1 commit into
theforeman:developfrom
MariaAga:39538

Conversation

@MariaAga

@MariaAga MariaAga commented Jul 17, 2026

Copy link
Copy Markdown
Member

new host page - to reproduce run one of the bulk actions - for example: change location, after the data refresh, the permissions dont get loaded, so the host kebab (edit,clone, clone) are disabled.
Updated all bulk actions to use the same refresh data function, that includes permissions.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a regression in the new Hosts page where, after running a bulk action and the table refreshes, host row actions (kebab menu: edit/clone/delete) become disabled because the refreshed host API response no longer includes permission flags.

Changes:

  • Adds permission checks via usePermissions (sourced from Foreman metadata permissions) in HostsIndex.
  • Updates row kebab action disabling logic to rely on the new permission checks instead of per-row API fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 392 to 396
const coreRowKebabItems = ({ id, name: hostName, compute_id: computeId }) => [
{
title: __('Edit'),
onClick: () => {
window.location.href = foremanUrl(`/hosts/${id}/edit`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot does have a point here. The permissions available thru ForemanContext are user-level and not resource-level.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

how can users restrict on host level?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the other solution would be to re-call the api on every hosts api call, to include permission (not really a good solution)
or to start editing all the host bulk actions to include the permissions (we plan to unify all the host bulk actions later, as we dont have much capacity now)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In our RBAC system you can have a filter that says "this user can only edit these hosts," and describes those hosts via a saved search. The row-level can_edit, etc. (apparently?) takes that into account, while the general "does the user have edit_hosts permission" doesn't.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The API will still prevent unauthorized actions, but assuming it's actually the case that the row-level nodes work with those special filters, I think the fallback makes sense.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll update all the bulk models already

Comment thread webpack/assets/javascripts/react_app/components/HostsIndex/index.js Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comment thread webpack/assets/javascripts/react_app/components/HostsIndex/index.js

@jeremylenz jeremylenz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wait, after the changes I no longer see any permission-related code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants