mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 09:43:46 +08:00
fe588cc7f8
* DEV: Fix the function prototype observers deprecation DEPRECATION: Function prototype extensions have been deprecated, please migrate from function(){}.observes('foo') to observer('foo', function() {}). [deprecation id: function-prototype-extensions.observes] See https://deprecations.emberjs.com/v3.x/#toc_function-prototype-extensions-observes for more details. * DEV: Fix the function prototype event listeners deprecation DEPRECATION: Function prototype extensions have been deprecated, please migrate from function(){}.on('foo') to on('foo', function() {}). [deprecation id: function-prototype-extensions.on] See https://deprecations.emberjs.com/v3.x/#toc_function-prototype-extensions-on for more details. * DEV: Simplify `default as` imports Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
import { alias, equal } from "@ember/object/computed";
|
|
import { inject } from "@ember/controller";
|
|
import Controller from "@ember/controller";
|
|
import { ajax } from "discourse/lib/ajax";
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
import { setting, i18n } from "discourse/lib/computed";
|
|
|
|
export default Controller.extend({
|
|
adminBackups: inject(),
|
|
status: alias("adminBackups.model"),
|
|
uploadLabel: i18n("admin.backups.upload.label"),
|
|
backupLocation: setting("backup_location"),
|
|
localBackupStorage: equal("backupLocation", "local"),
|
|
|
|
@discourseComputed("status.allowRestore", "status.isOperationRunning")
|
|
restoreTitle(allowRestore, isOperationRunning) {
|
|
if (!allowRestore) {
|
|
return "admin.backups.operations.restore.is_disabled";
|
|
} else if (isOperationRunning) {
|
|
return "admin.backups.operations.is_running";
|
|
} else {
|
|
return "admin.backups.operations.restore.title";
|
|
}
|
|
},
|
|
|
|
actions: {
|
|
toggleReadOnlyMode() {
|
|
if (!this.site.get("isReadOnly")) {
|
|
bootbox.confirm(
|
|
I18n.t("admin.backups.read_only.enable.confirm"),
|
|
I18n.t("no_value"),
|
|
I18n.t("yes_value"),
|
|
confirmed => {
|
|
if (confirmed) {
|
|
this.set("currentUser.hideReadOnlyAlert", true);
|
|
this._toggleReadOnlyMode(true);
|
|
}
|
|
}
|
|
);
|
|
} else {
|
|
this._toggleReadOnlyMode(false);
|
|
}
|
|
},
|
|
|
|
download(backup) {
|
|
const link = backup.get("filename");
|
|
ajax(`/admin/backups/${link}`, { type: "PUT" }).then(() =>
|
|
bootbox.alert(I18n.t("admin.backups.operations.download.alert"))
|
|
);
|
|
}
|
|
},
|
|
|
|
_toggleReadOnlyMode(enable) {
|
|
ajax("/admin/backups/readonly", {
|
|
type: "PUT",
|
|
data: { enable }
|
|
}).then(() => this.site.set("isReadOnly", enable));
|
|
}
|
|
});
|