Bläddra i källkod

[assist] Always show the SQL assist panel for the editor and metastore

Johan Ahlen 10 år sedan
förälder
incheckning
a3b6378

+ 2 - 1
apps/metastore/src/metastore/templates/metastore.mako

@@ -688,7 +688,8 @@ ${ assist.assistPanel() }
                   openItem: true,
                   showPreview: true,
                   showStats: false
-                }
+                },
+                visibleAssistPanels: ['sql']
               }
             }"></div>
         </div>

+ 2 - 2
desktop/core/src/desktop/static/desktop/js/assist/assistHelper.js

@@ -94,12 +94,12 @@
    * @param {Observable} observable
    * @param {*} [defaultValue] - Optional default value to use if not in total storage initially
    */
-  AssistHelper.prototype.withTotalStorage = function(owner, id, observable, defaultValue) {
+  AssistHelper.prototype.withTotalStorage = function(owner, id, observable, defaultValue, noInit) {
     var self = this;
 
     var cachedValue = self.getFromTotalStorage(owner, id, defaultValue);
 
-    if (cachedValue !== 'undefined') {
+    if (! noInit && cachedValue !== 'undefined') {
       observable(cachedValue);
     }
 

+ 10 - 5
desktop/core/src/desktop/templates/assist.mako

@@ -669,6 +669,7 @@ from desktop.views import _ko
        * @param {string} options.type
        * @param {number} options.minHeight
        * @param {string} options.icon
+       * @param {boolean} options.visible
        * @param {(AssistDbPanel|AssistHdfsPanel|AssistDocumentsPanel)} panelData
        * @constructor
        */
@@ -680,8 +681,8 @@ from desktop.views import _ko
         self.name = options.name;
         self.panelData = options.panelData;
 
-        self.visible = ko.observable();
-        options.assistHelper.withTotalStorage('assist', 'showingPanel_' + self.type, self.visible, false);
+        self.visible = ko.observable(options.visible);
+        options.assistHelper.withTotalStorage('assist', 'showingPanel_' + self.type, self.visible, false, options.visible);
         self.templateName = 'assist-' + self.type + '-inner-panel'
       }
 
@@ -852,6 +853,7 @@ from desktop.views import _ko
        * @param {Object} params
        * @param {Object[]} params.sourceTypes - All the available SQL source types
        * @param {boolean} params.onlySql - For the old query editors
+       * @param {string[]} params.visibleAssistPanels - Panels that will initially be shown regardless of total storage
        * @param {string} params.sourceTypes[].name - Example: Hive SQL
        * @param {string} params.sourceTypes[].type - Example: hive
        * @param {string} [params.activeSourceType] - Example: hive
@@ -893,7 +895,8 @@ from desktop.views import _ko
             name: '${ _("SQL") }',
             type: 'db',
             icon: 'fa-database',
-            minHeight: 55
+            minHeight: 55,
+            visible: params.visibleAssistPanels && params.visibleAssistPanels.indexOf('sql') !== -1
           })
         ];
 
@@ -906,7 +909,8 @@ from desktop.views import _ko
             name: '${ _("HDFS") }',
             type: 'hdfs',
             icon: 'fa-folder-o',
-            minHeight: 40
+            minHeight: 40,
+            visible: params.visibleAssistPanels && params.visibleAssistPanels.indexOf('hdfs') !== -1
           }));
           self.availablePanels.push(new AssistInnerPanel({
             panelData: new AssistDocumentsPanel({
@@ -917,7 +921,8 @@ from desktop.views import _ko
             name: '${ _("Documents") }',
             type: 'documents',
             icon: 'fa-files-o',
-            minHeight: 40
+            minHeight: 40,
+            visible: params.visibleAssistPanels && params.visibleAssistPanels.indexOf('documents') !== -1
           }));
         }
 

+ 2 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -324,7 +324,8 @@ ${ require.config() }
             openItem: false,
             showPreview: true,
             showStats: true
-          }
+          },
+          visibleAssistPanels: $root.editorMode ? ['sql'] : []
         }
       }"></div>
   </div>