FIX: backups index template wasn't properly bound

This commit is contained in:
Régis Hanol 2015-08-17 16:21:23 +02:00
parent 58c9ca6132
commit 73e4c6ae4d
4 changed files with 18 additions and 17 deletions

View File

@ -1,8 +1,6 @@
export default Ember.ArrayController.extend({ export default Ember.ArrayController.extend({
needs: ["adminBackups"], needs: ["adminBackups"],
status: Em.computed.alias("controllers.adminBackups"), status: Ember.computed.alias("controllers.adminBackups"),
isOperationRunning: Ember.computed.alias("status.model.isOperationRunning"),
restoreDisabled: Ember.computed.alias("status.model.restoreDisabled"),
uploadLabel: function() { return I18n.t("admin.backups.upload.label"); }.property(), uploadLabel: function() { return I18n.t("admin.backups.upload.label"); }.property(),

View File

@ -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;
}
});

View File

@ -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")
});

View File

@ -6,9 +6,9 @@
<div class="pull-right"> <div class="pull-right">
{{resumable-upload target="/admin/backups/upload" success="uploadSuccess" error="uploadError" uploadText=uploadLabel title="admin.backups.upload.title"}} {{resumable-upload target="/admin/backups/upload" success="uploadSuccess" error="uploadError" uploadText=uploadLabel title="admin.backups.upload.title"}}
{{#if site.isReadOnly}} {{#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}} {{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}} {{/if}}
</div> </div>
</th> </th>
@ -20,12 +20,12 @@
<td> <td>
<div class="pull-right"> <div class="pull-right">
<a {{bind-attr href="backup.link"}} class="btn download" title="{{i18n 'admin.backups.operations.download.title'}}">{{fa-icon "download"}}{{i18n 'admin.backups.operations.download.label'}}</a> <a {{bind-attr href="backup.link"}} class="btn download" title="{{i18n 'admin.backups.operations.download.title'}}">{{fa-icon "download"}}{{i18n 'admin.backups.operations.download.label'}}</a>
{{#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="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}} {{else}}
{{d-button icon="trash-o" action="destroyBackup" actionParam=backup class="btn-danger" title="admin.backups.operations.destroy.title"}} {{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}} {{/if}}
</div> </div>
</td> </td>