-
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
Refactor: Breadcrumbs Service #11590
Conversation
Ember Asset Size actionAs of 3bdf661 Files that got Bigger 🚨:
Files that stayed the same size 🤷:
|
Searchable, | ||
WithNamespaceResetting | ||
) { | ||
/* eslint-disable indent */ |
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.
Creating a follow-up task for this. Not valuable to tackle now.
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.
https://github.com/prettier/eslint-config-prettier would probably help with this.
Ember Test Audit comparison
|
Ember Test Audit flaky testsEmber Test Audit detected these flaky tests on 8a29d25:
|
Ember Test Audit flaky testsEmber Test Audit detected these flaky tests on main:
|
@ChaiWithJai just to help us (@hashicorp/pl-applications-frontend) understand how to prioritize review for this:
|
Copying from a Slack conversation with @ChaiWithJai, for reference:
|
|
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.
Great job on the refactoring!
I added some small comments and knit-picks, but the main ones are:
- the
is-active
class got dropped from the active crumb - the a11y lint rule should still be set and used in tests
- the auto-format in some of the template files made them a little weird and harder to read, I think it would be worth undoing those changes but I'm interesting in hearing what others think.
Searchable, | ||
WithNamespaceResetting | ||
) { | ||
/* eslint-disable indent */ |
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.
https://github.com/prettier/eslint-config-prettier would probably help with this.
<th>ID</th> | ||
<th>Created</th> | ||
<th>Modified</th> | ||
<th>Status</th> | ||
<th>Client</th> | ||
<th>Job</th> | ||
<th>Version</th> | ||
<th>CPU</th> | ||
<th>Memory</th> | ||
<th> | ||
ID | ||
</th> | ||
<th> | ||
Created | ||
</th> | ||
<th> | ||
Modified | ||
</th> | ||
<th> | ||
Status | ||
</th> | ||
<th> | ||
Client | ||
</th> | ||
<th> | ||
Job | ||
</th> | ||
<th> | ||
Version | ||
</th> | ||
<th> | ||
CPU | ||
</th> | ||
<th> | ||
Memory | ||
</th> |
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 find that this (and other table header changes) make the file harder to read. Is this something that can be disabled in your code formater?
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 have major issues with my eslint and prettier config. I'm planning to tackle this in one swoop later. But, I can spend the day tomorrow and figure this out.
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.
Cool, let me know if you need help. It may be easier to do it with an interactive rebase with git than manually revert them.
ui/app/controllers/servers/server.js
Outdated
get breadcrumb() { | ||
return { | ||
label: this.server.name, | ||
args: ['servers.server', this.server.id], | ||
}; | ||
} | ||
} |
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.
Is there a criteria fro when to use a list vs. a single object? The other controllers seem to use a list even if there's only one item. Perhaps this is something that should be standardized
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.
There's no criteria of when to use a single object versus a list. We use a list when we're in a route that wants to show that it is part of a hierarchy that it's not actually a part of in router.js
.
Generally, that's the only use case for using a list. Everything else should render to depict the route's model
.
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.
Yeah... I see the inconsistencies. Gonna re-do all the commits and clean this up tomorrow.
ui/tests/.eslintrc.js
Outdated
rules: { | ||
'ember-a11y-testing/a11y-audit-called': 'error', | ||
}, |
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 think we want to keep this, and only disable in specific cases.
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.
Hey, great callout. Upon examining this package in our package.json
this package is pointing to a commit in a repo and not the npm registry. No other HashiCorp product has this pattern. Its worth creating a follow-up issue to edit this behavior and be in line with HashiCorp's a11y standards.
Currently, this rule creates a lot of noise in our tests.
|
||
await waitFor('[data-test-job-breadcrumb]'); |
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.
Maybe move this up to keep all related assert
close together.
); | ||
|
||
await componentA11yAudit(this.element, assert); |
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.
This is probably why the linter was complaining.
font-size: x-large; | ||
} | ||
|
||
li:last-child a.active { |
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 LinkTo
component is connected to the route layer and gets an active property if the route is active.
We use last-child
if we're in a nested route because the parent route will also be set to active.
There's a namespace related issue where if the namespace
query parameter is not forwarded then LinkTo
will not be set to active. This is the same root cause as noted in 11327 and is noted by the Ember Core team.
We're watching the issue and all links will be properly highlighted when the issue is resolved by Ember Core and we don't think its worthwhile to create a workaround solution as this will be fixed by Core soon.
All breadcrumbs do not need a title property because some views drill down by using a tab-based UI (e.g. CSI volumes and the Job Overview) The goal is to help us identify breadcrumbs that are non-descriptive (i.e. breadcrumbs that display as an ID).
851db8e
to
4d39d88
Compare
Ember Test Audit flaky testsEmber Test Audit detected these flaky tests on 3bdf661:
|
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.
Nice improvement! Just for reference, code formatting changes will be handled in #11754
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. |
Background
Nomad and Waypoint both share a similar implementation of the Breadcrumbs service. Breadcrumbs are a navigation UI pattern to help users easily understand where they are when they’re inside of a deeply nested route.
Currently, Nomad and Waypoint use a Breadcrumbs service that uses the Router service to access the currentRoute and currentUrl and creates a computed derived state of a breadcrumbs array that is consumed by an AppBreadcrumbs component.
This pattern requires that Nomad and Waypoint both store state on the router. This breaks the Router/Controller boundary and the current use of the Router service breaks the Data Down, Actions Up paradigm by directly injecting the route into a service and passing the information into a component.
A Different Solution
Instead of violating the boundary between controllers and routers, we can use Renderless Components that consume our Breadcrumbs Service.
Our Breadcrumbs Service will be responsible for storing our breadcrumbs along with 2 functions: registering and deregistering breadcrumbs.
All Routes have templates that are rendered while the route is active, we can use a renderless component that consumes the Breadcrumbs Service and take advantage of 2 lifecycle methods: did-insert and will-destroy.
Whenever, a Route is initialized the component will intialize and register its trail of breadcrumbs to the breadcrumbs service. If we navigate away from the route, the component will unmount and unregister from our breadcrumbs trail.
Prior Art
We already follow this pattern in HCP