Bläddra i källkod

HUE-7357 [frontend] Remove the old global search

Johan Ahlen 8 år sedan
förälder
incheckning
39809e6

+ 0 - 3
desktop/conf.dist/hue.ini

@@ -176,9 +176,6 @@
   # e.g. Query result in Editors and Dashboards, file in File Browser...
   ## enable_download=true
 
-  # Choose whether to enable the new global search or not.
-  ## use_new_global_search=true
-
   # Choose whether to enable the new generic context popover or not.
   ## use_new_context_popover=false
 

+ 0 - 3
desktop/conf/pseudo-distributed.ini.tmpl

@@ -180,9 +180,6 @@
   # e.g. Query result in Editors and Dashboards, file in File Browser...
   ## enable_download=true
 
-  # Choose whether to enable the new global search or not.
-  ## use_new_global_search=true
-
   # Choose whether to enable the new SQL syntax checker or not
   ## enable_sql_syntax_check=true
 

+ 0 - 7
desktop/core/src/desktop/conf.py

@@ -1319,13 +1319,6 @@ ENABLE_SQL_SYNTAX_CHECK = Config(
   help=_('Choose whether to enable SQL syntax check or not.')
 )
 
-USE_NEW_GLOBAL_SEARCH = Config(
-  key='use_new_global_search',
-  default=True,
-  type=coerce_bool,
-  help=_('Choose whether to use the new global search or not.')
-)
-
 USE_NEW_CONTEXT_POPOVER = Config( # To remove when the new context popover is ready
   key='use_new_context_popover',
   default=False,

+ 1 - 5
desktop/core/src/desktop/templates/hue.mako

@@ -201,11 +201,7 @@ ${ hueIcons.symbols() }
         </div>
         <!-- /ko -->
 
-        % if conf.USE_NEW_GLOBAL_SEARCH.get():
-          <div class="search-container-top" data-bind="component: 'hue-global-search'"></div>
-        %else:
-          <div class="search-container-top-old" data-bind="component: 'hue-global-search-old'"></div>
-        % endif
+        <div class="search-container-top" data-bind="component: 'hue-global-search'"></div>
       </div>
 
       <div class="top-nav-right">

+ 0 - 138
desktop/core/src/desktop/templates/ko_components.mako

@@ -1073,24 +1073,6 @@ from desktop.views import _ko
     })();
   </script>
 
-  <script type="text/html" id="hue-global-search-old-template">
-    <input placeholder="${ _('Search data and saved documents...') }" type="text"
-           data-bind="autocomplete: {
-                source: searchAutocompleteSource,
-                itemTemplate: 'top-search-autocomp-item',
-                noMatchTemplate: 'top-search-autocomp-no-match',
-                classPrefix: 'nav-',
-                showOnFocus: true,
-                closeOnEnter: false,
-                onSelect: mainSearchSelect,
-                reopenPattern: /.*:$/
-              },
-              hasFocus: searchHasFocus,
-              clearable: { value: searchInput, onClear: function () { searchActive(false); huePubSub.publish('autocomplete.close'); } },
-              textInput: searchInput,
-              valueUpdate: 'afterkeydown'">
-  </script>
-
   <script type="text/html" id="top-search-autocomp-item">
     <a href="javascript:void(0);">
       <div>
@@ -1110,124 +1092,4 @@ from desktop.views import _ko
       <div>${ _('No match found') }</div>
     </div>
   </script>
