-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[UI] remove ember route action helper #23004
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] remove ember route action helper #23004
Conversation
|
LGTM |
| @action | ||
| delete(item) { | ||
| // Forwarders replacing route-action usage | ||
| @action onCreate(item, event) { |
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.
| @action onCreate(item, event) { | |
| @action | |
| onCreate(event, item) { |
two nit picks here it's not call to action but more of observation:
- having decorator on its own line is common format
- is there a reason you are passing event as a second arg? if there is no particular reason it would be more obvious in the future when we start using function on on modifers where event is always going to be first
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.
Fixed the decorator formatting.
Regarding (item, event) ordering
We are binding the item with onCreate when we are calling using fn in the corresponding template file:
@onCreate={{fn this.onCreate item}}
This will then come up as the first argument.
For consistency with how on modifiers work, I believe we will have to do refactoring at multiple places.
| import { getOwner } from '@ember/application'; | ||
|
|
||
| export default class TopologyController extends Controller { | ||
| get routeInstance() { |
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 shouldn't be a getter if it's not accessing any dynamic class member like tracked properties or other getters or args
- since we are not using it in many spots it would make sense to co locate with the invoke it like:
@action
createIntention(source, destination) {
const route = getOwner(this).lookup('route:dc.services.show.topology');
return route.createIntention(source, destination);
}|
|
||
| export default class DcAclsIndexRoute extends Route { | ||
| beforeModel() { | ||
| this.replaceWith('dc.acls.tokens'); |
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.
since you are creating a brand new route it would make sense not to introduce new deprecations so we have to inject router service instead of using route methods on the route it self so you would have something like:
@service router;
beforeModel() {
this.router.replaceWith('dc.acls.tokens');
| <Route | ||
| @name={{this.routeName}} | ||
| as |route|> | ||
| {{did-insert (route-action 'replaceWith' 'dc.acls.tokens')}} |
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.
don't we need to keep did-insert modifer? or are you handling it somewhere else
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, It is now handled directly in the route file here
| route.model.tomography | ||
| as |tomography|}} | ||
| {{#if (not tomography.distances)}} | ||
| {{did-insert (route-action 'replaceWith' 'dc.nodes.show')}} |
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.
same as above
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 also handled directly in the route like above.
| @isRemoteDC={{not dc.Local}} | ||
| @hasMetricsProvider={{gt config.data.metrics_provider.length 0}} | ||
| @oncreate={{route-action 'createIntention'}} | ||
| @oncreate={{fn this.createIntention}} |
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.
if you do not any arguments to the funtion you do not need fn you can just say:
| @oncreate={{fn this.createIntention}} | |
| @oncreate={{this.createIntention}} |
| {{! Listen out for blocking query/client setting changes }} | ||
| <DataSource | ||
| @src={{uri 'settings://consul:client'}} | ||
| @onchange={{fn this.onClientChanged}} |
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.
same
Description
We have been using ember-route-action-helper library for route-actions. This is no longer needed since the features of this addon are now provided directly by Ember.
Also, this library depends on a deprecated feature of Ember - deprecation id: ember-global
With no upgrades to this library in past few years, it can be removed now.
https://www.npmjs.com/package/ember-route-action-helper
Testing & Reproduction steps
Links
PR Checklist
PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
If applicable, I've documented the impact of any changes to security controls.
Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.