1
0
Fork 0

resolve a batch of router deprecations

Dieser Commit ist enthalten in:
merefield 2023-09-14 14:42:12 +01:00
Ursprung 31f917ec80
Commit e6f44b7dfc
10 geänderte Dateien mit 42 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -1,7 +1,10 @@
import CustomWizardApi from "../models/custom-wizard-api"; import CustomWizardApi from "../models/custom-wizard-api";
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from '@ember/service';
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
model(params) { model(params) {
if (params.name === "create") { if (params.name === "create") {
return CustomWizardApi.create({ isNew: true }); return CustomWizardApi.create({ isNew: true });
@ -12,7 +15,7 @@ export default DiscourseRoute.extend({
afterModel(model) { afterModel(model) {
if (model === null) { if (model === null) {
return this.transitionTo("adminWizardsApi"); return this.router.transitionTo("adminWizardsApi");
} }
}, },

Datei anzeigen

@ -1,7 +1,10 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import CustomWizardApi from "../models/custom-wizard-api"; import CustomWizardApi from "../models/custom-wizard-api";
import { inject as service } from '@ember/service';
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
model() { model() {
return CustomWizardApi.list(); return CustomWizardApi.list();
}, },
@ -25,11 +28,11 @@ export default DiscourseRoute.extend({
actions: { actions: {
changeApi(apiName) { changeApi(apiName) {
this.controllerFor("adminWizardsApi").set("apiName", apiName); this.controllerFor("adminWizardsApi").set("apiName", apiName);
this.transitionTo("adminWizardsApiShow", apiName); this.router.transitionTo("adminWizardsApiShow", apiName);
}, },
afterDestroy() { afterDestroy() {
this.transitionTo("adminWizardsApi").then(() => this.refresh()); this.router.transitionTo("adminWizardsApi").then(() => this.refresh());
}, },
afterSave(apiName) { afterSave(apiName) {
@ -38,7 +41,7 @@ export default DiscourseRoute.extend({
createApi() { createApi() {
this.controllerFor("adminWizardsApi").set("apiName", "create"); this.controllerFor("adminWizardsApi").set("apiName", "create");
this.transitionTo("adminWizardsApiShow", "create"); this.router.transitionTo("adminWizardsApiShow", "create");
}, },
}, },
}); });

Datei anzeigen

@ -1,15 +1,18 @@
import CustomWizardLogs from "../models/custom-wizard-logs"; import CustomWizardLogs from "../models/custom-wizard-logs";
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { A } from "@ember/array"; import { A } from "@ember/array";
import { inject as service } from '@ember/service';
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
model(params) { model(params) {
return CustomWizardLogs.list(params.wizardId); return CustomWizardLogs.list(params.wizardId);
}, },
afterModel(model) { afterModel(model) {
if (model === null) { if (model === null) {
return this.transitionTo("adminWizardsLogs"); return this.router.transitionTo("adminWizardsLogs");
} }
}, },

Datei anzeigen

@ -1,7 +1,10 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import { inject as service } from '@ember/service';
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
model() { model() {
return ajax(`/admin/wizards/wizard`); return ajax(`/admin/wizards/wizard`);
}, },
@ -18,7 +21,7 @@ export default DiscourseRoute.extend({
actions: { actions: {
changeWizard(wizardId) { changeWizard(wizardId) {
this.controllerFor("adminWizardsLogs").set("wizardId", wizardId); this.controllerFor("adminWizardsLogs").set("wizardId", wizardId);
this.transitionTo("adminWizardsLogsShow", wizardId); this.router.transitionTo("adminWizardsLogsShow", wizardId);
}, },
}, },
}); });

Datei anzeigen

@ -2,15 +2,18 @@ import { A } from "@ember/array";
import CustomWizardAdmin from "../models/custom-wizard-admin"; import CustomWizardAdmin from "../models/custom-wizard-admin";
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { formatModel } from "../lib/wizard-submission"; import { formatModel } from "../lib/wizard-submission";
import { inject as service } from '@ember/service';
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
model(params) { model(params) {
return CustomWizardAdmin.submissions(params.wizardId); return CustomWizardAdmin.submissions(params.wizardId);
}, },
afterModel(model) { afterModel(model) {
if (model === null) { if (model === null) {
return this.transitionTo("adminWizardsSubmissions"); return this.router.transitionTo("adminWizardsSubmissions");
} }
}, },

Datei anzeigen

@ -1,7 +1,10 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import { inject as service } from '@ember/service';
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
model() { model() {
return ajax(`/admin/wizards/wizard`); return ajax(`/admin/wizards/wizard`);
}, },
@ -18,7 +21,7 @@ export default DiscourseRoute.extend({
actions: { actions: {
changeWizard(wizardId) { changeWizard(wizardId) {
this.controllerFor("adminWizardsSubmissions").set("wizardId", wizardId); this.controllerFor("adminWizardsSubmissions").set("wizardId", wizardId);
this.transitionTo("adminWizardsSubmissionsShow", wizardId); this.router.transitionTo("adminWizardsSubmissionsShow", wizardId);
}, },
}, },
}); });

Datei anzeigen

@ -2,8 +2,11 @@ import CustomWizardAdmin from "../models/custom-wizard-admin";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n"; import I18n from "I18n";
import { inject as service } from '@ember/service';
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
model(params) { model(params) {
if (params.wizardId === "create") { if (params.wizardId === "create") {
return { create: true }; return { create: true };
@ -14,7 +17,7 @@ export default DiscourseRoute.extend({
afterModel(model) { afterModel(model) {
if (model.none) { if (model.none) {
return this.transitionTo("adminWizardsWizard"); return this.router.transitionTo("adminWizardsWizard");
} }
}, },

Datei anzeigen

@ -4,8 +4,11 @@ import EmberObject, { set } from "@ember/object";
import { A } from "@ember/array"; import { A } from "@ember/array";
import { all } from "rsvp"; import { all } from "rsvp";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import { inject as service } from '@ember/service';
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
model() { model() {
return ajax("/admin/wizards/wizard"); return ajax("/admin/wizards/wizard");
}, },
@ -80,14 +83,14 @@ export default DiscourseRoute.extend({
this.controllerFor("adminWizardsWizard").set("wizardId", wizardId); this.controllerFor("adminWizardsWizard").set("wizardId", wizardId);
if (wizardId) { if (wizardId) {
this.transitionTo("adminWizardsWizardShow", wizardId); this.router.transitionTo("adminWizardsWizardShow", wizardId);
} else { } else {
this.transitionTo("adminWizardsWizard"); this.router.transitionTo("adminWizardsWizard");
} }
}, },
afterDestroy() { afterDestroy() {
this.transitionTo("adminWizardsWizard").then(() => this.refresh()); this.router.transitionTo("adminWizardsWizard").then(() => this.refresh());
}, },
afterSave(wizardId) { afterSave(wizardId) {
@ -96,7 +99,7 @@ export default DiscourseRoute.extend({
createWizard() { createWizard() {
this.controllerFor("adminWizardsWizard").set("wizardId", "create"); this.controllerFor("adminWizardsWizard").set("wizardId", "create");
this.transitionTo("adminWizardsWizardShow", "create"); this.router.transitionTo("adminWizardsWizardShow", "create");
}, },
}, },
}); });

Datei anzeigen

@ -1,7 +1,10 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import { inject as service } from '@ember/service';
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
model() { model() {
return ajax("/admin/wizards"); return ajax("/admin/wizards");
}, },
@ -17,7 +20,7 @@ export default DiscourseRoute.extend({
afterModel(model, transition) { afterModel(model, transition) {
if (transition.targetName === "adminWizards.index") { if (transition.targetName === "adminWizards.index") {
this.transitionTo("adminWizardsWizard"); this.router.transitionTo("adminWizardsWizard");
} }
}, },
}); });

Datei anzeigen

@ -30,7 +30,7 @@ export default Route.extend({
afterModel(model) { afterModel(model) {
if (model.completed) { if (model.completed) {
return this.transitionTo("wizard.index"); return this.router.transitionTo("wizard.index");
} }
return model.set("wizardId", this.wizard.id); return model.set("wizardId", this.wizard.id);
}, },