Browse Source

HUE-8269 [dashboard] Hide the new adding mechanism under a feature flag

Enrico Berti 7 years ago
parent
commit
656e5c3485

+ 3 - 1
desktop/core/src/desktop/templates/common_dashboard.mako

@@ -25,7 +25,7 @@
   from desktop import conf
   from django.utils.translation import ugettext as _
 
-  from dashboard.conf import HAS_REPORT_ENABLED, USE_GRIDSTER
+  from dashboard.conf import HAS_REPORT_ENABLED, USE_GRIDSTER, USE_NEW_ADD_METHOD
   from desktop.views import _ko
 %>
 
@@ -116,6 +116,7 @@
     <img src="${ static('desktop/art/hint_arrow.svg') }" alt="${ _('Hint arrow') }" class="flip-horizontal" />
   </div>
 
+  % if USE_NEW_ADD_METHOD.get():
   <!-- ko if: $root.isGridster -->
   <div class="initial-hint empty-dashboard-plus" data-bind="fadeVisible: columns().length > 0 && showPlusButtonHint(), click: function(){ showPlusButtonHint(false); }">
     <div class="initial-hint-text">${_('Drag the top plus button or any field from the right assistant into your dashboard')}</div>
@@ -123,6 +124,7 @@
     <img src="${ static('desktop/art/hint_arrow.svg') }" alt="${ _('Hint arrow') }" style="width: 90px; margin-left: 80px; position: absolute; transform: rotate(33deg);" />
   </div>
   <!-- /ko -->
+  % endif
 
 
   <div data-bind="visible: isEditing() && previewColumns() != '' && columns().length == 0, css: {'with-top-margin': isEditing()}">

+ 7 - 0
desktop/libs/dashboard/src/dashboard/conf.py

@@ -58,6 +58,13 @@ USE_GRIDSTER = Config(
   type=coerce_bool
 )
 
+USE_NEW_ADD_METHOD = Config(
+  key="use_new_add_method",
+  help=_t("Activate the simplified drag in the dashboard."),
+  default=False,
+  type=coerce_bool
+)
+
 HAS_WIDGET_FILTER = Config(
   key="has_widget_filter",
   help=_t("Activate the widget filter and comparison (beta)."),

File diff suppressed because it is too large
+ 0 - 0
desktop/libs/dashboard/src/dashboard/static/dashboard/css/search.css


+ 3 - 1
desktop/libs/dashboard/src/dashboard/static/dashboard/js/search.ko.js

@@ -1860,7 +1860,8 @@ var GEO_TYPES = ['SpatialRecursivePrefixTreeFieldType'];
 var RANGE_SELECTABLE_WIDGETS = ['histogram-widget', 'bar-widget', 'line-widget'];
 
 
-var SearchViewModel = function (collection_json, query_json, initial_json, has_gridster_enabled) {
+var SearchViewModel = function (collection_json, query_json, initial_json, has_gridster_enabled, has_new_add_method) {
+
   var self = this;
 
   self.collectionJson = collection_json;
@@ -1868,6 +1869,7 @@ var SearchViewModel = function (collection_json, query_json, initial_json, has_g
   self.initialJson = initial_json;
 
   self.isGridster = ko.observable(!!has_gridster_enabled && (collection_json.layout.length === 0 || (collection_json.layout.length && collection_json.gridItems.length)));
+  self.hasNewAdd = ko.observable(!!has_new_add_method);
   self.isQueryBuilder = ko.observable(false);
 
   if ($.totalStorage('hue.enable.gridster') === false) {

+ 1 - 1
desktop/libs/dashboard/src/dashboard/static/dashboard/less/search.less

@@ -128,7 +128,7 @@
         .search-bar-query-operations {
           .flex(1);
           white-space: nowrap;
-          padding-right: 85px;
+          padding-right: 45px;
         }
 
         .search-bar-query {

+ 8 - 2
desktop/libs/dashboard/src/dashboard/templates/common_search.mako

@@ -20,7 +20,7 @@ from django.utils.translation import ugettext as _
 from desktop import conf
 from desktop.views import commonheader, commonfooter, _ko, commonshare
 
-from dashboard.conf import USE_GRIDSTER, HAS_REPORT_ENABLED, HAS_WIDGET_FILTER, HAS_TREE_WIDGET
+from dashboard.conf import USE_GRIDSTER, USE_NEW_ADD_METHOD, HAS_REPORT_ENABLED, HAS_WIDGET_FILTER, HAS_TREE_WIDGET
 %>
 
 <%namespace name="dashboard" file="common_dashboard.mako" />
@@ -134,9 +134,15 @@ from dashboard.conf import USE_GRIDSTER, HAS_REPORT_ENABLED, HAS_WIDGET_FILTER,
     <div class="search-bar-operations">
       <!-- ko if: $root.isGridster() -->
       <div class="btn-group">
+        % if USE_NEW_ADD_METHOD.get():
         <a class="btn draggable-plus-button move-cursor" title="${ _('Drag to add a widget') }" rel="tooltip" data-placement="bottom" data-bind="draggable: {data: $root.collection.supportAnalytics() ? draggableBucket() : draggableBar(), options: getDraggableOptions({ data: $root.collection.supportAnalytics() ? draggableBucket() : draggableBar(), plusButton: true })}, visible: columns().length, click: function() { isToolbarVisible(!isToolbarVisible()) }, css: {'btn': true, 'btn-inverse': isToolbarVisible }">
           <i class="fa fa-plus"></i>
         </a>
+        % else:
+        <a class="btn" title="${ _('Toggle the widget toolbar') }" rel="tooltip" data-placement="bottom" data-bind="visible: columns().length, click: function() { isToolbarVisible(!isToolbarVisible()) }, css: {'btn': true, 'btn-inverse': isToolbarVisible }">
+          <i class="fa fa-plus"></i>
+        </a>
+        % endif:
       </div>
       <!-- /ko -->
       <!-- ko ifnot: $root.isGridster -->
@@ -3839,7 +3845,7 @@ function newSearch() {
 }
 
 function loadSearch(collection, query, initial) {
-  searchViewModel = new SearchViewModel(collection, query, initial, ${ USE_GRIDSTER.get() and 'true' or 'false' });
+  searchViewModel = new SearchViewModel(collection, query, initial, ${ USE_GRIDSTER.get() and 'true' or 'false' }, ${ USE_NEW_ADD_METHOD.get() and 'true' or 'false' });
   ko.applyBindings(searchViewModel, $('#searchComponents')[0]);
 
   searchViewModel.timelineChartTypes = ko.observableArray([

Some files were not shown because too many files changed in this diff