Browse Source

HUE-4866 [fb] Add button to open sql files in editor

krish 8 years ago
parent
commit
e8582d3b6b

+ 6 - 0
apps/filebrowser/src/filebrowser/templates/listdir.mako

@@ -136,6 +136,12 @@ ${ fb_components.menubar() }
               </button>
               </button>
             % endif
             % endif
           % endif
           % endif
+          % if 'beeswax' in apps:
+            <a class="btn" title="${_('Open in Editor')}"
+              data-bind="visible: selectedFiles().length == 1 && isSelectedFileSql(), click: openFileInEditor">
+              ${_('Open in Editor')}
+            </a>
+          % endif
         </div>
         </div>
       </%def>
       </%def>
 
 

+ 8 - 0
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -1101,6 +1101,14 @@ from filebrowser.conf import ENABLE_EXTRACT_UPLOADED_ARCHIVE
         return self.selectedFiles()[0];
         return self.selectedFiles()[0];
       }, self).extend({ rateLimit: { timeout: 500, method: "notifyWhenChangesStop" } });
       }, self).extend({ rateLimit: { timeout: 500, method: "notifyWhenChangesStop" } });
 
 
+      self.isSelectedFileSql = ko.pureComputed(function() {
+        return self.selectedFile().name.endsWith('.sql') || self.selectedFile().name.endsWith('.hql');
+      });
+
+      self.openFileInEditor = function() {
+        huePubSub.publish('open.editor.query.external', {'statementType': 'file', 'statementPath': self.selectedFile().path});
+      };
+
       self.currentPath = ko.observable(currentDirPath);
       self.currentPath = ko.observable(currentDirPath);
       self.currentPath.subscribe(function (path) {
       self.currentPath.subscribe(function (path) {
         $(document).trigger('currPathLoaded', { path: path });
         $(document).trigger('currPathLoaded', { path: path });