DEV: Use aliased inject imports (#9086)

This is a common Ember idiom for easier differentiation between controller and service imports.
This commit is contained in:
Jarek Radosz 2020-03-06 17:41:41 +01:00 committed by GitHub
parent 03d5a80aef
commit ef6b7bd776
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 100 additions and 132 deletions

View File

@ -1,12 +1,11 @@
import { alias, equal } from "@ember/object/computed";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import { ajax } from "discourse/lib/ajax";
import discourseComputed from "discourse-common/utils/decorators";
import { setting, i18n } from "discourse/lib/computed";
export default Controller.extend({
adminBackups: inject(),
adminBackups: controller(),
status: alias("adminBackups.model"),
uploadLabel: i18n("admin.backups.upload.label"),
backupLocation: setting("backup_location"),

View File

@ -1,8 +1,8 @@
import { alias } from "@ember/object/computed";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
export default Controller.extend({
adminBackups: inject(),
adminBackups: controller(),
status: alias("adminBackups.model"),
init() {

View File

@ -1,13 +1,13 @@
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import { reads } from "@ember/object/computed";
import Controller, { inject } from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { bufferedProperty } from "discourse/mixins/buffered-content";
import { propertyNotEqual } from "discourse/lib/computed";
import { run } from "@ember/runloop";
export default Controller.extend(bufferedProperty("model"), {
adminBadges: inject(),
adminBadges: controller(),
saving: false,
savingStatus: "",
badgeTypes: reads("adminBadges.badgeTypes"),

View File

@ -1,10 +1,9 @@
import discourseComputed from "discourse-common/utils/decorators";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
export default Controller.extend({
adminSiteSettings: controller(),
categoryNameKey: null,
adminSiteSettings: inject(),
@discourseComputed("adminSiteSettings.visibleSiteSettings", "categoryNameKey")
category(categories, nameKey) {

View File

@ -1,13 +1,12 @@
import discourseComputed from "discourse-common/utils/decorators";
import { alias, sort } from "@ember/object/computed";
import { next } from "@ember/runloop";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import GrantBadgeController from "discourse/mixins/grant-badge-controller";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default Controller.extend(GrantBadgeController, {
adminUser: inject(),
adminUser: controller(),
user: alias("adminUser.model"),
userBadges: alias("model"),
allBadges: alias("badges"),

View File

@ -1,16 +1,15 @@
import discourseComputed from "discourse-common/utils/decorators";
import { or } from "@ember/object/computed";
import { schedule } from "@ember/runloop";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import WatchedWord from "admin/models/watched-word";
import { ajax } from "discourse/lib/ajax";
import { fmt } from "discourse/lib/computed";
import showModal from "discourse/lib/show-modal";
export default Controller.extend({
adminWatchedWords: controller(),
actionNameKey: null,
adminWatchedWords: inject(),
showWordsList: or(
"adminWatchedWords.filtered",
"adminWatchedWords.showWords"

View File

@ -1,14 +1,13 @@
import discourseComputed from "discourse-common/utils/decorators";
import { isEmpty } from "@ember/utils";
import { alias } from "@ember/object/computed";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { extractDomainFromUrl } from "discourse/lib/utilities";
import EmberObject from "@ember/object";
export default Controller.extend({
adminWebHooks: inject(),
adminWebHooks: controller(),
eventTypes: alias("adminWebHooks.eventTypes"),
defaultEventTypes: alias("adminWebHooks.defaultEventTypes"),
contentTypes: alias("adminWebHooks.contentTypes"),

View File

@ -1,7 +1,6 @@
import { isEmpty } from "@ember/utils";
import { and, not } from "@ember/object/computed";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { ajax } from "discourse/lib/ajax";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
@ -54,7 +53,7 @@ const SCSS_VARIABLE_NAMES = [
];
export default Controller.extend(ModalFunctionality, {
adminCustomizeThemesShow: inject(),
adminCustomizeThemesShow: controller(),
uploadUrl: "/admin/themes/upload_asset",

View File

@ -1,9 +1,8 @@
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
export default Controller.extend(ModalFunctionality, {
adminCustomizeColors: inject(),
adminCustomizeColors: controller(),
selectedBaseThemeId: null,

View File

@ -1,6 +1,5 @@
import { equal, match, alias } from "@ember/object/computed";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
@ -12,12 +11,13 @@ import { set } from "@ember/object";
const MIN_NAME_LENGTH = 4;
export default Controller.extend(ModalFunctionality, {
adminCustomizeThemes: controller(),
themesController: controller("adminCustomizeThemes"),
popular: equal("selection", "popular"),
local: equal("selection", "local"),
remote: equal("selection", "remote"),
create: equal("selection", "create"),
selection: "popular",
adminCustomizeThemes: inject(),
loading: false,
keyGenUrl: "/admin/themes/generate_key_pair",
importUrl: "/admin/themes/import",
@ -27,7 +27,6 @@ export default Controller.extend(ModalFunctionality, {
uploadUrl: null,
urlPlaceholder: "https://github.com/discourse/sample_theme",
advancedVisible: false,
themesController: inject("adminCustomizeThemes"),
selectedType: alias("themesController.currentTab"),
component: equal("selectedType", COMPONENTS),

View File

@ -1,9 +1,8 @@
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
export default Controller.extend(ModalFunctionality, {
adminBackupsLogs: inject(),
adminBackupsLogs: controller(),
actions: {
startBackupWithUploads() {

View File

@ -1,12 +1,11 @@
import discourseComputed from "discourse-common/utils/decorators";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { extractError } from "discourse/lib/ajax-error";
import { changeEmail } from "discourse/lib/user-activation";
export default Controller.extend(ModalFunctionality, {
login: inject(),
login: controller(),
currentEmail: null,
newEmail: null,

View File

@ -1,15 +1,14 @@
import { inject } from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import EmberObject from "@ember/object";
import Controller from "@ember/controller";
import Badge from "discourse/models/badge";
import UserBadge from "discourse/models/user-badge";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
export default Controller.extend({
application: controller(),
queryParams: ["username"],
noMoreBadges: false,
userBadges: null,
application: inject(),
hiddenSetTitle: true,
@discourseComputed("userBadgesAll")

View File

@ -1,12 +1,11 @@
import discourseComputed from "discourse-common/utils/decorators";
import { empty } from "@ember/object/computed";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import { topicLevels } from "discourse/lib/notification-levels";
// Support for changing the notification level of various topics
export default Controller.extend({
topicBulkActions: inject(),
topicBulkActions: controller(),
notificationLevelId: null,
@discourseComputed

View File

@ -1,7 +1,6 @@
import { isEmpty } from "@ember/utils";
import { notEmpty, or, not } from "@ember/object/computed";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import { ajax } from "discourse/lib/ajax";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { setting } from "discourse/lib/computed";
@ -26,7 +25,7 @@ export default Controller.extend(
NameValidation,
UserFieldsValidation,
{
login: inject(),
login: controller(),
complete: false,
accountChallenge: 0,

View File

@ -1,14 +1,13 @@
import { alias, not } from "@ember/object/computed";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import DiscourseURL from "discourse/lib/url";
import Category from "discourse/models/category";
import { observes } from "discourse-common/utils/decorators";
export default Controller.extend({
discoveryTopics: inject("discovery/topics"),
navigationCategory: inject("navigation/category"),
application: inject(),
discoveryTopics: controller("discovery/topics"),
navigationCategory: controller("navigation/category"),
application: controller(),
loading: false,

View File

@ -1,6 +1,6 @@
import discourseComputed from "discourse-common/utils/decorators";
import { reads } from "@ember/object/computed";
import { inject } from "@ember/controller";
import { inject as controller } from "@ember/controller";
import DiscoveryController from "discourse/controllers/discovery";
import { dasherize } from "@ember/string";
@ -12,7 +12,7 @@ const subcategoryStyleComponentNames = {
};
export default DiscoveryController.extend({
discovery: inject(),
discovery: controller(),
// this makes sure the composer isn't scoping to a specific category
category: null,

View File

@ -1,6 +1,6 @@
import discourseComputed from "discourse-common/utils/decorators";
import { alias, not, gt, empty, notEmpty, equal } from "@ember/object/computed";
import { inject } from "@ember/controller";
import { inject as controller } from "@ember/controller";
import DiscoveryController from "discourse/controllers/discovery";
import { queryParams } from "discourse/controllers/discovery-sortable";
import BulkTopicSelection from "discourse/mixins/bulk-topic-selection";
@ -11,8 +11,8 @@ import TopicList from "discourse/models/topic-list";
import Topic from "discourse/models/topic";
const controllerOpts = {
discovery: inject(),
discoveryTopics: inject("discovery/topics"),
discovery: controller(),
discoveryTopics: controller("discovery/topics"),
period: null,

View File

@ -1,7 +1,6 @@
import { isEmpty } from "@ember/utils";
import { or } from "@ember/object/computed";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import { ajax } from "discourse/lib/ajax";
import {
translateResults,
@ -26,8 +25,8 @@ const SortOrders = [
const PAGE_LIMIT = 10;
export default Controller.extend({
application: inject(),
composer: inject(),
application: controller(),
composer: controller(),
bulkSelectEnabled: null,
loading: false,

View File

@ -1,12 +1,11 @@
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import { observes } from "discourse-common/utils/decorators";
import { fmt } from "discourse/lib/computed";
export default Controller.extend({
group: inject(),
groupActivity: inject(),
application: inject(),
group: controller(),
groupActivity: controller(),
application: controller(),
canLoadMore: true,
loading: false,
emptyText: fmt("type", "groups.empty.%@"),

View File

@ -1,11 +1,11 @@
import Controller, { inject } from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import { alias } from "@ember/object/computed";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import { popupAjaxError } from "discourse/lib/ajax-error";
import discourseDebounce from "discourse/lib/debounce";
export default Controller.extend({
application: inject(),
application: controller(),
queryParams: ["order", "desc", "filter"],

View File

@ -1,13 +1,12 @@
import { inject } from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import EmberObject from "@ember/object";
import Controller from "@ember/controller";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
export default Controller.extend({
group: inject(),
group: controller(),
application: controller(),
loading: false,
offset: 0,
application: inject(),
init() {
this._super(...arguments);

View File

@ -1,11 +1,11 @@
import Controller, { inject } from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import discourseDebounce from "discourse/lib/debounce";
export default Controller.extend({
application: inject(),
application: controller(),
queryParams: ["order", "desc", "filter"],

View File

@ -1,6 +1,5 @@
import EmberObject from "@ember/object";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import discourseComputed from "discourse-common/utils/decorators";
import { inject as service } from "@ember/service";
import { readOnly } from "@ember/object/computed";
@ -15,7 +14,7 @@ const Tab = EmberObject.extend({
});
export default Controller.extend({
application: inject(),
application: controller(),
counts: null,
showing: "members",
destroying: null,

View File

@ -1,10 +1,9 @@
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import discourseDebounce from "discourse/lib/debounce";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
export default Controller.extend({
application: inject(),
application: controller(),
queryParams: ["order", "asc", "filter", "type"],
order: null,
asc: null,

View File

@ -4,8 +4,7 @@ import { alias, or, readOnly } from "@ember/object/computed";
import EmberObject from "@ember/object";
import { next } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import { ajax } from "discourse/lib/ajax";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import showModal from "discourse/lib/show-modal";
@ -27,9 +26,9 @@ const AuthErrors = [
];
export default Controller.extend(ModalFunctionality, {
createAccount: inject(),
forgotPassword: inject(),
application: inject(),
createAccount: controller(),
forgotPassword: controller(),
application: controller(),
loggingIn: false,
loggedIn: false,

View File

@ -1,11 +1,10 @@
import discourseComputed from "discourse-common/utils/decorators";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import FilterModeMixin from "discourse/mixins/filter-mode";
export default Controller.extend(FilterModeMixin, {
discovery: inject(),
discoveryTopics: inject("discovery/topics"),
discovery: controller(),
discoveryTopics: controller("discovery/topics"),
@discourseComputed("discoveryTopics.model", "discoveryTopics.model.draft")
draft: function() {

View File

@ -1,12 +1,11 @@
import discourseComputed from "discourse-common/utils/decorators";
import { equal } from "@ember/object/computed";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import { ajax } from "discourse/lib/ajax";
import { userPath } from "discourse/lib/url";
export default Controller.extend({
application: inject(),
application: controller(),
showLoginButton: equal("model.path", "login"),

View File

@ -1,8 +1,7 @@
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
export default Controller.extend({
tagGroups: inject(),
tagGroups: controller(),
actions: {
onDestroy() {

View File

@ -1,7 +1,7 @@
import Controller, { inject } from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
export default Controller.extend({
tagGroups: inject(),
tagGroups: controller(),
actions: {
onSave() {

View File

@ -1,6 +1,5 @@
import { alias } from "@ember/object/computed";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import BulkTopicSelection from "discourse/mixins/bulk-topic-selection";
import NavItem from "discourse/models/nav-item";
@ -8,7 +7,7 @@ import FilterModeMixin from "discourse/mixins/filter-mode";
import { queryParams } from "discourse/controllers/discovery-sortable";
export default Controller.extend(BulkTopicSelection, FilterModeMixin, {
application: inject(),
application: controller(),
tag: null,
additionalTags: null,

View File

@ -3,8 +3,7 @@ import { or, and, not, alias } from "@ember/object/computed";
import EmberObject from "@ember/object";
import { next } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import { bufferedProperty } from "discourse/mixins/buffered-content";
import Composer from "discourse/models/composer";
import DiscourseURL from "discourse/lib/url";
@ -39,8 +38,8 @@ export function registerCustomPostMessageCallback(type, callback) {
}
export default Controller.extend(bufferedProperty("model"), {
composer: inject(),
application: inject(),
composer: controller(),
application: controller(),
multiSelect: false,
selectedPostIds: null,
editingTopic: false,
@ -696,10 +695,10 @@ export default Controller.extend(bufferedProperty("model"), {
jumpToPostPrompt() {
const topic = this.model;
const controller = showModal("jump-to-post", {
const modal = showModal("jump-to-post", {
modalClass: "jump-to-post-modal"
});
controller.setProperties({
modal.setProperties({
topic,
postNumber: null,
jumpToIndex: index => this.send("jumpToIndex", index),
@ -840,8 +839,8 @@ export default Controller.extend(bufferedProperty("model"), {
addNotice(post) {
return new Promise(function(resolve, reject) {
const controller = showModal("add-post-notice");
controller.setProperties({ post, resolve, reject });
const modal = showModal("add-post-notice");
modal.setProperties({ post, resolve, reject });
});
},

View File

@ -1,14 +1,13 @@
import { alias } from "@ember/object/computed";
import { inject as service } from "@ember/service";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import { exportUserArchive } from "discourse/lib/export-csv";
import { observes } from "discourse-common/utils/decorators";
export default Controller.extend({
application: inject(),
application: controller(),
user: controller(),
router: service(),
user: inject(),
userActionType: null,
canDownloadPosts: alias("user.viewingSelf"),

View File

@ -1,8 +1,8 @@
import { alias, sort } from "@ember/object/computed";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
export default Controller.extend({
user: inject(),
user: controller(),
username: alias("user.model.username_lower"),
sortedBadges: sort("model", "badgeSortOrder"),

View File

@ -1,10 +1,9 @@
import { inject as service } from "@ember/service";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import DiscourseURL, { userPath, groupPath } from "discourse/lib/url";
export default Controller.extend({
topic: inject(),
topic: controller(),
router: service(),
actions: {

View File

@ -1,12 +1,11 @@
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import { ajax } from "discourse/lib/ajax";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import { readOnly } from "@ember/object/computed";
import { inject as service } from "@ember/service";
export default Controller.extend({
application: inject(),
application: controller(),
router: service(),
currentPath: readOnly("router._router.currentPath"),

View File

@ -1,9 +1,8 @@
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import { observes } from "discourse-common/utils/decorators";
export default Controller.extend({
application: inject(),
application: controller(),
@observes("model.canLoadMore")
_showFooter: function() {

View File

@ -1,14 +1,13 @@
import discourseComputed from "discourse-common/utils/decorators";
import { alias, equal, and } from "@ember/object/computed";
import { inject as service } from "@ember/service";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import Topic from "discourse/models/topic";
export default Controller.extend({
userTopicsList: controller("user-topics-list"),
user: controller(),
router: service(),
userTopicsList: inject("user-topics-list"),
user: inject(),
pmView: false,
viewingSelf: alias("user.viewingSelf"),

View File

@ -1,10 +1,9 @@
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
// Lists of topics on a user's page.
export default Controller.extend({
application: inject(),
application: controller(),
hideCategory: false,
showPosters: false,

View File

@ -1,11 +1,10 @@
import { equal } from "@ember/object/computed";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import Controller, { inject as controller } from "@ember/controller";
import discourseDebounce from "discourse/lib/debounce";
import { observes } from "discourse-common/utils/decorators";
export default Controller.extend({
application: inject(),
application: controller(),
queryParams: ["period", "order", "asc", "name", "group", "exclude_usernames"],
period: "weekly",
order: "likes_received",