-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move sorted project versions to project model * add handling for current version param * use 'release' instead of 'current' for displaying latest version * make sure that links on /release also link to /release * add suport for LTS version * make version sorting work for ember data as well * add acceptance test for /lts and /release * add ember-router-service * add short circuit to env variable to lts version
- Loading branch information
1 parent
5a26538
commit ffd2eb5
Showing
15 changed files
with
162 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Ember from 'ember'; | ||
|
||
const { inject } = Ember; | ||
|
||
export default Ember.Helper.extend({ | ||
|
||
router: inject.service(), | ||
|
||
compute([modelName, paramName]) { | ||
return this.get(`router.router.state.params.${modelName}.${paramName}`); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,43 @@ | ||
import DS from 'ember-data'; | ||
import Ember from 'ember'; | ||
import semverCompare from 'npm:semver-compare'; | ||
import getMinorVersion from "../utils/get-minor-version"; | ||
import _ from 'lodash'; | ||
import config from 'ember-api-docs/config/environment'; | ||
|
||
|
||
const {Model, attr, hasMany} = DS; | ||
const {computed,A} = Ember; | ||
|
||
export default Model.extend({ | ||
name: attr(), | ||
githubUrl: attr(), | ||
projectVersions: hasMany('project-version', {async: true}) | ||
projectVersions: hasMany('project-version', {async: true}), | ||
|
||
latestProjectVersion: computed.alias('sortedProjectVersions.firstObject'), | ||
sortedProjectVersions: computed(function() { | ||
let projectVersions = this.hasMany('projectVersions').ids().map(id => { | ||
return id.replace(this.id, '').split('-')[1]; | ||
}); | ||
let sortedVersions = projectVersions.sort((a, b) => semverCompare(b, a)); | ||
sortedVersions = sortedVersions.map((version) => { | ||
const minorVersion = getMinorVersion(version); | ||
return { id: version, minorVersion }; | ||
}); | ||
|
||
let groupedVersions = _.groupBy(sortedVersions, version => version.minorVersion); | ||
|
||
return A(_.values(groupedVersions).map(groupedVersion => groupedVersion[0])); | ||
}), | ||
|
||
getProjectVersion(version) { | ||
if (version === 'release') { | ||
return this.get('latestProjectVersion.id'); | ||
} | ||
if (version === 'lts') { | ||
return config.ltsVersion; | ||
} | ||
return version; | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { test } from 'qunit'; | ||
import moduleForAcceptance from 'ember-api-docs/tests/helpers/module-for-acceptance'; | ||
import { click } from 'ember-native-dom-helpers'; | ||
import Ember from 'ember'; | ||
|
||
const {$} = Ember; | ||
|
||
moduleForAcceptance('Acceptance | release lts project versions'); | ||
|
||
test('release url param', function(assert) { | ||
visit('/ember/release/namespaces/Ember'); | ||
|
||
let checkLinks = (label, selector, versionString) => { | ||
return $('.attributes a').toArray().forEach(el => { | ||
let href = el.attributes.href.value; | ||
if (href[0] === '/') { | ||
|
||
assert.ok(href.indexOf(versionString) > -1, `${label} link contains ${versionString} - ${href}`); | ||
} | ||
}); | ||
}; | ||
|
||
let checkSidebarLinks = versionString => { | ||
return checkLinks('side', | ||
'.toc-level-1.modules li:first-child a, .toc-level-1.namespaces li:first-child a, .toc-level-1.classes li:first-child a', | ||
versionString); | ||
}; | ||
|
||
let checkAttributeLinks = versionString => { | ||
return checkLinks('attributes', '.attributes a', versionString); | ||
}; | ||
|
||
let checkIndexListLinks = versionString => { | ||
return checkLinks('index-list', '.api-index-filter a', versionString); | ||
}; | ||
|
||
let checkActiveClass = versionString => { | ||
return assert.ok($('.tabbed-layout__menu li:first-child').hasClass('tabbed-layout__menu__item_selected'), `active class works with ${versionString}`) | ||
}; | ||
|
||
andThen(function() { | ||
assert.equal(currentURL(), '/ember/release/namespaces/Ember'); | ||
|
||
checkSidebarLinks('release'); | ||
checkActiveClass('release'); | ||
checkIndexListLinks('release'); | ||
checkAttributeLinks('release'); | ||
|
||
return click('.tabbed-layout__menu__item:nth-child(2)'); //clicking methods | ||
}); | ||
|
||
andThen(() => { | ||
assert.equal(currentURL(), '/ember/release/namespaces/Ember/methods?anchor='); | ||
return visit('/ember-data/release/namespaces/DS'); | ||
}); | ||
|
||
andThen(() => { | ||
assert.equal(currentURL(), '/ember-data/release/namespaces/DS'); | ||
|
||
checkSidebarLinks('release'); | ||
checkActiveClass('release'); | ||
checkIndexListLinks('release'); | ||
checkAttributeLinks('release'); | ||
|
||
return visit('/ember/lts/namespaces/Ember'); | ||
}); | ||
|
||
return andThen(() => { | ||
assert.equal(currentURL(), '/ember/lts/namespaces/Ember'); | ||
|
||
checkSidebarLinks('lts'); | ||
checkActiveClass('lts'); | ||
checkIndexListLinks('lts'); | ||
checkAttributeLinks('lts'); | ||
|
||
return this; | ||
}); | ||
}); |
Oops, something went wrong.