From 6493e4f641eeb1e9c9433f95ee1ff163dc5a65c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Thu, 26 Mar 2015 18:05:27 +0100 Subject: [PATCH] FIX: missing tooltip on backup screen --- .../components/resumable_upload_component.js | 6 +++ .../controllers/admin-backups-index.js.es6 | 43 ++++--------------- .../javascripts/admin/templates/backups.hbs | 6 +-- .../admin/templates/backups_index.hbs | 19 +++++--- config/locales/client.en.yml | 18 ++++---- 5 files changed, 41 insertions(+), 51 deletions(-) diff --git a/app/assets/javascripts/admin/components/resumable_upload_component.js b/app/assets/javascripts/admin/components/resumable_upload_component.js index a5ef4af921a..dc040464dd2 100644 --- a/app/assets/javascripts/admin/components/resumable_upload_component.js +++ b/app/assets/javascripts/admin/components/resumable_upload_component.js @@ -14,6 +14,7 @@ Discourse.ResumableUploadComponent = Ember.Component.extend(Discourse.StringBuff tagName: "button", classNames: ["btn", "ru"], classNameBindings: ["isUploading"], + attributeBindings: ["translatedTitle:title"], resumable: null, @@ -22,6 +23,11 @@ Discourse.ResumableUploadComponent = Ember.Component.extend(Discourse.StringBuff rerenderTriggers: ['isUploading', 'progress'], + translatedTitle: function() { + const title = this.get('title'); + return title ? I18n.t(title) : this.get('text'); + }.property('title', 'text'), + text: function() { if (this.get("isUploading")) { return this.get("progress") + " %"; 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 c3ade201b49..8eceb0bb7d0 100644 --- a/app/assets/javascripts/admin/controllers/admin-backups-index.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-backups-index.js.es6 @@ -1,49 +1,24 @@ export default Ember.ArrayController.extend({ needs: ["adminBackups"], status: Em.computed.alias("controllers.adminBackups"), - - uploadText: function() { return I18n.t("admin.backups.upload.text"); }.property(), - - readOnlyModeDisabled: Em.computed.alias("status.isOperationRunning"), - + isOperationRunning: Em.computed.alias("status.isOperationRunning"), restoreDisabled: Em.computed.alias("status.restoreDisabled"), + uploadLabel: function() { return I18n.t("admin.backups.upload.label"); }.property(), + restoreTitle: function() { if (!this.get('status.allowRestore')) { - return I18n.t("admin.backups.operations.restore.is_disabled"); + return "admin.backups.operations.restore.is_disabled"; } else if (this.get("status.isOperationRunning")) { - return I18n.t("admin.backups.operation_already_running"); + return "admin.backups.operations.is_running"; } else { - return I18n.t("admin.backups.operations.restore.title"); + return "admin.backups.operations.restore.title"; } - }.property("status.isOperationRunning"), - - destroyDisabled: Em.computed.alias("status.isOperationRunning"), - - destroyTitle: function() { - if (this.get("status.isOperationRunning")) { - return I18n.t("admin.backups.operation_already_running"); - } else { - return I18n.t("admin.backups.operations.destroy.title"); - } - }.property("status.isOperationRunning"), - - readOnlyModeTitle: function() { return this._readOnlyModeI18n("title"); }.property("site.isReadOnly"), - readOnlyModeText: function() { return this._readOnlyModeI18n("text"); }.property("site.isReadOnly"), - - _readOnlyModeI18n: function(value) { - var action = this.site.get("isReadOnly") ? "disable" : "enable"; - return I18n.t("admin.backups.read_only." + action + "." + value); - }, + }.property("status.{allowRestore,isOperationRunning}"), actions: { - /** - Toggle read-only mode - - @method toggleReadOnlyMode - **/ - toggleReadOnlyMode: function() { + toggleReadOnlyMode() { var self = this; if (!this.site.get("isReadOnly")) { bootbox.confirm( @@ -64,7 +39,7 @@ export default Ember.ArrayController.extend({ }, - _toggleReadOnlyMode: function(enable) { + _toggleReadOnlyMode(enable) { var site = this.site; Discourse.ajax("/admin/backups/readonly", { type: "PUT", diff --git a/app/assets/javascripts/admin/templates/backups.hbs b/app/assets/javascripts/admin/templates/backups.hbs index bcd14fadd60..510b9653088 100644 --- a/app/assets/javascripts/admin/templates/backups.hbs +++ b/app/assets/javascripts/admin/templates/backups.hbs @@ -9,7 +9,7 @@ {{#if canRollback}} {{d-button action="rollback" class="btn-rollback" - label="admin.backups.operations.rollback.text" + label="admin.backups.operations.rollback.label" title="admin.backups.operations.rollback.title" icon="ambulance" disabled=rollbackDisabled}} @@ -18,13 +18,13 @@ {{d-button action="cancelOperation" class="btn-danger" title="admin.backups.operations.cancel.title" - label="admin.backups.operations.cancel.text" + label="admin.backups.operations.cancel.label" icon="times"}} {{else}} {{d-button action="startBackup" class="btn-primary" title="admin.backups.operations.backup.title" - label="admin.backups.operations.backup.text" + label="admin.backups.operations.backup.label" icon="rocket"}} {{/if}} diff --git a/app/assets/javascripts/admin/templates/backups_index.hbs b/app/assets/javascripts/admin/templates/backups_index.hbs index bfbedd1be29..ca8830a0e8a 100644 --- a/app/assets/javascripts/admin/templates/backups_index.hbs +++ b/app/assets/javascripts/admin/templates/backups_index.hbs @@ -4,8 +4,12 @@ {{i18n 'admin.backups.columns.size'}}
- {{resumable-upload target="/admin/backups/upload" success="uploadSuccess" error="uploadError" uploadText=uploadText}} - + {{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=isOperationRunning title="admin.backups.read_only.disable.title" label="admin.backups.read_only.disable.label"}} + {{else}} + {{d-button icon="eye" action="toggleReadOnlyMode" disabled=isOperationRunning title="admin.backups.read_only.enable.title" label="admin.backups.read_only.enable.label"}} + {{/if}}
@@ -15,9 +19,14 @@ {{human-size backup.size}}
- {{i18n 'admin.backups.operations.download.text'}} - - + {{fa-icon "download"}}{{i18n 'admin.backups.operations.download.label'}} + {{#if isOperationRunning}} + {{d-button icon="trash-o" action="destroyBackup" actionParam=backup class="btn-danger no-text" disabled="true" title="admin.backups.operations.is_running"}} + {{d-button icon="play" action="startRestore" actionParam=backup disabled=restoreDisabled title=restoreTitle label="admin.backups.operations.restore.label"}} + {{else}} + {{d-button icon="trash-o" action="destroyBackup" actionParam=backup class="btn-danger no-text" title="admin.backups.operations.destroy.title"}} + {{d-button icon="play" action="startRestore" actionParam=backup disabled=restoreDisabled title=restoreTitle label="admin.backups.operations.restore.label"}} + {{/if}}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 9100d6d99d4..2690a0447fd 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1739,18 +1739,19 @@ en: read_only: enable: title: "Enable the read-only mode" - text: "Enable read-only mode" + label: "Enable read-only mode" confirm: "Are you sure you want to enable the read-only mode?" disable: title: "Disable the read-only mode" - text: "Disable read-only mode" + label: "Disable read-only mode" logs: none: "No logs yet..." columns: filename: "Filename" size: "Size" upload: - text: "Upload" + label: "Upload" + title: "Upload a backup to this instance" uploading: "Uploading..." success: "'{{filename}}' has successfully been uploaded." error: "There has been an error while uploading '{{filename}}': {{message}}" @@ -1758,28 +1759,27 @@ en: is_running: "An operation is currently running..." failed: "The {{operation}} failed. Please check the logs." cancel: - text: "Cancel" + label: "Cancel" title: "Cancel the current operation" confirm: "Are you sure you want to cancel the current operation?" backup: - text: "Backup" + label: "Backup" title: "Create a backup" confirm: "Do you want to start a new backup?" without_uploads: "Yes (do not include files)" download: - text: "Download" + label: "Download" title: "Download the backup" destroy: - text: "Delete" title: "Remove the backup" confirm: "Are you sure you want to destroy this backup?" restore: is_disabled: "Restore is disabled in the site settings." - text: "Restore" + label: "Restore" title: "Restore the backup" confirm: "Are your sure you want to restore this backup?" rollback: - text: "Rollback" + label: "Rollback" title: "Rollback the database to previous working state" confirm: "Are your sure you want to rollback the database to the previous working state?"