2015-11-20 08:14:50 -05:00
|
|
|
const VersionCheck = Discourse.Model.extend({
|
2013-07-03 11:06:07 -04:00
|
|
|
|
|
|
|
noCheckPerformed: function() {
|
|
|
|
return this.get('updated_at') === null;
|
|
|
|
}.property('updated_at'),
|
|
|
|
|
|
|
|
dataIsOld: function() {
|
2013-11-04 12:51:01 -05:00
|
|
|
return this.get('version_check_pending') || moment().diff(moment(this.get('updated_at')), 'hours') >= 48;
|
2013-07-03 11:06:07 -04:00
|
|
|
}.property('updated_at'),
|
|
|
|
|
|
|
|
staleData: function() {
|
|
|
|
return ( this.get('dataIsOld') ||
|
|
|
|
(this.get('installed_version') !== this.get('latest_version') && this.get('missing_versions_count') === 0) ||
|
|
|
|
(this.get('installed_version') === this.get('latest_version') && this.get('missing_versions_count') !== 0) );
|
|
|
|
}.property('dataIsOld', 'missing_versions_count', 'installed_version', 'latest_version'),
|
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
upToDate: function() {
|
2013-04-18 11:45:10 -04:00
|
|
|
return this.get('missing_versions_count') === 0 || this.get('missing_versions_count') === null;
|
2013-04-15 11:00:29 -04:00
|
|
|
}.property('missing_versions_count'),
|
2013-03-05 18:14:51 -05:00
|
|
|
|
|
|
|
behindByOneVersion: function() {
|
|
|
|
return this.get('missing_versions_count') === 1;
|
|
|
|
}.property('missing_versions_count'),
|
2013-02-21 14:09:28 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
gitLink: function() {
|
|
|
|
return "https://github.com/discourse/discourse/tree/" + this.get('installed_sha');
|
|
|
|
}.property('installed_sha'),
|
2013-02-21 15:03:43 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
shortSha: function() {
|
|
|
|
return this.get('installed_sha').substr(0,10);
|
|
|
|
}.property('installed_sha')
|
|
|
|
});
|
2013-02-21 15:03:43 -05:00
|
|
|
|
2015-11-20 08:14:50 -05:00
|
|
|
VersionCheck.reopenClass({
|
2013-02-22 15:41:12 -05:00
|
|
|
find: function() {
|
2013-05-07 13:30:12 -04:00
|
|
|
return Discourse.ajax('/admin/version_check').then(function(json) {
|
2015-11-20 08:14:50 -05:00
|
|
|
return VersionCheck.create(json);
|
2013-02-22 15:41:12 -05:00
|
|
|
});
|
|
|
|
}
|
2013-03-14 08:01:52 -04:00
|
|
|
});
|
2015-11-20 08:14:50 -05:00
|
|
|
|
|
|
|
export default VersionCheck;
|