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

Use via RouterDSL #56

Open
denzo opened this issue Apr 7, 2017 · 4 comments
Open

Use via RouterDSL #56

denzo opened this issue Apr 7, 2017 · 4 comments

Comments

@denzo
Copy link

denzo commented Apr 7, 2017

Hi there, we found ourselves writing the following code in routes, which is great. However, as the app grew we felt like we could all benefit from a birds eye view of all the routes that require abilities.

beforeModel: function() {
    if (!this.can('write post')) {
      this.transitionTo('index');
    }
  }

We thought the best place for overlooking those would be in the Router.map.

Router.map(function() {
  this.route('posts', { abilities: ['manage team', 'view post'] }, function() {
    this.route('create', { abilities: ['create post'] });
    this.route('show', { path: ':id', resourceAbilities: ['update post'] });
  });
});

We've implemented an extension of the RouterDSL in a similar manner to the way ember-torii does with authenticatedRoute.

I was wondering if you would be interested in including this type of functionality into this addon.

@blimmer
Copy link
Contributor

blimmer commented Apr 15, 2017

Hey @denzo and thanks for the information! I totally understand your use case for this and it's certainly an interesting solution.

My only concern is that this is modifying default Ember routing behavior. I wonder if there's a way to provide this behavior as an opt-in with another addon? I would happily link to this add-on in the README if people were interested in this kind of behavior.

What do you think?

@denzo
Copy link
Author

denzo commented Apr 15, 2017

That sounds perfectly reasonable. In fact that is how we designed our addon. ember-can is simply a dependency of ember-can-router-dsl.

Ok great, I'll ping you for some feedback when it's published.

@blimmer
Copy link
Contributor

blimmer commented Apr 15, 2017

That's awesome - please do ping me for some feedback once you've got something public. I'd be happy to have a look.

@rlivsey
Copy link
Member

rlivsey commented Apr 16, 2017

👍 awesome, definitely would work well as an addon.

Would be great to take a leaf from the ember-power-* addons and have a page listing extensions like this. Eg ember-power-select addons page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants