From 3f729438ad3b9f3c2e88a4c4c1e0e4c3972449f7 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 24 Feb 2015 13:47:46 -0500 Subject: [PATCH] ES6: Removed and renamed some admin views --- .../components/admin-report-counts.js.es6 | 3 ++ app/assets/javascripts/admin/models/report.js | 4 +- .../components/admin-report-counts.hbs | 13 ++++++ .../javascripts/admin/templates/dashboard.hbs | 46 +++++++++---------- .../reports/summed_counts_report.hbs | 13 ------ ...n_backups_view.js => admin-backups.js.es6} | 2 +- .../javascripts/admin/views/admin_api_view.js | 3 -- .../admin/views/admin_dashboard_view.js | 13 ------ .../views/report/admin_report_counts_view.js | 4 -- ...te_setting_view.js => site-setting.js.es6} | 10 +--- .../discourse/helpers/fa-icon.js.es6 | 21 +++++---- 11 files changed, 55 insertions(+), 77 deletions(-) create mode 100644 app/assets/javascripts/admin/components/admin-report-counts.js.es6 create mode 100644 app/assets/javascripts/admin/templates/components/admin-report-counts.hbs delete mode 100644 app/assets/javascripts/admin/templates/reports/summed_counts_report.hbs rename app/assets/javascripts/admin/views/{admin_backups_view.js => admin-backups.js.es6} (91%) delete mode 100644 app/assets/javascripts/admin/views/admin_api_view.js delete mode 100644 app/assets/javascripts/admin/views/admin_dashboard_view.js delete mode 100644 app/assets/javascripts/admin/views/report/admin_report_counts_view.js rename app/assets/javascripts/admin/views/{site_setting_view.js => site-setting.js.es6} (86%) diff --git a/app/assets/javascripts/admin/components/admin-report-counts.js.es6 b/app/assets/javascripts/admin/components/admin-report-counts.js.es6 new file mode 100644 index 00000000000..28e45b10ec7 --- /dev/null +++ b/app/assets/javascripts/admin/components/admin-report-counts.js.es6 @@ -0,0 +1,3 @@ +export default Ember.Component.extend({ + tagName: 'tbody' +}); diff --git a/app/assets/javascripts/admin/models/report.js b/app/assets/javascripts/admin/models/report.js index 8157adc0b4a..6f8bfdfff3d 100644 --- a/app/assets/javascripts/admin/models/report.js +++ b/app/assets/javascripts/admin/models/report.js @@ -92,9 +92,9 @@ Discourse.Report = Discourse.Model.extend({ icon: function() { switch( this.get('type') ) { case 'flags': - return 'fa-flag'; + return 'flag'; case 'likes': - return 'fa-heart'; + return 'heart'; default: return null; } diff --git a/app/assets/javascripts/admin/templates/components/admin-report-counts.hbs b/app/assets/javascripts/admin/templates/components/admin-report-counts.hbs new file mode 100644 index 00000000000..e91598e5da3 --- /dev/null +++ b/app/assets/javascripts/admin/templates/components/admin-report-counts.hbs @@ -0,0 +1,13 @@ + + + {{#if report.icon}} + {{fa-icon report.icon}} + {{/if}} + {{report.title}} + + {{report.todayCount}} + {{report.yesterdayCount}} {{fa-icon "caret-up" class="up"}} {{fa-icon "caret-down" class="down"}} + {{report.lastSevenDaysCount}} {{fa-icon "caret-up" class="up"}} {{fa-icon "caret-down" class="down"}} + {{report.lastThirtyDaysCount}} {{fa-icon "caret-up" class="up"}} {{fa-icon "caret-down" class="down"}} + {{report.total}} + diff --git a/app/assets/javascripts/admin/templates/dashboard.hbs b/app/assets/javascripts/admin/templates/dashboard.hbs index 74a508fe608..0f06bf37828 100644 --- a/app/assets/javascripts/admin/templates/dashboard.hbs +++ b/app/assets/javascripts/admin/templates/dashboard.hbs @@ -16,7 +16,7 @@ {{#unless loading}} - {{ render 'admin/templates/reports/trust_levels_report' users_by_trust_level tagName="tbody" }} + {{ render 'admin/templates/reports/trust_levels_report' users_by_trust_level tagName="tbody"}} {{/unless}} @@ -52,13 +52,13 @@ {{#unless loading}} {{ render 'admin/templates/reports/per_day_counts_report' visits tagName="tbody"}} - {{ render 'admin_report_counts' signups }} - {{ render 'admin_report_counts' topics }} - {{ render 'admin_report_counts' posts }} - {{ render 'admin_report_counts' likes }} - {{ render 'admin_report_counts' flags }} - {{ render 'admin_report_counts' bookmarks }} - {{ render 'admin_report_counts' emails }} + {{admin-report-counts report=signups}} + {{admin-report-counts report=topics}} + {{admin-report-counts report=posts}} + {{admin-report-counts report=likes}} + {{admin-report-counts report=flags}} + {{admin-report-counts report=bookmarks}} + {{admin-report-counts report=emails}} {{/unless}} @@ -76,10 +76,10 @@ {{#unless loading}} - {{ render 'admin_report_counts' page_view_anon_reqs }} - {{ render 'admin_report_counts' page_view_logged_in_reqs }} - {{ render 'admin_report_counts' page_view_crawler_reqs }} - {{ render 'admin_report_counts' page_view_total_reqs }} + {{admin-report-counts report=page_view_anon_reqs}} + {{admin-report-counts report=page_view_logged_in_reqs}} + {{admin-report-counts report=page_view_crawler_reqs}} + {{admin-report-counts report=page_view_total_reqs}} {{/unless}} @@ -98,11 +98,11 @@ {{#unless loading}} - {{ render 'admin_report_counts' user_to_user_private_messages }} - {{ render 'admin_report_counts' system_private_messages }} - {{ render 'admin_report_counts' notify_moderators_private_messages }} - {{ render 'admin_report_counts' notify_user_private_messages }} - {{ render 'admin_report_counts' moderator_warning_private_messages }} + {{admin-report-counts report=user_to_user_private_messages}} + {{admin-report-counts report=system_private_messages}} + {{admin-report-counts report=notify_moderators_private_messages}} + {{admin-report-counts report=notify_user_private_messages}} + {{admin-report-counts report=moderator_warning_private_messages}} {{/unless}} @@ -145,12 +145,12 @@ {{#unless loading}} - {{ render 'admin_report_counts' http_2xx_reqs }} - {{ render 'admin_report_counts' http_3xx_reqs}} - {{ render 'admin_report_counts' http_4xx_reqs}} - {{ render 'admin_report_counts' http_5xx_reqs}} - {{ render 'admin_report_counts' http_background_reqs }} - {{ render 'admin_report_counts' http_total_reqs }} + {{admin-report-counts report=http_2xx_reqs}} + {{admin-report-counts report=http_3xx_reqs}} + {{admin-report-counts report=http_4xx_reqs}} + {{admin-report-counts report=http_5xx_reqs}} + {{admin-report-counts report=http_background_reqs}} + {{admin-report-counts report=http_total_reqs}} {{/unless}} diff --git a/app/assets/javascripts/admin/templates/reports/summed_counts_report.hbs b/app/assets/javascripts/admin/templates/reports/summed_counts_report.hbs deleted file mode 100644 index b96b3f9b302..00000000000 --- a/app/assets/javascripts/admin/templates/reports/summed_counts_report.hbs +++ /dev/null @@ -1,13 +0,0 @@ - - - {{#if icon}} - - {{/if}} - {{title}} - - {{todayCount}} - {{yesterdayCount}} - {{lastSevenDaysCount}} - {{lastThirtyDaysCount}} - {{total}} - diff --git a/app/assets/javascripts/admin/views/admin_backups_view.js b/app/assets/javascripts/admin/views/admin-backups.js.es6 similarity index 91% rename from app/assets/javascripts/admin/views/admin_backups_view.js rename to app/assets/javascripts/admin/views/admin-backups.js.es6 index d1b049f9ac2..f0b9f108d7e 100644 --- a/app/assets/javascripts/admin/views/admin_backups_view.js +++ b/app/assets/javascripts/admin/views/admin-backups.js.es6 @@ -1,4 +1,4 @@ -Discourse.AdminBackupsView = Discourse.View.extend({ +export default Discourse.View.extend({ classNames: ["admin-backups"], _hijackDownloads: function() { diff --git a/app/assets/javascripts/admin/views/admin_api_view.js b/app/assets/javascripts/admin/views/admin_api_view.js deleted file mode 100644 index f57d84cd1cf..00000000000 --- a/app/assets/javascripts/admin/views/admin_api_view.js +++ /dev/null @@ -1,3 +0,0 @@ -Discourse.AdminApiView = Discourse.View.extend({ - templateName: 'admin/templates/api' -}); diff --git a/app/assets/javascripts/admin/views/admin_dashboard_view.js b/app/assets/javascripts/admin/views/admin_dashboard_view.js deleted file mode 100644 index 6bffc189dad..00000000000 --- a/app/assets/javascripts/admin/views/admin_dashboard_view.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - The default view in the admin section - - @class AdminDashboardView - @extends Discourse.View - @namespace Discourse - @module Discourse -**/ -Discourse.AdminDashboardView = Discourse.View.extend({ - templateName: 'admin/templates/dashboard' -}); - - diff --git a/app/assets/javascripts/admin/views/report/admin_report_counts_view.js b/app/assets/javascripts/admin/views/report/admin_report_counts_view.js deleted file mode 100644 index fb7bb9c6286..00000000000 --- a/app/assets/javascripts/admin/views/report/admin_report_counts_view.js +++ /dev/null @@ -1,4 +0,0 @@ -Discourse.AdminReportCountsView = Discourse.View.extend({ - templateName: 'admin/templates/reports/summed_counts_report', - tagName: 'tbody' -}); diff --git a/app/assets/javascripts/admin/views/site_setting_view.js b/app/assets/javascripts/admin/views/site-setting.js.es6 similarity index 86% rename from app/assets/javascripts/admin/views/site_setting_view.js rename to app/assets/javascripts/admin/views/site-setting.js.es6 index 4f5719d17b1..af12ff00b36 100644 --- a/app/assets/javascripts/admin/views/site_setting_view.js +++ b/app/assets/javascripts/admin/views/site-setting.js.es6 @@ -1,12 +1,4 @@ -/** - A view to display a site setting with edit controls - - @class SiteSettingView - @extends Discourse.View - @namespace Discourse - @module Discourse -**/ -Discourse.SiteSettingView = Discourse.View.extend(Discourse.ScrollTop, { +export default Discourse.View.extend(Discourse.ScrollTop, { classNameBindings: [':row', ':setting', 'content.overridden'], preview: function() { diff --git a/app/assets/javascripts/discourse/helpers/fa-icon.js.es6 b/app/assets/javascripts/discourse/helpers/fa-icon.js.es6 index f91800fb0bd..e979ebab90e 100644 --- a/app/assets/javascripts/discourse/helpers/fa-icon.js.es6 +++ b/app/assets/javascripts/discourse/helpers/fa-icon.js.es6 @@ -1,24 +1,27 @@ import registerUnbound from 'discourse/helpers/register-unbound'; -function iconClasses(icon, modifier) { +function iconClasses(icon, params) { var classes = "fa fa-" + icon; - if (modifier) { classes += " fa-" + modifier; } + if (params.modifier) { classes += " fa-" + params.modifier; } + if (params['class']) { classes += ' ' + params['class']; } return classes; } -function iconHTML(icon, label, modifier) { - var html = ""; + if (params.label) { + html += "" + I18n.t(params.label) + ""; } return html; } registerUnbound('fa-icon', function(icon, params) { - return new Handlebars.SafeString(iconHTML(icon, params.label, params.modifier)); + return new Handlebars.SafeString(iconHTML(icon, params)); }); -export { iconClasses, iconHTML }; +export { iconHTML };