feat(filter-box): hide druid options if druid not enabled (#14921)

* feat(filter-box): hide druid options if druid not enabled

* add bootstrap export
This commit is contained in:
Ville Brofeldt 2021-06-07 22:49:56 +03:00 committed by GitHub
parent 7f4e036433
commit 422c32cb7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 23 deletions

View File

@ -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'],
],
},

View File

@ -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",