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

42 lines
990 B
Plaintext
Raw Normal View History

2018-06-15 11:03:24 -04:00
import { ajax } from "discourse/lib/ajax";
import computed from "ember-addons/ember-computed-decorators";
2016-08-03 10:13:02 -04:00
const VersionCheck = Discourse.Model.extend({
2018-06-15 11:03:24 -04:00
@computed("updated_at")
2016-08-03 10:13:02 -04:00
noCheckPerformed(updatedAt) {
return updatedAt === null;
},
2018-06-15 11:03:24 -04:00
@computed("missing_versions_count")
2016-08-03 10:13:02 -04:00
upToDate(missingVersionsCount) {
return missingVersionsCount === 0 || missingVersionsCount === null;
},
2018-06-15 11:03:24 -04:00
@computed("missing_versions_count")
2016-08-03 10:13:02 -04:00
behindByOneVersion(missingVersionsCount) {
return missingVersionsCount === 1;
},
@computed("installed_sha")
gitLink(installedSHA) {
if (installedSHA) {
return `https://github.com/discourse/discourse/commits/${installedSHA}`;
2016-08-03 10:13:02 -04:00
}
},
2018-06-15 11:03:24 -04:00
@computed("installed_sha")
2016-08-03 10:13:02 -04:00
shortSha(installedSHA) {
if (installedSHA) {
return installedSHA.substr(0, 10);
}
2016-08-03 10:13:02 -04:00
}
});
VersionCheck.reopenClass({
2016-08-03 10:13:02 -04:00
find() {
2018-06-15 11:03:24 -04:00
return ajax("/admin/version_check").then(json => VersionCheck.create(json));
}
});
export default VersionCheck;