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

ui: Improved main navigation #7673

Merged
merged 11 commits into from
Apr 21, 2020
Merged

Conversation

johncowen
Copy link
Contributor

This PR reduces the individual places where we use our 'app chrome' component (<HashicorpConsul />).

Previously it individually wrapped the loading state, the app itself, the app error state and then individually the settings page. This was all due to not knowing important data required for the main navigation such as the current DC and current namespace until the user had entered the DC route.

We now get around this restriction by passing data up from the child DC route to the parent application controller (thanks @meirish for the suggestion!)

As a consequence of this we have moved the loading of Datacenters and Namespace up to the application route, which is almost never reloaded/refreshed. We therefore use our new <Datasource /> component to only reload datacenters and namespaces when the menus themselves are opened.

<Datasource />s work just like <img /> tags, so you can set their loading="" to be loading="eager" or loading="lazy" for lazy loading, just like <img /> tags.

We also move our Datacenter adapter to use query like the rest of the adapters in the UI instead of findAll.

There are a few other related changes here, such as trying to ensure that href-mut will always generated a URL even if the router service returns a currentRoute === null, and a more sane way of checking whether a user needs redirecting from a nspace.index route (big thanks to @randallmorey for the transition vs currentURL work here)

There's probably more work to come here in reducing the error and loading states in the application route to other individual components.

@johncowen johncowen added the theme/ui Anything related to the UI label Apr 20, 2020
@johncowen johncowen requested a review from a team April 20, 2020 17:25
@kaxcode kaxcode force-pushed the ui/feature/improved-main-nav branch from 5b72dd3 to a8a30bd Compare April 20, 2020 21:07
@johncowen johncowen force-pushed the ui/feature/improved-main-nav branch from a8a30bd to 5b72dd3 Compare April 21, 2020 08:41
@johncowen johncowen force-pushed the ui/feature/improved-main-nav branch from 5b72dd3 to 8c32ba9 Compare April 21, 2020 08:47
Copy link
Contributor

@kaxcode kaxcode left a comment

Choose a reason for hiding this comment

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

LGTM

token: service('repository/token'),
type: service('data-source/protocols/http/blocking'),
source: function(src, configuration) {
const [, dc /*nspace*/, , model, ...rest] = src.split('/');
const [, , /*nspace*/ dc, model, ...rest] = src.split('/');
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you leave an extra comma here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh no hehehe, I just tried to fix this about 4 times before I realised prettier is 'unfixing' it for me whenever I commit! 🤣

I've got a PR coming soon that uncomments this nspace so the problem will go away when I PR that.

@johncowen johncowen force-pushed the ui/feature/improved-main-nav branch 3 times, most recently from bd11bc1 to 566e833 Compare April 21, 2020 14:30
@johncowen johncowen merged commit 6ffab72 into ui-staging Apr 21, 2020
johncowen added a commit that referenced this pull request Apr 30, 2020
* Make datacenter queries use query vs findAll like the rest of the app

* Make sure we have an element to pass to isInViewport

* Make sure href-mut doesn't error even if the currentRoute === null

* More post test cleanup and Safari fix (safari requires http:// URLs)

* Reverse order of datasource nspace/dc's and add a namespace source

* Rearrange routes/templates/controllers to only use HashicorpConsul once

* Add datasources and correct token namespace detection/redirection

* Remove old dc findAll adapter method

* Add more comments around the 'child route/parent controller' vars
kaxcode pushed a commit that referenced this pull request May 11, 2020
* Make datacenter queries use query vs findAll like the rest of the app

* Make sure we have an element to pass to isInViewport

* Make sure href-mut doesn't error even if the currentRoute === null

* More post test cleanup and Safari fix (safari requires http:// URLs)

* Reverse order of datasource nspace/dc's and add a namespace source

* Rearrange routes/templates/controllers to only use HashicorpConsul once

* Add datasources and correct token namespace detection/redirection

* Remove old dc findAll adapter method

* Add more comments around the 'child route/parent controller' vars
johncowen added a commit that referenced this pull request May 12, 2020
* Make datacenter queries use query vs findAll like the rest of the app

* Make sure we have an element to pass to isInViewport

* Make sure href-mut doesn't error even if the currentRoute === null

* More post test cleanup and Safari fix (safari requires http:// URLs)

* Reverse order of datasource nspace/dc's and add a namespace source

* Rearrange routes/templates/controllers to only use HashicorpConsul once

* Add datasources and correct token namespace detection/redirection

* Remove old dc findAll adapter method

* Add more comments around the 'child route/parent controller' vars
@johncowen johncowen deleted the ui/feature/improved-main-nav branch June 8, 2020 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/ui Anything related to the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants