DEV: migrate more routes away from the old `actions:` pattern (#15275)

This commit is contained in:
Andrei Prigorshnev 2021-12-15 15:06:10 +01:00 committed by GitHub
parent a09b6fe114
commit 6afab87d50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 89 additions and 68 deletions

View File

@ -14,6 +14,7 @@ import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
import PermissionType from "discourse/models/permission-type";
import TopicList from "discourse/models/topic-list";
import { action } from "@ember/object";
// A helper function to create a category route with parameters
export default (filterArg, params) => {
@ -208,17 +209,24 @@ export default (filterArg, params) => {
this.searchService.set("searchContext", null);
},
actions: {
@action
setNotification(notification_level) {
this.currentModel.setNotification(notification_level);
},
@action
triggerRefresh() {
this.refresh();
},
changeSort,
resetParams,
@action
changeSort(sortBy) {
changeSort.call(this, sortBy);
},
@action
resetParams(skipParams = []) {
resetParams.call(this, skipParams);
},
});
};

View File

@ -12,6 +12,7 @@ import { deepEqual } from "discourse-common/lib/object";
import { defaultHomepage } from "discourse/lib/utilities";
import { isEmpty } from "@ember/utils";
import { inject as service } from "@ember/service";
import { action } from "@ember/object";
// A helper to build a topic route for a filter
function filterQueryParams(params, defaultParams) {
@ -151,9 +152,14 @@ export default function (filter, extras) {
});
},
actions: {
changeSort,
resetParams,
@action
changeSort(sortBy) {
changeSort.call(this, sortBy);
},
@action
resetParams(skipParams = []) {
resetParams.call(this, skipParams);
},
},
extras

View File

@ -16,6 +16,7 @@ import { escapeExpression } from "discourse/lib/utilities";
import { makeArray } from "discourse-common/lib/helpers";
import { setTopicList } from "discourse/lib/topic-list-tracker";
import showModal from "discourse/lib/show-modal";
import { action } from "@ember/object";
export default DiscourseRoute.extend(FilterModeMixin, {
navMode: "latest",
@ -170,11 +171,12 @@ export default DiscourseRoute.extend(FilterModeMixin, {
this.searchService.set("searchContext", null);
},
actions: {
@action
renameTag(tag) {
showModal("rename-tag", { model: tag });
},
@action
createTopic() {
if (this.get("currentUser.has_topic_draft")) {
this.openTopicDraft();
@ -203,11 +205,13 @@ export default DiscourseRoute.extend(FilterModeMixin, {
}
},
@action
dismissReadTopics(dismissTopics) {
const operationType = dismissTopics ? "topics" : "posts";
this.send("dismissRead", operationType);
},
@action
dismissRead(operationType) {
const controller = this.controllerFor("tags-show");
let options = {
@ -225,11 +229,14 @@ export default DiscourseRoute.extend(FilterModeMixin, {
controller.send("dismissRead", operationType, options);
},
resetParams,
@action
resetParams(skipParams = []) {
resetParams.call(this, skipParams);
},
@action
didTransition() {
this.controllerFor("tag.show")._showFooter();
return true;
},
},
});