Nested tabs with routing

Hi,
when I started adding Ansible content into new host detail page, I found out the page currently does not support routing for the second level of tabs (tabs within tabs). I believe we should invest our time in having routed subtabs as it is not difficult to achieve and it gives us a good control over the active tabs and therefore content that is displayed. Based on information from @MariSvirik, reflecting tab changes in URL is valuable from a usability point of view.

There is currently no clear consensus on the scheme that we would use. Traditionally, tabs are addressed with # sign, which we currently have on smart proxies show page and new version of content view pages in lab features. Examples: /smart_proxies/4-centos-proxy#properties, /labs/content_views/2#versions

However, using # multiple times is not possible so we cannot have /hosts/:id#tab#subtab. It is possible to use query params instead of the second # and that is also what RoutedTabs component in Katello mentions, so the resulting URL would be /host/:id#tab?subtab=foo.

My personal preference is to replace # with regular path segments in the same way as the Katello pages currently have it, so we would end up with /hosts/:id/:tab/:subtab. I have opened a PR which shows how that might look like. There were also suggestions to push # one level down and have it for the last level of tabs, that is /host/:id/:tab#subtab

What do you think we should use?

  • /hosts/:id#tab?subtab=foo
  • /hosts/:id/:tab#subtab
  • /hosts/:id/:tab/:subtab
  • something else, I’ll explain in a comment below

0 voters

2 Likes

I’m inclined to use :tab#subtab, but I think it is not that simple, I think we need to always take in account what does the tab really mean, if it is more of a standalone page, or just content division.

If the tab splits larger chunks of funcionality, it should use /:tab on the other hand if it’s just a way how to visually divide content that would even make sense on one page, I think it should be #tab

For host detail I think it make sense as /:tab#subtab although it migh not be the case for all pages.
As a subthough I think if we are splitting larger features by tabs, we are doing tabs wrong, but I do not know enough about UX.

I would suggest sticking with only #subtab as is the case for some existing pages.
Not all pages use client side routing yet, and fragments (#something) are the only part of a url that is not sent to the server or trigger a page reload when navigated to. This is the standard method for indicating which part of a page should be displayed. We also already have code that knows how to handle finding subtabs and navigating to them on legacy pages.
If needed to disambiguate two subtabs with the same name on different tabs, you could use #tab-subtab as a unique identifier for the specific subtab.

2 Likes

Could you point me to an existing Foreman page has 2 levels of tabs and uses only #subtab for a (reliable) navigation? I did not find any.

Even though the chance of name collision is not high, avoiding clash on subtab name would require a synchronization across all plugins that add tabs. Developer adding a tab would have to be aware of all other names to choose a name that is not yet used. Same goes for reviewers. And if we find out that 2 plugins added a tab with the same name when testing the next Foreman RC, how do we decide which plugin should rename its tab?

The smart proxy page has this for puppet CA, when selecting “certificate” or “autosign” from the action dropdown on the index or show page. This was the original reason that code was created. There may be other places as well that use it.

I’d be fine with normalizing on #tab-subtab if we want to make sure we don’t run into this issue.

I’d really hate that. #... should be id of element to be selected, if it is not, I’d rather have any other solution than having custom hybrid that only works if our custom JS takes care of it, but looks like standartized solution :slight_smile:

After discussing with UX enthusiast friend of mine, the Host page is not really having sub-tabs, but it has sub-menu (first level of tabs) that should be in url, and only the sub tabs are real tabs. This should also be differentiated in the UI as the menu should look more like menu and the tabs within the sub-menu items should be displayed as tabs. But it’s just external opinion obviously and probably should be left to more experienced people like @MariSvirik

Though I liked that opinion and so I quite strongly incline to /<tab(host-menu-item)>#<subtab(real tab)> in Host detail page usecase.

My suggestion is to use #tab-subtab as the id of the subtab to be selected if we’re concerned about name conflicts, not to break it down to parts in our code and select them. Finding the parent tab of the tab to display should be easy to do in case there is one and shouldn’t rely on having the #tab part correctly set.

I disagree, some of the tabs don’t have subtabs, and in any case the data is loaded when the whole page is loaded, even if it isn’t displayed directly.

This would require front end routing to know which paths are for tabs and what are for subactions (think about endpoints like /hosts/4/externalNodes or /hosts/4/clone which are endpoints vs. /hosts/4/ansible or /hosts/4/details which may be tab names).
It would also make our code for finding the right tab name more complex, since If we stick with only using the fragment, finding what tab to display is a simple uri.fragment(), no need to combine tab = uri.path().split('/')[-1]; subtab = uri.fragment() and handle all edge cases of mismatches. Just find the tab with the right id, display it, and if it has a parent, display that as well.

You raised a good point about actions vs. tabs. But we are currently using ‘/’ between host id and tab (e.g. /content_hosts/53/tasks) So how come we haven’t encountered that problem yet?

What about this:
hosts/ host id/ #tab-subtab
or just
hosts/ host id/ tab#subtab