mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:38:39 +08:00

`discourse-common` was created in the past to share logic between the 'wizard' app and the main 'discourse' app. Since then, the wizard has been consolidated into the main app, so the separation of `discourse-common` is no longer useful. This commit moves `discourse-common/(lib|utils)/*` into `discourse/lib/*`, adds shims for the imports, and updates existing uses in core.
55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
import Controller, { inject as controller } from "@ember/controller";
|
|
import { action } from "@ember/object";
|
|
import { alias, equal } from "@ember/object/computed";
|
|
import { service } from "@ember/service";
|
|
import { ajax } from "discourse/lib/ajax";
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
import { computedI18n, setting } from "discourse/lib/computed";
|
|
import discourseComputed from "discourse/lib/decorators";
|
|
import getURL from "discourse/lib/get-url";
|
|
import { i18n } from "discourse-i18n";
|
|
|
|
export default class AdminBackupsIndexController extends Controller {
|
|
@service dialog;
|
|
@controller adminBackups;
|
|
|
|
@alias("adminBackups.model") status;
|
|
@computedI18n("admin.backups.upload.label") uploadLabel;
|
|
@setting("backup_location") backupLocation;
|
|
@equal("backupLocation", "local") localBackupStorage;
|
|
|
|
get restoreSettingsUrl() {
|
|
return getURL("/admin/backups/settings?filter=allow_restore");
|
|
}
|
|
|
|
@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";
|
|
}
|
|
}
|
|
|
|
@action
|
|
async download(backup) {
|
|
try {
|
|
await ajax(`/admin/backups/${backup.filename}`, { type: "PUT" });
|
|
this.dialog.alert(i18n("admin.backups.operations.download.alert"));
|
|
} catch (err) {
|
|
popupAjaxError(err);
|
|
}
|
|
}
|
|
|
|
@discourseComputed("status.isOperationRunning")
|
|
deleteTitle() {
|
|
if (this.status.isOperationRunning) {
|
|
return "admin.backups.operations.is_running";
|
|
}
|
|
|
|
return "admin.backups.operations.destroy.title";
|
|
}
|
|
}
|