Skip to content

Fixes #39532 - All hosts - add action - bulk add capsule#616

Open
Lukshio wants to merge 3 commits into
theforeman:masterfrom
Lukshio:addBulkAction
Open

Fixes #39532 - All hosts - add action - bulk add capsule#616
Lukshio wants to merge 3 commits into
theforeman:masterfrom
Lukshio:addBulkAction

Conversation

@Lukshio

@Lukshio Lukshio commented Jul 16, 2026

Copy link
Copy Markdown

Users can assign an OpenSCAP Proxy to a host. This can be done individually for a host via the host edit form, but also in bulk via the legacy host overview UI (see screenshot). The new UI currently doesn't support this.

Option can be found on AllHosts page -> select hosts -> kebab menu -> Change association -> OpenSCAP Capsule

@MariaAga MariaAga left a comment

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.

initial review:
Capsule is for downstream, and gets translated from "Proxy" please only use proxy here.

Going to do some tests now, and then a more in depth review once it gets updated

Comment thread webpack/components/HostsIndex/ChangeOpenscapProxyAction.js
};

const descriptionText = selectAllHostsMode ? (
<>

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.

FormattedMessage might be helpful here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I was wondering what will be the best approach, but I decided to not use FormattedMessage so we don't rely on external libs.

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.

we use react-intl anyway for out translations

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Would you prefer to have it in FormattedMessage or I can leave it like this?

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.

I think you can leave it as is. was mostly sharing info

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.

Success message doesn't include host count (inconsistent with core bulk actions)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I tried changing org and location but it does not show count either

@sbernhard

Copy link
Copy Markdown
Contributor

Please have a look at this, too: #615
Might be a valid different approach or a nice addition.

handleModalClose();
};

const handleError = () => {

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.

Would it be possible to re-use the error handling from theforeman/foreman#11045 ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@sbernhard Thanks for the feedback. It is actually solving different issues. In my case, I am using handleError for closing the modal and setting state. For handleSuccess I am using for refreshing the page and closing modal.

The foreman PR is solving parsing error/sucess messages from the server response and displaying Toast by using addToast. In my case, I am using directly success/errorToast built in APIActions so it's actually different codes for different purpose.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I also added my comments to the PR

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.

I'm starting to think we might need a generic handleSuccess as a lot of the bulk actions ignore the perPage param (and probably others) in the data reset - and we can either fix it 1, by 1, or send something similar to fetchBulkParams - like refreshData in the ForemanActionsBarContext

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think that at this moment we should finish the changes and schedule some further reactor in cooperation with UX team, unifying the design and code.

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.

Yeah good idea.

@MariaAga MariaAga left a comment

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.

(midway review as I cant comment on the discussion without clicking "submit review")
Capsule is still mentioned in the code, PR title, and commits.
Also casing should be always OpenSCAP Proxy (and not OpenSCAP proxy)

>
<Stack hasGutter>
<StackItem>{descriptionText}</StackItem>
{proxyStatus === STATUS.RESOLVED && proxies?.results?.length > 0 && (

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.

Could you add a spinner/skeleton until its resolved?

handleModalClose();
};

const handleError = () => {

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.

I'm starting to think we might need a generic handleSuccess as a lot of the bulk actions ignore the perPage param (and probably others) in the data reset - and we can either fix it 1, by 1, or send something similar to fetchBulkParams - like refreshData in the ForemanActionsBarContext

key: BULK_CHANGE_OPENSCAP_PROXY_KEY,
url: foremanUrl('/api/v2/hosts/bulk/change_openscap_proxy'),
handleSuccess,
successToast: response => response.data.message,

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.

This doesnt parse the response correctly so the toast just says "success"

Comment on lines +57 to +59
message: n_("Failed to assign OpenSCAP Proxy to %s host",
"Failed to assign OpenSCAP Proxy to %s hosts",
failed_hosts.count) % failed_hosts.count,

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.

Could the message include also how many were successful/not done? (if I try 60, and see that 55 failed its unclear if the other 5 were skipped or successful)

handleModalClose();
};

const handleError = () => {

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.

Yeah good idea.

Comment on lines +75 to +80
dispatch(
APIActions.get({
key: HOSTS_API_REQUEST_KEY,
url: foremanUrl(HOSTS_API_PATH),
})
);

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.

I'm hoping to get this in to avoid bugs theforeman/foreman#11110

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