mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Use import { inject as controller}
Ember idiom (#13140)
This commit is contained in:
parent
5c3c2b8d31
commit
51b360916c
@ -1,4 +1,4 @@
|
||||
import Controller, { inject } from "@ember/controller";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import AdminDashboard from "admin/models/admin-dashboard";
|
||||
import I18n from "I18n";
|
||||
import PeriodComputationMixin from "admin/mixins/period-computation";
|
||||
@ -18,7 +18,7 @@ function staticReport(reportType) {
|
||||
export default Controller.extend(PeriodComputationMixin, {
|
||||
isLoading: false,
|
||||
dashboardFetchedAt: null,
|
||||
exceptionController: inject("exception"),
|
||||
exceptionController: controller("exception"),
|
||||
logSearchQueriesEnabled: setting("log_search_queries"),
|
||||
|
||||
@discourseComputed("siteSettings.dashboard_general_tab_activity_metrics")
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Controller, { inject } from "@ember/controller";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import AdminDashboard from "admin/models/admin-dashboard";
|
||||
import VersionCheck from "admin/models/version-check";
|
||||
import { computed } from "@ember/object";
|
||||
@ -10,7 +10,7 @@ const PROBLEMS_CHECK_MINUTES = 1;
|
||||
export default Controller.extend({
|
||||
isLoading: false,
|
||||
dashboardFetchedAt: null,
|
||||
exceptionController: inject("exception"),
|
||||
exceptionController: controller("exception"),
|
||||
showVersionChecks: setting("version_checks"),
|
||||
|
||||
@discourseComputed("problems.length")
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Controller, { inject } from "@ember/controller";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
import I18n from "I18n";
|
||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
@ -9,7 +9,7 @@ import { isEmpty } from "@ember/utils";
|
||||
import { next } from "@ember/runloop";
|
||||
|
||||
export default Controller.extend(ModalFunctionality, {
|
||||
topicController: inject("topic"),
|
||||
topicController: controller("topic"),
|
||||
|
||||
saving: false,
|
||||
newOwner: null,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Controller, { inject } from "@ember/controller";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
import I18n from "I18n";
|
||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
@ -9,7 +9,7 @@ import { next } from "@ember/runloop";
|
||||
|
||||
// Modal related to changing the timestamp of posts
|
||||
export default Controller.extend(ModalFunctionality, {
|
||||
topicController: inject("topic"),
|
||||
topicController: controller("topic"),
|
||||
saving: false,
|
||||
date: "",
|
||||
time: "",
|
||||
|
@ -1,5 +1,5 @@
|
||||
import Composer, { SAVE_ICONS, SAVE_LABELS } from "discourse/models/composer";
|
||||
import Controller, { inject } from "@ember/controller";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import EmberObject, { action, computed } from "@ember/object";
|
||||
import { alias, and, or, reads } from "@ember/object/computed";
|
||||
import {
|
||||
@ -93,7 +93,7 @@ export function addPopupMenuOptionsCallback(callback) {
|
||||
}
|
||||
|
||||
export default Controller.extend({
|
||||
topicController: inject("topic"),
|
||||
topicController: controller("topic"),
|
||||
router: service(),
|
||||
|
||||
checkedMessages: false,
|
||||
@ -1137,11 +1137,11 @@ export default Controller.extend({
|
||||
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
if (this.get("model.hasMetaData") || this.get("model.replyDirty")) {
|
||||
const controller = showModal("discard-draft", {
|
||||
const modal = showModal("discard-draft", {
|
||||
model: this.model,
|
||||
modalClass: "discard-draft-modal",
|
||||
});
|
||||
controller.setProperties({
|
||||
modal.setProperties({
|
||||
onDestroyDraft: () => {
|
||||
this.destroyDraft()
|
||||
.then(() => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Controller, { inject } from "@ember/controller";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import I18n from "I18n";
|
||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
import { action } from "@ember/object";
|
||||
@ -7,7 +7,7 @@ import discourseComputed from "discourse-common/utils/decorators";
|
||||
// Modal that displays confirmation text when user deletes a topic
|
||||
// The modal will display only if the topic exceeds a certain amount of views
|
||||
export default Controller.extend(ModalFunctionality, {
|
||||
topicController: inject("topic"),
|
||||
topicController: controller("topic"),
|
||||
deletingTopic: false,
|
||||
|
||||
@discourseComputed("deletingTopic")
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Controller, { inject } from "@ember/controller";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
|
||||
// Just add query params here to have them automatically passed to topic list filters.
|
||||
export const queryParams = {
|
||||
@ -17,7 +17,7 @@ export const queryParams = {
|
||||
|
||||
// Basic controller options
|
||||
const controllerOpts = {
|
||||
discoveryTopics: inject("discovery/topics"),
|
||||
discoveryTopics: controller("discovery/topics"),
|
||||
queryParams: Object.keys(queryParams),
|
||||
};
|
||||
|
||||
@ -27,22 +27,21 @@ controllerOpts.queryParams.forEach((p) => {
|
||||
});
|
||||
|
||||
export function changeSort(sortBy) {
|
||||
let { controller } = this;
|
||||
let model = this.controllerFor("discovery.topics").model;
|
||||
if (sortBy === controller.order) {
|
||||
controller.toggleProperty("ascending");
|
||||
model.updateSortParams(sortBy, controller.ascending);
|
||||
|
||||
if (sortBy === this.controller.order) {
|
||||
this.controller.toggleProperty("ascending");
|
||||
model.updateSortParams(sortBy, this.controller.ascending);
|
||||
} else {
|
||||
controller.setProperties({ order: sortBy, ascending: false });
|
||||
this.controller.setProperties({ order: sortBy, ascending: false });
|
||||
model.updateSortParams(sortBy, false);
|
||||
}
|
||||
}
|
||||
|
||||
export function resetParams(skipParams = []) {
|
||||
let { controller } = this;
|
||||
controllerOpts.queryParams.forEach((p) => {
|
||||
if (!skipParams.includes(p)) {
|
||||
controller.set(p, queryParams[p].default);
|
||||
this.controller.set(p, queryParams[p].default);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Controller, { inject } from "@ember/controller";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import EmberObject from "@ember/object";
|
||||
import I18n from "I18n";
|
||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
@ -8,7 +8,7 @@ import { categoryLinkHTML } from "discourse/helpers/category-link";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
|
||||
export default Controller.extend(ModalFunctionality, {
|
||||
topicController: inject("topic"),
|
||||
topicController: controller("topic"),
|
||||
|
||||
loading: true,
|
||||
pinnedInCategoryCount: 0,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Controller, { inject } from "@ember/controller";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import Badge from "discourse/models/badge";
|
||||
import GrantBadgeController from "discourse/mixins/grant-badge-controller";
|
||||
import I18n from "I18n";
|
||||
@ -9,7 +9,7 @@ import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { extractError } from "discourse/lib/ajax-error";
|
||||
|
||||
export default Controller.extend(ModalFunctionality, GrantBadgeController, {
|
||||
topicController: inject("topic"),
|
||||
topicController: controller("topic"),
|
||||
loading: true,
|
||||
saving: false,
|
||||
selectedBadgeId: null,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Controller, { inject } from "@ember/controller";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import { alias, equal } from "@ember/object/computed";
|
||||
import { mergeTopic, movePosts } from "discourse/models/topic";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
@ -41,7 +41,7 @@ export default Controller.extend(ModalFunctionality, {
|
||||
];
|
||||
},
|
||||
|
||||
topicController: inject("topic"),
|
||||
topicController: controller("topic"),
|
||||
selectedPostsCount: alias("topicController.selectedPostsCount"),
|
||||
selectedAllPosts: alias("topicController.selectedAllPosts"),
|
||||
selectedPosts: alias("topicController.selectedPosts"),
|
||||
|
@ -1,6 +1,6 @@
|
||||
import NavigationDefaultController from "discourse/controllers/navigation/default";
|
||||
import { inject } from "@ember/controller";
|
||||
import { inject as controller } from "@ember/controller";
|
||||
|
||||
export default NavigationDefaultController.extend({
|
||||
discoveryCategories: inject("discovery/categories"),
|
||||
discoveryCategories: controller("discovery/categories"),
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Controller, { inject } from "@ember/controller";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import {
|
||||
iOSWithVisualViewport,
|
||||
isiPad,
|
||||
@ -34,7 +34,7 @@ export default Controller.extend({
|
||||
currentThemeId: -1,
|
||||
previewingColorScheme: false,
|
||||
selectedDarkColorSchemeId: null,
|
||||
preferencesController: inject("preferences"),
|
||||
preferencesController: controller("preferences"),
|
||||
makeColorSchemeDefault: true,
|
||||
|
||||
init() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Controller, { inject } from "@ember/controller";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import Bookmark from "discourse/models/bookmark";
|
||||
import I18n from "I18n";
|
||||
import { Promise } from "rsvp";
|
||||
@ -6,8 +6,8 @@ import EmberObject, { action } from "@ember/object";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
|
||||
export default Controller.extend({
|
||||
application: inject(),
|
||||
user: inject(),
|
||||
application: controller(),
|
||||
user: controller(),
|
||||
|
||||
content: null,
|
||||
loading: false,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Controller, { inject } from "@ember/controller";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import { alias } from "@ember/object/computed";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { durationTiny } from "discourse/lib/formatter";
|
||||
@ -7,7 +7,7 @@ import { durationTiny } from "discourse/lib/formatter";
|
||||
const MAX_BADGES = 6;
|
||||
|
||||
export default Controller.extend({
|
||||
userController: inject("user"),
|
||||
userController: controller("user"),
|
||||
user: alias("userController.model"),
|
||||
|
||||
@discourseComputed("model.badges.length")
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Controller, { inject } from "@ember/controller";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import EmberObject, { computed, set } from "@ember/object";
|
||||
import { and, equal, gt, not, or } from "@ember/object/computed";
|
||||
import CanCheckEmails from "discourse/mixins/can-check-emails";
|
||||
@ -15,7 +15,7 @@ import { inject as service } from "@ember/service";
|
||||
|
||||
export default Controller.extend(CanCheckEmails, {
|
||||
router: service(),
|
||||
userNotifications: inject("user-notifications"),
|
||||
userNotifications: controller("user-notifications"),
|
||||
adminTools: optionalService(),
|
||||
|
||||
@discourseComputed("model.username")
|
||||
|
Loading…
Reference in New Issue
Block a user