Skip to content

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

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

Fixes #39532 - All hosts - add action - bulk add capsule#616
Lukshio wants to merge 4 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

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"

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.

It is parsed correctly, but it usually exceeds this rule: https://github.com/theforeman/foreman/blob/7170b302c65d0a318179151f41fb7c699fe01629/webpack/assets/javascripts/react_app/components/ToastsList/helpers.js#L23

thinking of that 60 chars are really low limit to our messages

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.

You can wrap it in a <div> so it will be sent inside the alert body
image

      addToast({
        type: 'success',
        message: <div>Ex amet voluptate laborum sint ea ut in commodo. Nulla voluptate velit qui est cupidatat ea et commodo ipsum proident adipisicing occaecat. Consequat quis commodo minim nulla ipsum aute ipsum.</div>
      })

@Lukshio Lukshio Jul 20, 2026

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 to avoid using extra addToast when successToast can be used, but I guess that there is no other option. Then it probably can be aligned with theforeman/foreman#11045 or maybe it should be part of the bigger bulk actions refactor. Maybe we could edit addToast to convert title to text once it reach the 60 chars limitation, wdym @MariaAga

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.

Maybe we could edit addToast to convert title to text once it reach the 60 chars limitation

That would be a good feature

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.

Feature introduced here, in favor of that I am bringing back old handler theforeman/foreman#11114

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

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.

Let's wait until it gets merged

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.

@ofedoren Could you take a look at the ruby here?
Should this be under api? then its missing docs, or should it be under controllers

Comment thread webpack/components/HostsIndex/__tests__/ChangeOpenscapProxyAction.test.js Outdated
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