-
Notifications
You must be signed in to change notification settings - Fork 112
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
Fixes #37228 - Replace Ansible/Roles page with React component #696
base: master
Are you sure you want to change the base?
Fixes #37228 - Replace Ansible/Roles page with React component #696
Conversation
21c7da7
to
9eb1804
Compare
What is blocking us from using this change? Possibly at the start of a new release cycle? |
I'll review it ASAP. |
The functionality works well. However, the page is loading much slower than before. I’m wondering if it’s an issue on my side or if the new code is causing the app to load slower. |
@nofaralfasi |
webpack/components/AnsibleRoles/components/AnsibleRolesTableRowActionButton.js
Outdated
Show resolved
Hide resolved
Of course, the site load would be pretty fast but rendering the page takes longer as its done in the browser itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Foreman we have the TableIndexPage
component which is intended for these index pages. Have you considered using that and if so, why was it insufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to Ewouds question, the js loading is slower between ruby and js, but faster between full React pages.
Can this be a full react page? it will need to be added in webpack/routes/routes.js
, config/routes.rb
Sorry for the delay, I was occupied otherwise. |
Thanks, that's what I was looking for. |
^^Nevermind, I just noticed the |
9eb1804
to
5783590
Compare
Sorry for the holdup, I was occupied otherwise. |
webpack/components/AnsibleRoles/components/AnsibleRolesImportButton.js
Outdated
Show resolved
Hide resolved
@@ -7,6 +10,12 @@ def index | |||
@ui_ansible_roles = resource_scope_for_index(:permission => :view_ansible_roles) | |||
end | |||
|
|||
api :DELETE, '/ui_ansible_roles/:id', N_('Deletes Ansible role') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any permission filtering here. Am I missing something?
Also, couldn't this just use the regular REST API to delete roles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I forgot to add the permission.
The table component uses the same endpoint for querying and deleting items, so it's unfortunately not possible to use the API just for deletion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure this is the right approach? Adding an API call here doesn't seem right to me. I know it might be simpler, but we can still use the existing API call to delete a role. It might require some frontend adjustments, but it will align with the rest of our code.
For reference, this is how we do it on the new hosts page: https://github.com/theforeman/foreman/blame/6aac916fb183f47596e8d543756faac27750a21e/webpack/assets/javascripts/react_app/components/HostsIndex/index.js#L283
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this would require significant changes to TableIndexPage.js and Table.js in core, as the idea is that TableIndexPage represents an interface to a single controller that has the necessary CRUD methods.
One could add another prop, deletionURL
to TableIndexPage and Table that would take precedence over the original URL for deletion but I am not sure that is a cleaner solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we add the Delete
option to the rowKebabItems
action items instead of using the isDeleteable
property? From there, we can use the URL of the existing API for the delete action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, we would lose the delete modal that way.
5783590
to
e263308
Compare
57587ef
to
d2b6c5c
Compare
I added some tests for the React components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The page is significantly improved now. Thank you, @Thorben-D, for your hard work!
Here are a few notes from me:
- The "Import from" button is positioned on the same row as the top navigation, causing it to appear centered on the page.
- Table rows have a clickable cursor, but clicking them does not trigger any action.
- Clicking the Documentation button opens it in the current window.
- If the current user lacks permissions to view hosts or hostgroups, the corresponding options in the action menu should be disabled (same as we have now for the delete option).
- When the current user has permissions only to import roles (without viewing permissions), loading the Ansible Roles page results in the following error message: "There was an error requesting Smart Proxies," and the smart-proxy cannot be selected.
This is fixed in foreman core
Those are issues from foreman core |
d2b6c5c
to
b77f8cc
Compare
Thanks for testing! I looked into the error you discovered. Regarding the "view X" buttons, while it is of course possible to hide those based on permissions, I would either have to lift the existing request up or add a second one to make it work. Both solutions would noticeably slow the page down however. |
@nofaralfasi / @ekohl This PR is now open since Mar 6 and we invested a lot to improve foreman_ansible here. @Thorben-D answered all the questions and worked hard to get it done. |
@Thorben-D Could you please rebase the PR? I'll re-check the permission issue, and let's see if the tests pass after the rebase. Update: |
9e9cd95
to
17b614a
Compare
Thank you for having another look! |
:params => { :id => @role.id }, | ||
:session => set_session_user | ||
assert_response :success | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test to verify that a user without the destroy_ansible_roles
permission cannot perform this action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this is necessary. The permissions should already be tested by a test in core and I didn't really find an existing test that tested this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MariaAga what are your thoughts about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not my area, but I couldnt find a test in core for it in core
Overall, it looks good to me. Once Ewoud's and my comments are addressed, I believe we should merge this |
17b614a
to
28c9905
Compare
@nofaralfasi The server actually sends back the following message: |
@Thorben-D what about permissions to view hosts or hostgroups? I think we should disable the buttons that are not permitted in the action menu. Update: after discussing it with @ekohl, we agreed that to maintain consistency across the UI, this table should be aligned with the others. Specifically, the view actions for hosts and hostgroups should be presented as links within their respective column counts. |
28c9905
to
ca5bdfb
Compare
Apologies, I did not see the last comment. I updated the design to match the desired outcome. Links in the columns will only be given if a user has the authorization to view them. |
ca5bdfb
to
5f218bc
Compare
Feature #37228
The new component acts as a drop-in replacement for the previously used erb-table.
This is required by #707