-
Notifications
You must be signed in to change notification settings - Fork 2k
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: Refactor breadcrumbs #4458
UI: Refactor breadcrumbs #4458
Conversation
Hey @DingoEatingFuzz I've had a brief look over this and have a few initial thoughts. The main thing is right now I've tried this branch and I'm not sure if I'm seeing things correctly. When I first checked the branch and tried the breadcrumbs I kept getting a grey error page when clicking the penultimate breadcrumb. So I checked out master again, and strangely kept getting a similar grey error page when doing the same. I didn't think to screengrab this at the time, but it doesn't look like this is happening now, must've been something I'd done I rechecked out this branch, deleted the First time round I got this: I checked this with the public nomad demo site and I'm pretty sure I should see more breadcrumbs here? I restarted the app and tried again, and this time I get this: I'm pretty sure that it still should give me more breadcrumbs, but even more strange is that its giving my 1 extra than before? I don't know maybe I've misunderstood what I should be seeing. Feel free to ping me when you are about and we can check over together if it helps. Apart from this I think its definitely a good move to refactor this a little. I found I'd get lost quite easily when working on this a few months ago. I've had a quick scan over your approach here, before saying the following I'd caveat it with 'different strokes for different folks' so please take it as different thinking rather than anything else.
I'll have another look a bit later on and see if I can figure why I'm getting inconsistencies, it might be something I'm doing wrong, but definitely shout me later if you want and we can talk through it more. Cheers |
Those screenshots are definitely off. I just ran through everything again locally and everything looks right. I also proxied to the demo cluster (
Ember is a conventions over configuration framework, so ideally the amount of "different strokes for different folks" decision-making is minimal.
Yes. Right now the component can accept a breadcrumbs attribute to make it a little more reusable. However, in practice this doesn't happen. The whole point of this work was to get repetitive breadcrumbs code out of templates and into a higher-level place. An alternative that gets part of the way there would be to remove the dependency
I disagree. The component is coupled to a service and that service gets breadcrumbs from Routes, but the component doesn't know that. If the service were to generate breadcrumbs in some other way (as seen in integration tests) the component works fine. That's strong evidence that there isn't a tight coupling to routes.
I'm assuming by control here you mean the content? In that case, as mentioned, breadcrumbs can be overridden from the outside.
Yep, exactly this.
Definitely something worth being cautious of. I think the delineation of a route being responsible for its own breadcrumbs, a service responsible for assembling the full breadcrumb trail, and a component responsible for rendering the trail is ideal separation of concerns. This model is supported by both crumbly and TFE.
Right now it only has job related code, but it could have varying stuff in the future. It almost had task-group related code, but that code turned out to not be as reusable as I had hoped.
In your mind, what is the "view layer"? At the very least, the route would have to pass it to the controller to pass it to a template. This sounds like a lot of repetitive code.
So you would like to see a
What are the "breadrumbs models"? The
I don't think a single service having nuanced code for turning any model type into every possible breadcrumb is a good idea. This service would balloon over time and become a "god object". With an interface like this, where the only provided arguments are
I don't see how that is a benefit? So a future diff may be I think a Routes are meant to bridge the gap between URLs and application state. Since breadcrumbs are a function of a URL (or at least a function of location in an application), they are aligned with this bridge between URLs and application state. Services meanwhile have no defined purpose. They are the "miscellaneous" datatype. Anything and everything could go in a service, which makes them a poor way to organize an application. They are certainly useful and I'm obviously not advocating an anti-service stance since this PR introduces a service. Just as a general practice--much like being cautious of coupling is a general practice--you should be cautious of over-using services. You could easily create entire applications with services alone, leaving Routes and Controller with nothing left to do but be in the right place for the framework to call into them. But at this point, why use the framework? |
Hey @DingoEatingFuzz I'm finishing for the day, but couple of points. There's nothing I'd particularly 'like to see', I'm more bouncing ideas around and offering a different viewpoint in case it helps - if it doesn't then no problem! I've just checked deleted the entire nomad repo here locally, re-cloned and checked out the same I don't get the same outcome as before, as far as I can see, but this time I get this happening: Anyway, speak Monday 👋 |
Hm. I haven't seen that state, but it could be a bug. Did you get there by clicking through a job to the allocation? |
Hey @DingoEatingFuzz , I just tried again now. Not sure if this the only way, but I changed the namespace to 'namespace-1', then went into Clients. Clicked the top client, then clicked the top allocation. When I did this the second place in the breadcrumb trail was blank, like the image above. Thinking on, should the breadcrumb read 'Clients > ClientID > AllocationID' when I go this route? Thanks, |
…utes Works by segmenting the currentRouteName from the router service and walking over each route in the current hierarchy to collect crumbs.
… not Example: parent job to child job navigation
Now that breadcrumbs are a zero config component, the corresponding template can be moved up to parent routes.
eda9aeb
to
4eaf2e4
Compare
This has been rebased against master to include the bugfix in #4475. You should no longer be able to get to an allocation with a missing breadcrumb!
It makes more sense given the architecture of Nomad for allocation breadcrumbs to extend the job/task-group trail. This also isn't new behavior to this PR. |
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.
Apologies for the wait! I've had a good click around an I always get filled up breadcrumbs now so 👍
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
The primary motivation for this refactor was to reduce a bunch of copy/pasting.
The existing implementation made sense in the early days when breadcrumbs were unknown and the full extent of how they would be used was being figured out. Now that the design has settled and there are many pages in the UI, a refactor is due.
High-level Overview
currentRouteName
andcurrentURL
to know when the page has changed. When the page changes, it looks up all the routes in the current hierarchy and concatenates crumbs. This is similar to how to ember-crumbly works, but different enough that it didn't make sense to try and make using ember-crumbly work.app-breadcrumbs
component gets the breadcrumbs information from the breadcrumbs service and renders them. Breadcrumbs can be objects with a label andlink-to
args or a PromiseProxyObject that resolves with the appropriate object.jobs.hbs
.The diff only has more insertions than deletions because test coverage went up. Full controllers were deleted since they were only used to manage breadcrumbs.
Unusual Features
link-to
args aren't determined strictly by the route. This is partly because of the previous unusual feature and also because of the namespace query param.