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