2016-07-01 01:55:44 +08:00
|
|
|
import { ajax } from 'discourse/lib/ajax';
|
2016-08-03 22:13:02 +08:00
|
|
|
import computed from 'ember-addons/ember-computed-decorators';
|
|
|
|
|
2015-11-21 09:27:06 +08:00
|
|
|
const VersionCheck = Discourse.Model.extend({
|
2013-07-03 23:06:07 +08:00
|
|
|
|
2016-08-03 22:13:02 +08:00
|
|
|
@computed('updated_at')
|
|
|
|
noCheckPerformed(updatedAt) {
|
|
|
|
return updatedAt === null;
|
|
|
|
},
|
|
|
|
|
|
|
|
@computed('missing_versions_count')
|
|
|
|
upToDate(missingVersionsCount) {
|
|
|
|
return missingVersionsCount === 0 || missingVersionsCount === null;
|
|
|
|
},
|
|
|
|
|
|
|
|
@computed('missing_versions_count')
|
|
|
|
behindByOneVersion(missingVersionsCount) {
|
|
|
|
return missingVersionsCount === 1;
|
|
|
|
},
|
|
|
|
|
|
|
|
@computed('git_branch', 'installed_sha')
|
|
|
|
gitLink(gitBranch, installedSHA) {
|
|
|
|
if (gitBranch) {
|
|
|
|
return `https://github.com/discourse/discourse/compare/${installedSHA}...${gitBranch}`;
|
|
|
|
} else {
|
|
|
|
return `https://github.com/discourse/discourse/tree/${installedSHA}`;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
@computed('installed_sha')
|
|
|
|
shortSha(installedSHA) {
|
|
|
|
return installedSHA.substr(0, 10);
|
|
|
|
}
|
2013-02-23 04:41:12 +08:00
|
|
|
});
|
2013-02-22 04:03:43 +08:00
|
|
|
|
2015-11-21 09:27:06 +08:00
|
|
|
VersionCheck.reopenClass({
|
2016-08-03 22:13:02 +08:00
|
|
|
find() {
|
|
|
|
return ajax('/admin/version_check').then(json => VersionCheck.create(json));
|
2013-02-23 04:41:12 +08:00
|
|
|
}
|
2013-03-14 20:01:52 +08:00
|
|
|
});
|
2015-11-21 09:27:06 +08:00
|
|
|
|
|
|
|
export default VersionCheck;
|