소스 검색

HUE-2360 [sentry] Sometimes Groups are not loaded we see the input box instead

Wait for isLoadingGroups to be false
Implemented onBlur and onFocus on select2
Disabled groups links if not sentry admin
Enrico Berti 11 년 전
부모
커밋
37b8f9d
3개의 변경된 파일22개의 추가작업 그리고 4개의 파일을 삭제
  1. 11 4
      apps/security/src/security/templates/hive.mako
  2. 10 0
      apps/security/static/js/common.ko.js
  3. 1 0
      apps/security/static/js/hive.ko.js

+ 11 - 4
apps/security/src/security/templates/hive.mako

@@ -290,6 +290,7 @@ ${ layout.menubar(section='hive') }
                   <span data-bind="text: name"/>
                 </td>
                 <td>
+                  <!-- ko if: $root.is_sentry_admin -->
                   <a class="pointer" data-bind="click: function() { if ($root.is_sentry_admin) { showEditGroups(true); } }">
                     <span data-bind="foreach: groups, visible: ! showEditGroups() && ! groupsChanged()">
                       <span data-bind="text: $data"></span>
@@ -298,13 +299,19 @@ ${ layout.menubar(section='hive') }
                       <i class="fa fa-plus"></i> ${ _('Add a group') }
                     </span>
                   </a>
-                  <div data-bind="visible: showEditGroups() || groupsChanged()">
-                    <select data-bind="options: $root.selectableHadoopGroups, selectedOptions: groups, select2: { update: groups, type: 'group'}" size="5" multiple="true" style="width: 400px"></select>
+                  <!-- /ko -->
+                  <!-- ko ifnot: $root.is_sentry_admin -->
+                    <span data-bind="foreach: groups">
+                      <span data-bind="text: $data"></span>
+                    </span>
+                  <!-- /ko -->
+                  <div data-bind="visible: showEditGroups() || (groupsChanged() && ! $root.isLoadingRoles())">
+                    <select data-bind="options: $root.selectableHadoopGroups, selectedOptions: groups, select2: { update: groups, type: 'group', onBlur: function(){ showEditGroups(false); } }" size="5" multiple="true" style="width: 400px"></select>
                     &nbsp;
-                    <a class="pointer" data-bind="visible: groupsChanged, click: resetGroups">
+                    <a class="pointer" data-bind="visible: groupsChanged() && ! $root.isLoadingRoles(), click: resetGroups">
                       <i class="fa fa-undo"></i>
                     </a>
-                    <a class="pointer" data-bind="visible: groupsChanged, click: saveGroups">
+                    <a class="pointer" data-bind="visible: groupsChanged && ! $root.isLoadingRoles(), click: saveGroups">
                       <i class="fa fa-save"></i>
                     </a>
                   </div>

+ 10 - 0
apps/security/static/js/common.ko.js

@@ -54,6 +54,16 @@ ko.bindingHandlers.select2 = {
             valueAccessor().update(e.val);
           }
         })
+        .on("select2-focus", function(e) {
+          if (typeof options.onFocus != "undefined"){
+            options.onFocus();
+          }
+        })
+        .on("select2-blur", function(e) {
+          if (typeof options.onBlur != "undefined"){
+            options.onBlur();
+          }
+        })
         .on("select2-open", function () {
           $(".select2-input").off("keyup").data("type", options.type).on("keyup", function (e) {
             if (e.keyCode === 13) {

+ 1 - 0
apps/security/static/js/hive.ko.js

@@ -917,6 +917,7 @@ var HiveViewModel = function (initial) {
         }
         else {
           self.roles.removeAll();
+          self.originalRoles.removeAll();
           var _roles = [];
           var _originalRoles = [];
           $.each(data.roles, function (index, item) {