From fab36e6cf7580d0b89c26f98c00ce6384ba54700 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 21 Oct 2016 14:09:52 -0400 Subject: [PATCH] Fix more deprecations: - Remove all `needs:` code --- .../controllers/admin-badges-show.js.es6 | 8 +++---- .../admin-customize-css-html-show.js.es6 | 13 +++++------ .../admin-site-settings-category.js.es6 | 2 +- .../controllers/admin-web-hooks-show.js.es6 | 12 +++++----- .../modals/admin-badge-preview.js.es6 | 8 +++---- .../modals/admin-edit-badge-groupings.js.es6 | 1 - .../modals/admin-start-backup.js.es6 | 22 ++++++++----------- .../discourse/components/queued-post.js.es6 | 1 - .../discourse/controllers/badges/show.js.es6 | 4 ++-- .../discourse/controllers/change-owner.js.es6 | 4 +--- .../controllers/change-timestamp.js.es6 | 3 +-- .../discourse/controllers/composer.js.es6 | 8 ++++--- .../controllers/create-account.js.es6 | 4 ++-- .../controllers/discovery-sortable.js.es6 | 8 +++---- .../discourse/controllers/discovery.js.es6 | 13 ++++++----- .../controllers/discovery/categories.js.es6 | 2 +- .../controllers/discovery/topics.js.es6 | 15 +++++++------ .../controllers/edit-category.js.es6 | 6 ++--- .../controllers/feature-topic.js.es6 | 4 ++-- .../controllers/full-page-search.js.es6 | 4 ++-- .../discourse/controllers/invite.js.es6 | 6 ++--- .../keyboard-shortcuts-help.js.es6 | 6 ++--- .../discourse/controllers/login.js.es6 | 16 +++++++++----- .../discourse/controllers/merge-topic.js.es6 | 5 ++--- .../controllers/navigation/default.js.es6 | 3 ++- .../discourse/controllers/quote-button.js.es6 | 15 +++++++------ .../discourse/controllers/search-help.js.es6 | 2 -- .../discourse/controllers/share.js.es6 | 8 +++---- .../discourse/controllers/split-topic.js.es6 | 5 ++--- .../discourse/controllers/static.js.es6 | 4 ++-- .../discourse/controllers/tags-show.js.es6 | 4 ++-- .../controllers/topic-bulk-actions.js.es6 | 4 ++-- .../discourse/controllers/topic.js.es6 | 17 ++++++++------ .../controllers/upload-customization.js.es6 | 4 ++-- .../controllers/user-activity.js.es6 | 12 +++++----- .../discourse/controllers/user-card.js.es6 | 12 +++++----- .../discourse/controllers/user-posts.js.es6 | 4 ++-- .../controllers/user-private-messages.js.es6 | 19 +++++++++------- .../discourse/controllers/user-summary.js.es6 | 4 ++-- .../controllers/user-topics-list.js.es6 | 5 +++-- .../discourse/controllers/user.js.es6 | 5 +++-- .../discourse/controllers/users.js.es6 | 4 ++-- .../discourse/lib/show-modal.js.es6 | 1 + .../mixins/modal-functionality.js.es6 | 4 +--- .../discourse/views/modal-body.js.es6 | 2 +- .../controllers/poll-ui-builder.js.es6 | 1 - .../javascripts/views/poll-ui-builder.js.es6 | 2 -- 47 files changed, 159 insertions(+), 157 deletions(-) diff --git a/app/assets/javascripts/admin/controllers/admin-badges-show.js.es6 b/app/assets/javascripts/admin/controllers/admin-badges-show.js.es6 index 122a63c42d1..7d11fc86226 100644 --- a/app/assets/javascripts/admin/controllers/admin-badges-show.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-badges-show.js.es6 @@ -7,10 +7,10 @@ export default Ember.Controller.extend(BufferedContent, { saving: false, savingStatus: '', - badgeTypes: Em.computed.alias('adminBadges.badgeTypes'), - badgeGroupings: Em.computed.alias('adminBadges.badgeGroupings'), - badgeTriggers: Em.computed.alias('adminBadges.badgeTriggers'), - protectedSystemFields: Em.computed.alias('adminBadges.protectedSystemFields'), + badgeTypes: Ember.computed.alias('adminBadges.badgeTypes'), + badgeGroupings: Ember.computed.alias('adminBadges.badgeGroupings'), + badgeTriggers: Ember.computed.alias('adminBadges.badgeTriggers'), + protectedSystemFields: Ember.computed.alias('adminBadges.protectedSystemFields'), readOnly: Ember.computed.alias('buffered.system'), showDisplayName: propertyNotEqual('name', 'displayName'), diff --git a/app/assets/javascripts/admin/controllers/admin-customize-css-html-show.js.es6 b/app/assets/javascripts/admin/controllers/admin-customize-css-html-show.js.es6 index 03c855a969c..47cf280ae6c 100644 --- a/app/assets/javascripts/admin/controllers/admin-customize-css-html-show.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-customize-css-html-show.js.es6 @@ -33,7 +33,7 @@ export default Ember.Controller.extend(activeSections, { return !this.get('model.changed') || this.get('model.isSaving'); }.property('model.changed', 'model.isSaving'), - needs: ['adminCustomizeCssHtml'], + adminCustomizeCssHtml: Ember.inject.controller(), undoPreviewUrl: url('/?preview-style='), defaultStyleUrl: url('/?preview-style=default'), @@ -44,13 +44,12 @@ export default Ember.Controller.extend(activeSections, { }, destroy() { - const self = this; - return bootbox.confirm(I18n.t("admin.customize.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) { + return bootbox.confirm(I18n.t("admin.customize.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), result => { if (result) { - const model = self.get('model'); - model.destroyRecord().then(function() { - self.get('controllers.adminCustomizeCssHtml').get('model').removeObject(model); - self.transitionToRoute('adminCustomizeCssHtml'); + const model = this.get('model'); + model.destroyRecord().then(() => { + this.get('adminCustomizeCssHtml').get('model').removeObject(model); + this.transitionToRoute('adminCustomizeCssHtml'); }); } }); diff --git a/app/assets/javascripts/admin/controllers/admin-site-settings-category.js.es6 b/app/assets/javascripts/admin/controllers/admin-site-settings-category.js.es6 index 3feb90f40ea..027957b1954 100644 --- a/app/assets/javascripts/admin/controllers/admin-site-settings-category.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-site-settings-category.js.es6 @@ -11,6 +11,6 @@ export default Ember.Controller.extend({ } else { return []; } - }.property('controllers.adminSiteSettings.content', 'categoryNameKey') + }.property('adminSiteSettings.content', 'categoryNameKey') }); diff --git a/app/assets/javascripts/admin/controllers/admin-web-hooks-show.js.es6 b/app/assets/javascripts/admin/controllers/admin-web-hooks-show.js.es6 index 7cb76be26cd..53d8370403b 100644 --- a/app/assets/javascripts/admin/controllers/admin-web-hooks-show.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-web-hooks-show.js.es6 @@ -4,10 +4,10 @@ import computed from 'ember-addons/ember-computed-decorators'; import InputValidation from 'discourse/models/input-validation'; export default Ember.Controller.extend({ - needs: ['adminWebHooks'], - eventTypes: Em.computed.alias('controllers.adminWebHooks.eventTypes'), - defaultEventTypes: Em.computed.alias('controllers.adminWebHooks.defaultEventTypes'), - contentTypes: Em.computed.alias('controllers.adminWebHooks.contentTypes'), + adminWebHooks: Ember.inject.controller(), + eventTypes: Ember.computed.alias('adminWebHooks.eventTypes'), + defaultEventTypes: Ember.computed.alias('adminWebHooks.defaultEventTypes'), + contentTypes: Ember.computed.alias('adminWebHooks.contentTypes'), @computed('model.isSaving', 'saved', 'saveButtonDisabled') savingStatus(isSaving, saved, saveButtonDisabled) { @@ -68,7 +68,7 @@ export default Ember.Controller.extend({ const saveWebHook = () => { return model.save().then(() => { this.set('saved', true); - this.get('controllers.adminWebHooks').get('model').addObject(model); + this.get('adminWebHooks').get('model').addObject(model); }).catch(popupAjaxError); }; @@ -88,7 +88,7 @@ export default Ember.Controller.extend({ if (result) { const model = this.get('model'); model.destroyRecord().then(() => { - this.get('controllers.adminWebHooks').get('model').removeObject(model); + this.get('adminWebHooks').get('model').removeObject(model); this.transitionToRoute('adminWebHooks'); }).catch(popupAjaxError); } diff --git a/app/assets/javascripts/admin/controllers/modals/admin-badge-preview.js.es6 b/app/assets/javascripts/admin/controllers/modals/admin-badge-preview.js.es6 index 8f93884c604..8aaf637552e 100644 --- a/app/assets/javascripts/admin/controllers/modals/admin-badge-preview.js.es6 +++ b/app/assets/javascripts/admin/controllers/modals/admin-badge-preview.js.es6 @@ -1,11 +1,9 @@ import { escapeExpression } from 'discourse/lib/utilities'; export default Ember.Controller.extend({ - needs: ['modal'], - - sample: Em.computed.alias('model.sample'), - errors: Em.computed.alias('model.errors'), - count: Em.computed.alias('model.grant_count'), + sample: Ember.computed.alias('model.sample'), + errors: Ember.computed.alias('model.errors'), + count: Ember.computed.alias('model.grant_count'), count_warning: function() { if (this.get('count') <= 10) { diff --git a/app/assets/javascripts/admin/controllers/modals/admin-edit-badge-groupings.js.es6 b/app/assets/javascripts/admin/controllers/modals/admin-edit-badge-groupings.js.es6 index 086080c1738..fe0416bc307 100644 --- a/app/assets/javascripts/admin/controllers/modals/admin-edit-badge-groupings.js.es6 +++ b/app/assets/javascripts/admin/controllers/modals/admin-edit-badge-groupings.js.es6 @@ -1,6 +1,5 @@ import { ajax } from 'discourse/lib/ajax'; export default Ember.Controller.extend({ - needs: ['modal'], modelChanged: function(){ const model = this.get('model'); diff --git a/app/assets/javascripts/admin/controllers/modals/admin-start-backup.js.es6 b/app/assets/javascripts/admin/controllers/modals/admin-start-backup.js.es6 index 15cd838245b..c041b24f744 100644 --- a/app/assets/javascripts/admin/controllers/modals/admin-start-backup.js.es6 +++ b/app/assets/javascripts/admin/controllers/modals/admin-start-backup.js.es6 @@ -2,31 +2,27 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality'; import Backup from 'admin/models/backup'; export default Ember.Controller.extend(ModalFunctionality, { - needs: ["adminBackupsLogs"], + adminBackupsLogs: Ember.inject.controller(), - _startBackup: function (withUploads) { - var self = this; - Discourse.User.currentProp("hideReadOnlyAlert", true); - Backup.start(withUploads).then(function() { - self.get("controllers.adminBackupsLogs").clear(); - self.send("backupStarted"); + _startBackup(withUploads) { + this.currentUser.set('hideReadOnlyAlert', true); + Backup.start(withUploads).then(() => { + this.get("adminBackupsLogs.logs").clear(); + this.send("backupStarted"); }); }, actions: { - - startBackup: function () { + startBackup() { this._startBackup(); }, - startBackupWithoutUpload: function () { + startBackupWithoutUpload() { this._startBackup(false); }, - cancel: function () { + cancel() { this.send("closeModal"); } - } - }); diff --git a/app/assets/javascripts/discourse/components/queued-post.js.es6 b/app/assets/javascripts/discourse/components/queued-post.js.es6 index 28f5a90fdd0..9629724b438 100644 --- a/app/assets/javascripts/discourse/components/queued-post.js.es6 +++ b/app/assets/javascripts/discourse/components/queued-post.js.es6 @@ -13,7 +13,6 @@ function updateState(state, opts) { post.update(args).then(() => { this.sendAction('removePost', post); - // this.get('controllers.queued-posts.model').removeObject(post); }).catch(popupAjaxError); }; } diff --git a/app/assets/javascripts/discourse/controllers/badges/show.js.es6 b/app/assets/javascripts/discourse/controllers/badges/show.js.es6 index 086e353c07b..f7f79f14c48 100644 --- a/app/assets/javascripts/discourse/controllers/badges/show.js.es6 +++ b/app/assets/javascripts/discourse/controllers/badges/show.js.es6 @@ -5,7 +5,7 @@ export default Ember.Controller.extend({ queryParams: ['username'], noMoreBadges: false, userBadges: null, - needs: ["application"], + application: Ember.inject.controller(), @computed('username') user(username) { @@ -55,7 +55,7 @@ export default Ember.Controller.extend({ @observes('canLoadMore') _showFooter() { - this.set("controllers.application.showFooter", !this.get("canLoadMore")); + this.set("application.showFooter", !this.get("canLoadMore")); } }); diff --git a/app/assets/javascripts/discourse/controllers/change-owner.js.es6 b/app/assets/javascripts/discourse/controllers/change-owner.js.es6 index 532b21a0bbb..84c323b88a6 100644 --- a/app/assets/javascripts/discourse/controllers/change-owner.js.es6 +++ b/app/assets/javascripts/discourse/controllers/change-owner.js.es6 @@ -4,9 +4,7 @@ import DiscourseURL from 'discourse/lib/url'; // Modal related to changing the ownership of posts export default Ember.Controller.extend(SelectedPostsCount, ModalFunctionality, { - needs: ['topic'], - - topicController: Em.computed.alias('controllers.topic'), + topicController: Ember.inject.controller('topic'), selectedPosts: Em.computed.alias('topicController.selectedPosts'), saving: false, new_user: null, diff --git a/app/assets/javascripts/discourse/controllers/change-timestamp.js.es6 b/app/assets/javascripts/discourse/controllers/change-timestamp.js.es6 index 1cd859cfa68..c24cf785c90 100644 --- a/app/assets/javascripts/discourse/controllers/change-timestamp.js.es6 +++ b/app/assets/javascripts/discourse/controllers/change-timestamp.js.es6 @@ -4,9 +4,8 @@ import DiscourseURL from 'discourse/lib/url'; // Modal related to changing the timestamp of posts export default Ember.Controller.extend(ModalFunctionality, { - needs: ['topic'], - topicController: Em.computed.alias('controllers.topic'), + topicController: Ember.inject.controller('topic'), saving: false, date: '', time: '', diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6 index c04063ed1b0..49473cc70bc 100644 --- a/app/assets/javascripts/discourse/controllers/composer.js.es6 +++ b/app/assets/javascripts/discourse/controllers/composer.js.es6 @@ -51,7 +51,9 @@ export function addPopupMenuOptionsCallback(callback) { } export default Ember.Controller.extend({ - needs: ['modal', 'topic', 'application'], + topicController: Ember.inject.controller('topic'), + application: Ember.inject.controller(), + replyAsNewTopicDraft: Em.computed.equal('model.draftKey', Composer.REPLY_AS_NEW_TOPIC_KEY), checkedMessages: false, messageCount: null, @@ -102,7 +104,7 @@ export default Ember.Controller.extend({ } }), - topicModel: Ember.computed.alias('controllers.topic.model'), + topicModel: Ember.computed.alias('topicController.model'), @computed('model.canEditTitle', 'model.creatingPrivateMessage') canEditTags(canEditTitle, creatingPrivateMessage) { @@ -484,7 +486,7 @@ export default Ember.Controller.extend({ self.appEvents.one('composer:will-open', () => bootbox.alert(error)); }); - if (this.get('controllers.application.currentRouteName').split('.')[0] === 'topic' && + if (this.get('application.currentRouteName').split('.')[0] === 'topic' && composer.get('topic.id') === this.get('topicModel.id')) { staged = composer.get('stagedPost'); } diff --git a/app/assets/javascripts/discourse/controllers/create-account.js.es6 b/app/assets/javascripts/discourse/controllers/create-account.js.es6 index 9bed6142a42..b3d04dd7496 100644 --- a/app/assets/javascripts/discourse/controllers/create-account.js.es6 +++ b/app/assets/javascripts/discourse/controllers/create-account.js.es6 @@ -7,7 +7,7 @@ import { emailValid } from 'discourse/lib/utilities'; import InputValidation from 'discourse/models/input-validation'; export default Ember.Controller.extend(ModalFunctionality, { - needs: ['login'], + login: Ember.inject.controller(), uniqueUsernameValidation: null, globalNicknameExists: false, @@ -345,7 +345,7 @@ export default Ember.Controller.extend(ModalFunctionality, { actions: { externalLogin(provider) { - this.get('controllers.login').send('externalLogin', provider); + this.get('login').send('externalLogin', provider); }, createAccount() { diff --git a/app/assets/javascripts/discourse/controllers/discovery-sortable.js.es6 b/app/assets/javascripts/discourse/controllers/discovery-sortable.js.es6 index 5ac8d4b7339..91fd9489905 100644 --- a/app/assets/javascripts/discourse/controllers/discovery-sortable.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery-sortable.js.es6 @@ -1,5 +1,5 @@ // Just add query params here to have them automatically passed to topic list filters. -export var queryParams = { +export const queryParams = { order: { replace: true, refreshModel: true }, ascending: { replace: true, refreshModel: true }, status: { replace: true, refreshModel: true }, @@ -10,12 +10,12 @@ export var queryParams = { }; // Basic controller options -var controllerOpts = { - needs: ['discovery/topics'], +const controllerOpts = { + discoveryTopics: Ember.inject.controller('discovery/topics'), queryParams: Object.keys(queryParams), }; // Aliases for the values -controllerOpts.queryParams.forEach(p => controllerOpts[p] = Em.computed.alias(`controllers.discovery/topics.${p}`)); +controllerOpts.queryParams.forEach(p => controllerOpts[p] = Ember.computed.alias(`discoveryTopics.${p}`)); export default Ember.Controller.extend(controllerOpts); diff --git a/app/assets/javascripts/discourse/controllers/discovery.js.es6 b/app/assets/javascripts/discourse/controllers/discovery.js.es6 index 2be7bfd2066..79128e82ad7 100644 --- a/app/assets/javascripts/discourse/controllers/discovery.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery.js.es6 @@ -1,16 +1,19 @@ import DiscourseURL from 'discourse/lib/url'; export default Ember.Controller.extend({ - needs: ['navigation/category', 'discovery/topics', 'application'], + discoveryTopics: Ember.inject.controller('discovery/topics'), + navigationCategory: Ember.inject.controller('navigation/category'), + application: Ember.inject.controller(), + loading: false, - category: Em.computed.alias('controllers.navigation/category.category'), - noSubcategories: Em.computed.alias('controllers.navigation/category.noSubcategories'), + category: Em.computed.alias('navigationCategory.category'), + noSubcategories: Em.computed.alias('navigationCategory.noSubcategories'), - loadedAllItems: Em.computed.not("controllers.discovery/topics.model.canLoadMore"), + loadedAllItems: Em.computed.not("discoveryTopics.model.canLoadMore"), _showFooter: function() { - this.set("controllers.application.showFooter", this.get("loadedAllItems")); + this.set("application.showFooter", this.get("loadedAllItems")); }.observes("loadedAllItems"), showMoreUrl(period) { diff --git a/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 index 2202a0793e3..3fa74ca054f 100644 --- a/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 @@ -2,7 +2,7 @@ import computed from 'ember-addons/ember-computed-decorators'; import DiscoveryController from 'discourse/controllers/discovery'; export default DiscoveryController.extend({ - needs: ['modal', 'discovery'], + discovery: Ember.inject.controller(), // this makes sure the composer isn't scoping to a specific category category: null, diff --git a/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 index 008ab29a3b0..4c92f6da87f 100644 --- a/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 @@ -5,13 +5,14 @@ import { endWith } from 'discourse/lib/computed'; import showModal from 'discourse/lib/show-modal'; const controllerOpts = { - needs: ['discovery'], + discovery: Ember.inject.controller(), + discoveryTopics: Ember.inject.controller('discovery/topics'), + period: null, - canStar: Em.computed.alias('controllers.discovery/topics.currentUser.id'), - showTopicPostBadges: Em.computed.not('controllers.discovery/topics.new'), - - redirectedReason: Em.computed.alias('currentUser.redirected_to_top.reason'), + canStar: Ember.computed.alias('currentUser.id'), + showTopicPostBadges: Ember.computed.not('discoveryTopics.new'), + redirectedReason: Ember.computed.alias('currentUser.redirected_to_top.reason'), order: 'default', ascending: false, @@ -46,12 +47,12 @@ const controllerOpts = { this.setProperties({ order: "default", ascending: false }); // Don't refresh if we're still loading - if (this.get('controllers.discovery.loading')) { return; } + if (this.get('discovery.loading')) { return; } // If we `send('loading')` here, due to returning true it bubbles up to the // router and ember throws an error due to missing `handlerInfos`. // Lesson learned: Don't call `loading` yourself. - this.set('controllers.discovery.loading', true); + this.set('discovery.loading', true); this.store.findFiltered('topicList', {filter}).then(list => { const TopicList = require('discourse/models/topic-list').default; diff --git a/app/assets/javascripts/discourse/controllers/edit-category.js.es6 b/app/assets/javascripts/discourse/controllers/edit-category.js.es6 index d77783bc0a3..cdc773d592b 100644 --- a/app/assets/javascripts/discourse/controllers/edit-category.js.es6 +++ b/app/assets/javascripts/discourse/controllers/edit-category.js.es6 @@ -20,9 +20,9 @@ export default Ember.Controller.extend(ModalFunctionality, { changeSize: function() { if (!Ember.isEmpty(this.get('model.description'))) { - this.set('controllers.modal.modalClass', 'edit-category-modal full'); + this.set('modal.modalClass', 'edit-category-modal full'); } else { - this.set('controllers.modal.modalClass', 'edit-category-modal small'); + this.set('modal.modalClass', 'edit-category-modal small'); } }.observes('model.description'), @@ -34,7 +34,7 @@ export default Ember.Controller.extend(ModalFunctionality, { }.property('model.id', 'model.name'), titleChanged: function() { - this.set('controllers.modal.title', this.get('title')); + this.set('modal.title', this.get('title')); }.observes('title'), disabled: function() { diff --git a/app/assets/javascripts/discourse/controllers/feature-topic.js.es6 b/app/assets/javascripts/discourse/controllers/feature-topic.js.es6 index bb195b636b4..997f2a08889 100644 --- a/app/assets/javascripts/discourse/controllers/feature-topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/feature-topic.js.es6 @@ -5,7 +5,7 @@ import computed from 'ember-addons/ember-computed-decorators'; import InputValidation from 'discourse/models/input-validation'; export default Ember.Controller.extend(ModalFunctionality, { - needs: ["topic"], + topicController: Ember.inject.controller('topic'), loading: true, pinnedInCategoryCount: 0, @@ -106,7 +106,7 @@ export default Ember.Controller.extend(ModalFunctionality, { }, _forwardAction(name) { - this.get("controllers.topic").send(name); + this.get("topicController").send(name); this.send("closeModal"); }, diff --git a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 index d6998661269..91e5b907d2c 100644 --- a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 +++ b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 @@ -14,7 +14,7 @@ const SortOrders = [ ]; export default Ember.Controller.extend({ - needs: ["application"], + application: Ember.inject.controller(), bulkSelectEnabled: null, loading: Em.computed.not("model"), @@ -131,7 +131,7 @@ export default Ember.Controller.extend({ @observes('loading') _showFooter() { - this.set("controllers.application.showFooter", !this.get("loading")); + this.set("application.showFooter", !this.get("loading")); }, @computed('hasResults') diff --git a/app/assets/javascripts/discourse/controllers/invite.js.es6 b/app/assets/javascripts/discourse/controllers/invite.js.es6 index cd4c6afec3d..03d848e6a22 100644 --- a/app/assets/javascripts/discourse/controllers/invite.js.es6 +++ b/app/assets/javascripts/discourse/controllers/invite.js.es6 @@ -2,7 +2,7 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality'; import { emailValid } from 'discourse/lib/utilities'; export default Ember.Controller.extend(ModalFunctionality, { - needs: ['user-invited-show'], + userInvitedShow: Ember.inject.controller('user-invited-show'), // If this isn't defined, it will proxy to the user model on the preferences // page which is wrong. @@ -169,7 +169,7 @@ export default Ember.Controller.extend(ModalFunctionality, { if (this.get('disabled')) { return; } const groupNames = this.get('model.groupNames'), - userInvitedController = this.get('controllers.user-invited-show'), + userInvitedController = this.get('userInvitedShow'), model = this.get('model'); model.setProperties({ saving: true, error: false }); @@ -215,7 +215,7 @@ export default Ember.Controller.extend(ModalFunctionality, { if (this.get('disabled')) { return; } const groupNames = this.get('model.groupNames'), - userInvitedController = this.get('controllers.user-invited-show'), + userInvitedController = this.get('userInvitedShow'), model = this.get('model'); var topicId = null; diff --git a/app/assets/javascripts/discourse/controllers/keyboard-shortcuts-help.js.es6 b/app/assets/javascripts/discourse/controllers/keyboard-shortcuts-help.js.es6 index 5e0414bcd08..7a50811e572 100644 --- a/app/assets/javascripts/discourse/controllers/keyboard-shortcuts-help.js.es6 +++ b/app/assets/javascripts/discourse/controllers/keyboard-shortcuts-help.js.es6 @@ -1,9 +1,7 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality'; export default Ember.Controller.extend(ModalFunctionality, { - needs: ['modal'], - - onShow: function() { - this.set('controllers.modal.modalClass', 'keyboard-shortcuts-modal'); + onShow() { + this.set('modal.modalClass', 'keyboard-shortcuts-modal'); } }); diff --git a/app/assets/javascripts/discourse/controllers/login.js.es6 b/app/assets/javascripts/discourse/controllers/login.js.es6 index 8909993ccaf..ecde7b9f8ec 100644 --- a/app/assets/javascripts/discourse/controllers/login.js.es6 +++ b/app/assets/javascripts/discourse/controllers/login.js.es6 @@ -11,13 +11,17 @@ const AuthErrors = 'not_allowed_from_ip_address']; export default Ember.Controller.extend(ModalFunctionality, { - needs: ['modal', 'createAccount', 'forgotPassword', 'application'], + + createAccount: Ember.inject.controller(), + forgotPassword: Ember.inject.controller(), + application: Ember.inject.controller(), + authenticate: null, loggingIn: false, loggedIn: false, canLoginLocal: setting('enable_local_logins'), - loginRequired: Em.computed.alias('controllers.application.loginRequired'), + loginRequired: Em.computed.alias('application.loginRequired'), resetForm: function() { this.set('authenticate', null); @@ -37,7 +41,7 @@ export default Ember.Controller.extend(ModalFunctionality, { loginDisabled: Em.computed.or('loggingIn', 'loggedIn'), showSignupLink: function() { - return this.get('controllers.application.canSignUp') && + return this.get('application.canSignUp') && !this.get('loggingIn') && Ember.isEmpty(this.get('authenticate')); }.property('loggingIn', 'authenticate'), @@ -160,7 +164,7 @@ export default Ember.Controller.extend(ModalFunctionality, { }, createAccount: function() { - const createAccountController = this.get('controllers.createAccount'); + const createAccountController = this.get('createAccount'); if (createAccountController) { createAccountController.resetForm(); const loginName = this.get('loginName'); @@ -174,7 +178,7 @@ export default Ember.Controller.extend(ModalFunctionality, { }, forgotPassword: function() { - const forgotPasswordController = this.get('controllers.forgotPassword'); + const forgotPasswordController = this.get('forgotPassword'); if (forgotPasswordController) { forgotPasswordController.set("accountEmailOrUsername", this.get("loginName")); } this.send("showForgotPassword"); } @@ -229,7 +233,7 @@ export default Ember.Controller.extend(ModalFunctionality, { return; } - const createAccountController = this.get('controllers.createAccount'); + const createAccountController = this.get('createAccount'); createAccountController.setProperties({ accountEmail: options.email, accountUsername: options.username, diff --git a/app/assets/javascripts/discourse/controllers/merge-topic.js.es6 b/app/assets/javascripts/discourse/controllers/merge-topic.js.es6 index 197c9fcb377..34bfa8ba34e 100644 --- a/app/assets/javascripts/discourse/controllers/merge-topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/merge-topic.js.es6 @@ -5,12 +5,11 @@ import DiscourseURL from 'discourse/lib/url'; // Modal related to merging of topics export default Ember.Controller.extend(SelectedPostsCount, ModalFunctionality, { - needs: ['topic'], + topicController: Ember.inject.controller('topic'), saving: false, selectedTopicId: null, - topicController: Em.computed.alias('controllers.topic'), selectedPosts: Em.computed.alias('topicController.selectedPosts'), selectedReplies: Em.computed.alias('topicController.selectedReplies'), allPostsSelected: Em.computed.alias('topicController.allPostsSelected'), @@ -26,7 +25,7 @@ export default Ember.Controller.extend(SelectedPostsCount, ModalFunctionality, { }.property('saving'), onShow() { - this.set('controllers.modal.modalClass', 'split-modal'); + this.set('modal.modalClass', 'split-modal'); }, actions: { diff --git a/app/assets/javascripts/discourse/controllers/navigation/default.js.es6 b/app/assets/javascripts/discourse/controllers/navigation/default.js.es6 index 1d23c1fb2b1..93ae014e474 100644 --- a/app/assets/javascripts/discourse/controllers/navigation/default.js.es6 +++ b/app/assets/javascripts/discourse/controllers/navigation/default.js.es6 @@ -1,7 +1,8 @@ import computed from "ember-addons/ember-computed-decorators"; export default Ember.Controller.extend({ - needs: ['discovery', 'discovery/topics'], + discovery: Ember.inject.controller(), + discoveryTopics: Ember.inject.controller('discovery/topics'), @computed() categories() { diff --git a/app/assets/javascripts/discourse/controllers/quote-button.js.es6 b/app/assets/javascripts/discourse/controllers/quote-button.js.es6 index f3e0447a7f3..d91712542e6 100644 --- a/app/assets/javascripts/discourse/controllers/quote-button.js.es6 +++ b/app/assets/javascripts/discourse/controllers/quote-button.js.es6 @@ -3,13 +3,14 @@ import computed from 'ember-addons/ember-computed-decorators'; import { selectedText } from 'discourse/lib/utilities'; export default Ember.Controller.extend({ - needs: ['topic', 'composer'], + topic: Ember.inject.controller(), + composer: Ember.inject.controller(), @computed('buffer', 'postId') post(buffer, postId) { if (!postId || Ember.isEmpty(buffer)) { return null; } - const postStream = this.get('controllers.topic.model.postStream'); + const postStream = this.get('topic.model.postStream'); const post = postStream.findLoadedPost(postId); return post; @@ -22,7 +23,7 @@ export default Ember.Controller.extend({ if (!this.currentUser) return; // don't display the "quote-reply" button if we can't reply - const topicDetails = this.get('controllers.topic.model.details'); + const topicDetails = this.get('topic.model.details'); if (!(topicDetails.get('can_reply_as_new_topic') || topicDetails.get('can_create_post'))) { return; } @@ -106,7 +107,7 @@ export default Ember.Controller.extend({ // defer load if needed, if in an expanded replies section if (!post) { - const postStream = this.get('controllers.topic.model.postStream'); + const postStream = this.get('topic.model.postStream'); return postStream.loadPost(postId).then(p => { this.set('post', p); return this.quoteText(); @@ -114,12 +115,12 @@ export default Ember.Controller.extend({ } // If we can't create a post, delegate to reply as new topic - if (!this.get('controllers.topic.model.details.can_create_post')) { - this.get('controllers.topic').send('replyAsNewTopic', post); + if (!this.get('topic.model.details.can_create_post')) { + this.get('topic').send('replyAsNewTopic', post); return; } - const composerController = this.get('controllers.composer'); + const composerController = this.get('composer'); const composerOpts = { action: Composer.REPLY, draftKey: post.get('topic.draft_key') diff --git a/app/assets/javascripts/discourse/controllers/search-help.js.es6 b/app/assets/javascripts/discourse/controllers/search-help.js.es6 index 7f5958ae4de..0d5bb501047 100644 --- a/app/assets/javascripts/discourse/controllers/search-help.js.es6 +++ b/app/assets/javascripts/discourse/controllers/search-help.js.es6 @@ -1,8 +1,6 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality'; export default Ember.Controller.extend(ModalFunctionality, { - needs: ['modal'], - showGoogleSearch: function() { return !Discourse.SiteSettings.login_required; }.property() diff --git a/app/assets/javascripts/discourse/controllers/share.js.es6 b/app/assets/javascripts/discourse/controllers/share.js.es6 index 97f1fb4d267..00dc5363648 100644 --- a/app/assets/javascripts/discourse/controllers/share.js.es6 +++ b/app/assets/javascripts/discourse/controllers/share.js.es6 @@ -3,10 +3,10 @@ import { longDateNoYear } from 'discourse/lib/formatter'; import computed from 'ember-addons/ember-computed-decorators'; export default Ember.Controller.extend({ - needs: ['topic'], + topic: Ember.inject.controller(), - title: Ember.computed.alias('controllers.topic.model.title'), - canReplyAsNewTopic: Ember.computed.alias('controllers.topic.model.details.can_reply_as_new_topic'), + title: Ember.computed.alias('topic.model.title'), + canReplyAsNewTopic: Ember.computed.alias('topic.model.details.can_reply_as_new_topic'), @computed('type', 'postNumber') shareTitle(type, postNumber) { @@ -31,7 +31,7 @@ export default Ember.Controller.extend({ }, replyAsNewTopic() { - const topicController = this.get("controllers.topic"); + const topicController = this.get("topic"); const postStream = topicController.get("model.postStream"); const postId = this.get("postId") || postStream.findPostIdForPostNumber(1); const post = postStream.findLoadedPost(postId); diff --git a/app/assets/javascripts/discourse/controllers/split-topic.js.es6 b/app/assets/javascripts/discourse/controllers/split-topic.js.es6 index b8a1a72509e..c8ea321570e 100644 --- a/app/assets/javascripts/discourse/controllers/split-topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/split-topic.js.es6 @@ -6,12 +6,11 @@ import DiscourseURL from 'discourse/lib/url'; // Modal related to auto closing of topics export default Ember.Controller.extend(SelectedPostsCount, ModalFunctionality, { - needs: ['topic'], topicName: null, saving: false, categoryId: null, - topicController: Em.computed.alias('controllers.topic'), + topicController: Ember.inject.controller('topic'), selectedPosts: Em.computed.alias('topicController.selectedPosts'), selectedReplies: Em.computed.alias('topicController.selectedReplies'), allPostsSelected: Em.computed.alias('topicController.allPostsSelected'), @@ -28,7 +27,7 @@ export default Ember.Controller.extend(SelectedPostsCount, ModalFunctionality, { onShow() { this.setProperties({ - 'controllers.modal.modalClass': 'split-modal', + 'modal.modalClass': 'split-modal', saving: false, categoryId: null, topicName: '' diff --git a/app/assets/javascripts/discourse/controllers/static.js.es6 b/app/assets/javascripts/discourse/controllers/static.js.es6 index 5b87c64c710..2c31b962c75 100644 --- a/app/assets/javascripts/discourse/controllers/static.js.es6 +++ b/app/assets/javascripts/discourse/controllers/static.js.es6 @@ -2,13 +2,13 @@ import { ajax } from 'discourse/lib/ajax'; import computed from 'ember-addons/ember-computed-decorators'; export default Ember.Controller.extend({ - needs: ['application'], + application: Ember.inject.controller(), showLoginButton: Em.computed.equal("model.path", "login"), @computed("model.path") showSignupButton() { - return this.get("model.path") === "login" && this.get('controllers.application.canSignUp'); + return this.get("model.path") === "login" && this.get('application.canSignUp'); }, actions: { diff --git a/app/assets/javascripts/discourse/controllers/tags-show.js.es6 b/app/assets/javascripts/discourse/controllers/tags-show.js.es6 index f80b98c6c7a..0e8e15db508 100644 --- a/app/assets/javascripts/discourse/controllers/tags-show.js.es6 +++ b/app/assets/javascripts/discourse/controllers/tags-show.js.es6 @@ -40,7 +40,7 @@ if (customNavItemHref) { export default Ember.Controller.extend(BulkTopicSelection, { - needs: ["application"], + application: Ember.inject.controller(), tag: null, additionalTags: null, @@ -81,7 +81,7 @@ export default Ember.Controller.extend(BulkTopicSelection, { }, _showFooter: function() { - this.set("controllers.application.showFooter", !this.get("list.canLoadMore")); + this.set("application.showFooter", !this.get("list.canLoadMore")); }.observes("list.canLoadMore"), footerMessage: function() { diff --git a/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 b/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 index 49c5e1d7fbb..d378084e8a7 100644 --- a/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 @@ -24,7 +24,7 @@ export default Ember.Controller.extend(ModalFunctionality, { emptyTags: Ember.computed.empty('tags'), onShow() { - this.set('controllers.modal.modalClass', 'topic-bulk-actions-modal small'); + this.set('modal.modalClass', 'topic-bulk-actions-modal small'); const buttonRows = []; let row = []; @@ -86,7 +86,7 @@ export default Ember.Controller.extend(ModalFunctionality, { showChangeCategory() { this.send('changeBulkTemplate', 'modal/bulk_change_category'); - this.set('controllers.modal.modalClass', 'topic-bulk-actions-modal full'); + this.set('modal.modalClass', 'topic-bulk-actions-modal full'); }, showNotificationLevel() { diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index c6af25b50b5..e4c5d23973f 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -11,7 +11,10 @@ import { categoryBadgeHTML } from 'discourse/helpers/category-link'; import Post from 'discourse/models/post'; export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { - needs: ['modal', 'composer', 'quote-button', 'application'], + composer: Ember.inject.controller(), + quoteButton: Ember.inject.controller('quote-button'), + application: Ember.inject.controller(), + multiSelect: false, allPostsSelected: false, editingTopic: false, @@ -282,8 +285,8 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { // Post related methods replyToPost(post) { - const composerController = this.get('controllers.composer'), - quoteController = this.get('controllers.quote-button'), + const composerController = this.get('composer'), + quoteController = this.get('quoteButton'), quotedText = Quote.build(quoteController.get('post'), quoteController.get('buffer')), topic = post ? post.get('topic') : this.get('model'); @@ -380,7 +383,7 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { return false; } - const composer = this.get('controllers.composer'), + const composer = this.get('composer'), composerModel = composer.get('model'), opts = { post: post, @@ -602,8 +605,8 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { }, replyAsNewTopic(post) { - const composerController = this.get('controllers.composer'); - const quoteController = this.get('controllers.quote-button'); + const composerController = this.get('composer'); + const quoteController = this.get('quoteButton'); post = post || quoteController.get('post'); const quotedText = Quote.build(post, quoteController.get('buffer')); @@ -905,7 +908,7 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { _showFooter: function() { const showFooter = this.get("model.postStream.loaded") && this.get("model.postStream.loadedAllPosts"); - this.set("controllers.application.showFooter", showFooter); + this.set("application.showFooter", showFooter); }.observes("model.postStream.{loaded,loadedAllPosts}") }); diff --git a/app/assets/javascripts/discourse/controllers/upload-customization.js.es6 b/app/assets/javascripts/discourse/controllers/upload-customization.js.es6 index d7a980a0b42..ae7575887a9 100644 --- a/app/assets/javascripts/discourse/controllers/upload-customization.js.es6 +++ b/app/assets/javascripts/discourse/controllers/upload-customization.js.es6 @@ -2,7 +2,7 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality'; export default Ember.Controller.extend(ModalFunctionality, { notReady: Em.computed.not('ready'), - needs: ['adminCustomizeCssHtml'], + adminCustomizeCssHtml: Ember.inject.controller(), ready: function() { try { @@ -22,7 +22,7 @@ export default Ember.Controller.extend(ModalFunctionality, { delete object.id; delete object.key; - const controller = this.get('controllers.adminCustomizeCssHtml'); + const controller = this.get('adminCustomizeCssHtml'); controller.send('newCustomization', object); } } diff --git a/app/assets/javascripts/discourse/controllers/user-activity.js.es6 b/app/assets/javascripts/discourse/controllers/user-activity.js.es6 index 55ab7846cae..b899408f420 100644 --- a/app/assets/javascripts/discourse/controllers/user-activity.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-activity.js.es6 @@ -1,11 +1,13 @@ import { exportUserArchive } from 'discourse/lib/export-csv'; export default Ember.Controller.extend({ + application: Ember.inject.controller(), + user: Ember.inject.controller(), + userActionType: null, - needs: ["application", "user"], - currentPath: Em.computed.alias('controllers.application.currentPath'), - viewingSelf: Em.computed.alias("controllers.user.viewingSelf"), - showBookmarks: Em.computed.alias("controllers.user.showBookmarks"), + currentPath: Ember.computed.alias('application.currentPath'), + viewingSelf: Ember.computed.alias("user.viewingSelf"), + showBookmarks: Ember.computed.alias("user.showBookmarks"), _showFooter: function() { var showFooter; @@ -15,7 +17,7 @@ export default Ember.Controller.extend({ } else { showFooter = this.get("model.statsCountNonPM") <= this.get("model.stream.itemsLoaded"); } - this.set("controllers.application.showFooter", showFooter); + this.set("application.showFooter", showFooter); }.observes("userActionType", "model.stream.itemsLoaded"), actions: { diff --git a/app/assets/javascripts/discourse/controllers/user-card.js.es6 b/app/assets/javascripts/discourse/controllers/user-card.js.es6 index 377ffb97a85..1a2cdd78125 100644 --- a/app/assets/javascripts/discourse/controllers/user-card.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-card.js.es6 @@ -3,7 +3,9 @@ import { propertyNotEqual, setting } from 'discourse/lib/computed'; import computed from 'ember-addons/ember-computed-decorators'; export default Ember.Controller.extend({ - needs: ['topic', 'application'], + topic: Ember.inject.controller(), + application: Ember.inject.controller(), + visible: false, user: null, username: null, @@ -15,10 +17,10 @@ export default Ember.Controller.extend({ // If inside a topic topicPostCount: null, - postStream: Em.computed.alias('controllers.topic.model.postStream'), + postStream: Em.computed.alias('topic.model.postStream'), enoughPostsForFiltering: Em.computed.gte('topicPostCount', 2), - viewingTopic: Em.computed.match('controllers.application.currentPath', /^topic\./), - viewingAdmin: Em.computed.match('controllers.application.currentPath', /^admin\./), + viewingTopic: Em.computed.match('application.currentPath', /^topic\./), + viewingAdmin: Em.computed.match('application.currentPath', /^admin\./), showFilter: Em.computed.and('viewingTopic', 'postStream.hasNoFilters', 'enoughPostsForFiltering'), showName: propertyNotEqual('user.name', 'user.username'), hasUserFilters: Em.computed.gt('postStream.userFilters.length', 0), @@ -97,7 +99,7 @@ export default Ember.Controller.extend({ this.setProperties({ username, userLoading: username, cardTarget: target, post }); const args = { stats: false }; - args.include_post_count_for = this.get('controllers.topic.model.id'); + args.include_post_count_for = this.get('topic.model.id'); args.skip_track_visit = true; return Discourse.User.findByUsername(username, args).then((user) => { diff --git a/app/assets/javascripts/discourse/controllers/user-posts.js.es6 b/app/assets/javascripts/discourse/controllers/user-posts.js.es6 index e06143db481..25c730d97ad 100644 --- a/app/assets/javascripts/discourse/controllers/user-posts.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-posts.js.es6 @@ -1,7 +1,7 @@ export default Ember.Controller.extend({ - needs: ["application"], + application: Ember.inject.controller(), _showFooter: function() { - this.set("controllers.application.showFooter", !this.get("model.canLoadMore")); + this.set("application.showFooter", !this.get("model.canLoadMore")); }.observes("model.canLoadMore") }); diff --git a/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6 b/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6 index 18f010adccd..bb79db55d37 100644 --- a/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6 @@ -2,18 +2,21 @@ import computed from 'ember-addons/ember-computed-decorators'; import Topic from 'discourse/models/topic'; export default Ember.Controller.extend({ - needs: ["application", "user-topics-list", "user"], + application: Ember.inject.controller(), + userTopicsList: Ember.inject.controller('user-topics-list'), + user: Ember.inject.controller(), + pmView: false, - viewingSelf: Em.computed.alias('controllers.user.viewingSelf'), + viewingSelf: Em.computed.alias('user.viewingSelf'), isGroup: Em.computed.equal('pmView', 'groups'), - currentPath: Em.computed.alias('controllers.application.currentPath'), - selected: Em.computed.alias('controllers.user-topics-list.selected'), - bulkSelectEnabled: Em.computed.alias('controllers.user-topics-list.bulkSelectEnabled'), + currentPath: Em.computed.alias('application.currentPath'), + selected: Em.computed.alias('userTopicsList.selected'), + bulkSelectEnabled: Em.computed.alias('userTopicsList.bulkSelectEnabled'), showNewPM: function(){ - return this.get('controllers.user.viewingSelf') && + return this.get('user.viewingSelf') && Discourse.User.currentProp('can_send_private_messages'); - }.property('controllers.user.viewingSelf'), + }.property('user.viewingSelf'), @computed('selected.[]', 'bulkSelectEnabled') hasSelection(selected, bulkSelectEnabled){ @@ -39,7 +42,7 @@ export default Ember.Controller.extend({ } Topic.bulkOperation(selected,params).then(() => { - const model = this.get('controllers.user-topics-list.model'); + const model = this.get('userTopicsList.model'); const topics = model.get('topics'); topics.removeObjects(selected); selected.clear(); diff --git a/app/assets/javascripts/discourse/controllers/user-summary.js.es6 b/app/assets/javascripts/discourse/controllers/user-summary.js.es6 index d41962d96ca..c40014854cb 100644 --- a/app/assets/javascripts/discourse/controllers/user-summary.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-summary.js.es6 @@ -6,8 +6,8 @@ const MAX_SUMMARY_RESULTS = 6; const MAX_BADGES = 6; export default Ember.Controller.extend({ - needs: ['user'], - user: Ember.computed.alias('controllers.user.model'), + userController: Ember.inject.controller('user'), + user: Ember.computed.alias('userController.model'), @computed("model.topics.length") moreTopics(topicsLength) { return topicsLength >= MAX_SUMMARY_RESULTS; }, diff --git a/app/assets/javascripts/discourse/controllers/user-topics-list.js.es6 b/app/assets/javascripts/discourse/controllers/user-topics-list.js.es6 index e4d428a4f90..8e150fd2890 100644 --- a/app/assets/javascripts/discourse/controllers/user-topics-list.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-topics-list.js.es6 @@ -1,11 +1,12 @@ // Lists of topics on a user's page. export default Ember.Controller.extend({ - needs: ["application", "user"], + application: Ember.inject.controller(), + hideCategory: false, showPosters: false, _showFooter: function() { - this.set("controllers.application.showFooter", !this.get("model.canLoadMore")); + this.set("application.showFooter", !this.get("model.canLoadMore")); }.observes("model.canLoadMore"), actions: { diff --git a/app/assets/javascripts/discourse/controllers/user.js.es6 b/app/assets/javascripts/discourse/controllers/user.js.es6 index b5151f1b33c..d2965681817 100644 --- a/app/assets/javascripts/discourse/controllers/user.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user.js.es6 @@ -6,8 +6,9 @@ import User from 'discourse/models/user'; export default Ember.Controller.extend(CanCheckEmails, { indexStream: false, userActionType: null, - needs: ['application','user-notifications', 'user-topics-list'], - currentPath: Em.computed.alias('controllers.application.currentPath'), + application: Ember.inject.controller(), + userNotifications: Ember.inject.controller('user-notifications'), + currentPath: Ember.computed.alias('application.currentPath'), @computed("content.username") viewingSelf(username) { diff --git a/app/assets/javascripts/discourse/controllers/users.js.es6 b/app/assets/javascripts/discourse/controllers/users.js.es6 index 8ad3eabcba5..f5bb1963025 100644 --- a/app/assets/javascripts/discourse/controllers/users.js.es6 +++ b/app/assets/javascripts/discourse/controllers/users.js.es6 @@ -1,7 +1,7 @@ import debounce from 'discourse/lib/debounce'; export default Ember.Controller.extend({ - needs: ["application"], + application: Ember.inject.controller(), queryParams: ["period", "order", "asc", "name"], period: "weekly", order: "likes_received", @@ -15,7 +15,7 @@ export default Ember.Controller.extend({ }, 500).observes("nameInput"), _showFooter: function() { - this.set("controllers.application.showFooter", !this.get("model.canLoadMore")); + this.set("application.showFooter", !this.get("model.canLoadMore")); }.observes("model.canLoadMore"), actions: { diff --git a/app/assets/javascripts/discourse/lib/show-modal.js.es6 b/app/assets/javascripts/discourse/lib/show-modal.js.es6 index 6237163d061..0306b001e0f 100644 --- a/app/assets/javascripts/discourse/lib/show-modal.js.es6 +++ b/app/assets/javascripts/discourse/lib/show-modal.js.es6 @@ -26,6 +26,7 @@ export default function(name, opts) { } if (controller) { + controller.set('modal', modalController); const model = opts.model; if (model) { controller.set('model', model); } if (controller.onShow) { controller.onShow(); } diff --git a/app/assets/javascripts/discourse/mixins/modal-functionality.js.es6 b/app/assets/javascripts/discourse/mixins/modal-functionality.js.es6 index 42a279b8036..7394488fcb8 100644 --- a/app/assets/javascripts/discourse/mixins/modal-functionality.js.es6 +++ b/app/assets/javascripts/discourse/mixins/modal-functionality.js.es6 @@ -1,8 +1,6 @@ -export default Em.Mixin.create({ +export default Ember.Mixin.create({ flashMessage: null, - needs: ['modal'], - flash(message, messageClass) { this.set('flashMessage', Em.Object.create({ message, messageClass })); } diff --git a/app/assets/javascripts/discourse/views/modal-body.js.es6 b/app/assets/javascripts/discourse/views/modal-body.js.es6 index 05998dac405..f3dfa7c937f 100644 --- a/app/assets/javascripts/discourse/views/modal-body.js.es6 +++ b/app/assets/javascripts/discourse/views/modal-body.js.es6 @@ -15,7 +15,7 @@ export default Ember.View.extend({ const title = this.get('title'); if (title) { - this.set('controller.controllers.modal.title', title); + this.set('controller.modal.title', title); } }, diff --git a/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6 b/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6 index a57195303ef..391a5d76acf 100644 --- a/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6 +++ b/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6 @@ -2,7 +2,6 @@ import { default as computed, observes } from 'ember-addons/ember-computed-decor import InputValidation from 'discourse/models/input-validation'; export default Ember.Controller.extend({ - needs: ['modal'], numberPollType: 'number', multiplePollType: 'multiple', diff --git a/plugins/poll/assets/javascripts/views/poll-ui-builder.js.es6 b/plugins/poll/assets/javascripts/views/poll-ui-builder.js.es6 index 6ce0bf58203..52144834366 100644 --- a/plugins/poll/assets/javascripts/views/poll-ui-builder.js.es6 +++ b/plugins/poll/assets/javascripts/views/poll-ui-builder.js.es6 @@ -1,8 +1,6 @@ import ModalBodyView from "discourse/views/modal-body"; export default ModalBodyView.extend({ - needs: ['modal'], - templateName: 'modals/poll-ui-builder', title: I18n.t("poll.ui_builder.title") });