Skip to content

A platform for community discussion. Free, open, simple.

DEV: migrate (almost all) routes from `actions:` to `@action` syntax (#14722)

Andrei Prigorshnev284ab8cdf74d
diff --git a/app/assets/javascripts/discourse/app/routes/about.js b/app/assets/javascripts/discourse/app/routes/about.js
index efc663e0a47..44d06514afe 100644
--- a/app/assets/javascripts/discourse/app/routes/about.js
+++ b/app/assets/javascripts/discourse/app/routes/about.js
@@ -1,6 +1,7 @@
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
import { ajax } from "discourse/lib/ajax";
+import { action } from "@ember/object";
export default DiscourseRoute.extend({
model() {
@@ -36,10 +37,9 @@ export default DiscourseRoute.extend({
return I18n.t("about.simple_title");
},
- actions: {
- didTransition() {
- this.controllerFor("application").set("showFooter", true);
- return true;
- },
+ @action
+ didTransition() {
+ this.controllerFor("application").set("showFooter", true);
+ return true;
},
});
diff --git a/app/assets/javascripts/discourse/app/routes/build-admin-user-posts-route.js b/app/assets/javascripts/discourse/app/routes/build-admin-user-posts-route.js
index b56971fdae5..1045f310227 100644
--- a/app/assets/javascripts/discourse/app/routes/build-admin-user-posts-route.js
+++ b/app/assets/javascripts/discourse/app/routes/build-admin-user-posts-route.js
@@ -1,14 +1,14 @@
import DiscourseRoute from "discourse/routes/discourse";
import { emojiUnescape } from "discourse/lib/text";
import { escapeExpression } from "discourse/lib/utilities";
+import { action } from "@ember/object";
export default function (filter) {
return DiscourseRoute.extend({
- actions: {
- didTransition() {
- this.controllerFor("user-posts")._showFooter();
- return true;
- },
+ @action
+ didTransition() {
+ this.controllerFor("user-posts")._showFooter();
+ return true;
},
model() {
diff --git a/app/assets/javascripts/discourse/app/routes/discovery-categories.js b/app/assets/javascripts/discourse/app/routes/discovery-categories.js
index 344a3be619e..f689c27e87d 100644
--- a/app/assets/javascripts/discourse/app/routes/discovery-categories.js
+++ b/app/assets/javascripts/discourse/app/routes/discovery-categories.js
@@ -1,6 +1,6 @@
import CategoryList from "discourse/models/category-list";
import DiscourseRoute from "discourse/routes/discourse";
-import EmberObject from "@ember/object";
+import EmberObject, { action } from "@ember/object";
import I18n from "I18n";
import OpenComposer from "discourse/mixins/open-composer";
import PreloadStore from "discourse/lib/preload-store";
@@ -130,31 +130,34 @@ const DiscoveryCategoriesRoute = DiscourseRoute.extend(OpenComposer, {
});
},
- actions: {
- triggerRefresh() {
- this.refresh();
- },
+ @action
+ triggerRefresh() {
+ this.refresh();
+ },
- createCategory() {
- this.transitionTo("newCategory");
- },
+ @action
+ createCategory() {
+ this.transitionTo("newCategory");
+ },
- reorderCategories() {
- showModal("reorderCategories");
- },
+ @action
+ reorderCategories() {
+ showModal("reorderCategories");
+ },
- createTopic() {
- if (this.get("currentUser.has_topic_draft")) {
- this.openTopicDraft();
- } else {
- this.openComposer(this.controllerFor("discovery/categories"));
- }
- },
+ @action
+ createTopic() {
+ if (this.get("currentUser.has_topic_draft")) {
+ this.openTopicDraft();
+ } else {
+ this.openComposer(this.controllerFor("discovery/categories"));
+ }
+ },
- didTransition() {
- next(() => this.controllerFor("application").set("showFooter", true));
- return true;
- },
+ @action
+ didTransition() {
+ next(() => this.controllerFor("application").set("showFooter", true));
+ return true;
},
});
diff --git a/app/assets/javascripts/discourse/app/routes/discovery.js b/app/assets/javascripts/discourse/app/routes/discovery.js
index c8ab3ad57fb..55a5ca0f057 100644
--- a/app/assets/javascripts/discourse/app/routes/discovery.js
+++ b/app/assets/javascripts/discourse/app/routes/discovery.js
@@ -8,6 +8,7 @@ import User from "discourse/models/user";
import { scrollTop } from "discourse/mixins/scroll-top";
import { setTopicList } from "discourse/lib/topic-list-tracker";
import Site from "discourse/models/site";
+import { action } from "@ember/object";
export default DiscourseRoute.extend(OpenComposer, {
queryParams: {
@@ -44,52 +45,57 @@ export default DiscourseRoute.extend(OpenComposer, {
}
},
- actions: {
- loading() {
- this.controllerFor("discovery").loadingBegan();
+ @action
+ loading() {
+ this.controllerFor("discovery").loadingBegan();
- // We don't want loading to bubble
- return true;
- },
+ // We don't want loading to bubble
+ return true;
+ },
- loadingComplete() {
- this.controllerFor("discovery").loadingComplete();
- if (!this.session.get("topicListScrollPosition")) {
- scrollTop();
- }
- },
+ @action
+ loadingComplete() {
+ this.controllerFor("discovery").loadingComplete();
+ if (!this.session.get("topicListScrollPosition")) {
+ scrollTop();
+ }
+ },
- didTransition() {
- this.send("loadingComplete");
+ @action
+ didTransition() {
+ this.send("loadingComplete");
- const model = this.controllerFor("discovery/topics").get("model");
- setTopicList(model);
- },
+ const model = this.controllerFor("discovery/topics").get("model");
+ setTopicList(model);
+ },
- // clear a pinned topic
- clearPin(topic) {
- topic.clearPin();
- },
+ // clear a pinned topic
+ @action
+ clearPin(topic) {
+ topic.clearPin();
+ },
- createTopic() {
- if (this.get("currentUser.has_topic_draft")) {
- this.openTopicDraft();
- } else {
- this.openComposer(this.controllerFor("discovery/topics"));
- }
- },
+ @action
+ createTopic() {
+ if (this.get("currentUser.has_topic_draft")) {
+ this.openTopicDraft();
+ } else {
+ this.openComposer(this.controllerFor("discovery/topics"));
+ }
+ },
- dismissReadTopics(dismissTopics) {
- const operationType = dismissTopics ? "topics" : "posts";
- this.send("dismissRead", operationType);
- },
+ @action
+ dismissReadTopics(dismissTopics) {
+ const operationType = dismissTopics ? "topics" : "posts";
+ this.send("dismissRead", operationType);
+ },
- dismissRead(operationType) {
- const controller = this.controllerFor("discovery/topics");
- controller.send("dismissRead", operationType, {
- categoryId: controller.get("category.id"),
- includeSubcategories: !controller.noSubcategories,
- });
- },
+ @action
+ dismissRead(operationType) {
+ const controller = this.controllerFor("discovery/topics");
+ controller.send("dismissRead", operationType, {
+ categoryId: controller.get("category.id"),
+ includeSubcategories: !controller.noSubcategories,
+ });
},
});
diff --git a/app/assets/javascripts/discourse/app/routes/exception.js b/app/assets/javascripts/discourse/app/routes/exception.js
index c87b06d4f05..2bd40f18878 100644
--- a/app/assets/javascripts/discourse/app/routes/exception.js
+++ b/app/assets/javascripts/discourse/app/routes/exception.js
@@ -1,14 +1,14 @@
import DiscourseRoute from "discourse/routes/discourse";
+import { action } from "@ember/object";
export default DiscourseRoute.extend({
serialize() {
return "";
},
- actions: {
- didTransition() {
- this.controllerFor("application").set("showFooter", true);
- return true;
- },
+ @action
+ didTransition() {
+ this.controllerFor("application").set("showFooter", true);
+ return true;
},
});
diff --git a/app/assets/javascripts/discourse/app/routes/full-page-search.js b/app/assets/javascripts/discourse/app/routes/full-page-search.js
index 71ccb8fdbda..a348b6b504a 100644
--- a/app/assets/javascripts/discourse/app/routes/full-page-search.js
+++ b/app/assets/javascripts/discourse/app/routes/full-page-search.js
@@ -9,6 +9,7 @@ import I18n from "I18n";
import PreloadStore from "discourse/lib/preload-store";
import { ajax } from "discourse/lib/ajax";
import { escapeExpression } from "discourse/lib/utilities";
+import { action } from "@ember/object";
export default DiscourseRoute.extend({
queryParams: {
@@ -64,10 +65,9 @@ export default DiscourseRoute.extend({
});
},
- actions: {
- didTransition() {
- this.controllerFor("full-page-search")._showFooter();
- return true;
- },
+ @action
+ didTransition() {
+ this.controllerFor("full-page-search")._showFooter();
+ return true;
},
});
diff --git a/app/assets/javascripts/discourse/app/routes/group-activity-posts.js b/app/assets/javascripts/discourse/app/routes/group-activity-posts.js
index 0c805e51cc0..dddbc26f876 100644
--- a/app/assets/javascripts/discourse/app/routes/group-activity-posts.js
+++ b/app/assets/javascripts/discourse/app/routes/group-activity-posts.js
@@ -1,6 +1,6 @@
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
-import { get } from "@ember/object";
+import { action, get } from "@ember/object";
export function buildGroupPage(type) {
return DiscourseRoute.extend({
@@ -29,10 +29,9 @@ export function buildGroupPage(type) {
this.render("group-activity-posts");
},
- actions: {
- didTransition() {
- return true;
- },
+ @action
+ didTransition() {
+ return true;
},
});
}
diff --git a/app/assets/javascripts/discourse/app/routes/group-manage-logs.js b/app/assets/javascripts/discourse/app/routes/group-manage-logs.js
index 4cdd9bd0cc9..cf5130d466d 100644
--- a/app/assets/javascripts/discourse/app/routes/group-manage-logs.js
+++ b/app/assets/javascripts/discourse/app/routes/group-manage-logs.js
@@ -1,5 +1,6 @@
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
+import { action } from "@ember/object";
export default DiscourseRoute.extend({
titleToken() {
@@ -14,9 +15,8 @@ export default DiscourseRoute.extend({
this.controllerFor("group-manage-logs").setProperties({ model });
},
- actions: {
- willTransition() {
- this.controllerFor("group-manage-logs").reset();
- },
+ @action
+ willTransition() {
+ this.controllerFor("group-manage-logs").reset();
},
});
diff --git a/app/assets/javascripts/discourse/app/routes/preferences-account.js b/app/assets/javascripts/discourse/app/routes/preferences-account.js
index 47bcae2b828..fc12eb6c076 100644
--- a/app/assets/javascripts/discourse/app/routes/preferences-account.js
+++ b/app/assets/javascripts/discourse/app/routes/preferences-account.js
@@ -1,6 +1,7 @@
import RestrictedUserRoute from "discourse/routes/restricted-user";
import UserBadge from "discourse/models/user-badge";
import showModal from "discourse/lib/show-modal";
+import { action } from "@ember/object";
export default RestrictedUserRoute.extend({
showFooter: true,
@@ -33,9 +34,8 @@ export default RestrictedUserRoute.extend({
});
},
- actions: {
- showAvatarSelector(user) {
- showModal("avatar-selector").setProperties({ user });
- },
+ @action
+ showAvatarSelector(user) {
+ showModal("avatar-selector").setProperties({ user });
},
});
diff --git a/app/assets/javascripts/discourse/app/routes/preferences-second-factor.js b/app/assets/javascripts/discourse/app/routes/preferences-second-factor.js
index 54c5b9ccb3f..46d296b2e52 100644
--- a/app/assets/javascripts/discourse/app/routes/preferences-second-factor.js
+++ b/app/assets/javascripts/discourse/app/routes/preferences-second-factor.js
@@ -1,4 +1,5 @@
import RestrictedUserRoute from "discourse/routes/restricted-user";
+import { action } from "@ember/object";
export default RestrictedUserRoute.extend({
showFooter: true,
@@ -34,27 +35,26 @@ export default RestrictedUserRoute.extend({
.finally(() => controller.set("loading", false));
},
- actions: {
- willTransition(transition) {
- this._super(...arguments);
-
- const controller = this.controllerFor("preferences/second-factor");
- const user = controller.get("currentUser");
- const settings = controller.get("siteSettings");
-
- if (
- transition.targetName === "preferences.second-factor" ||
- !user ||
- user.is_anonymous ||
- user.second_factor_enabled ||
- (settings.enforce_second_factor === "staff" && !user.staff) ||
- settings.enforce_second_factor === "no"
- ) {
- return true;
- }
-
- transition.abort();
- return false;
- },
+ @action
+ willTransition(transition) {
+ this._super(...arguments);
+
+ const controller = this.controllerFor("preferences/second-factor");
+ const user = controller.get("currentUser");
+ const settings = controller.get("siteSettings");
+
+ if (
+ transition.targetName === "preferences.second-factor" ||
+ !user ||
+ user.is_anonymous ||
+ user.second_factor_enabled ||
+ (settings.enforce_second_factor === "staff" && !user.staff) ||
+ settings.enforce_second_factor === "no"
+ ) {
+ return true;
+ }
+
+ transition.abort();
+ return false;
},
});
diff --git a/app/assets/javascripts/discourse/app/routes/review-index.js b/app/assets/javascripts/discourse/app/routes/review-index.js
index a19b0f9952b..67c16c6a31b 100644
--- a/app/assets/javascripts/discourse/app/routes/review-index.js
+++ b/app/assets/javascripts/discourse/app/routes/review-index.js
@@ -1,5 +1,6 @@
import DiscourseRoute from "discourse/routes/discourse";
import { isPresent } from "@ember/utils";
+import { action } from "@ember/object";
export default DiscourseRoute.extend({
model(params) {
@@ -74,9 +75,8 @@ export default DiscourseRoute.extend({
this.messageBus.unsubscribe("/reviewable_claimed");
},
- actions: {
- refreshRoute() {
- this.refresh();
- },
+ @action
+ refreshRoute() {
+ this.refresh();
},
});
diff --git a/app/assets/javascripts/discourse/app/routes/topic-from-params.js b/app/assets/javascripts/discourse/app/routes/topic-from-params.js
index e2918e1f420..b1f30baa5ce 100644
--- a/app/assets/javascripts/discourse/app/routes/topic-from-params.js
+++ b/app/assets/javascripts/discourse/app/routes/topic-from-params.js
@@ -4,6 +4,7 @@ import Draft from "discourse/models/draft";
import { isEmpty } from "@ember/utils";
import { isTesting } from "discourse-common/config/environment";
import { schedule } from "@ember/runloop";
+import { action } from "@ember/object";
// This route is used for retrieving a topic based on params
export default DiscourseRoute.extend({
@@ -114,16 +115,12 @@ export default DiscourseRoute.extend({
}
},
- actions: {
- willTransition() {
- this.controllerFor("topic").set(
- "previousURL",
- document.location.pathname
- );
-
- // NOTE: omitting this return can break the back button when transitioning quickly between
- // topics and the latest page.
- return true;
- },
+ @action
+ willTransition() {
+ this.controllerFor("topic").set("previousURL", document.location.pathname);
+
+ // NOTE: omitting this return can break the back button when transitioning quickly between
+ // topics and the latest page.
+ return true;
},
});
diff --git a/app/assets/javascripts/discourse/app/routes/topic.js b/app/assets/javascripts/discourse/app/routes/topic.js
index a5c26b1d3d8..a7c4b6a3fb7 100644
--- a/app/assets/javascripts/discourse/app/routes/topic.js
+++ b/app/assets/javascripts/discourse/app/routes/topic.js
@@ -2,7 +2,7 @@ import { cancel, later, schedule } from "@ember/runloop";
import DiscourseRoute from "discourse/routes/discourse";
import DiscourseURL from "discourse/lib/url";
import { ID_CONSTRAINT } from "discourse/models/topic";
-import { get } from "@ember/object";
+import { action, get } from "@ember/object";
import { isEmpty } from "@ember/utils";
import { inject as service } from "@ember/service";
import { setTopicId } from "discourse/lib/topic-list-tracker";
@@ -60,185 +60,197 @@ const TopicRoute = DiscourseRoute.extend({
}
},
- actions: {
- showInvite() {
- let invitePanelTitle;
+ @action
+ showInvite() {
+ let invitePanelTitle;
- if (this.isPM) {
- invitePanelTitle = "topic.invite_private.title";
- } else if (this.invitingToTopic) {
- invitePanelTitle = "topic.invite_reply.title";
- } else {
- invitePanelTitle = "user.invited.create";
- }
+ if (this.isPM) {
+ invitePanelTitle = "topic.invite_private.title";
+ } else if (this.invitingToTopic) {
+ invitePanelTitle = "topic.invite_reply.title";
+ } else {
+ invitePanelTitle = "user.invited.create";
+ }
- showModal("share-and-invite", {
- modalClass: "share-and-invite",
- panels: [
- {
- id: "invite",
- title: invitePanelTitle,
- model: {
- inviteModel: this.modelFor("topic"),
- },
+ showModal("share-and-invite", {
+ modalClass: "share-and-invite",
+ panels: [
+ {
+ id: "invite",
+ title: invitePanelTitle,
+ model: {
+ inviteModel: this.modelFor("topic"),
},
- ],
- });
- },
-
- showFlags(model) {
- let controller = showModal("flag", { model });
- controller.setProperties({ flagTopic: false });
- },
-
- showFlagTopic() {
- const model = this.modelFor("topic");
- let controller = showModal("flag", { model });
- controller.setProperties({ flagTopic: true });
- },
-
- showPagePublish() {
- const model = this.modelFor("topic");
- showModal("publish-page", {
- model,
- title: "topic.publish_page.title",
- });
- },
+ },
+ ],
+ });
+ },
- showTopicTimerModal() {
- const model = this.modelFor("topic");
+ @action
+ showFlags(model) {
+ let controller = showModal("flag", { model });
+ controller.setProperties({ flagTopic: false });
+ },
- const topicTimer = model.get("topic_timer");
- if (!topicTimer) {
- model.set("topic_timer", {});
- }
+ @action
+ showFlagTopic() {
+ const model = this.modelFor("topic");
+ let controller = showModal("flag", { model });
+ controller.setProperties({ flagTopic: true });
+ },
- showModal("edit-topic-timer", { model });
- this.controllerFor("modal").set("modalClass", "edit-topic-timer-modal");
- },
+ @action
+ showPagePublish() {
+ const model = this.modelFor("topic");
+ showModal("publish-page", {
+ model,
+ title: "topic.publish_page.title",
+ });
+ },
- showTopicSlowModeUpdate() {
- const model = this.modelFor("topic");
+ @action
+ showTopicTimerModal() {
+ const model = this.modelFor("topic");
- showModal("edit-slow-mode", { model });
- },
+ const topicTimer = model.get("topic_timer");
+ if (!topicTimer) {
+ model.set("topic_timer", {});
+ }
- showChangeTimestamp() {
- showModal("change-timestamp", {
- model: this.modelFor("topic"),
- title: "topic.change_timestamp.title",
- });
- },
+ showModal("edit-topic-timer", { model });
+ this.controllerFor("modal").set("modalClass", "edit-topic-timer-modal");
+ },
- showFeatureTopic() {
- showModal("featureTopic", {
- model: this.modelFor("topic"),
- title: "topic.feature_topic.title",
- });
- this.controllerFor("modal").set("modalClass", "feature-topic-modal");
- this.controllerFor("feature_topic").reset();
- },
-
- showHistory(model, revision) {
- let historyController = showModal("history", {
- model,
- modalClass: "history-modal",
- });
- historyController.refresh(model.get("id"), revision || "latest");
- historyController.set("post", model);
- historyController.set("topicController", this.controllerFor("topic"));
- },
-
- showGrantBadgeModal() {
- showModal("grant-badge", {
- model: this.modelFor("topic"),
- title: "admin.badges.grant_badge",
- });
- },
+ @action
+ showTopicSlowModeUpdate() {
+ const model = this.modelFor("topic");
- showRawEmail(model) {
- showModal("raw-email", { model });
- this.controllerFor("raw_email").loadRawEmail(model.get("id"));
- },
+ showModal("edit-slow-mode", { model });
+ },
- moveToTopic() {
- showModal("move-to-topic", {
- model: this.modelFor("topic"),
- title: "topic.move_to.title",
- });
- },
+ @action
+ showChangeTimestamp() {
+ showModal("change-timestamp", {
+ model: this.modelFor("topic"),
+ title: "topic.change_timestamp.title",
+ });
+ },
- changeOwner() {
- showModal("change-owner", {
- model: this.modelFor("topic"),
- title: "topic.change_owner.title",
- });
- },
+ @action
+ showFeatureTopic() {
+ showModal("featureTopic", {
+ model: this.modelFor("topic"),
+ title: "topic.feature_topic.title",
+ });
+ this.controllerFor("modal").set("modalClass", "feature-topic-modal");
+ this.controllerFor("feature_topic").reset();
+ },
- // Use replaceState to update the URL once it changes
- postChangedRoute(currentPost) {
- // do nothing if we are transitioning to another route
- if (this.isTransitioning || TopicRoute.disableReplaceState) {
- return;
- }
+ @action
+ showHistory(model, revision) {
+ let historyController = showModal("history", {
+ model,
+ modalClass: "history-modal",
+ });
+ historyController.refresh(model.get("id"), revision || "latest");
+ historyController.set("post", model);
+ historyController.set("topicController", this.controllerFor("topic"));
+ },
- const topic = this.modelFor("topic");
+ @action
+ showGrantBadgeModal() {
+ showModal("grant-badge", {
+ model: this.modelFor("topic"),
+ title: "admin.badges.grant_badge",
+ });
+ },
- if (topic && currentPost) {
- let postUrl;
+ @action
+ showRawEmail(model) {
+ showModal("raw-email", { model });
+ this.controllerFor("raw_email").loadRawEmail(model.get("id"));
+ },
- if (currentPost > 1) {
- postUrl = topic.urlForPostNumber(currentPost);
- } else {
- postUrl = topic.url;
- }
+ @action
+ moveToTopic() {
+ showModal("move-to-topic", {
+ model: this.modelFor("topic"),
+ title: "topic.move_to.title",
+ });
+ },
+
+ @action
+ changeOwner() {
+ showModal("change-owner", {
+ model: this.modelFor("topic"),
+ title: "topic.change_owner.title",
+ });
+ },
+
+ // Use replaceState to update the URL once it changes
+ @action
+ postChangedRoute(currentPost) {
+ // do nothing if we are transitioning to another route
+ if (this.isTransitioning || TopicRoute.disableReplaceState) {
+ return;
+ }
- if (this._router.currentRoute.queryParams) {
- let searchParams;
+ const topic = this.modelFor("topic");
+ if (topic && currentPost) {
+ let postUrl;
+ if (currentPost > 1) {
+ postUrl = topic.urlForPostNumber(currentPost);
+ } else {
+ postUrl = topic.url;
+ }
- Object.entries(this._router.currentRoute.queryParams).map(
- ([key, value]) => {
- if (!searchParams) {
- searchParams = new URLSearchParams();
- }
+ if (this._router.currentRoute.queryParams) {
+ let searchParams;
- searchParams.append(key, value);
+ Object.entries(this._router.currentRoute.queryParams).map(
+ ([key, value]) => {
+ if (!searchParams) {
+ searchParams = new URLSearchParams();
}
- );
- if (searchParams) {
- postUrl += `?${searchParams.toString()}`;
+ searchParams.append(key, value);
}
- }
+ );
- cancel(this.scheduledReplace);
-
- this.setProperties({
- lastScrollPos: parseInt($(document).scrollTop(), 10),
- scheduledReplace: later(
- this,
- "_replaceUnlessScrolling",
- postUrl,
- Ember.Test ? 0 : SCROLL_DELAY
- ),
- });
+ if (searchParams) {
+ postUrl += `?${searchParams.toString()}`;
+ }
}
- },
-
- didTransition() {
- const controller = this.controllerFor("topic");
- controller._showFooter();
- const topicId = controller.get("model.id");
- setTopicId(topicId);
- return true;
- },
-
- willTransition() {
- this._super(...arguments);
+
cancel(this.scheduledReplace);
- this.set("isTransitioning", true);
- return true;
- },
+
+ this.setProperties({
+ lastScrollPos: parseInt($(document).scrollTop(), 10),
+ scheduledReplace: later(
+ this,
+ "_replaceUnlessScrolling",
+ postUrl,
+ Ember.Test ? 0 : SCROLL_DELAY
+ ),
+ });
+ }
+ },
+
+ @action
+ didTransition() {
+ const controller = this.controllerFor("topic");
+ controller._showFooter();
+ const topicId = controller.get("model.id");
+ setTopicId(topicId);
+ return true;
+ },
+
+ @action
+ willTransition() {
+ this._super(...arguments);
+ cancel(this.scheduledReplace);
+ this.set("isTransitioning", true);
+ return true;
},
// replaceState can be very slow on Android Chrome. This function debounces replaceState
diff --git a/app/assets/javascripts/discourse/app/routes/user-activity-drafts.js b/app/assets/javascripts/discourse/app/routes/user-activity-drafts.js
index 97e49701b4c..0eaf79c8b07 100644
--- a/app/assets/javascripts/discourse/app/routes/user-activity-drafts.js
+++ b/app/assets/javascripts/discourse/app/routes/user-activity-drafts.js
@@ -1,5 +1,6 @@
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
+import { action } from "@ember/object";
export default DiscourseRoute.extend({
model() {
@@ -38,10 +39,9 @@ export default DiscourseRoute.extend({
this.appEvents.off("draft:destroyed", this, this.refresh);
},
- actions: {
- didTransition() {
- this.controllerFor("user-activity")._showFooter();
- return true;
- },
+ @action
+ didTransition() {
+ this.controllerFor("user-activity")._showFooter();
+ return true;
},
});
diff --git a/app/assets/javascripts/discourse/app/routes/user-badges.js b/app/assets/javascripts/discourse/app/routes/user-badges.js
index 3f2d04421a2..b88a8bbbaa4 100644
--- a/app/assets/javascripts/discourse/app/routes/user-badges.js
+++ b/app/assets/javascripts/discourse/app/routes/user-badges.js
@@ -1,6 +1,7 @@
import DiscourseRoute from "discourse/routes/discourse";
import UserBadge from "discourse/models/user-badge";
import ViewingActionType from "discourse/mixins/viewing-action-type";
+import { action } from "@ember/object";
export default DiscourseRoute.extend(ViewingActionType, {
model() {
@@ -19,10 +20,9 @@ export default DiscourseRoute.extend(ViewingActionType, {
this.render("user/badges", { into: "user" });
},
- actions: {
- didTransition() {
- this.controllerFor("application").set("showFooter", true);
- return true;
- },
+ @action
+ didTransition() {
+ this.controllerFor("application").set("showFooter", true);
+ return true;
},
});
diff --git a/app/assets/javascripts/discourse/app/routes/user-invited-show.js b/app/assets/javascripts/discourse/app/routes/user-invited-show.js
index 81a4c033937..af6f4a3eeb4 100644
--- a/app/assets/javascripts/discourse/app/routes/user-invited-show.js
+++ b/app/assets/javascripts/discourse/app/routes/user-invited-show.js
@@ -1,5 +1,6 @@
import DiscourseRoute from "discourse/routes/discourse";
import Invite from "discourse/models/invite";
+import { action } from "@ember/object";
export default DiscourseRoute.extend({
model(params) {
@@ -26,9 +27,8 @@ export default DiscourseRoute.extend({
});
},
- actions: {
- triggerRefresh() {
- this.refresh();
- },
+ @action
+ triggerRefresh() {
+ this.refresh();
},
});
diff --git a/app/assets/javascripts/discourse/app/routes/user-notifications.js b/app/assets/javascripts/discourse/app/routes/user-notifications.js
index 600ca093bbb..01ed463a756 100644
--- a/app/assets/javascripts/discourse/app/routes/user-notifications.js
+++ b/app/assets/javascripts/discourse/app/routes/user-notifications.js
@@ -1,5 +1,6 @@
import DiscourseRoute from "discourse/routes/discourse";
import ViewingActionType from "discourse/mixins/viewing-action-type";
+import { action } from "@ember/object";
export default DiscourseRoute.extend(ViewingActionType, {
controllerName: "user-notifications",
@@ -9,11 +10,10 @@ export default DiscourseRoute.extend(ViewingActionType, {
this.render("user/notifications");
},
- actions: {
- didTransition() {
- this.controllerFor("user-notifications")._showFooter();
- return true;
- },
+ @action
+ didTransition() {
+ this.controllerFor("user-notifications")._showFooter();
+ return true;
},
model(params) {
diff --git a/app/assets/javascripts/discourse/app/routes/user.js b/app/assets/javascripts/discourse/app/routes/user.js
index 0b54a67a9ff..e88075cfd60 100644
--- a/app/assets/javascripts/discourse/app/routes/user.js
+++ b/app/assets/javascripts/discourse/app/routes/user.js
@@ -1,6 +1,7 @@
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
import User from "discourse/models/user";
+import { action } from "@ember/object";
export default DiscourseRoute.extend({
titleToken() {
@@ -10,14 +11,14 @@ export default DiscourseRoute.extend({
}
},
- actions: {
- undoRevokeApiKey(key) {
- key.undoRevoke();
- },
+ @action
+ undoRevokeApiKey(key) {
+ key.undoRevoke();
+ },
- revokeApiKey(key) {
- key.revoke();
- },
+ @action
+ revokeApiKey(key) {
+ key.revoke();
},
beforeModel() {
diff --git a/app/assets/javascripts/discourse/app/routes/users.js b/app/assets/javascripts/discourse/app/routes/users.js
index 5af0399c0fa..442f2b3b555 100644
--- a/app/assets/javascripts/discourse/app/routes/users.js
+++ b/app/assets/javascripts/discourse/app/routes/users.js
@@ -3,6 +3,7 @@ import I18n from "I18n";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { Promise } from "rsvp";
+import { action } from "@ember/object";
export default DiscourseRoute.extend({
queryParams: {
@@ -55,10 +56,9 @@ export default DiscourseRoute.extend({
]);
},
- actions: {
- didTransition() {
- this.controllerFor("users")._showFooter();
- return true;
- },
+ @action
+ didTransition() {
+ this.controllerFor("users")._showFooter();
+ return true;
},
});