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

fix: resolve ember-global deprecation #904

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 18.17.1
88 changes: 88 additions & 0 deletions app/controllers/project-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,92 @@ export default class ProjectVersionController extends Controller {
togglePrivateClasses() {
set(this, 'showPrivateClasses', !this.showPrivateClasses);
}

@action
updateProject(project, ver /*, component */) {
let projectVersionID = ver.compactVersion;
let endingRoute;
switch (this.router.currentRouteName) {
case 'project-version.classes.class': {
let className = this._getEncodedNameForCurrentClass();
endingRoute = `classes/${className}`;
break;
}
case 'project-version.classes.class.index': {
let className = this._getEncodedNameForCurrentClass();
endingRoute = `classes/${className}`;
break;
}
case 'project-version.modules.module.index': {
let moduleName = encodeURIComponent(
this.paramsFor('project-version.modules.module').module
);
endingRoute = `modules/${moduleName}`;
break;
}
case 'project-version.namespaces.namespace.index': {
let namespaceName = this.paramsFor(
'project-version.namespaces.namespace'
).namespace;
endingRoute = `namespaces/${namespaceName}`;
break;
}
case 'project-version.classes.class.methods.index': {
let className = this._getEncodedNameForCurrentClass();
endingRoute = `classes/${className}/methods`;
break;
}
case 'project-version.classes.class.events.index': {
let className = this._getEncodedNameForCurrentClass();
endingRoute = `classes/${className}/events`;
break;
}
case 'project-version.classes.class.properties.index': {
let className = this._getEncodedNameForCurrentClass();
endingRoute = `classes/${className}/properties`;
break;
}
case 'project-version.classes.class.methods.method': {
let className = this._getEncodedNameForCurrentClass();
let methodName = this.paramsFor(
'project-version.classes.class.methods.method'
).method;
endingRoute = `classes/${className}/methods/${methodName}?anchor=${methodName}`;
break;
}
case 'project-version.classes.class.events.event': {
let className = this._getEncodedNameForCurrentClass();
let eventName = this.paramsFor(
'project-version.classes.class.events.event'
).event;
endingRoute = `classes/${className}/events/${eventName}?anchor=${eventName}`;
break;
}
case 'project-version.classes.class.properties.property': {
let className = this._getEncodedNameForCurrentClass();
let propertyName = this.paramsFor(
'project-version.classes.class.properties.property'
).property;
endingRoute = `classes/${className}/properties/${propertyName}?anchor=${propertyName}`;
break;
}
default:
endingRoute = '';
break;
}
// if the user is navigating to/from api versions >= 2.16, take them
// to the home page instead of trying to translate the url
let shouldConvertPackages = this.shouldConvertPackages(
ver,
this.project.version
);
let isEmberProject = project === 'ember';
if (!isEmberProject || !shouldConvertPackages) {
this.router.transitionTo(
`/${project}/${projectVersionID}/${endingRoute}`
);
} else {
this.router.transitionTo(`/${project}/${projectVersionID}`);
}
}
}
21 changes: 19 additions & 2 deletions app/routes/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
@service
legacyModuleMappings;

title(tokens) {
let [version, entity] = tokens;
title() {
let entity = this.headData.modelName;
let version = this.headData.modelVersion;
if (!entity) {
entity = 'Ember';
}
Expand All @@ -30,6 +31,22 @@
async afterModel() {
set(this, 'headData.cdnDomain', ENV.API_HOST);
await this.legacyModuleMappings.initMappings();

let entity = this.headData.modelName;
let version = this.headData.modelVersion;
if (!entity) {
entity = 'Ember';
}
if (version) {
const compactVersion = getCompactVersion(version);
const title = `${[entity, compactVersion].join(
' - '
)} - Ember API Documentation`;
set(this, 'headData.title', title);
return title;
}
return '';

return super.afterModel(...arguments);

Check failure on line 50 in app/routes/application.js

View workflow job for this annotation

GitHub Actions / Lint files

Unreachable code
}
}
93 changes: 4 additions & 89 deletions app/routes/project-version.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import semverCompare from 'semver-compare';
Expand Down Expand Up @@ -44,6 +43,10 @@ export default class ProjectVersionRoute extends Route {
});
}

afterModel(model) {
this.headData.modelVersion = model.version;
}

