-
-
Notifications
You must be signed in to change notification settings - Fork 145
Fix template edit link #130
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ import Component from '@ember/component'; | |
| import layout from './template'; | ||
| import { computed } from '@ember/object'; | ||
| import appFiles from 'ember-cli-addon-docs/app-files'; | ||
| import { dasherize } from '@ember/string'; | ||
| import addonFiles from 'ember-cli-addon-docs/addon-files'; | ||
| import config from 'dummy/config/environment'; | ||
| import { getOwner } from '@ember/application'; | ||
|
|
||
|
|
@@ -23,20 +23,23 @@ export default Component.extend({ | |
| editCurrentPageUrl: computed('router.currentRouteName', function() { | ||
| let path = this.get('router.currentRouteName'); | ||
| if (!path) { | ||
| // `routing` doesn't exist for old ember versions via ember-try | ||
| // `router` doesn't exist for old ember versions via ember-try | ||
| return; | ||
| } | ||
|
|
||
| path = path.replace(/\./g, '/'); | ||
|
|
||
| if (path === 'docs/api/class') { | ||
| let params = getOwner(this).lookup('route:application').paramsFor('docs.api.class'); | ||
| let klass = dasherize(params.class_id.replace(/-.+$/g, '')); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| let path = `pods/${path}`; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As before, remove the assumption that the files are within |
||
| if (path === 'docs/api/item') { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| let { path } = getOwner(this).lookup('route:application').paramsFor('docs.api.item'); | ||
| let file = addonFiles.find(f => f.match(path)); | ||
|
|
||
| return `${packageJson.repository}/edit/master/addon/components/${klass}/component.js`; | ||
| if (file) { | ||
| return `${packageJson.repository}/edit/master/addon/${file}`; | ||
| } | ||
| } else { | ||
| let templatePath = `pods/${path}`; | ||
| let file = appFiles.find(file => file.match(`${templatePath}/template.(hbs|md)`)); | ||
| let file = appFiles | ||
| .filter(file => file.match(/template.(hbs|md)/)) | ||
| .find(file => file.match(path)); | ||
|
|
||
| return `${packageJson.repository}/edit/master/tests/dummy/app/${file}`; | ||
| } | ||
|
|
||
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.
Needed to add the logic to also expose the
addontree contents, otherwise you had to really guess a lot about what the current URL on Github would be. At least now we have a reference of the actual files to try and match against.