Skip to content

[WIP] Rename /modules to /packages (#285) #315

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

Closed

Conversation

amyrlam
Copy link
Member

@amyrlam amyrlam commented Aug 2, 2017

Resolves: #285

@amyrlam
Copy link
Member Author

amyrlam commented Aug 2, 2017

very WIP:

  • not sure about failing tests

  • want to have /modules/* manual input in url bar redirect to /packages/*, not sure how given that it's not a beforeModel

  • getting this strange error, ideas?

Warning: failed to stat /Users/alam/src/ember-api-docs/tmp/broccoli_merge_trees-input_base_path-7W5XmxWe.tmp/0/ember-api-docs/controllers/project-version/packages/package/events.js

@jenweber
Copy link
Contributor

jenweber commented Sep 4, 2017

@amyrlam
I see the "warning: failed to stat..." error all the time. I think it's safe to ignore for the scope of this.

I resolved a test failure for "lists all subpackages on the package page" by changing line 28:
let numberSubModules = Object.keys(container.get('submodules')).length; Submodules should be plural.

Here's one possible way to keep routes like "modules" around. As time goes on, we'll accumulate more of these urls that we need to support. You could create a wildcard in the router like this.route('catch-all', { path: '*:' });. Then in the catch-all, handle exceptions like modules/packages:

import Ember from 'ember';

export default Ember.Route.extend({
  beforeModel(transition) {
    let intended = transition.intent.url
    if (intended.match(/modules/i)) {
      let repaired = intended.replace('modules', 'packages')
      this.replaceWith(repaired)
    } else {
      this.transitionTo('404')
    }
  }
});

@sivakumar-kailasam @toddjordan what do you think about having a catch all route in the api docs?

@jenweber
Copy link
Contributor

jenweber commented Sep 4, 2017

Cc @locks regarding wildcard routes as a way to handle legacy urls. What do you think?

@amyrlam
Copy link
Member Author

amyrlam commented Sep 7, 2017

@jenweber heya, thanks for the feedback. please keep it coming!

i'm just getting back from a ~2wk vacation with almost no interweb access. will revisit this PR friday/this weekend

@jenweber
Copy link
Contributor

jenweber commented Sep 9, 2017

@amyrlam learning team feedback on my idea above is, wildcard routes can be messy and we shouldn't use them for this case.

In order to support both /packages and /models routes, the suggestion from the learning team chat is that the app should have 2 routes, one for packages and one for models. The only job of /modules will be to redirect. So the router would look something like

    this.route('packages', {path: '/packages'}, function() {
      this.route('module', {path: '/:module'}, itemRoutes);
    });
    this.route('modules')

The /:module dynamic segment can stay the same, since it's internal.

Does that make sense? I wasn't quite sure what you meant when you mentioned some issues with beforeModel in your comment above, and I haven't really dug into the routing structure of the app much myself. I think you can possibly use the redirect hook to catch the full intended transition.

@toddjordan
Copy link
Contributor

Thanks so much for this work, but we took a simpler approach by just renaming the labels and not changing our internal references. That way if we change our minds back it won't be a big deal :-P

@toddjordan toddjordan closed this Jan 20, 2018
Gaurav0 pushed a commit to Gaurav0/ember-api-docs that referenced this pull request Sep 16, 2019
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

Successfully merging this pull request may close these issues.

3 participants