// Using redirect instead of afterModel so transition succeeds and returns 307
redirect(model, transition) {
const lookupParams = (routeName) => {
Expand Down Expand Up @@ -144,94 +147,6 @@ export default class ProjectVersionRoute extends Route {
};
}

@action
updateProject(project, ver /*, component */) {
let projectVersionID = ver.compactVersion;
let endingRoute;
switch (this.router.currentRouteName) {
case 'project-version.classes.class': {
let className = this._getEncodedNameForCurrentClass();
endingRoute = `classes/${className}`;
break;
}
case 'project-version.classes.class.index': {
let className = this._getEncodedNameForCurrentClass();
endingRoute = `classes/${className}`;
break;
}
case 'project-version.modules.module.index': {
let moduleName = encodeURIComponent(
this.paramsFor('project-version.modules.module').module
);
endingRoute = `modules/${moduleName}`;
break;
}
case 'project-version.namespaces.namespace.index': {
let namespaceName = this.paramsFor(
'project-version.namespaces.namespace'
).namespace;
endingRoute = `namespaces/${namespaceName}`;
break;
}
case 'project-version.classes.class.methods.index': {
let className = this._getEncodedNameForCurrentClass();
endingRoute = `classes/${className}/methods`;
break;
}
case 'project-version.classes.class.events.index': {
let className = this._getEncodedNameForCurrentClass();
endingRoute = `classes/${className}/events`;
break;
}
case 'project-version.classes.class.properties.index': {
let className = this._getEncodedNameForCurrentClass();
endingRoute = `classes/${className}/properties`;
break;
}
case 'project-version.classes.class.methods.method': {
let className = this._getEncodedNameForCurrentClass();
let methodName = this.paramsFor(
'project-version.classes.class.methods.method'
).method;
endingRoute = `classes/${className}/methods/${methodName}?anchor=${methodName}`;
break;
}
case 'project-version.classes.class.events.event': {
let className = this._getEncodedNameForCurrentClass();
let eventName = this.paramsFor(
'project-version.classes.class.events.event'
).event;
endingRoute = `classes/${className}/events/${eventName}?anchor=${eventName}`;
break;
}
case 'project-version.classes.class.properties.property': {
let className = this._getEncodedNameForCurrentClass();
let propertyName = this.paramsFor(
'project-version.classes.class.properties.property'
).property;
endingRoute = `classes/${className}/properties/${propertyName}?anchor=${propertyName}`;
break;
}
default:
endingRoute = '';
break;
}
// if the user is navigating to/from api versions >= 2.16, take them
// to the home page instead of trying to translate the url
let shouldConvertPackages = this.shouldConvertPackages(
ver,
this.projectService.version
);
let isEmberProject = project === 'ember';
if (!isEmberProject || !shouldConvertPackages) {
this.router.transitionTo(
`/${project}/${projectVersionID}/${endingRoute}`
);
} else {
this.router.transitionTo(`/${project}/${projectVersionID}`);
}
}

// Input some version info, returns a boolean based on
// whether the user is switching versions for a 2.16 docs release or later.
// The urls for pre-2.16 classes and later packages are quite different
Expand Down
4 changes: 4 additions & 0 deletions app/routes/project-version/classes/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
return this.find('class', `${project}-${projectVersion}-${klass}`);
}

afterModel(model) {
this.headData.modelName = model.name;
}

