Repository: ambari Updated Branches: refs/heads/trunk a6b9e9559 -> 7492c33dd
AMBARI-10933. Incorrect raw edit value should not launch dialog (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0dbb7054 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0dbb7054 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0dbb7054 Branch: refs/heads/trunk Commit: 0dbb7054e394b373e8b8fe729c878157b1efc776 Parents: a6b9e95 Author: Oleg Nechiporenko <[email protected]> Authored: Tue May 5 18:25:55 2015 +0300 Committer: Oleg Nechiporenko <[email protected]> Committed: Tue May 5 18:25:55 2015 +0300 ---------------------------------------------------------------------- ambari-web/app/messages.js | 2 +- ambari-web/app/styles/widgets.less | 3 +++ .../templates/common/configs/widgets/controls.hbs | 13 +++++++++---- .../common/configs/widgets/config_widget_view.js | 18 +++++++++++++++--- 4 files changed, 28 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/0dbb7054/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index b78010c..63c0e5b 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -2620,7 +2620,7 @@ Em.I18n.translations = { 'config.group.save.confirmation.manage.button': 'Manage Hosts', 'config.group.description.default': 'New configuration group created on {0}', - 'config.infoMessage.wrong.value.for.widget': 'Config value can\'t be converted to widget value', + 'config.infoMessage.wrong.value.for.widget': 'Configuration value cannot be converted into UI control value', 'config.warnMessage.outOfBoundaries.greater': 'Values greater than {0} are not recommended', 'config.warnMessage.outOfBoundaries.less': 'Values smaller than {0} are not recommended', http://git-wip-us.apache.org/repos/asf/ambari/blob/0dbb7054/ambari-web/app/styles/widgets.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/widgets.less b/ambari-web/app/styles/widgets.less index 76e4c0a..36f6674 100644 --- a/ambari-web/app/styles/widgets.less +++ b/ambari-web/app/styles/widgets.less @@ -87,6 +87,9 @@ &.active { color: @widget-config-override-action-active-color; } + &.text-error { + color: #b94a48; + } } } } http://git-wip-us.apache.org/repos/asf/ambari/blob/0dbb7054/ambari-web/app/templates/common/configs/widgets/controls.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/widgets/controls.hbs b/ambari-web/app/templates/common/configs/widgets/controls.hbs index 1ac8678..9dcfa24 100644 --- a/ambari-web/app/templates/common/configs/widgets/controls.hbs +++ b/ambari-web/app/templates/common/configs/widgets/controls.hbs @@ -32,10 +32,15 @@ {{/if}} {{/if}} {{#if view.showPencil}} - <a href="#" - {{bindAttr class=":icon-pencil :widget-action :widget-action-switch-view view.isHover::hide view.showAsTextBox::active"}} - {{action "toggleWidgetView" target="view"}}> - </a> + {{#if view.isWidgetViewAllowed}} + <a href="#" + {{bindAttr class=":icon-pencil :widget-action :widget-action-switch-view view.isHover::hide view.showAsTextBox::active"}} + {{action "toggleWidgetView" target="view"}}> + </a> + {{else}} + <i class="icon-pencil widget-action widget-action-switch-view text-error" + data-toggle="tooltip" {{translateAttr data-original-title="config.infoMessage.wrong.value.for.widget"}}></i> + {{/if}} {{/if}} </div> <div class="widget-col right"> http://git-wip-us.apache.org/repos/asf/ambari/blob/0dbb7054/ambari-web/app/views/common/configs/widgets/config_widget_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/widgets/config_widget_view.js b/ambari-web/app/views/common/configs/widgets/config_widget_view.js index 01758b7..43219e6 100644 --- a/ambari-web/app/views/common/configs/widgets/config_widget_view.js +++ b/ambari-web/app/views/common/configs/widgets/config_widget_view.js @@ -317,6 +317,9 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo * @method toggleWidgetView */ toggleWidgetView: function() { + if (!this.get('isWidgetViewAllowed')) { + return false; + } if (this.get('showAsTextBox')) { this.textBoxToWidget(); } else { @@ -340,8 +343,6 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo if (this.isValueCompatibleWithWidget()) { this.setValue(this.get('config.value')); this.set("showAsTextBox", false); - } else { - App.showAlertPopup(Em.I18n.t('common.warning'), Em.I18n.t('config.infoMessage.wrong.value.for.widget')); } }, @@ -351,6 +352,17 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo */ isValueCompatibleWithWidget: function() { return this.get('config.isValid'); - } + }, + + /** + * Returns <code>true</code> if raw value can be used by widget or widget view is activated. + * @returns {Boolean} + */ + isWidgetViewAllowed: function() { + if (!this.get('showAsTextBox')) { + return true; + } + return this.isValueCompatibleWithWidget(); + }.property('config.value', 'showAsTextBox') });
