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