You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2021/01/29 14:25:53 UTC

[superset] 15/18: fix(explore): pass partitionColumn when creating new adhoc filter (#12789)

This is an automated email from the ASF dual-hosted git repository.

villebro pushed a commit to branch 1.0
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 7b94db0bff7570250db2075f06d63e33fa5696aa
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Wed Jan 27 15:48:54 2021 +0200

    fix(explore): pass partitionColumn when creating new adhoc filter (#12789)
    
    * fix(explore): pass partitionColumn when creating new adhoc filter
    
    * add default value to state
    
    * remove duplicated code
    
    * update translations
---
 .../controls/FilterControl/AdhocFilterControl.jsx        | 16 ++++------------
 .../AdhocFilterEditPopoverSimpleTabContent.jsx           |  6 +++++-
 superset/translations/de/LC_MESSAGES/messages.json       |  2 +-
 superset/translations/de/LC_MESSAGES/messages.po         |  2 +-
 superset/translations/en/LC_MESSAGES/messages.json       |  2 +-
 superset/translations/en/LC_MESSAGES/messages.po         |  2 +-
 superset/translations/es/LC_MESSAGES/messages.json       |  2 +-
 superset/translations/es/LC_MESSAGES/messages.po         |  2 +-
 superset/translations/fr/LC_MESSAGES/messages.json       |  2 +-
 superset/translations/fr/LC_MESSAGES/messages.po         |  2 +-
 superset/translations/it/LC_MESSAGES/messages.json       |  2 +-
 superset/translations/it/LC_MESSAGES/messages.po         |  2 +-
 superset/translations/ja/LC_MESSAGES/messages.json       |  2 +-
 superset/translations/ja/LC_MESSAGES/messages.po         |  2 +-
 superset/translations/ko/LC_MESSAGES/messages.json       |  2 +-
 superset/translations/ko/LC_MESSAGES/messages.po         |  2 +-
 superset/translations/messages.pot                       |  2 +-
 superset/translations/pt/LC_MESSAGES/message.json        |  2 +-
 superset/translations/pt/LC_MESSAGES/message.po          |  2 +-
 superset/translations/pt_BR/LC_MESSAGES/messages.json    |  2 +-
 superset/translations/pt_BR/LC_MESSAGES/messages.po      |  2 +-
 superset/translations/ru/LC_MESSAGES/messages.json       |  2 +-
 superset/translations/ru/LC_MESSAGES/messages.po         |  2 +-
 superset/translations/zh/LC_MESSAGES/messages.json       |  2 +-
 superset/translations/zh/LC_MESSAGES/messages.po         |  2 +-
 25 files changed, 32 insertions(+), 36 deletions(-)

diff --git a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterControl.jsx b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterControl.jsx
index bad9bba..2f8366b 100644
--- a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterControl.jsx
+++ b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterControl.jsx
@@ -96,11 +96,13 @@ class AdhocFilterControl extends React.Component {
         onRemoveFilter={() => this.onRemoveFilter(index)}
         onMoveLabel={this.moveLabel}
         onDropLabel={() => this.props.onChange(this.state.values)}
+        partitionColumn={this.state.partitionColumn}
       />
     );
     this.state = {
       values: filters,
       options: this.optionsForSelect(this.props),
+      partitionColumn: null,
     };
   }
 
@@ -128,18 +130,7 @@ class AdhocFilterControl extends React.Component {
                 partitions.cols &&
                 Object.keys(partitions.cols).length === 1
               ) {
-                const partitionColumn = partitions.cols[0];
-                this.valueRenderer = (adhocFilter, index) => (
-                  <AdhocFilterOption
-                    adhocFilter={adhocFilter}
-                    onFilterEdit={this.onFilterEdit}
-                    options={this.state.options}
-                    datasource={this.props.datasource}
-                    partitionColumn={partitionColumn}
-                    onRemoveFilter={() => this.onRemoveFilter(index)}
-                    key={index}
-                  />
-                );
+                this.setState({ partitionColumn: partitions.cols[0] });
               }
             }
           })
