From 690b579a96edd55b9dbd3d86318bf56677142f11 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 29 Apr 2015 16:26:14 -0400 Subject: [PATCH] Fixes some deprecations --- .../discourse/components/category-drop.js.es6 | 13 +++--- .../discourse/controllers/about.js.es6 | 4 +- .../discourse/controllers/badges/show.js.es6 | 20 ++++------ .../discourse/controllers/discovery.js.es6 | 6 +-- .../controllers/discovery/topics.js.es6 | 22 +++++----- .../discourse/controllers/static.js.es6 | 6 +-- .../controllers/topic-entrance.js.es6 | 6 +-- .../discourse/controllers/user-card.js.es6 | 4 +- .../discourse/mixins/string-buffer.js.es6 | 5 ++- .../javascripts/discourse/router.js.es6 | 2 +- .../javascripts/discourse/templates/about.hbs | 40 +++++++++---------- .../discourse/templates/badges/show.hbs | 10 ++--- .../templates/components/category-drop.hbs | 10 ++--- .../discourse/templates/discovery/topics.hbs | 8 ++-- .../discourse/templates/static.hbs | 4 +- 15 files changed, 75 insertions(+), 85 deletions(-) diff --git a/app/assets/javascripts/discourse/components/category-drop.js.es6 b/app/assets/javascripts/discourse/components/category-drop.js.es6 index faa87ea45ce..bb63d0bbf95 100644 --- a/app/assets/javascripts/discourse/components/category-drop.js.es6 +++ b/app/assets/javascripts/discourse/components/category-drop.js.es6 @@ -2,10 +2,7 @@ var get = Ember.get; export default Ember.Component.extend({ classNameBindings: ['category::no-category', 'categories:has-drop','categoryStyle'], - - categoryStyle: function(){ - return Discourse.SiteSettings.category_style; - }.property(), + categoryStyle: Discourse.computed.setting('category_style'), tagName: 'li', @@ -50,11 +47,11 @@ export default Ember.Component.extend({ if (color) { var style = ""; if (color) { style += "background-color: #" + color + ";" } - return style; + return style.htmlSafe(); } } - return "background-color: #eee;"; + return "background-color: #eee;".htmlSafe(); }.property('category'), badgeStyle: function() { @@ -68,11 +65,11 @@ export default Ember.Component.extend({ var style = ""; if (color) { style += "background-color: #" + color + "; border-color: #" + color + ";"; } if (textColor) { style += "color: #" + textColor + "; "; } - return style; + return style.htmlSafe(); } } - return "background-color: #eee; color: #333"; + return "background-color: #eee; color: #333".htmlSafe(); }.property('category'), clickEventName: function() { diff --git a/app/assets/javascripts/discourse/controllers/about.js.es6 b/app/assets/javascripts/discourse/controllers/about.js.es6 index e35882706a4..3452f63d3c0 100644 --- a/app/assets/javascripts/discourse/controllers/about.js.es6 +++ b/app/assets/javascripts/discourse/controllers/about.js.es6 @@ -1,6 +1,4 @@ -import ObjectController from 'discourse/controllers/object'; - -export default ObjectController.extend({ +export default Ember.Controller.extend({ faqOverriden: Ember.computed.gt('siteSettings.faq_url.length', 0), contactInfo: function() { diff --git a/app/assets/javascripts/discourse/controllers/badges/show.js.es6 b/app/assets/javascripts/discourse/controllers/badges/show.js.es6 index ed43f558889..77bfa341bfb 100644 --- a/app/assets/javascripts/discourse/controllers/badges/show.js.es6 +++ b/app/assets/javascripts/discourse/controllers/badges/show.js.es6 @@ -1,25 +1,19 @@ import ObjectController from 'discourse/controllers/object'; -/** - Controller for showing a particular badge. - - @class BadgesShowController - @extends ObjectController - @namespace Discourse - @module Discourse -**/ export default ObjectController.extend({ + noMoreBadges: false, + userBadges: null, needs: ["application"], actions: { - loadMore: function() { - var self = this; - var userBadges = this.get('userBadges'); + loadMore() { + const self = this; + const userBadges = this.get('userBadges'); Discourse.UserBadge.findByBadgeId(this.get('model.id'), { offset: userBadges.length - }).then(function(userBadges) { - self.get('userBadges').pushObjects(userBadges); + }).then(function(result) { + userBadges.pushObjects(result); if(userBadges.length === 0){ self.set('noMoreBadges', true); } diff --git a/app/assets/javascripts/discourse/controllers/discovery.js.es6 b/app/assets/javascripts/discourse/controllers/discovery.js.es6 index abaaa1e2b4b..6bb1d5ad909 100644 --- a/app/assets/javascripts/discourse/controllers/discovery.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery.js.es6 @@ -1,13 +1,11 @@ -import ObjectController from 'discourse/controllers/object'; - -export default ObjectController.extend({ +export default Ember.Controller.extend({ needs: ['navigation/category', 'discovery/topics', 'application'], loading: false, category: Em.computed.alias('controllers.navigation/category.category'), noSubcategories: Em.computed.alias('controllers.navigation/category.noSubcategories'), - loadedAllItems: Em.computed.not("controllers.discovery/topics.canLoadMore"), + loadedAllItems: Em.computed.not("controllers.discovery/topics.model.canLoadMore"), _showFooter: function() { this.set("controllers.application.showFooter", this.get("loadedAllItems")); diff --git a/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 index 293d9c826c7..98bb9e70e1b 100644 --- a/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 @@ -13,6 +13,7 @@ var controllerOpts = { order: 'default', ascending: false, + expandGloballyPinned: false, actions: { @@ -80,6 +81,7 @@ var controllerOpts = { }.property(), isFilterPage: function(filter, filterType) { + if (!filter) { return false; } return filter.match(new RegExp(filterType + '$', 'gi')) ? true : false; }, @@ -92,15 +94,15 @@ var controllerOpts = { }.property('filter', 'topics.length'), showDismissAtTop: function() { - return (this.isFilterPage(this.get('filter'), 'new') || - this.isFilterPage(this.get('filter'), 'unread')) && - this.get('topics.length') >= 30; - }.property('filter', 'topics.length'), + return (this.isFilterPage(this.get('model.filter'), 'new') || + this.isFilterPage(this.get('model.filter'), 'unread')) && + this.get('model.topics.length') >= 30; + }.property('model.filter', 'model.topics.length'), - hasTopics: Em.computed.gt('topics.length', 0), - allLoaded: Em.computed.empty('more_topics_url'), - latest: Discourse.computed.endWith('filter', 'latest'), - new: Discourse.computed.endWith('filter', 'new'), + hasTopics: Em.computed.gt('model.topics.length', 0), + allLoaded: Em.computed.empty('model.more_topics_url'), + latest: Discourse.computed.endWith('model.filter', 'latest'), + new: Discourse.computed.endWith('model.filter', 'new'), top: Em.computed.notEmpty('period'), yearly: Em.computed.equal('period', 'yearly'), monthly: Em.computed.equal('period', 'monthly'), @@ -114,7 +116,7 @@ var controllerOpts = { if( category ) { return I18n.t('topics.bottom.category', {category: category.get('name')}); } else { - var split = this.get('filter').split('/'); + var split = (this.get('filter') || '').split('/'); if (this.get('topics.length') === 0) { return I18n.t("topics.none." + split[0], { category: split[1] @@ -130,7 +132,7 @@ var controllerOpts = { footerEducation: function() { if (!this.get('allLoaded') || this.get('topics.length') > 0 || !Discourse.User.current()) { return; } - var split = this.get('filter').split('/'); + var split = (this.get('filter') || '').split('/'); if (split[0] !== 'new' && split[0] !== 'unread') { return; } diff --git a/app/assets/javascripts/discourse/controllers/static.js.es6 b/app/assets/javascripts/discourse/controllers/static.js.es6 index f2e18692d0a..2e9050b2d5a 100644 --- a/app/assets/javascripts/discourse/controllers/static.js.es6 +++ b/app/assets/javascripts/discourse/controllers/static.js.es6 @@ -1,9 +1,9 @@ -export default Em.ObjectController.extend({ - showLoginButton: Em.computed.equal('path', 'login'), +export default Ember.Controller.extend({ + showLoginButton: Em.computed.equal('model.path', 'login'), actions: { markFaqRead: function() { - if (Discourse.User.current()) { + if (this.currentUser) { Discourse.ajax("/users/read-faq", { method: "POST" }); } } diff --git a/app/assets/javascripts/discourse/controllers/topic-entrance.js.es6 b/app/assets/javascripts/discourse/controllers/topic-entrance.js.es6 index 411496b06f0..b98b14550df 100644 --- a/app/assets/javascripts/discourse/controllers/topic-entrance.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic-entrance.js.es6 @@ -17,7 +17,7 @@ function entranceDate(dt, showTime) { ); } -export default Ember.ObjectController.extend({ +export default Ember.Controller.extend({ position: null, createdDate: function() { @@ -51,11 +51,11 @@ export default Ember.ObjectController.extend({ }, enterTop: function() { - Discourse.URL.routeTo(this.get('url')); + Discourse.URL.routeTo(this.get('model.url')); }, enterBottom: function() { - Discourse.URL.routeTo(this.get('lastPostUrl')); + Discourse.URL.routeTo(this.get('model.lastPostUrl')); } } }); diff --git a/app/assets/javascripts/discourse/controllers/user-card.js.es6 b/app/assets/javascripts/discourse/controllers/user-card.js.es6 index 60922c4c152..74fcda0630b 100644 --- a/app/assets/javascripts/discourse/controllers/user-card.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-card.js.es6 @@ -1,6 +1,4 @@ -import ObjectController from 'discourse/controllers/object'; - -export default ObjectController.extend({ +export default Ember.Controller.extend({ needs: ['topic', 'application'], visible: false, user: null, diff --git a/app/assets/javascripts/discourse/mixins/string-buffer.js.es6 b/app/assets/javascripts/discourse/mixins/string-buffer.js.es6 index 469873d22f2..ebc293fa9e9 100644 --- a/app/assets/javascripts/discourse/mixins/string-buffer.js.es6 +++ b/app/assets/javascripts/discourse/mixins/string-buffer.js.es6 @@ -19,9 +19,12 @@ export default Ember.Mixin.create({ }, _rerenderString() { + const $sel = this.$(); + if ($sel) { return; } + const buffer = []; this.renderString(buffer); - this.$().html(buffer.join('')); + $sel.html(buffer.join('')); }, rerenderString() { diff --git a/app/assets/javascripts/discourse/router.js.es6 b/app/assets/javascripts/discourse/router.js.es6 index 70ca3b85768..a7669926df2 100644 --- a/app/assets/javascripts/discourse/router.js.es6 +++ b/app/assets/javascripts/discourse/router.js.es6 @@ -2,7 +2,7 @@ const rootURL = Discourse.BaseUri && Discourse.BaseUri !== "/" ? Discourse.BaseU const Router = Ember.Router.extend({ rootURL, - location: Ember.Test ? 'none': 'discourse-location' + location: Ember.testing ? 'none': 'discourse-location' }); export function mapRoutes() { diff --git a/app/assets/javascripts/discourse/templates/about.hbs b/app/assets/javascripts/discourse/templates/about.hbs index b555a334862..ca3f050ffe0 100644 --- a/app/assets/javascripts/discourse/templates/about.hbs +++ b/app/assets/javascripts/discourse/templates/about.hbs @@ -14,15 +14,15 @@
-

{{i18n 'about.title' title=title}}

-

{{description}}

+

{{i18n 'about.title' title=model.title}}

+

{{model.description}}

- {{#if admins}} + {{#if model.admins}}

{{i18n 'about.our_admins'}}

- {{#each a in admins}} + {{#each a in model.admins}} {{user-small user=a}} {{/each}}
@@ -30,12 +30,12 @@
{{/if}} - {{#if moderators}} + {{#if model.moderators}}

{{i18n 'about.our_moderators'}}

- {{#each m in moderators}} + {{#each m in model.moderators}} {{user-small user=m}} {{/each}}
@@ -55,33 +55,33 @@ {{i18n 'about.topic_count'}} - {{number stats.topic_count}} - {{number stats.topics_7_days}} - {{number stats.topics_30_days}} + {{number model.stats.topic_count}} + {{number model.stats.topics_7_days}} + {{number model.stats.topics_30_days}} {{i18n 'about.post_count'}} - {{number stats.post_count}} - {{number stats.posts_7_days}} - {{number stats.posts_30_days}} + {{number model.stats.post_count}} + {{number model.stats.posts_7_days}} + {{number model.stats.posts_30_days}} {{i18n 'about.user_count'}} - {{number stats.user_count}} - {{number stats.users_7_days}} - {{number stats.users_30_days}} + {{number model.stats.user_count}} + {{number model.stats.users_7_days}} + {{number model.stats.users_30_days}} {{i18n 'about.active_user_count'}} — - {{number stats.active_users_7_days}} - {{number stats.active_users_30_days}} + {{number model.stats.active_users_7_days}} + {{number model.stats.active_users_30_days}} {{i18n 'about.like_count'}} - {{number stats.like_count}} - {{number stats.likes_7_days}} - {{number stats.likes_30_days}} + {{number model.stats.like_count}} + {{number model.stats.likes_7_days}} + {{number model.stats.likes_30_days}}
diff --git a/app/assets/javascripts/discourse/templates/badges/show.hbs b/app/assets/javascripts/discourse/templates/badges/show.hbs index 3579c70eec1..ed72176c528 100644 --- a/app/assets/javascripts/discourse/templates/badges/show.hbs +++ b/app/assets/javascripts/discourse/templates/badges/show.hbs @@ -1,16 +1,16 @@

{{#link-to 'badges.index'}}{{i18n 'badges.title'}}{{/link-to}} - - {{displayName}} + {{fa-icon "angle-right"}} + {{model.displayName}}

- - - + + + diff --git a/app/assets/javascripts/discourse/templates/components/category-drop.hbs b/app/assets/javascripts/discourse/templates/components/category-drop.hbs index 803fe6f19ca..f997416464a 100644 --- a/app/assets/javascripts/discourse/templates/components/category-drop.hbs +++ b/app/assets/javascripts/discourse/templates/components/category-drop.hbs @@ -1,6 +1,6 @@ {{#if category}} - - + + {{#if category.read_restricted}} {{fa-icon "lock"}} {{/if}} @@ -8,14 +8,14 @@ {{else}} {{#if noSubcategories}} - {{i18n 'categories.no_subcategory'}} + {{i18n 'categories.no_subcategory'}} {{else}} - {{allCategoriesLabel}} + {{allCategoriesLabel}} {{/if}} {{/if}} {{#if categories}} - +
{{#if subCategory}} diff --git a/app/assets/javascripts/discourse/templates/discovery/topics.hbs b/app/assets/javascripts/discourse/templates/discovery/topics.hbs index bdcc9800fb3..5a92b7f011d 100644 --- a/app/assets/javascripts/discourse/templates/discovery/topics.hbs +++ b/app/assets/javascripts/discourse/templates/discovery/topics.hbs @@ -39,19 +39,19 @@ canBulkSelect=canBulkSelect changeSort="changeSort" toggleBulkSelect="toggleBulkSelect" - hideCategory=hideCategory + hideCategory=model.hideCategory order=order ascending=ascending bulkSelectEnabled=bulkSelectEnabled selected=selected expandGloballyPinned=expandGloballyPinned - expandAllPinned=expandAllPinned - topics=topics}} + expandAllPinned=model.expandAllPinned + topics=model.topics}} {{/if}}
- {{conditional-loading-spinner condition=loadingMore}} + {{conditional-loading-spinner condition=model.loadingMore}} {{#if allLoaded}} {{#if showDismissRead}} diff --git a/app/assets/javascripts/discourse/templates/static.hbs b/app/assets/javascripts/discourse/templates/static.hbs index ff09643a727..d84e205785b 100644 --- a/app/assets/javascripts/discourse/templates/static.hbs +++ b/app/assets/javascripts/discourse/templates/static.hbs @@ -1,9 +1,9 @@
- {{{html}}} + {{{model.html}}} {{#if showLoginButton}} - + {{/if}}
{{user-badge badge=this}}{{{displayDescriptionHtml}}}{{i18n 'badges.granted' count=grant_count}}{{user-badge badge=model}}{{{model.displayDescriptionHtml}}}{{i18n 'badges.granted' count=model.grant_count}} {{i18n 'badges.allow_title'}} {{{view.allowTitle}}}
{{i18n 'badges.multiple_grant'}} {{{view.multipleGrant}}}