DEV: Resolve transitionTo deprecation (#185)

This commit is contained in:
David Taylor 2023-12-01 18:30:36 +00:00 committed by GitHub
parent 316303da5d
commit 2ea8d7b6eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 14 deletions

View File

@ -1,7 +1,10 @@
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { popupAjaxError } from "discourse/lib/ajax-error"; import { popupAjaxError } from "discourse/lib/ajax-error";
import { inject as service } from "@ember/service";
export default Controller.extend({ export default Controller.extend({
router: service(),
actions: { actions: {
createPlan() { createPlan() {
if (this.get("model.plan.product_id") === undefined) { if (this.get("model.plan.product_id") === undefined) {
@ -12,7 +15,9 @@ export default Controller.extend({
this.get("model.plan") this.get("model.plan")
.save() .save()
.then(() => { .then(() => {
this.transitionToRoute("adminPlugins.discourse-subscriptions.plans"); this.router.transitionTo(
"adminPlugins.discourse-subscriptions.plans"
);
}) })
.catch(popupAjaxError); .catch(popupAjaxError);
}, },

View File

@ -1,17 +1,20 @@
import { popupAjaxError } from "discourse/lib/ajax-error"; import { popupAjaxError } from "discourse/lib/ajax-error";
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { inject as service } from "@ember/service";
export default Controller.extend({ export default Controller.extend({
router: service(),
actions: { actions: {
cancelProduct() { cancelProduct() {
this.transitionToRoute("adminPlugins.discourse-subscriptions.products"); this.router.transitionTo("adminPlugins.discourse-subscriptions.products");
}, },
createProduct() { createProduct() {
this.get("model.product") this.get("model.product")
.save() .save()
.then((product) => { .then((product) => {
this.transitionToRoute( this.router.transitionTo(
"adminPlugins.discourse-subscriptions.products.show", "adminPlugins.discourse-subscriptions.products.show",
product.id product.id
); );
@ -23,7 +26,7 @@ export default Controller.extend({
this.get("model.product") this.get("model.product")
.update() .update()
.then(() => { .then(() => {
this.transitionToRoute( this.router.transitionTo(
"adminPlugins.discourse-subscriptions.products" "adminPlugins.discourse-subscriptions.products"
); );
}) })

View File

@ -8,6 +8,7 @@ import { inject as service } from "@ember/service";
export default Controller.extend({ export default Controller.extend({
dialog: service(), dialog: service(),
router: service(),
selectedPlan: null, selectedPlan: null,
promoCode: null, promoCode: null,
cardholderName: null, cardholderName: null,
@ -98,7 +99,7 @@ export default Controller.extend({
this.alert("plans.success"); this.alert("plans.success");
this.set("loading", false); this.set("loading", false);
this.transitionToRoute( this.router.transitionTo(
plan.type === "recurring" plan.type === "recurring"
? "user.billing.subscriptions" ? "user.billing.subscriptions"
: "user.billing.payments", : "user.billing.payments",

View File

@ -1,11 +1,16 @@
import Route from "@ember/routing/route"; import Route from "@ember/routing/route";
import { action } from "@ember/object"; import { action } from "@ember/object";
import { inject as service } from "@ember/service";
export default Route.extend({ export default Route.extend({
router: service(),
@action @action
showSettings() { showSettings() {
const controller = this.controllerFor("adminSiteSettings"); const controller = this.controllerFor("adminSiteSettings");
this.transitionTo("adminSiteSettingsCategory", "plugins").then(() => { this.router
.transitionTo("adminSiteSettingsCategory", "plugins")
.then(() => {
controller.set("filter", "plugin:discourse-subscriptions campaign"); controller.set("filter", "plugin:discourse-subscriptions campaign");
controller.set("_skipBounce", true); controller.set("_skipBounce", true);
controller.filterContentNow("plugins"); controller.filterContentNow("plugins");

View File

@ -1,7 +1,10 @@
import Route from "@ember/routing/route"; import Route from "@ember/routing/route";
import Product from "discourse/plugins/discourse-subscriptions/discourse/models/product"; import Product from "discourse/plugins/discourse-subscriptions/discourse/models/product";
import { inject as service } from "@ember/service";
export default Route.extend({ export default Route.extend({
router: service(),
model() { model() {
return Product.findAll(); return Product.findAll();
}, },
@ -11,12 +14,12 @@ export default Route.extend({
const product = products[0]; const product = products[0];
if (this.currentUser && product.subscribed && !product.repurchaseable) { if (this.currentUser && product.subscribed && !product.repurchaseable) {
this.transitionTo( this.router.transitionTo(
"user.billing.subscriptions", "user.billing.subscriptions",
this.currentUser.username this.currentUser.username
); );
} else { } else {
this.transitionTo("subscribe.show", product.id); this.router.transitionTo("subscribe.show", product.id);
} }
} }
}, },

View File

@ -1,9 +1,11 @@
import Route from "@ember/routing/route"; import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
export default Route.extend({ export default Route.extend({
router: service(),
templateName: "user/billing/index", templateName: "user/billing/index",
redirect() { redirect() {
this.transitionTo("user.billing.subscriptions.index"); this.router.transitionTo("user.billing.subscriptions.index");
}, },
}); });

View File

@ -6,13 +6,14 @@ import { inject as service } from "@ember/service";
export default Route.extend({ export default Route.extend({
dialog: service(), dialog: service(),
router: service(),
model() { model() {
return UserSubscription.findAll(); return UserSubscription.findAll();
}, },
@action @action
updateCard(subscriptionId) { updateCard(subscriptionId) {
this.transitionTo("user.billing.subscriptions.card", subscriptionId); this.router.transitionTo("user.billing.subscriptions.card", subscriptionId);
}, },
@action @action
cancelSubscription(subscription) { cancelSubscription(subscription) {