FEATURE: backup without uploads
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||
|
||||
import ObjectController from 'discourse/controllers/object';
|
||||
|
||||
export default ObjectController.extend(ModalFunctionality, {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||
import Controller from 'discourse/controllers/controller';
|
||||
|
||||
export default Controller.extend(ModalFunctionality, {
|
||||
|
||||
needs: ["adminBackupsLogs"],
|
||||
|
||||
_startBackup: function (withUploads) {
|
||||
var self = this;
|
||||
Discourse.User.currentProp("hideReadOnlyAlert", true);
|
||||
Discourse.Backup.start(withUploads).then(function() {
|
||||
self.get("controllers.adminBackupsLogs").clear();
|
||||
self.send("backupStarted");
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
||||
startBackup: function () {
|
||||
return this._startBackup();
|
||||
},
|
||||
|
||||
startBackupWithoutUpload: function () {
|
||||
return this._startBackup(false);
|
||||
},
|
||||
|
||||
cancel: function () {
|
||||
this.send("closeModal");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
@@ -52,8 +52,9 @@ Discourse.Backup.reopenClass({
|
||||
@method start
|
||||
@returns {Promise} a promise that resolves when the backup has started
|
||||
**/
|
||||
start: function() {
|
||||
return Discourse.ajax("/admin/backups", { type: "POST" }).then(function(result) {
|
||||
start: function (withUploads) {
|
||||
if (withUploads === undefined) { withUploads = true; }
|
||||
return Discourse.ajax("/admin/backups", { type: "POST", data: { with_uploads: withUploads } }).then(function(result) {
|
||||
if (!result.success) { bootbox.alert(result.message); }
|
||||
});
|
||||
},
|
||||
|
||||
@@ -47,22 +47,14 @@ Discourse.AdminBackupsRoute = Discourse.Route.extend({
|
||||
@method startBackup
|
||||
**/
|
||||
startBackup: function() {
|
||||
var self = this;
|
||||
bootbox.confirm(
|
||||
I18n.t("admin.backups.operations.backup.confirm"),
|
||||
I18n.t("no_value"),
|
||||
I18n.t("yes_value"),
|
||||
function(confirmed) {
|
||||
if (confirmed) {
|
||||
Discourse.User.currentProp("hideReadOnlyAlert", true);
|
||||
Discourse.Backup.start().then(function() {
|
||||
self.controllerFor("adminBackupsLogs").clear();
|
||||
self.modelFor("adminBackups").set("isOperationRunning", true);
|
||||
self.transitionTo("admin.backups.logs");
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
Discourse.Route.showModal(this, 'admin_start_backup');
|
||||
this.controllerFor('modal').set('modalClass', 'start-backup-modal');
|
||||
},
|
||||
|
||||
backupStarted: function () {
|
||||
this.modelFor("adminBackups").set("isOperationRunning", true);
|
||||
this.transitionTo("admin.backups.logs");
|
||||
this.send("closeModal");
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<button {{action startBackup}} class="btn btn-primary">{{i18n yes_value}}</button>
|
||||
<button {{action startBackupWithoutUpload}} class="btn">{{i18n admin.backups.operations.backup.without_uploads}}</button>
|
||||
<button {{action cancel}} class="btn">{{i18n no_value}}</button>
|
||||
@@ -0,0 +1,4 @@
|
||||
Discourse.AdminStartBackupView = Discourse.ModalBodyView.extend({
|
||||
templateName: 'admin/templates/modal/admin_start_backup',
|
||||
title: I18n.t('admin.backups.operations.backup.confirm')
|
||||
});
|
||||
Reference in New Issue
Block a user