discourse/app/assets/javascripts/admin/models/version-check.js.es6

43 lines
1.1 KiB
Plaintext
Raw Normal View History

2016-06-30 13:55:44 -04:00
import { ajax } from 'discourse/lib/ajax';
2016-08-03 10:13:02 -04:00
import computed from 'ember-addons/ember-computed-decorators';
const VersionCheck = Discourse.Model.extend({
2016-08-03 10:13:02 -04: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);
}
});
VersionCheck.reopenClass({
2016-08-03 10:13:02 -04:00
find() {
return ajax('/admin/version_check').then(json => VersionCheck.create(json));
}
});
export default VersionCheck;