-
-  <script type="text/javascript">
-    (function () {
-
-      var SEARCH_FACET_ICON = 'fa-tags';
-      var SEARCH_TYPE_ICONS = {
-        'DATABASE': 'fa-database',
-        'TABLE': 'fa-table',
-        'VIEW': 'fa-eye',
-        'FIELD': 'fa-columns',
-        'PARTITION': 'fa-th',
-        'SOURCE': 'fa-server',
-        'OPERATION': 'fa-cogs',
-        'OPERATION_EXECUTION': 'fa-cog',
-        'DIRECTORY': 'fa-folder-o',
-        'FILE': 'fa-file-o',
-        'SUB_OPERATION': 'fa-code-fork',
-        'COLLECTION': 'fa-search',
-        'HBASE': 'fa-th-large',
-        'HUE': 'fa-file-o'
-      };
-
-      var GlobalSearchOld = function (params) {
-        var self = this;
-        self.apiHelper = ApiHelper.getInstance();
-        self.searchHasFocus = ko.observable(false);
-        self.searchInput = ko.observable();
-        self.searchActive = ko.observable(false);
-      };
-
-      GlobalSearchOld.prototype.mainSearchSelect = function (entry) {
-        if (entry.data && entry.data.link) {
-          huePubSub.publish('open.link', entry.data.link);
-        } else if (!/:\s*$/.test(entry.value)) {
-          huePubSub.publish('assist.show.sql');
-          huePubSub.publish('assist.db.search', entry.value);
-        }
-      };
-
-      GlobalSearchOld.prototype.searchAutocompleteSource = function (request, callback) {
-        var apiHelper = ApiHelper.getInstance();
-        // TODO: Extract complete contents to common module (shared with nav search autocomplete)
-        var facetMatch = request.term.match(/([a-z]+):\s*(\S+)?$/i);
-        var isFacet = facetMatch !== null;
-        var partialMatch = isFacet ? null : request.term.match(/\S+$/);
-        var partial = isFacet && facetMatch[2] ? facetMatch[2] : (partialMatch ? partialMatch[0] : '');
-        var beforePartial = request.term.substring(0, request.term.length - partial.length);
-
-        apiHelper.globalSearchAutocomplete({
-          query:  request.term,
-          successCallback: function (data) {
-            var values = [];
-            var facetPartialRe = new RegExp(partial.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); // Protect for 'tags:*axe'
-
-            if (typeof data.resultsHuedocuments !== 'undefined') {
-              data.resultsHuedocuments.forEach(function (result) {
-                values.push({ data: { label: result.hue_name, icon: SEARCH_TYPE_ICONS[result.type],  description: result.hue_description, link: result.link }, value: beforePartial + result.originalName });
-              });
-            }
-            if (values.length > 0) {
-              values.push({ divider: true });
-            }
-
-            if (isFacet && typeof data.facets !== 'undefined') { // Is typed facet, e.g. type: type:bla
-              var facetInQuery = facetMatch[1];
-              if (typeof data.facets[facetInQuery] !== 'undefined') {
-                $.map(data.facets[facetInQuery], function (count, value) {
-                  if (facetPartialRe.test(value)) {
-                    values.push({ data: { label: facetInQuery + ':' + value, icon: SEARCH_FACET_ICON, description: count }, value: beforePartial + value})
-                  }
-                });
-              }
-            } else {
-              if (typeof data.facets !== 'undefined') {
-                Object.keys(data.facets).forEach(function (facet) {
-                  if (facetPartialRe.test(facet)) {
-                    if (Object.keys(data.facets[facet]).length > 0) {
-                      values.push({ data: { label: facet + ':', icon: SEARCH_FACET_ICON, description: $.map(data.facets[facet], function (key, value) { return value + ' (' + key + ')'; }).join(', ') }, value: beforePartial + facet + ':'});
-                    } else { // Potential facet from the list
-                      values.push({ data: { label: facet + ':', icon: SEARCH_FACET_ICON, description: '' }, value: beforePartial + facet + ':'});
-                    }
-                  } else if (partial.length > 0) {
-                    Object.keys(data.facets[facet]).forEach(function (facetValue) {
-                      if (facetValue.indexOf(partial) !== -1) {
-                        values.push({ data: { label: facet + ':' + facetValue, icon: SEARCH_FACET_ICON, description: facetValue }, value: beforePartial + facet + ':' + facetValue });
-                      }
-                    });
-                  }
-                });
-              }
-            }
-
-
-            if (!facetMatch && typeof data.results !== 'undefined' && data.results.length > 0) {
-              if (values.length > 0) {
-                values.push({ divider: true });
-              }
-              data.results.forEach(function (result) {
-                values.push({ data: { label: result.hue_name, icon: SEARCH_TYPE_ICONS[result.type],  description: result.hue_description }, value: beforePartial + result.originalName });
-              });
-            }
-
-            if (values.length === 0) {
-              values.push({ noMatch: true });
-            }
-            callback(values);
-          },
-          silenceErrors: true,
-          errorCallback: function () {
-            callback([]);
-          }
-        });
-      };
-
-      ko.components.register('hue-global-search-old', {
-        viewModel: GlobalSearchOld,
-        template: {element: 'hue-global-search-old-template'}
-      });
-    })();
-  </script>
 </%def>