Skip to content
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 #36822 - Design new hosts overview page #9860

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

parthaa
Copy link
Contributor

@parthaa parthaa commented Oct 10, 2023

Update the TableIndexPage as a part of this action to accept things like select all

Works with Katello/katello#10771

@github-actions github-actions bot added the UI label Oct 10, 2023
@parthaa parthaa force-pushed the my-changes branch 7 times, most recently from 1ab4260 to 4462bb4 Compare October 12, 2023 20:57
@parthaa parthaa changed the title [WIP] Fixes #36822 - Design new hosts page Fixes #36822 - Design new hosts page Oct 12, 2023
Copy link
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.

It's finally here! 🥳

A couple things I noticed to start:

  • Search works, but autocomplete doesn't
  • Kebab is too far to the right

config/routes.rb Outdated Show resolved Hide resolved
@ekohl ekohl changed the title Fixes #36822 - Design new hosts page Fixes #36822 - Design new hosts overview page Oct 13, 2023

const customActionKebabs = [
{
title: __('Change content source'),
Copy link
Contributor

Choose a reason for hiding this comment

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

This should actually be in Katello since it's linking to a Katello page.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should set this up similar to the way it's already done for host details.

See -> https://github.com/Katello/katello/blob/a57828483396b6e02e4b6d849202a0253abe9004/webpack/components/extensions/HostDetails/ActionsBar/index.js#L71

Exported from Katello to Foreman here -> https://github.com/Katello/katello/blob/a57828483396b6e02e4b6d849202a0253abe9004/webpack/global_index.js#L70

Consumed here in Foreman ->

which is then rendered here ->

const registeredItems = useSelector(selectKebabItems, shallowEqual);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

@jeremylenz
Copy link
Contributor

Also: Should add a setting "Use new All Hosts page" or some such, which will control whether the All Hosts link in the main nav goes to the new or the old page.

@parthaa
Copy link
Contributor Author

parthaa commented Oct 16, 2023

Also: Should add a setting "Use new All Hosts page" or some such, which will control whether the All Hosts link in the main nav goes to the new or the old page.

Updated the menu


const registeredItems = useSelector(selectKebabItems, shallowEqual);
const customToolbarItems = (
<ForemanHostsIndexActionsBarContext.Provider value={{...selectAllOptions, fetchBulkParams}}>
Copy link
Contributor

Choose a reason for hiding this comment

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

🥳 🚀

Comment on lines 30 to 37
const response = useAPI(
'get',
`${MODELS_API_PATH}?include_permissions=true`,
{
key: API_REQUEST_KEY,
}
);

Copy link
Member

Choose a reason for hiding this comment

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

I didnt check the rest of the PR, but can we not move this out of the table? the reason for the table component is so other components will not handle api calls.
Also this change breaks webhooks which also use the table component (https://github.com/theforeman/foreman_webhooks/blob/master/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/WebhooksIndexPage.js)

Copy link
Contributor

Choose a reason for hiding this comment

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

It made a lot more sense to me and @parthaa to move it up one level. This way the host-specifc parts (including the host API call) are in the host table component, while the generic table parts are in the table component. Not having access to response in the hosts table caused a lot of problems.

Perhaps we could leave it as is and update webhooks instead?

Copy link
Member

Choose a reason for hiding this comment

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

Cant the code use redux selectors to access the response?

Copy link
Contributor

@jeremylenz jeremylenz Oct 23, 2023

Choose a reason for hiding this comment

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

That's a possibility, just seemed a bit less elegant to me.

Personally I feel like needing to access response thru Redux defeats the whole purpose of useAPI.

@parthaa thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed it in the latest commit. Secret sauce here is this line

let response = useAPI(
    replacementResponse ? null : 'get',
    apiUrl.includes('include_permissions')
      ? apiUrl
      : `${apiUrl}?include_permissions=true`,
    {
      ...apiOptions,
      params: defaultParams,
    }
  );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

method being null implies that useAPI effects wont do anything.

Copy link
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.

some silly nits

controller="hosts"
isDeleteable
columns={columns}
creatable={false}
Copy link
Member

Choose a reason for hiding this comment

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

Why is creatable false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think on the Hosts Index page we need create button as the same level as Hosts header. So decided to add that to the HostIndex component and not use TableIndex for that.

Copy link
Member

Choose a reason for hiding this comment

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

Will that be added in a different pr?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, we'll be adding Delete right after this PR :)

Copy link
Member

Choose a reason for hiding this comment

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

And the create? 🙃

Copy link
Contributor

Choose a reason for hiding this comment

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

oops, misread that!

I can add create in the same PR, if partha doesn't add it here

@@ -415,6 +415,7 @@ def ui_settings
labFeatures: Setting[:lab_features],
safeMode: Setting[:safemode_render],
displayFqdnForHosts: Setting[:display_fqdn_for_hosts],
displayNewHostsPage: Setting[:new_hosts_page]
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd put this under User settings, since lab features is there too?

Copy link
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.

Few things to wrap up -

image

  1. Can we fix the kebab placement?
  2. Can we suppress the "No results" message while the page is loading?
  3. 'Hosts' link should respect the setting every place it's used

@MariaAga
Copy link
Member

@jeremylenz

Can we suppress the "No results" message while the page is loading?

why? its showing "no results - loading"

@jeremylenz
Copy link
Contributor

why? its showing "no results - loading"

'No results' is a lie if it's still loading. We don't know the number of results until it loads.

anyway, we can fix this later, I'm not gonna block on this one :)

@jeremylenz
Copy link
Contributor

Decided to leave for follow-up PR:

Multi-delete
Loading message (maybe)
Kebab placement

@parthaa can you please squash the commits and fix lint :)

@parthaa parthaa force-pushed the my-changes branch 2 times, most recently from d005c3f to cc2bc38 Compare October 25, 2023 15:57
jeremylenz
jeremylenz previously approved these changes Oct 25, 2023
Copy link
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.

APJ. Let's get this in and continue on, since this will unblock everything else :)

thanks @parthaa!

@parthaa
Copy link
Contributor Author

parthaa commented Oct 25, 2023

'No results' is a lie if it's still loading. We don't know the number of results until it loads.

anyway, we can fix this later, I'm not gonna block on this one :)

That logic is in TableIndexPage anyway. So once we make a decision all the pages using it should get updated appropriately.

Copy link
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.

looks like Foreman and integration tests need a look!

Created a HostIndex component

Update the TableIndexPage as a part of this action to accept things like
select all

Co-authored-by: Jeremy Lenz <[email protected]>
@jeremylenz jeremylenz merged commit 3688a0d into theforeman:develop Oct 26, 2023
13 checks passed
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