Show which SHA is installed on the admin dashboard

This commit is contained in:
Neil Lalonde 2013-02-21 13:26:30 -05:00
parent 1e794f98a7
commit 8620024798
7 changed files with 27 additions and 19 deletions

View file

@ -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);

View file

@ -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',

View file

@ -7,8 +7,9 @@
{{else}}
{{i18n admin.dashboard.version}}: <span class="version-number">{{ versionCheck.installed_version }}</span>
{{log versionCheck}}
{{#if versionCheck.installed_sha}}
<span class="git-version">(<a {{bindAttr href="gitLink"}} target="_blank">{{shortSha}}</a>)</span>
{{/if}}
<span class="version-notes">
{{#if upToDate }}

View file

@ -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;
}

View file

@ -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

View file

@ -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

View file

@ -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