From 86200247985349a42676d8f5cf7354111e558f82 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Thu, 21 Feb 2013 13:26:30 -0500 Subject: [PATCH] Show which SHA is installed on the admin dashboard --- .../controllers/admin_dashboard_controller.js | 28 +++++++++++-------- .../javascripts/admin/models/version_check.js | 2 +- .../admin/templates/dashboard.js.handlebars | 5 ++-- app/assets/stylesheets/admin/admin_base.scss | 4 +-- app/models/discourse_version_check.rb | 2 +- .../discourse_version_check_serializer.rb | 2 +- lib/discourse_updates.rb | 3 +- 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/admin/controllers/admin_dashboard_controller.js b/app/assets/javascripts/admin/controllers/admin_dashboard_controller.js index cb11e1dff..efc3243d9 100644 --- a/app/assets/javascripts/admin/controllers/admin_dashboard_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_dashboard_controller.js @@ -3,23 +3,23 @@ /** This controller supports the default interface when you enter the admin section. - @class AdminDashboardController + @class AdminDashboardController @extends Ember.Controller @namespace Discourse @module Discourse - **/ + **/ window.Discourse.AdminDashboardController = Ember.Controller.extend({ loading: true, versionCheck: null, - upToDate: (function() { - if (this.versionCheck) { - return this.versionCheck.latest_version === this.versionCheck.installed_version; + upToDate: function() { + if (this.get('versionCheck')) { + return this.get('versionCheck.latest_version') === this.get('versionCheck.installed_version'); } return true; - }).property('versionCheck'), + }.property('versionCheck'), - updateIconClasses: (function() { + updateIconClasses: function() { var classes; classes = "icon icon-warning-sign "; if (this.get('versionCheck.critical_updates')) { @@ -28,15 +28,21 @@ classes += "updates-available"; } return classes; - }).property('versionCheck'), + }.property('versionCheck.critical_updates'), - priorityClass: (function() { + priorityClass: function() { if (this.get('versionCheck.critical_updates')) { return 'version-check critical'; } - return 'version-check normal'; - }).property('versionCheck') + }.property('versionCheck.critical_updates'), + gitLink: function() { + return "https://github.com/discourse/discourse/tree/" + this.get('versionCheck.installed_sha'); + }.property('versionCheck.installed_sha'), + + shortSha: function() { + return this.get('versionCheck.installed_sha').substr(0,10); + }.property('versionCheck.installed_sha') }); }).call(this); diff --git a/app/assets/javascripts/admin/models/version_check.js b/app/assets/javascripts/admin/models/version_check.js index 79ac13650..f47c81cc2 100644 --- a/app/assets/javascripts/admin/models/version_check.js +++ b/app/assets/javascripts/admin/models/version_check.js @@ -4,7 +4,7 @@ Discourse.VersionCheck.reopenClass({ find: function() { - var promise = new RSVP.Promise() + var promise = new RSVP.Promise(); jQuery.ajax({ url: '/admin/version_check', dataType: 'json', diff --git a/app/assets/javascripts/admin/templates/dashboard.js.handlebars b/app/assets/javascripts/admin/templates/dashboard.js.handlebars index 04d8319a9..9ee62a1e2 100644 --- a/app/assets/javascripts/admin/templates/dashboard.js.handlebars +++ b/app/assets/javascripts/admin/templates/dashboard.js.handlebars @@ -7,8 +7,9 @@ {{else}} {{i18n admin.dashboard.version}}: {{ versionCheck.installed_version }} - {{log versionCheck}} - + {{#if versionCheck.installed_sha}} + ({{shortSha}}) + {{/if}} {{#if upToDate }} diff --git a/app/assets/stylesheets/admin/admin_base.scss b/app/assets/stylesheets/admin/admin_base.scss index 018580af8..910314958 100644 --- a/app/assets/stylesheets/admin/admin_base.scss +++ b/app/assets/stylesheets/admin/admin_base.scss @@ -87,10 +87,10 @@ margin-left: 24px; } - .critical .version-notes .normal-note { + &.critical .version-notes .normal-note { display: none; } - .normal .version-notes .critical-note { + &.normal .version-notes .critical-note { display: none; } diff --git a/app/models/discourse_version_check.rb b/app/models/discourse_version_check.rb index ac7a04807..144ffdbf3 100644 --- a/app/models/discourse_version_check.rb +++ b/app/models/discourse_version_check.rb @@ -5,7 +5,7 @@ class DiscourseVersionCheck include ActiveAttr::MassAssignment include ActiveModel::Serialization - attr_accessor :latest_version, :installed_version, :critical_updates + attr_accessor :latest_version, :critical_updates, :installed_version, :installed_sha def active_model_serializer DiscourseVersionCheckSerializer diff --git a/app/serializers/discourse_version_check_serializer.rb b/app/serializers/discourse_version_check_serializer.rb index 424696521..a13ca3c70 100644 --- a/app/serializers/discourse_version_check_serializer.rb +++ b/app/serializers/discourse_version_check_serializer.rb @@ -1,5 +1,5 @@ class DiscourseVersionCheckSerializer < ApplicationSerializer - attributes :latest_version, :installed_version, :critical_updates + attributes :latest_version, :critical_updates, :installed_version, :installed_sha self.root = false end \ No newline at end of file diff --git a/lib/discourse_updates.rb b/lib/discourse_updates.rb index c4f1fe418..c5c793b11 100644 --- a/lib/discourse_updates.rb +++ b/lib/discourse_updates.rb @@ -5,8 +5,9 @@ module DiscourseUpdates def check_version DiscourseVersionCheck.new( latest_version: latest_version || Discourse::VERSION::STRING, + critical_updates: critical_update_available?, installed_version: Discourse::VERSION::STRING, - critical_updates: critical_update_available? + installed_sha: (Discourse.git_version == 'unknown' ? nil : Discourse.git_version) # TODO: more info, like links and release messages ) end