Skip to content

Commit e2ceca9

Browse files
committed
WIP stuff
1 parent 9b7e6ad commit e2ceca9

File tree

12 files changed

+99
-581
lines changed

12 files changed

+99
-581
lines changed

app/router.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,6 @@ AppRouter.map(function () {
9797
ember-cli
9898
project
9999
100-
/:project/:project_version
101-
/classes/:class
102-
/methods, /properties, /events
103-
/functions/:module (no sub routes)
104-
/namespaces/:namespace
105-
/methods, /properties, /events
106-
/modules/:module
107-
/methods, /properties, /events
108-
109-
SUB ROUTES
110-
111-
Instead of https://api.emberjs.com/ember/4.6/classes/Engine/methods/unregister?anchor=unregister
112-
We can do https://api.emberjs.com/ember/4.6/classes/Engine/methods?anchor=unregister
113-
114-
/methods/:method
115-
/properties/:property
116-
/events/:event
117-
118100
OTHER STATES
119101
private, deprecated, inherited, protected
120102
inherited is not reflected in URL state but it's checked by default

app/routes/project-version.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,69 @@ export default class ProjectVersionRoute extends Route {
133133
};
134134
}
135135

136+
@action
137+
updateProject(project, ver /*, component */) {
138+
let projectVersionID = ver.compactVersion;
139+
let endingRoute;
140+
switch (this.router.currentRouteName) {
141+
case 'project-version.classes.class': {
142+
let className = this._getEncodedNameForCurrentClass();
143+
endingRoute = `classes/${className}`;
144+
break;
145+
}
146+
case 'project-version.classes.class.index': {
147+
let className = this._getEncodedNameForCurrentClass();
148+
endingRoute = `classes/${className}`;
149+
break;
150+
}
151+
case 'project-version.modules.module.index': {
152+
let moduleName = encodeURIComponent(
153+
this.paramsFor('project-version.modules.module').module
154+
);
155+
endingRoute = `modules/${moduleName}`;
156+
break;
157+
}
158+
case 'project-version.namespaces.namespace.index': {
159+
let namespaceName = this.paramsFor(
160+
'project-version.namespaces.namespace'
161+
).namespace;
162+
endingRoute = `namespaces/${namespaceName}`;
163+
break;
164+
}
165+
default:
166+
endingRoute = '';
167+
break;
168+
}
169+
// if the user is navigating to/from api versions >= 2.16, take them
170+
// to the home page instead of trying to translate the url
171+
let shouldConvertPackages = this.shouldConvertPackages(
172+
ver,
173+
this.projectService.version
174+
);
175+
let isEmberProject = project === 'ember';
176+
if (!isEmberProject || !shouldConvertPackages) {
177+
this.router.transitionTo(
178+
`/${project}/${projectVersionID}/${endingRoute}`
179+
);
180+
} else {
181+
this.router.transitionTo(`/${project}/${projectVersionID}`);
182+
}
183+
}
184+
185+
// Input some version info, returns a boolean based on
186+
// whether the user is switching versions for a 2.16 docs release or later.
187+
// The urls for pre-2.16 classes and later packages are quite different
188+
shouldConvertPackages(targetVer, previousVer) {
189+
let targetVersion = getCompactVersion(targetVer.id);
190+
let previousVersion = getCompactVersion(previousVer);
191+
let previousComparison = semverCompare(previousVersion, '2.16');
192+
let targetComparison = semverCompare(targetVersion, '2.16');
193+
return (
194+
(previousComparison < 0 && targetComparison >= 0) ||
195+
(previousComparison >= 0 && targetComparison < 0)
196+
);
197+
}
198+
136199
/**
137200
splits the first encoded revision string in the list and takes the string after the version (which is the encoded name), then decodes the result.
138201
*/

app/utils/hash-to-url.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
"ember-qunit": "^5.1.5",
9595
"ember-resolver": "^8.0.3",
9696
"ember-rfc176-data": "^0.3.17",
97+
"ember-route-action-helper": "^2.0.8",
98+
"ember-scroll": "^1.0.3",
9799
"ember-showdown-shiki": "^1.2.1",
98100
"ember-sinon": "^4.1.1",
99101
"ember-source": "~3.28.8",

pnpm-lock.yaml

Lines changed: 34 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/acceptance/anchors-test.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/acceptance/items-test.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)