@@ -323,6 +314,7 @@ class AdhocFilterControl extends React.Component {
         datasource={this.props.datasource}
         options={this.state.options}
         onFilterEdit={this.onNewFilter}
+        partitionColumn={this.state.partitionColumn}
         createNew
       >
         {trigger}
diff --git a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx
index df79f57..0664369 100644
--- a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx
+++ b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx
@@ -304,7 +304,11 @@ export default class AdhocFilterEditPopoverSimpleTabContent extends React.Compon
     }
 
     const operatorSelectProps = {
-      placeholder: t('%s operators(s)', OPERATORS_OPTIONS.length),
+      placeholder: t(
+        '%s operator(s)',
+        OPERATORS_OPTIONS.filter(op => this.isOperatorRelevant(op, subject))
+          .length,
+      ),
       // like AGGREGTES_OPTIONS, operator options are string
       value: operator,
       onChange: this.onOperatorChange,
diff --git a/superset/translations/de/LC_MESSAGES/messages.json b/superset/translations/de/LC_MESSAGES/messages.json
index 72de85b..fda247c 100644
--- a/superset/translations/de/LC_MESSAGES/messages.json
+++ b/superset/translations/de/LC_MESSAGES/messages.json
@@ -1706,7 +1706,7 @@
       "%s column(s) and metric(s)": [""],
       "%s column(s)": ["Spalten auflisten"],
       "To filter on a metric, use Custom SQL tab.": [""],
-      "%s operators(s)": [""],
+      "%s operator(s)": [""],
       "Type a value here": [""],
       "Filter value (case sensitive)": [""],
       "choose WHERE or HAVING...": [""],
diff --git a/superset/translations/de/LC_MESSAGES/messages.po b/superset/translations/de/LC_MESSAGES/messages.po
index 8cd006f..9eaa43d 100644
--- a/superset/translations/de/LC_MESSAGES/messages.po
+++ b/superset/translations/de/LC_MESSAGES/messages.po
@@ -6082,7 +6082,7 @@ msgstr ""
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:307
 #, python-format
-msgid "%s operators(s)"
+msgid "%s operator(s)"
 msgstr ""
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:326
diff --git a/superset/translations/en/LC_MESSAGES/messages.json b/superset/translations/en/LC_MESSAGES/messages.json
index 28521e4..2c6dfa3 100644
--- a/superset/translations/en/LC_MESSAGES/messages.json
+++ b/superset/translations/en/LC_MESSAGES/messages.json
@@ -1616,7 +1616,7 @@
       "%s column(s) and metric(s)": [""],
       "%s column(s)": [""],
       "To filter on a metric, use Custom SQL tab.": [""],
-      "%s operators(s)": [""],
+      "%s operator(s)": [""],
       "Type a value here": [""],
       "Filter value (case sensitive)": [""],
       "choose WHERE or HAVING...": [""],
diff --git a/superset/translations/en/LC_MESSAGES/messages.po b/superset/translations/en/LC_MESSAGES/messages.po
index 86c784c..5237f05 100644
--- a/superset/translations/en/LC_MESSAGES/messages.po
+++ b/superset/translations/en/LC_MESSAGES/messages.po
@@ -6081,7 +6081,7 @@ msgstr ""
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:307
 #, python-format
-msgid "%s operators(s)"
+msgid "%s operator(s)"
 msgstr ""
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:326
diff --git a/superset/translations/es/LC_MESSAGES/messages.json b/superset/translations/es/LC_MESSAGES/messages.json
index 7ad0696..3789e44 100644
--- a/superset/translations/es/LC_MESSAGES/messages.json
+++ b/superset/translations/es/LC_MESSAGES/messages.json
@@ -1835,7 +1835,7 @@
       "%s column(s) and metric(s)": [""],
       "%s column(s)": [""],
       "To filter on a metric, use Custom SQL tab.": [""],
-      "%s operators(s)": [""],
+      "%s operator(s)": [""],
       "Type a value here": [""],
       "Filter value (case sensitive)": [""],
       "choose WHERE or HAVING...": [""],
diff --git a/superset/translations/es/LC_MESSAGES/messages.po b/superset/translations/es/LC_MESSAGES/messages.po
index c916cc5..9d9a94e 100644
--- a/superset/translations/es/LC_MESSAGES/messages.po
+++ b/superset/translations/es/LC_MESSAGES/messages.po
@@ -6154,7 +6154,7 @@ msgstr ""
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:307
 #, python-format
-msgid "%s operators(s)"
+msgid "%s operator(s)"
 msgstr ""
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:326
diff --git a/superset/translations/fr/LC_MESSAGES/messages.json b/superset/translations/fr/LC_MESSAGES/messages.json
index 151f527..1756548 100644
--- a/superset/translations/fr/LC_MESSAGES/messages.json
+++ b/superset/translations/fr/LC_MESSAGES/messages.json
@@ -1955,7 +1955,7 @@
       "To filter on a metric, use Custom SQL tab.": [
         "À filtrer sur une métrique, utiliser l'onglet Custom SQL."
       ],
-      "%s operators(s)": ["%s opérateur(s)"],
+      "%s operator(s)": ["%s opérateur(s)"],
       "Type a value here": ["Saisir une valeur ici"],
       "Filter value (case sensitive)": [""],
       "choose WHERE or HAVING...": ["Choisir WHERE or HAVING..."],
diff --git a/superset/translations/fr/LC_MESSAGES/messages.po b/superset/translations/fr/LC_MESSAGES/messages.po
index 660cceb..2f1f84e 100644
--- a/superset/translations/fr/LC_MESSAGES/messages.po
+++ b/superset/translations/fr/LC_MESSAGES/messages.po
@@ -6228,7 +6228,7 @@ msgstr "À filtrer sur une métrique, utiliser l'onglet Custom SQL."
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:307
 #, python-format
-msgid "%s operators(s)"
+msgid "%s operator(s)"
 msgstr "%s opérateur(s)"
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:326
diff --git a/superset/translations/it/LC_MESSAGES/messages.json b/superset/translations/it/LC_MESSAGES/messages.json
index da4561b..025b06f 100644
--- a/superset/translations/it/LC_MESSAGES/messages.json
+++ b/superset/translations/it/LC_MESSAGES/messages.json
@@ -1727,7 +1727,7 @@
       "%s column(s) and metric(s)": [""],
       "%s column(s)": ["Visualizza colonne"],
       "To filter on a metric, use Custom SQL tab.": [""],
-      "%s operators(s)": ["Seleziona operatore"],
+      "%s operator(s)": ["Seleziona operatore"],
       "Type a value here": [""],
       "Filter value (case sensitive)": [""],
       "choose WHERE or HAVING...": [""],
diff --git a/superset/translations/it/LC_MESSAGES/messages.po b/superset/translations/it/LC_MESSAGES/messages.po
index 1157574..9a9cbac 100644
--- a/superset/translations/it/LC_MESSAGES/messages.po
+++ b/superset/translations/it/LC_MESSAGES/messages.po
@@ -6126,7 +6126,7 @@ msgstr ""
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:307
 #, python-format
-msgid "%s operators(s)"
+msgid "%s operator(s)"
 msgstr "Seleziona operatore"
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:326
diff --git a/superset/translations/ja/LC_MESSAGES/messages.json b/superset/translations/ja/LC_MESSAGES/messages.json
index 7f7284f..35ffaac 100644
--- a/superset/translations/ja/LC_MESSAGES/messages.json
+++ b/superset/translations/ja/LC_MESSAGES/messages.json
@@ -1643,7 +1643,7 @@
       "%s column(s) and metric(s)": [""],
       "%s column(s)": [""],
       "To filter on a metric, use Custom SQL tab.": [""],
-      "%s operators(s)": ["オペレータを選択"],
+      "%s operator(s)": ["オペレータを選択"],
       "Type a value here": [""],
       "Filter value (case sensitive)": [""],
       "choose WHERE or HAVING...": [""],
diff --git a/superset/translations/ja/LC_MESSAGES/messages.po b/superset/translations/ja/LC_MESSAGES/messages.po
index 089826c..48a9a70 100644
--- a/superset/translations/ja/LC_MESSAGES/messages.po
+++ b/superset/translations/ja/LC_MESSAGES/messages.po
@@ -6072,7 +6072,7 @@ msgstr ""
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:307
 #, python-format
-msgid "%s operators(s)"
+msgid "%s operator(s)"
 msgstr "オペレータを選択"
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:326
diff --git a/superset/translations/ko/LC_MESSAGES/messages.json b/superset/translations/ko/LC_MESSAGES/messages.json
index f756a74..03ebcdc 100644
--- a/superset/translations/ko/LC_MESSAGES/messages.json
+++ b/superset/translations/ko/LC_MESSAGES/messages.json
@@ -1617,7 +1617,7 @@
       "%s column(s) and metric(s)": [""],
       "%s column(s)": [""],
       "To filter on a metric, use Custom SQL tab.": [""],
-      "%s operators(s)": [""],
+      "%s operator(s)": [""],
       "Type a value here": [""],
       "Filter value (case sensitive)": [""],
       "choose WHERE or HAVING...": [""],
diff --git a/superset/translations/ko/LC_MESSAGES/messages.po b/superset/translations/ko/LC_MESSAGES/messages.po
index 7168410..befed31 100644
--- a/superset/translations/ko/LC_MESSAGES/messages.po
+++ b/superset/translations/ko/LC_MESSAGES/messages.po
@@ -6072,7 +6072,7 @@ msgstr ""
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:307
 #, python-format
-msgid "%s operators(s)"
+msgid "%s operator(s)"
 msgstr ""
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:326
diff --git a/superset/translations/messages.pot b/superset/translations/messages.pot
index 4fd8fd0..d2ad863 100644
--- a/superset/translations/messages.pot
+++ b/superset/translations/messages.pot
@@ -6081,7 +6081,7 @@ msgstr ""
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:307
 #, python-format
-msgid "%s operators(s)"
+msgid "%s operator(s)"
 msgstr ""
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:326
diff --git a/superset/translations/pt/LC_MESSAGES/message.json b/superset/translations/pt/LC_MESSAGES/message.json
index dd45b3e..4ac7dd8 100644
--- a/superset/translations/pt/LC_MESSAGES/message.json
+++ b/superset/translations/pt/LC_MESSAGES/message.json
@@ -1724,7 +1724,7 @@
       "%s column(s) and metric(s)": [""],
       "%s column(s)": ["Lista de Colunas"],
       "To filter on a metric, use Custom SQL tab.": [""],
-      "%s operators(s)": ["Selecione operador"],
+      "%s operator(s)": ["Selecione operador"],
       "type a value here": [""],
       "Filter value (case sensitive)": [""],
       "choose WHERE or HAVING...": [""],
diff --git a/superset/translations/pt/LC_MESSAGES/message.po b/superset/translations/pt/LC_MESSAGES/message.po
index 6ceaeaf..c05e5ce 100644
--- a/superset/translations/pt/LC_MESSAGES/message.po
+++ b/superset/translations/pt/LC_MESSAGES/message.po
@@ -5723,7 +5723,7 @@ msgstr ""
 
 #: superset-frontend/src/explore/components/AdhocFilterEditPopoverSimpleTabContent.jsx:307
 #, python-format
-msgid "%s operators(s)"
+msgid "%s operator(s)"
 msgstr "Selecione operador"
 
 #: superset-frontend/src/explore/components/AdhocFilterEditPopoverSimpleTabContent.jsx:326
diff --git a/superset/translations/pt_BR/LC_MESSAGES/messages.json b/superset/translations/pt_BR/LC_MESSAGES/messages.json
index 669f13b..c492e21 100644
--- a/superset/translations/pt_BR/LC_MESSAGES/messages.json
+++ b/superset/translations/pt_BR/LC_MESSAGES/messages.json
@@ -2244,7 +2244,7 @@
       "To filter on a metric, use Custom SQL tab.": [
         "Para filtrar uma métrica, use a aba SQL personalizado."
       ],
-      "%s operators(s)": ["%s operador(es)"],
+      "%s operator(s)": ["%s operador(es)"],
       "Type a value here": ["digite um valor aqui"],
       "Filter value (case sensitive)": [
         "Filtrar valor (sensível a maiúscula/minúscula)"
diff --git a/superset/translations/pt_BR/LC_MESSAGES/messages.po b/superset/translations/pt_BR/LC_MESSAGES/messages.po
index 2a89d39..223c8a0 100644
--- a/superset/translations/pt_BR/LC_MESSAGES/messages.po
+++ b/superset/translations/pt_BR/LC_MESSAGES/messages.po
@@ -6489,7 +6489,7 @@ msgstr "Para filtrar uma métrica, use a aba SQL personalizado."
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:307
 #, python-format
-msgid "%s operators(s)"
+msgid "%s operator(s)"
 msgstr "%s operador(es)"
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:326
diff --git a/superset/translations/ru/LC_MESSAGES/messages.json b/superset/translations/ru/LC_MESSAGES/messages.json
index e346451..bd3938d 100644
--- a/superset/translations/ru/LC_MESSAGES/messages.json
+++ b/superset/translations/ru/LC_MESSAGES/messages.json
@@ -1839,7 +1839,7 @@
       "%s column(s) and metric(s)": [""],
       "%s column(s)": ["Список столбцов"],
       "To filter on a metric, use Custom SQL tab.": [""],
-      "%s operators(s)": ["%s параметр(ы)"],
+      "%s operator(s)": ["%s параметр(ы)"],
       "Type a value here": [""],
       "Filter value (case sensitive)": [""],
       "choose WHERE or HAVING...": [""],
diff --git a/superset/translations/ru/LC_MESSAGES/messages.po b/superset/translations/ru/LC_MESSAGES/messages.po
index 2731756..f726c40 100644
--- a/superset/translations/ru/LC_MESSAGES/messages.po
+++ b/superset/translations/ru/LC_MESSAGES/messages.po
@@ -6170,7 +6170,7 @@ msgstr ""
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:307
 #, python-format
-msgid "%s operators(s)"
+msgid "%s operator(s)"
 msgstr "%s параметр(ы)"
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:326
diff --git a/superset/translations/zh/LC_MESSAGES/messages.json b/superset/translations/zh/LC_MESSAGES/messages.json
index 231643f..5b0edc0 100644
--- a/superset/translations/zh/LC_MESSAGES/messages.json
+++ b/superset/translations/zh/LC_MESSAGES/messages.json
@@ -1731,7 +1731,7 @@
       "To filter on a metric, use Custom SQL tab.": [
         "若要在计量值上筛选,请使用自定义SQL选项卡。"
       ],
-      "%s operators(s)": ["%s 运算符"],
+      "%s operator(s)": ["%s 运算符"],
       "Type a value here": ["在这里键入一个值"],
       "Filter value (case sensitive)": [""],
       "choose WHERE or HAVING...": ["选择WHERE或HAVING子句..."],
diff --git a/superset/translations/zh/LC_MESSAGES/messages.po b/superset/translations/zh/LC_MESSAGES/messages.po
index 02f864f..f431964 100644
--- a/superset/translations/zh/LC_MESSAGES/messages.po
+++ b/superset/translations/zh/LC_MESSAGES/messages.po
@@ -6134,7 +6134,7 @@ msgstr "若要在计量值上筛选,请使用自定义SQL选项卡。"
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:307
 #, python-format
-msgid "%s operators(s)"
+msgid "%s operator(s)"
 msgstr "%s 运算符"
 
 #: superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent.jsx:326