feat(filter-box): hide druid options if druid not enabled (#14921)
* feat(filter-box): hide druid options if druid not enabled
* add bootstrap export
(cherry picked from commit 422c32cb7de90ef7b7902d98a7e0102a25a01859)
diff --git a/superset-frontend/src/visualizations/FilterBox/controlPanel.jsx b/superset-frontend/src/visualizations/FilterBox/controlPanel.jsx
index 51c41d5..34a814a 100644
--- a/superset-frontend/src/visualizations/FilterBox/controlPanel.jsx
+++ b/superset-frontend/src/visualizations/FilterBox/controlPanel.jsx
@@ -20,6 +20,36 @@
import { t } from '@superset-ui/core';
import { sections } from '@superset-ui/chart-controls';
+const appContainer = document.getElementById('app');
+const bootstrapData = JSON.parse(appContainer.getAttribute('data-bootstrap'));
+const druidIsActive = !!bootstrapData?.common?.conf?.DRUID_IS_ACTIVE;
+const druidSection = druidIsActive
+ ? [
+ [
+ {
+ name: 'show_druid_time_granularity',
+ config: {
+ type: 'CheckboxControl',
+ label: t('Show Druid granularity dropdown'),
+ default: false,
+ description: t('Check to include Druid granularity dropdown'),
+ },
+ },
+ ],
+ [
+ {
+ name: 'show_druid_time_origin',
+ config: {
+ type: 'CheckboxControl',
+ label: t('Show Druid time origin'),
+ default: false,
+ description: t('Check to include time origin dropdown'),
+ },
+ },
+ ],
+ ]
+ : [];
+
export default {
controlPanelSections: [
sections.legacyTimeseriesTime,
@@ -51,6 +81,8 @@
description: t('Whether to include a time filter'),
},
},
+ ],
+ [
{
name: 'instant_filtering',
config: {
@@ -69,41 +101,30 @@
name: 'show_sqla_time_granularity',
config: {
type: 'CheckboxControl',
- label: t('Show SQL granularity dropdown'),
+ label: druidIsActive
+ ? t('Show SQL time grain dropdown')
+ : t('Show time grain dropdown'),
default: false,
- description: t('Check to include SQL granularity dropdown'),
- },
- },
- {
- name: 'show_sqla_time_column',
- config: {
- type: 'CheckboxControl',
- label: t('Show SQL time column'),
- default: false,
- description: t('Check to include time column dropdown'),
+ description: druidIsActive
+ ? t('Check to include SQL time grain dropdown')
+ : t('Check to include time grain dropdown'),
},
},
],
[
{
- name: 'show_druid_time_granularity',
+ name: 'show_sqla_time_column',
config: {
type: 'CheckboxControl',
- label: t('Show Druid granularity dropdown'),
+ label: druidIsActive
+ ? t('Show SQL time column')
+ : t('Show time column'),
default: false,
- description: t('Check to include Druid granularity dropdown'),
- },
- },
- {
- name: 'show_druid_time_origin',
- config: {
- type: 'CheckboxControl',
- label: t('Show Druid time origin'),
- default: false,
- description: t('Check to include time origin dropdown'),
+ description: t('Check to include time column dropdown'),
},
},
],
+ ...druidSection,
['adhoc_filters'],
],
},
diff --git a/superset/views/base.py b/superset/views/base.py
index 74e05db..949406a 100644
--- a/superset/views/base.py
+++ b/superset/views/base.py
@@ -87,6 +87,7 @@
"SUPERSET_DASHBOARD_PERIODICAL_REFRESH_LIMIT",
"SUPERSET_DASHBOARD_PERIODICAL_REFRESH_WARNING_MESSAGE",
"DISABLE_DATASET_SOURCE_EDIT",
+ "DRUID_IS_ACTIVE",
"ENABLE_JAVASCRIPT_CONTROLS",
"DEFAULT_SQLLAB_LIMIT",
"DEFAULT_VIZ_TYPE",