2019-11-09 03:13:35 +08:00
|
|
|
import EmberObject from "@ember/object";
|
2016-07-01 01:55:44 +08:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
2019-11-08 05:38:28 +08:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2016-08-03 22:13:02 +08:00
|
|
|
|
2023-03-17 18:18:42 +08:00
|
|
|
export default class VersionCheck extends EmberObject {
|
|
|
|
static find() {
|
|
|
|
return ajax("/admin/version_check").then((json) =>
|
|
|
|
VersionCheck.create(json)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("updated_at")
|
2016-08-03 22:13:02 +08:00
|
|
|
noCheckPerformed(updatedAt) {
|
|
|
|
return updatedAt === null;
|
2023-03-17 18:18:42 +08:00
|
|
|
}
|
2016-08-03 22:13:02 +08:00
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("missing_versions_count")
|
2016-08-03 22:13:02 +08:00
|
|
|
upToDate(missingVersionsCount) {
|
|
|
|
return missingVersionsCount === 0 || missingVersionsCount === null;
|
2023-03-17 18:18:42 +08:00
|
|
|
}
|
2016-08-03 22:13:02 +08:00
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("missing_versions_count")
|
2016-08-03 22:13:02 +08:00
|
|
|
behindByOneVersion(missingVersionsCount) {
|
|
|
|
return missingVersionsCount === 1;
|
2023-03-17 18:18:42 +08:00
|
|
|
}
|
2016-08-03 22:13:02 +08:00
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("installed_sha")
|
2019-10-18 03:08:43 +08:00
|
|
|
gitLink(installedSHA) {
|
|
|
|
if (installedSHA) {
|
|
|
|
return `https://github.com/discourse/discourse/commits/${installedSHA}`;
|
2016-08-03 22:13:02 +08:00
|
|
|
}
|
2023-03-17 18:18:42 +08:00
|
|
|
}
|
2016-08-03 22:13:02 +08:00
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("installed_sha")
|
2016-08-03 22:13:02 +08:00
|
|
|
shortSha(installedSHA) {
|
2019-09-11 04:38:23 +08:00
|
|
|
if (installedSHA) {
|
2022-04-01 23:35:17 +08:00
|
|
|
return installedSHA.slice(0, 10);
|
2019-09-11 04:38:23 +08:00
|
|
|
}
|
2023-03-17 18:18:42 +08:00
|
|
|
}
|
|
|
|
}
|