diff --git a/app/assets/javascripts/admin/controllers/admin-backups-index.js.es6 b/app/assets/javascripts/admin/controllers/admin-backups-index.js.es6 index fb052e6fc..1617e6133 100644 --- a/app/assets/javascripts/admin/controllers/admin-backups-index.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-backups-index.js.es6 @@ -1,8 +1,6 @@ export default Ember.ArrayController.extend({ needs: ["adminBackups"], - status: Em.computed.alias("controllers.adminBackups"), - isOperationRunning: Ember.computed.alias("status.model.isOperationRunning"), - restoreDisabled: Ember.computed.alias("status.model.restoreDisabled"), + status: Ember.computed.alias("controllers.adminBackups"), uploadLabel: function() { return I18n.t("admin.backups.upload.label"); }.property(), diff --git a/app/assets/javascripts/admin/models/backup-status.js.es6 b/app/assets/javascripts/admin/models/backup-status.js.es6 new file mode 100644 index 000000000..2de301f95 --- /dev/null +++ b/app/assets/javascripts/admin/models/backup-status.js.es6 @@ -0,0 +1,12 @@ +import computed from "ember-addons/ember-computed-decorators"; + +export default Discourse.Model.extend({ + + restoreDisabled: Em.computed.not("restoreEnabled"), + + @computed("allowRestore", "isOperationRunning") + restoreEnabled(allowRestore, isOperationRunning) { + return allowRestore && !isOperationRunning; + } + +}); diff --git a/app/assets/javascripts/admin/models/backup_status.js b/app/assets/javascripts/admin/models/backup_status.js deleted file mode 100644 index e67a34bc3..000000000 --- a/app/assets/javascripts/admin/models/backup_status.js +++ /dev/null @@ -1,9 +0,0 @@ -Discourse.BackupStatus = Discourse.Model.extend({ - - restoreDisabled: Em.computed.not("restoreEnabled"), - - restoreEnabled: function() { - return this.get('allowRestore') && !this.get("isOperationRunning"); - }.property("isOperationRunning", "allowRestore") - -}); diff --git a/app/assets/javascripts/admin/templates/backups_index.hbs b/app/assets/javascripts/admin/templates/backups_index.hbs index 0b66fcaf7..09bf83bc6 100644 --- a/app/assets/javascripts/admin/templates/backups_index.hbs +++ b/app/assets/javascripts/admin/templates/backups_index.hbs @@ -6,9 +6,9 @@
{{resumable-upload target="/admin/backups/upload" success="uploadSuccess" error="uploadError" uploadText=uploadLabel title="admin.backups.upload.title"}} {{#if site.isReadOnly}} - {{d-button icon="eye" action="toggleReadOnlyMode" disabled=model.isOperationRunning title="admin.backups.read_only.disable.title" label="admin.backups.read_only.disable.label"}} + {{d-button icon="eye" action="toggleReadOnlyMode" disabled=status.model.isOperationRunning title="admin.backups.read_only.disable.title" label="admin.backups.read_only.disable.label"}} {{else}} - {{d-button icon="eye" action="toggleReadOnlyMode" disabled=model.isOperationRunning title="admin.backups.read_only.enable.title" label="admin.backups.read_only.enable.label"}} + {{d-button icon="eye" action="toggleReadOnlyMode" disabled=status.model.isOperationRunning title="admin.backups.read_only.enable.title" label="admin.backups.read_only.enable.label"}} {{/if}}
@@ -20,12 +20,12 @@
{{fa-icon "download"}}{{i18n 'admin.backups.operations.download.label'}} - {{#if model.isOperationRunning}} + {{#if status.model.isOperationRunning}} {{d-button icon="trash-o" action="destroyBackup" actionParam=backup class="btn-danger" disabled="true" title="admin.backups.operations.is_running"}} - {{d-button icon="play" action="startRestore" actionParam=backup disabled=model.restoreDisabled title=restoreTitle label="admin.backups.operations.restore.label"}} + {{d-button icon="play" action="startRestore" actionParam=backup disabled=status.model.restoreDisabled title=restoreTitle label="admin.backups.operations.restore.label"}} {{else}} {{d-button icon="trash-o" action="destroyBackup" actionParam=backup class="btn-danger" title="admin.backups.operations.destroy.title"}} - {{d-button icon="play" action="startRestore" actionParam=backup disabled=model.restoreDisabled title=restoreTitle label="admin.backups.operations.restore.label"}} + {{d-button icon="play" action="startRestore" actionParam=backup disabled=status.model.restoreDisabled title=restoreTitle label="admin.backups.operations.restore.label"}} {{/if}}