mirror of
https://github.com/discourse/discourse.git
synced 2024-12-19 08:14:54 +08:00
49c49e8ae0
This takes the uppy chunking algorithm and combines it with some form submission from resumable.js for parity with the current backup controller to make local backup uploads work with uppy. We can then use this to replace the resumable-upload component and the resumable.js library from our codebase, once stable. This is disabled by default, so people using local backups will not be affected. The enable_experimental_backup_uploader site setting must be enabled for this to work.
61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
import Controller, { inject as controller } from "@ember/controller";
|
|
import { alias, equal } from "@ember/object/computed";
|
|
import { i18n, setting } from "discourse/lib/computed";
|
|
import I18n from "I18n";
|
|
import { ajax } from "discourse/lib/ajax";
|
|
import bootbox from "bootbox";
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
|
|
export default Controller.extend({
|
|
adminBackups: controller(),
|
|
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));
|
|
},
|
|
});
|