Skip to content

Commit 8a5e7cc

Browse files
committed
Auto merge of #4239 - Turbo87:router-deprecation, r=Turbo87
Fix `transitionTo()` and `replaceWith()` deprecations on routes These two methods on the `Route` base class are deprecated in favor of using the `router` service instead.
2 parents e41e0a7 + 1d04128 commit 8a5e7cc

File tree

12 files changed

+28
-13
lines changed

12 files changed

+28
-13
lines changed

app/routes/category.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { inject as service } from '@ember/service';
44

55
export default class CategoryRoute extends Route {
66
@service notifications;
7+
@service router;
78
@service store;
89

910
async model(params) {
@@ -12,7 +13,7 @@ export default class CategoryRoute extends Route {
1213
} catch (error) {
1314
if (error instanceof NotFoundError) {
1415
this.notifications.error(`Category '${params.category_id}' does not exist`);
15-
return this.replaceWith('index');
16+
return this.router.replaceWith('index');
1617
}
1718

1819
throw error;

app/routes/confirm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import ajax from '../utils/ajax';
55

66
export default class ConfirmRoute extends Route {
77
@service notifications;
8+
@service router;
89
@service session;
910
@service store;
1011

@@ -29,6 +30,6 @@ export default class ConfirmRoute extends Route {
2930
}
3031
}
3132

32-
this.replaceWith('index');
33+
this.router.replaceWith('index');
3334
}
3435
}

app/routes/crate/dependencies.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import Route from '@ember/routing/route';
2+
import { inject as service } from '@ember/service';
23

34
export default class VersionRoute extends Route {
5+
@service router;
6+
47
async model() {
58
let crate = this.modelFor('crate');
69
let versions = await crate.get('versions');
710

811
let { defaultVersion } = crate;
912
let version = versions.find(version => version.num === defaultVersion) ?? versions.lastObject;
1013

11-
this.replaceWith('crate.version-dependencies', crate, version.num);
14+
this.router.replaceWith('crate.version-dependencies', crate, version.num);
1215
}
1316
}

app/routes/crate/docs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { inject as service } from '@ember/service';
44
export default class CrateDocsRoute extends Route {
55
@service notifications;
66
@service redirector;
7+
@service router;
78

89
redirect() {
910
let crate = this.modelFor('crate');
@@ -16,7 +17,7 @@ export default class CrateDocsRoute extends Route {
1617
// no documentation is found
1718
let message = 'Crate does not supply a documentation URL';
1819
this.notifications.error(message);
19-
this.replaceWith('crate', crate);
20+
this.router.replaceWith('crate', crate);
2021
}
2122
}
2223
}

app/routes/crate/owners.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import Route from '@ember/routing/route';
2+
import { inject as service } from '@ember/service';
23

34
export default class OwnersRoute extends Route {
5+
@service router;
6+
47
redirect() {
58
let crate = this.modelFor('crate');
69

7-
this.transitionTo('crate.settings', crate);
10+
this.router.transitionTo('crate.settings', crate);
811
}
912
}

app/routes/crate/range.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class VersionRoute extends Route {
2323
let versionNum = maxSatisfying(unyankedVersionNums, npmRange) ?? maxSatisfying(allVersionNums, npmRange);
2424
if (!versionNum) {
2525
this.notifications.error(`No matching version of crate '${crate.name}' found for: ${range}`);
26-
this.replaceWith('crate.index');
26+
this.router.replaceWith('crate.index');
2727
}
2828

2929
this.router.replaceWith('crate.version', versionNum);

app/routes/crate/repo.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { inject as service } from '@ember/service';
44
export default class RepoRoute extends Route {
55
@service notifications;
66
@service redirector;
7+
@service router;
78

89
redirect() {
910
let crate = this.modelFor('crate');
@@ -16,7 +17,7 @@ export default class RepoRoute extends Route {
1617
// no repository is found
1718
let message = 'Crate does not supply a repository URL';
1819
this.notifications.error(message);
19-
this.replaceWith('crate', crate);
20+
this.router.replaceWith('crate', crate);
2021
}
2122
}
2223
}

app/routes/crate/reverse-dependencies.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { inject as service } from '@ember/service';
33

44
export default class ReverseDependenciesRoute extends Route {
55
@service notifications;
6+
@service router;
67
@service store;
78

89
queryParams = {
@@ -25,7 +26,7 @@ export default class ReverseDependenciesRoute extends Route {
2526
}
2627

2728
this.notifications.error(message);
28-
this.replaceWith('index');
29+
this.router.replaceWith('index');
2930
}
3031
}
3132

app/routes/crate/version-dependencies.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { inject as service } from '@ember/service';
33

44
export default class VersionRoute extends Route {
55
@service notifications;
6+
@service router;
67

78
async model(params) {
89
let crate = this.modelFor('crate');
@@ -12,7 +13,7 @@ export default class VersionRoute extends Route {
1213
let version = versions.find(version => version.num === requestedVersion);
1314
if (!version) {
1415
this.notifications.error(`Version '${requestedVersion}' of crate '${crate.name}' does not exist`);
15-
this.replaceWith('crate.index');
16+
this.router.replaceWith('crate.index');
1617
}
1718

1819
try {
@@ -21,7 +22,7 @@ export default class VersionRoute extends Route {
2122
this.notifications.error(
2223
`Failed to load the list of dependencies for the '${crate.name}' crate. Please try again later!`,
2324
);
24-
this.replaceWith('crate.index');
25+
this.router.replaceWith('crate.index');
2526
}
2627

2728
return version;

app/routes/keyword.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { inject as service } from '@ember/service';
44

55
export default class KeywordRoute extends Route {
66
@service notifications;
7+
@service router;
78
@service store;
89

910
async model({ keyword_id }) {
@@ -12,7 +13,7 @@ export default class KeywordRoute extends Route {
1213
} catch (error) {
1314
if (error instanceof NotFoundError) {
1415
this.notifications.error(`Keyword '${keyword_id}' does not exist`);
15-
return this.replaceWith('index');
16+
return this.router.replaceWith('index');
1617
}
1718

1819
throw error;

app/routes/team.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { inject as service } from '@ember/service';
33

44
export default class TeamRoute extends Route {
55
@service notifications;
6+
@service router;
67
@service store;
78

89
queryParams = {
@@ -24,7 +25,7 @@ export default class TeamRoute extends Route {
2425
} catch (error) {
2526
if (error.errors?.some(e => e.detail === 'Not Found')) {
2627
this.notifications.error(`Team '${params.team_id}' does not exist`);
27-
return this.replaceWith('index');
28+
return this.router.replaceWith('index');
2829
}
2930

3031
throw error;

app/routes/user.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { inject as service } from '@ember/service';
33

44
export default class UserRoute extends Route {
55
@service notifications;
6+
@service router;
67
@service store;
78

89
queryParams = {
@@ -23,7 +24,7 @@ export default class UserRoute extends Route {
2324
} catch (error) {
2425
if (error.errors?.some(e => e.detail === 'Not Found')) {
2526
this.notifications.error(`User '${params.user_id}' does not exist`);
26-
return this.replaceWith('index');
27+
return this.router.replaceWith('index');
2728
}
2829

2930
throw error;

0 commit comments

Comments
 (0)