find(typeName, param) {
return this.store.find(typeName, param).catch((e1) => {
if (typeName != 'namespace') {
Expand Down Expand Up @@ -91,7 +95,7 @@
}
}

afterModel(klass) {

Check failure on line 98 in app/routes/project-version/classes/class.js

View workflow job for this annotation

GitHub Actions / Lint files

Duplicate name 'afterModel'
if (!klass.isError) {
let description = klass.get('ogDescription') || klass.get('description');
if (description) {
Expand Down
2 changes: 2 additions & 0 deletions app/routes/project-version/functions/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export default class FunctionRoute extends Route {
if (description) {
set(this, 'headData.description', createExcerpt(description));
}

this.headData.functionName = model?.fn?.name;
}

getFunctionObjFromList(classObj, functionName) {
Expand Down
2 changes: 2 additions & 0 deletions app/services/head-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ export default class HeadDataService extends Service {
@tracked canonicalUrl;
@tracked description;
@tracked cdnDomain;
@tracked modelName;
@tracked modelVersion;
}
6 changes: 3 additions & 3 deletions app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<SearchInput />
</EsNavbar>
</EsHeader>
<main class="container">
<main class='container'>
{{outlet}}
</main>
<EsFooter />

{{!-- required by ember-cli-meta-tags --}}
<HeadLayout />
{{! required by ember-cli-meta-tags }}
<HeadLayout />
10 changes: 5 additions & 5 deletions app/templates/head.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<title>{{this.model.title}}</title>

<link rel="dns-prefetch" href="{{this.model.cdnDomain}}">
<meta property="og:title" content={{this.model.title}}>
<link rel='dns-prefetch' href='{{this.model.cdnDomain}}' />
<meta property='og:title' content={{this.model.title}} />

{{#if this.model.description}}
<meta name="description" content={{this.model.description}}>
<meta property="og:description" content={{this.model.description}}>
<meta name='description' content={{this.model.description}} />
<meta property='og:description' content={{this.model.description}} />
{{/if}}
{{#unless this.model.isRelease}}
<link rel="canonical" href={{this.model.canonicalUrl}}>
<link rel='canonical' href={{this.model.canonicalUrl}} />
{{/unless}}
2 changes: 1 addition & 1 deletion app/templates/project-version.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<div class="select-container">
<PowerSelect
@onChange={{route-action "updateProject" this.activeProject}}
@onChange={{fn this.updateProject this.activeProject}}
@options={{this.projectVersions}}
@selected={{this.selectedProjectVersion}}
@ariaLabel="Select a version"
Expand Down
2 changes: 1 addition & 1 deletion config/deprecation-workflow.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
self.deprecationWorkflow = self.deprecationWorkflow || {};
self.deprecationWorkflow.config = {
workflow: [
{ handler: 'silence', matchId: 'ember-global' },
{ handler: 'throw', matchId: 'ember-global' },
{ handler: 'silence', matchId: 'ember.component.reopen' },
{ handler: 'silence', matchId: 'implicit-injections' },
{ handler: 'silence', matchId: 'manager-capabilities.modifiers-3-13' },
Expand Down
18 changes: 7 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"broccoli-asset-rev": "^3.0.0",
"broccoli-funnel": "^2.0.1",
"broccoli-merge-trees": "^2.0.0",
"ember-a11y-testing": "^0.5.4",
"ember-a11y-testing": "^5.2.1",
"ember-anchor": "^1.0.3",
"ember-auto-import": "^2.7.2",
"ember-cli": "~3.28.6",
Expand All @@ -71,17 +71,16 @@
"ember-cli-babel": "^7.26.10",
"ember-cli-bourbon": "^2.0.1",
"ember-cli-browserstack": "^1.0.1",
"ember-cli-clipboard": "^0.8.1",
"ember-cli-clipboard": "^1.1.0",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-deploy": "^1.0.1",
"ember-cli-deploy-build": "^1.1.0",
"ember-cli-deploy-gzip": "^1.0.0",
"ember-cli-deprecation-workflow": "^2.1.0",
"ember-cli-document-title-northm": "^1.0.3",
"ember-cli-fastboot": "^4.1.5",
"ember-cli-head": "^2.0.0",
"ember-cli-htmlbars": "^6.1.1",
"ember-cli-inject-live-reload": "^2.1.0",
"ember-cli-meta-tags": "^7.0.0",
"ember-cli-sass": "^10.0.1",
"ember-cli-showdown": "^9.0.1",
"ember-cli-terser": "^4.0.2",
Expand All @@ -91,25 +90,22 @@
"ember-data-fastboot": "https://github.com/cardstack/ember-data-fastboot#6e6fb8bbf0b405ae174160cc1e4833c5582f68cd",
"ember-export-application-global": "^2.0.1",
"ember-fetch": "^8.1.1",
"ember-inflector": "^3.0.0",
"ember-load-initializers": "^2.1.2",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-metrics": "^1.5.2",
"ember-page-title": "^6.2.2",
"ember-power-select": "^6.0.1",
"ember-power-select": "^7.2.0",
"ember-qunit": "^5.1.5",
"ember-resolver": "^8.0.3",
"ember-rfc176-data": "^0.3.17",
"ember-route-action-helper": "^2.0.5",
"ember-showdown-shiki": "^1.2.1",
"ember-sinon": "^4.1.1",
"ember-source": "~3.28.8",
"ember-styleguide": "^3.3.0",
"ember-styleguide": "3.3.0",
"ember-svg-jar": "^2.4.2",
"ember-template-lint": "^3.15.0",
"ember-test-selectors": "^6.0.0",
"ember-tether": "1.0.0",
"ember-truth-helpers": "^2.1.0",
"ember-tether": "2.0.1",
"ember-truth-helpers": "^4.0.3",
"ember-web-app": "^2.0.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
Expand Down
Loading
Loading