DEV: migrate more routes away from the old `actions:` pattern (#15275)
This commit is contained in:
parent
a09b6fe114
commit
6afab87d50
|
@ -14,6 +14,7 @@ import DiscourseRoute from "discourse/routes/discourse";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import PermissionType from "discourse/models/permission-type";
|
import PermissionType from "discourse/models/permission-type";
|
||||||
import TopicList from "discourse/models/topic-list";
|
import TopicList from "discourse/models/topic-list";
|
||||||
|
import { action } from "@ember/object";
|
||||||
|
|
||||||
// A helper function to create a category route with parameters
|
// A helper function to create a category route with parameters
|
||||||
export default (filterArg, params) => {
|
export default (filterArg, params) => {
|
||||||
|
@ -208,17 +209,24 @@ export default (filterArg, params) => {
|
||||||
this.searchService.set("searchContext", null);
|
this.searchService.set("searchContext", null);
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
@action
|
||||||
setNotification(notification_level) {
|
setNotification(notification_level) {
|
||||||
this.currentModel.setNotification(notification_level);
|
this.currentModel.setNotification(notification_level);
|
||||||
},
|
},
|
||||||
|
|
||||||
triggerRefresh() {
|
@action
|
||||||
this.refresh();
|
triggerRefresh() {
|
||||||
},
|
this.refresh();
|
||||||
|
},
|
||||||
|
|
||||||
changeSort,
|
@action
|
||||||
resetParams,
|
changeSort(sortBy) {
|
||||||
|
changeSort.call(this, sortBy);
|
||||||
|
},
|
||||||
|
|
||||||
|
@action
|
||||||
|
resetParams(skipParams = []) {
|
||||||
|
resetParams.call(this, skipParams);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { deepEqual } from "discourse-common/lib/object";
|
||||||
import { defaultHomepage } from "discourse/lib/utilities";
|
import { defaultHomepage } from "discourse/lib/utilities";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import { inject as service } from "@ember/service";
|
import { inject as service } from "@ember/service";
|
||||||
|
import { action } from "@ember/object";
|
||||||
|
|
||||||
// A helper to build a topic route for a filter
|
// A helper to build a topic route for a filter
|
||||||
function filterQueryParams(params, defaultParams) {
|
function filterQueryParams(params, defaultParams) {
|
||||||
|
@ -151,9 +152,14 @@ export default function (filter, extras) {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
@action
|
||||||
changeSort,
|
changeSort(sortBy) {
|
||||||
resetParams,
|
changeSort.call(this, sortBy);
|
||||||
|
},
|
||||||
|
|
||||||
|
@action
|
||||||
|
resetParams(skipParams = []) {
|
||||||
|
resetParams.call(this, skipParams);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extras
|
extras
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { escapeExpression } from "discourse/lib/utilities";
|
||||||
import { makeArray } from "discourse-common/lib/helpers";
|
import { makeArray } from "discourse-common/lib/helpers";
|
||||||
import { setTopicList } from "discourse/lib/topic-list-tracker";
|
import { setTopicList } from "discourse/lib/topic-list-tracker";
|
||||||
import showModal from "discourse/lib/show-modal";
|
import showModal from "discourse/lib/show-modal";
|
||||||
|
import { action } from "@ember/object";
|
||||||
|
|
||||||
export default DiscourseRoute.extend(FilterModeMixin, {
|
export default DiscourseRoute.extend(FilterModeMixin, {
|
||||||
navMode: "latest",
|
navMode: "latest",
|
||||||
|
@ -170,66 +171,72 @@ export default DiscourseRoute.extend(FilterModeMixin, {
|
||||||
this.searchService.set("searchContext", null);
|
this.searchService.set("searchContext", null);
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
@action
|
||||||
renameTag(tag) {
|
renameTag(tag) {
|
||||||
showModal("rename-tag", { model: tag });
|
showModal("rename-tag", { model: tag });
|
||||||
},
|
},
|
||||||
|
|
||||||
createTopic() {
|
@action
|
||||||
if (this.get("currentUser.has_topic_draft")) {
|
createTopic() {
|
||||||
this.openTopicDraft();
|
if (this.get("currentUser.has_topic_draft")) {
|
||||||
} else {
|
this.openTopicDraft();
|
||||||
const controller = this.controllerFor("tag.show");
|
} else {
|
||||||
const composerController = this.controllerFor("composer");
|
const controller = this.controllerFor("tag.show");
|
||||||
composerController
|
const composerController = this.controllerFor("composer");
|
||||||
.open({
|
composerController
|
||||||
categoryId: controller.get("category.id"),
|
.open({
|
||||||
action: Composer.CREATE_TOPIC,
|
categoryId: controller.get("category.id"),
|
||||||
draftKey: Composer.NEW_TOPIC_KEY,
|
action: Composer.CREATE_TOPIC,
|
||||||
})
|
draftKey: Composer.NEW_TOPIC_KEY,
|
||||||
.then(() => {
|
})
|
||||||
// Pre-fill the tags input field
|
.then(() => {
|
||||||
if (composerController.canEditTags && controller.get("model.id")) {
|
// Pre-fill the tags input field
|
||||||
const composerModel = this.controllerFor("composer").get("model");
|
if (composerController.canEditTags && controller.get("model.id")) {
|
||||||
composerModel.set(
|
const composerModel = this.controllerFor("composer").get("model");
|
||||||
"tags",
|
composerModel.set(
|
||||||
[
|
"tags",
|
||||||
controller.get("model.id"),
|
[
|
||||||
...makeArray(controller.additionalTags),
|
controller.get("model.id"),
|
||||||
].filter(Boolean)
|
...makeArray(controller.additionalTags),
|
||||||
);
|
].filter(Boolean)
|
||||||
}
|
);
|
||||||
});
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
dismissReadTopics(dismissTopics) {
|
|
||||||
const operationType = dismissTopics ? "topics" : "posts";
|
|
||||||
this.send("dismissRead", operationType);
|
|
||||||
},
|
|
||||||
|
|
||||||
dismissRead(operationType) {
|
|
||||||
const controller = this.controllerFor("tags-show");
|
|
||||||
let options = {
|
|
||||||
tagName: controller.get("tag.id"),
|
|
||||||
};
|
|
||||||
const categoryId = controller.get("category.id");
|
|
||||||
|
|
||||||
if (categoryId) {
|
|
||||||
options = Object.assign({}, options, {
|
|
||||||
categoryId,
|
|
||||||
includeSubcategories: !controller.noSubcategories,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
controller.send("dismissRead", operationType, options);
|
@action
|
||||||
},
|
dismissReadTopics(dismissTopics) {
|
||||||
|
const operationType = dismissTopics ? "topics" : "posts";
|
||||||
|
this.send("dismissRead", operationType);
|
||||||
|
},
|
||||||
|
|
||||||
resetParams,
|
@action
|
||||||
|
dismissRead(operationType) {
|
||||||
|
const controller = this.controllerFor("tags-show");
|
||||||
|
let options = {
|
||||||
|
tagName: controller.get("tag.id"),
|
||||||
|
};
|
||||||
|
const categoryId = controller.get("category.id");
|
||||||
|
|
||||||
didTransition() {
|
if (categoryId) {
|
||||||
this.controllerFor("tag.show")._showFooter();
|
options = Object.assign({}, options, {
|
||||||
return true;
|
categoryId,
|
||||||
},
|
includeSubcategories: !controller.noSubcategories,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
controller.send("dismissRead", operationType, options);
|
||||||
|
},
|
||||||
|
|
||||||
|
@action
|
||||||
|
resetParams(skipParams = []) {
|
||||||
|
resetParams.call(this, skipParams);
|
||||||
|
},
|
||||||
|
|
||||||
|
@action
|
||||||
|
didTransition() {
|
||||||
|
this.controllerFor("tag.show")._showFooter();
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue