Quellcode durchsuchen

AMBARI-7885. Slider view should show validation messages on main Slider Apps page. (Max Shepel via akovalenko)

Aleksandr Kovalenko vor 10 Jahren
Ursprung
Commit
9933aac477

+ 6 - 0
contrib/views/slider/src/main/resources/ui/app/initialize.js

@@ -90,6 +90,12 @@ App.initializer({
        */
       viewEnabled: false,
 
+      /**
+       * Should Slider View be disabled
+       * @type {bool}
+       */
+      viewDisabled: Em.computed.not('viewEnabled'),
+
       /**
        * List of errors
        * @type {string[]}

+ 2 - 9
contrib/views/slider/src/main/resources/ui/app/styles/common.less

@@ -104,13 +104,6 @@ select {
   opacity:0;
 }
 
-
-.slider-errors-wrapper {
-  position: absolute;
-  top: 0;
-  left: 0;
-  width: 100%;
-  height: 100%;
-  padding: 10px;
-  background-color: #fff;
+.error-message {
+  font-weight: bold;
 }

+ 8 - 10
contrib/views/slider/src/main/resources/ui/app/templates/application.hbs

@@ -23,15 +23,13 @@
 
 
 {{#unless App.viewEnabled}}
-  <div class="slider-errors-wrapper">
-    {{#if App.viewErrors.length}}
-      <div class="alert alert-danger">
-        {{#each error in App.viewErrors}}
-          <h3 class="error-message">{{{error.message}}}</h3>
-        {{/each}}
-      </div>
-    {{/if}}
-  </div>
+  {{#if App.viewErrors.length}}
+    <div class="alert alert-danger">
+      {{#each error in App.viewErrors}}
+        <div class="error-message">{{{error.message}}}</div>
+      {{/each}}
+    </div>
+  {{/if}}
 {{/unless}}
 
 <div class="slider-header">
@@ -45,7 +43,7 @@
           </div>
         {{/if}}
         <div class="create-app pull-right">
-          <a href="#" class="btn btn-primary" {{action createApp}}>
+          <a href="#" class="btn btn-primary" {{bind-attr disabled="App.viewDisabled"}} {{action createApp}}>
             <i class="icon-plus"></i><span>&nbsp;{{t slider.apps.create}}</span>
           </a>
         </div>

+ 17 - 1
contrib/views/slider/src/main/resources/ui/test/integration/pages/slider_errors_test.js

@@ -41,6 +41,22 @@ QUnit.module('integration/pages - index', {
 test('Slider has validation errors', function () {
 
   visit('/');
-  equal(find('.slider-errors-wrapper .error-message').length, 2, 'Error-messages exist on the page');
+  equal(find('.error-message').length, 2, 'Error-messages exist on the page');
+  ok(find('.create-app a').attr('disabled'), 'Create App button is disabled');
+
+});
+
+test('Slider has no validation errors', function () {
+
+  Em.run(function () {
+    App.__container__.lookup('controller:Slider').getParametersFromViewPropertiesSuccessCallback({
+      validations: [],
+      parameters: {}
+    });
+  });
+
+  visit('/');
+  equal(find('.error-message').length, 0, 'No error-messages on the page');
+  ok(!find('.create-app a').attr('disabled'), 'Create App button is enabled');
 
 });