mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 09:57:25 +08:00
DEV: Upgrade replaceRoute
on Controller (#22648)
Per https://deprecations.emberjs.com/v3.x/#toc_routing-transition-methods We are upgrading all `this.replaceRoute` calls on controllers to directly call the router service (`this.router.replaceRoute`)
This commit is contained in:
@ -7,6 +7,7 @@ import { inject as service } from "@ember/service";
|
|||||||
|
|
||||||
export default class AdminCustomizeColorsShowController extends Controller {
|
export default class AdminCustomizeColorsShowController extends Controller {
|
||||||
@service dialog;
|
@service dialog;
|
||||||
|
@service router;
|
||||||
onlyOverridden = false;
|
onlyOverridden = false;
|
||||||
|
|
||||||
@computed("model.colors.[]", "onlyOverridden")
|
@computed("model.colors.[]", "onlyOverridden")
|
||||||
@ -58,7 +59,7 @@ export default class AdminCustomizeColorsShowController extends Controller {
|
|||||||
);
|
);
|
||||||
newColorScheme.save().then(() => {
|
newColorScheme.save().then(() => {
|
||||||
this.allColors.pushObject(newColorScheme);
|
this.allColors.pushObject(newColorScheme);
|
||||||
this.replaceRoute("adminCustomize.colors.show", newColorScheme);
|
this.router.replaceRoute("adminCustomize.colors.show", newColorScheme);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ export default class AdminCustomizeColorsShowController extends Controller {
|
|||||||
didConfirm: () => {
|
didConfirm: () => {
|
||||||
return this.model.destroy().then(() => {
|
return this.model.destroy().then(() => {
|
||||||
this.allColors.removeObject(this.model);
|
this.allColors.removeObject(this.model);
|
||||||
this.replaceRoute("adminCustomize.colors");
|
this.router.replaceRoute("adminCustomize.colors");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -3,8 +3,11 @@ import EmberObject, { action } from "@ember/object";
|
|||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import showModal from "discourse/lib/show-modal";
|
import showModal from "discourse/lib/show-modal";
|
||||||
|
import { inject as service } from "@ember/service";
|
||||||
|
|
||||||
export default class AdminCustomizeColorsController extends Controller {
|
export default class AdminCustomizeColorsController extends Controller {
|
||||||
|
@service router;
|
||||||
|
|
||||||
@discourseComputed("model.@each.id")
|
@discourseComputed("model.@each.id")
|
||||||
baseColorScheme() {
|
baseColorScheme() {
|
||||||
return this.model.findBy("is_base", true);
|
return this.model.findBy("is_base", true);
|
||||||
@ -35,7 +38,7 @@ export default class AdminCustomizeColorsController extends Controller {
|
|||||||
newColorScheme.save().then(() => {
|
newColorScheme.save().then(() => {
|
||||||
this.model.pushObject(newColorScheme);
|
this.model.pushObject(newColorScheme);
|
||||||
newColorScheme.set("savingStatus", null);
|
newColorScheme.set("savingStatus", null);
|
||||||
this.replaceRoute("adminCustomize.colors.show", newColorScheme);
|
this.router.replaceRoute("adminCustomize.colors.show", newColorScheme);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,11 @@ import Controller from "@ember/controller";
|
|||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { url } from "discourse/lib/computed";
|
import { url } from "discourse/lib/computed";
|
||||||
|
import { inject as service } from "@ember/service";
|
||||||
|
|
||||||
export default class AdminCustomizeThemesEditController extends Controller {
|
export default class AdminCustomizeThemesEditController extends Controller {
|
||||||
|
@service router;
|
||||||
|
|
||||||
section = null;
|
section = null;
|
||||||
currentTarget = 0;
|
currentTarget = 0;
|
||||||
maximized = false;
|
maximized = false;
|
||||||
@ -48,7 +51,12 @@ export default class AdminCustomizeThemesEditController extends Controller {
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
fieldAdded(target, name) {
|
fieldAdded(target, name) {
|
||||||
this.replaceRoute(this.editRouteName, this.get("model.id"), target, name);
|
this.router.replaceRoute(
|
||||||
|
this.editRouteName,
|
||||||
|
this.get("model.id"),
|
||||||
|
target,
|
||||||
|
name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
@ -60,7 +68,7 @@ export default class AdminCustomizeThemesEditController extends Controller {
|
|||||||
(f) => f.edited
|
(f) => f.edited
|
||||||
);
|
);
|
||||||
|
|
||||||
this.replaceRoute(
|
this.router.replaceRoute(
|
||||||
this.editRouteName,
|
this.editRouteName,
|
||||||
this.get("model.id"),
|
this.get("model.id"),
|
||||||
firstTarget.name,
|
firstTarget.name,
|
||||||
@ -72,6 +80,6 @@ export default class AdminCustomizeThemesEditController extends Controller {
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
goBack() {
|
goBack() {
|
||||||
this.replaceRoute(this.showRouteName, this.model.id);
|
this.router.replaceRoute(this.showRouteName, this.model.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import discourseComputed from "discourse-common/utils/decorators";
|
|||||||
import getURL from "discourse-common/lib/get-url";
|
import getURL from "discourse-common/lib/get-url";
|
||||||
import { makeArray } from "discourse-common/lib/helpers";
|
import { makeArray } from "discourse-common/lib/helpers";
|
||||||
import { setting } from "discourse/lib/computed";
|
import { setting } from "discourse/lib/computed";
|
||||||
|
import { inject as service } from "@ember/service";
|
||||||
|
|
||||||
function staticReport(reportType) {
|
function staticReport(reportType) {
|
||||||
return computed("reports.[]", function () {
|
return computed("reports.[]", function () {
|
||||||
@ -18,6 +19,8 @@ function staticReport(reportType) {
|
|||||||
export default class AdminDashboardGeneralController extends Controller.extend(
|
export default class AdminDashboardGeneralController extends Controller.extend(
|
||||||
PeriodComputationMixin
|
PeriodComputationMixin
|
||||||
) {
|
) {
|
||||||
|
@service router;
|
||||||
|
@service siteSettings;
|
||||||
@controller("exception") exceptionController;
|
@controller("exception") exceptionController;
|
||||||
|
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
@ -137,7 +140,7 @@ export default class AdminDashboardGeneralController extends Controller.extend(
|
|||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
this.exceptionController.set("thrown", e.jqXHR);
|
this.exceptionController.set("thrown", e.jqXHR);
|
||||||
this.replaceRoute("exception");
|
this.router.replaceRoute("exception");
|
||||||
})
|
})
|
||||||
.finally(() => this.set("isLoading", false));
|
.finally(() => this.set("isLoading", false));
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,13 @@ import AdminDashboard from "admin/models/admin-dashboard";
|
|||||||
import VersionCheck from "admin/models/version-check";
|
import VersionCheck from "admin/models/version-check";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { setting } from "discourse/lib/computed";
|
import { setting } from "discourse/lib/computed";
|
||||||
|
import { inject as service } from "@ember/service";
|
||||||
|
|
||||||
const PROBLEMS_CHECK_MINUTES = 1;
|
const PROBLEMS_CHECK_MINUTES = 1;
|
||||||
|
|
||||||
export default class AdminDashboardController extends Controller {
|
export default class AdminDashboardController extends Controller {
|
||||||
|
@service router;
|
||||||
|
@service siteSettings;
|
||||||
@controller("exception") exceptionController;
|
@controller("exception") exceptionController;
|
||||||
|
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
@ -88,7 +91,7 @@ export default class AdminDashboardController extends Controller {
|
|||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
this.exceptionController.set("thrown", e.jqXHR);
|
this.exceptionController.set("thrown", e.jqXHR);
|
||||||
this.replaceRoute("exception");
|
this.router.replaceRoute("exception");
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.set("isLoading", false);
|
this.set("isLoading", false);
|
||||||
|
Reference in New Issue
Block a user