diff --git a/superset-frontend/src/visualizations/FilterBox/controlPanel.jsx b/superset-frontend/src/visualizations/FilterBox/controlPanel.jsx index 51c41d5c35e..34a814a43ef 100644 --- a/superset-frontend/src/visualizations/FilterBox/controlPanel.jsx +++ b/superset-frontend/src/visualizations/FilterBox/controlPanel.jsx @@ -20,6 +20,36 @@ import React from 'react'; 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 @@ export default { description: t('Whether to include a time filter'), }, }, + ], + [ { name: 'instant_filtering', config: { @@ -69,41 +101,30 @@ export default { 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 74e05db5402..949406a999f 100644 --- a/superset/views/base.py +++ b/superset/views/base.py @@ -87,6 +87,7 @@ FRONTEND_CONF_KEYS = ( "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",