2019-11-07 15:38:28 -06:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2018-06-15 10:03:24 -05:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
2016-08-03 09:13:02 -05:00
|
|
|
|
2015-11-20 19:27:06 -06:00
|
|
|
const VersionCheck = Discourse.Model.extend({
|
2019-11-07 15:38:28 -06:00
|
|
|
@discourseComputed("updated_at")
|
2016-08-03 09:13:02 -05:00
|
|
|
noCheckPerformed(updatedAt) {
|
|
|
|
return updatedAt === null;
|
|
|
|
},
|
|
|
|
|
2019-11-07 15:38:28 -06:00
|
|
|
@discourseComputed("missing_versions_count")
|
2016-08-03 09:13:02 -05:00
|
|
|
upToDate(missingVersionsCount) {
|
|
|
|
return missingVersionsCount === 0 || missingVersionsCount === null;
|
|
|
|
},
|
|
|
|
|
2019-11-07 15:38:28 -06:00
|
|
|
@discourseComputed("missing_versions_count")
|
2016-08-03 09:13:02 -05:00
|
|
|
behindByOneVersion(missingVersionsCount) {
|
|
|
|
return missingVersionsCount === 1;
|
|
|
|
},
|
|
|
|
|
2019-11-07 15:38:28 -06:00
|
|
|
@discourseComputed("installed_sha")
|
2019-10-17 14:08:43 -05:00
|
|
|
gitLink(installedSHA) {
|
|
|
|
if (installedSHA) {
|
|
|
|
return `https://github.com/discourse/discourse/commits/${installedSHA}`;
|
2016-08-03 09:13:02 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2019-11-07 15:38:28 -06:00
|
|
|
@discourseComputed("installed_sha")
|
2016-08-03 09:13:02 -05:00
|
|
|
shortSha(installedSHA) {
|
2019-09-10 15:38:23 -05:00
|
|
|
if (installedSHA) {
|
|
|
|
return installedSHA.substr(0, 10);
|
|
|
|
}
|
2016-08-03 09:13:02 -05:00
|
|
|
}
|
2013-02-22 14:41:12 -06:00
|
|
|
});
|
2013-02-21 14:03:43 -06:00
|
|
|
|
2015-11-20 19:27:06 -06:00
|
|
|
VersionCheck.reopenClass({
|
2016-08-03 09:13:02 -05:00
|
|
|
find() {
|
2018-06-15 10:03:24 -05:00
|
|
|
return ajax("/admin/version_check").then(json => VersionCheck.create(json));
|
2013-02-22 14:41:12 -06:00
|
|
|
}
|
2013-03-14 07:01:52 -05:00
|
|
|
});
|
2015-11-20 19:27:06 -06:00
|
|
|
|
|
|
|
export default VersionCheck;
|