فهرست منبع

[home2] Add sharing to the right-click context menu

Johan Ahlen 9 سال پیش
والد
کامیت
f3b9970

+ 2 - 1
desktop/core/src/desktop/static/desktop/css/hue3.css

@@ -2325,6 +2325,7 @@ body {
   line-height: 22px;
   vertical-align: middle;
   padding: 6px 16px 6px 38px;
+  cursor: default;
 
   color: #CCC;
   text-decoration: none;
@@ -2332,7 +2333,7 @@ body {
   white-space: nowrap;
 }
 
-.hue-context-menu > li > a:hover {
+.hue-context-menu > li > a:not(.disabled):hover {
   background-color: #DBE8F1;
 }
 

+ 2 - 8
desktop/core/src/desktop/static/desktop/js/fileBrowser/hueDocument.js

@@ -113,7 +113,7 @@
 
   HueDocument.prototype.handleTypeAheadSelection = function () {
     var self = this;
-    if (self.selectedUserOrGroup() !== null) {
+    if (self.selectedUserOrGroup()) {
       if (typeof self.selectedUserOrGroup().username !== 'undefined') {
         self.definition().perms[self.selectedPerm()].users.push(self.selectedUserOrGroup());
       } else {
@@ -181,13 +181,7 @@
       })
     };
 
-    if (!self.loaded()) {
-      window.setTimeout(function () {
-        self.initUserTypeahead(fetchFunction);
-      }, 2000);
-    } else {
-      fetchFunction();
-    }
+    self.initUserTypeahead(fetchFunction);
   };
 
   HueDocument.prototype.prettifyUserNames = function (users) {

+ 12 - 7
desktop/core/src/desktop/static/desktop/js/fileBrowser/hueFileEntry.js

@@ -48,7 +48,7 @@
     self.path = self.definition.name;
     self.app = options.app;
 
-    self.activeDocument = ko.observable();
+    self.document = ko.observable();
 
     self.entriesToDelete = ko.observableArray();
 
@@ -88,17 +88,22 @@
   HueFileEntry.prototype.showSharingModal = function () {
     var self = this;
     if (self.selectedEntry()) {
-      if (! self.activeDocument()) {
-        self.activeDocument(new HueDocument({
-          assistHelper: self.assistHelper,
-          fileEntry: self
-        }));
-        self.activeDocument().load();
+      if (! self.selectedEntry().document()) {
+        self.selectedEntry().loadDocument();
       }
       $('#shareDocumentModal').modal('show');
     }
   };
 
+  HueFileEntry.prototype.loadDocument = function () {
+    var self = this;
+    self.document(new HueDocument({
+      assistHelper: self.assistHelper,
+      fileEntry: self
+    }));
+    self.document().load();
+  };
+
   /**
    * @param {HueFileEntry[]} entries
    */

+ 4 - 3
desktop/core/src/desktop/templates/file_browser.mako

@@ -244,11 +244,11 @@ from desktop.views import _ko
     </div>
 
     <div id="shareDocumentModal" class="modal hide fade">
-      <!-- ko with: activeEntry -->
-      <!-- ko with: activeDocument -->
+      <!-- ko with: activeEntry().selectedEntry() -->
+      <!-- ko with: document -->
       <div class="modal-header">
         <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
-        <h3>${_('Sharing Settings')}</h3>
+        <h3>${_('Sharing')} - <span data-bind="text: $parent.name"></span></h3>
       </div>
       <div class="modal-body" style="overflow-y: visible">
         <!-- ko with: definition -->
@@ -464,6 +464,7 @@ from desktop.views import _ko
               <ul class="hue-context-menu">
                 <li><a href="javascript:void(0);" data-bind="click: contextMenuDownload"><i class="fa fa-download"></i> ${ _('Download') }</a></li>
                 <li><a href="javascript:void(0);" data-bind="click: function() { $parent.showDeleteConfirmation(); }"><i class="fa fa-fw fa-times"></i> ${ _('Delete') }</a></li>
+                <li data-bind="css: { 'disabled': $parent.selectedEntries().length !== 1 }"><a href="javascript:void(0);" data-bind="click: function() { $parent.showSharingModal(); }, css: { 'disabled': $parent.selectedEntries().length !== 1 }"><i class="fa fa-fw fa-users"></i> ${ _('Share') }</a> </li>
               </ul>
               <div class="fb-primary-col">
                 <i class="fa fa-fw" data-bind="css: { 'fa-folder-o' : isDirectory, 'fa-file-o': ! isDirectory }"></i>