Skip to content

Commit

Permalink
feat(chart-controls): move cross-filtering control to data panel (apa…
Browse files Browse the repository at this point in the history
…che#1248)

* feat(chart-controls): move cross-filtering control to data panel

* fix: license

* fix: add test

* fix: add test

* fix: codedev

* fix: test
  • Loading branch information
stephenLYZ authored and zhaoyongjie committed Nov 25, 2021
1 parent ddecb3e commit 5633007
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ export * from './components/MetricOption';
// React control components
export { default as sharedControls } from './shared-controls';
export { default as sharedControlComponents } from './shared-controls/components';
export * from './shared-controls/emitFilterControl';
export * from './shared-controls/components';
export * from './types';
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';

const enableCrossFilter = isFeatureEnabled(FeatureFlag.DASHBOARD_CROSS_FILTERS);

export const emitFilterControl = enableCrossFilter
? [
{
name: 'emit_filter',
config: {
type: 'CheckboxControl',
label: t('Emit dashboard cross filters'),
default: false,
renderTrigger: true,
description: t('Emit dashboard cross filters.'),
},
},
]
: [];
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { emitFilterControl } from '../../src/shared-controls/emitFilterControl';

describe('isFeatureFlagEnabled', () => {
it('returns empty array for unset feature flag', () => {
expect(emitFilterControl).toHaveLength(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import { t } from '@superset-ui/core';
import {
D3_FORMAT_DOCS,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
formatSelectOptions,
sections,
emitFilterControl,
} from '@superset-ui/chart-controls';
import { DEFAULT_FORM_DATA } from '../Pie/types';

const { emitFilter } = DEFAULT_FORM_DATA;

export default {
controlPanelSections: [
Expand All @@ -37,6 +35,7 @@ export default {
controlSetRows: [
['metrics'],
['adhoc_filters'],
emitFilterControl,
['groupby'],
['columns'],
['limit'],
Expand Down Expand Up @@ -65,20 +64,6 @@ export default {
expanded: true,
controlSetRows: [
['color_scheme'],
isFeatureEnabled(FeatureFlag.DASHBOARD_CROSS_FILTERS)
? [
{
name: 'emit_filter',
config: {
type: 'CheckboxControl',
label: t('Enable emitting filters'),
default: emitFilter,
renderTrigger: true,
description: t('Enable emmiting filters.'),
},
},
]
: [],
[
{
name: 'x_ticks_layout',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@
* under the License.
*/
import React from 'react';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import { t } from '@superset-ui/core';
import {
ControlPanelConfig,
D3_FORMAT_OPTIONS,
sections,
sharedControls,
ControlStateMapping,
emitFilterControl,
} from '@superset-ui/chart-controls';
import { DEFAULT_FORM_DATA, EchartsFunnelLabelTypeType } from './types';
import { legendSection } from '../controls';

const { labelType, numberFormat, showLabels, emitFilter } = DEFAULT_FORM_DATA;
const { labelType, numberFormat, showLabels } = DEFAULT_FORM_DATA;

const funnelLegendSection = [...legendSection];
funnelLegendSection.splice(2, 1);
Expand All @@ -43,6 +44,7 @@ const config: ControlPanelConfig = {
['groupby'],
['metric'],
['adhoc_filters'],
emitFilterControl,
[
{
name: 'row_limit',
Expand Down Expand Up @@ -70,20 +72,6 @@ const config: ControlPanelConfig = {
expanded: true,
controlSetRows: [
['color_scheme'],
isFeatureEnabled(FeatureFlag.DASHBOARD_CROSS_FILTERS)
? [
{
name: 'emit_filter',
config: {
type: 'CheckboxControl',
label: t('Enable emitting filters'),
default: emitFilter,
renderTrigger: true,
description: t('Enable emmiting filters.'),
},
},
]
: [],
...funnelLegendSection,
// eslint-disable-next-line react/jsx-key
[<h1 className="section-header">{t('Labels')}</h1>],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,13 @@
* under the License.
*/
import React from 'react';
import {
t,
validateNonEmpty,
validateInteger,
isFeatureEnabled,
FeatureFlag,
} from '@superset-ui/core';
import { t, validateNonEmpty, validateInteger } from '@superset-ui/core';
import {
sharedControls,
ControlPanelConfig,
D3_FORMAT_OPTIONS,
sections,
emitFilterControl,
} from '@superset-ui/chart-controls';
import { DEFAULT_FORM_DATA } from './types';

Expand All @@ -51,6 +46,7 @@ const config: ControlPanelConfig = {
],
['metric'],
['adhoc_filters'],
emitFilterControl,
[
{
name: 'row_limit',
Expand Down Expand Up @@ -127,20 +123,6 @@ const config: ControlPanelConfig = {
},
],
['color_scheme'],
isFeatureEnabled(FeatureFlag.DASHBOARD_CROSS_FILTERS)
? [
{
name: 'emit_filter',
config: {
type: 'CheckboxControl',
label: t('Enable emitting filters'),
default: DEFAULT_FORM_DATA.emitFilter,
renderTrigger: true,
description: t('Enable emmiting filters.'),
},
},
]
: [],
[
{
name: 'font_size',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
* under the License.
*/
import React from 'react';
import { FeatureFlag, isFeatureEnabled, t, validateNonEmpty } from '@superset-ui/core';
import { t, validateNonEmpty } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlPanelsContainerProps,
D3_FORMAT_DOCS,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
sections,
emitFilterControl,
} from '@superset-ui/chart-controls';
import { DEFAULT_FORM_DATA } from './types';
import { legendSection } from '../controls';
Expand All @@ -38,7 +39,6 @@ const {
outerRadius,
numberFormat,
showLabels,
emitFilter,
} = DEFAULT_FORM_DATA;

const config: ControlPanelConfig = {
Expand All @@ -51,6 +51,7 @@ const config: ControlPanelConfig = {
['groupby'],
['metric'],
['adhoc_filters'],
emitFilterControl,
['row_limit'],
[
{
Expand Down Expand Up @@ -83,20 +84,6 @@ const config: ControlPanelConfig = {
},
},
],
isFeatureEnabled(FeatureFlag.DASHBOARD_CROSS_FILTERS)
? [
{
name: 'emit_filter',
config: {
type: 'CheckboxControl',
label: t('Enable emitting filters'),
default: emitFilter,
renderTrigger: true,
description: t('Enable emmiting filters.'),
},
},
]
: [],
...legendSection,
// eslint-disable-next-line react/jsx-key
[<h1 className="section-header">{t('Labels')}</h1>],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
import React from 'react';
import {
ChartDataResponseResult,
FeatureFlag,
GenericDataType,
isFeatureEnabled,
QueryFormMetric,
t,
validateNumber,
Expand All @@ -33,20 +31,14 @@ import {
D3_TIME_FORMAT_OPTIONS,
sections,
sharedControls,
emitFilterControl,
} from '@superset-ui/chart-controls';
import { ControlFormItemSpec } from '@superset-ui/chart-controls/lib/components/ControlForm';
import { DEFAULT_FORM_DATA } from './types';
import { LABEL_POSITION } from '../constants';
import { legendSection } from '../controls';

const {
labelType,
labelPosition,
numberFormat,
showLabels,
isCircle,
emitFilter,
} = DEFAULT_FORM_DATA;
const { labelType, labelPosition, numberFormat, showLabels, isCircle } = DEFAULT_FORM_DATA;

const radarMetricMaxValue: { name: string; config: ControlFormItemSpec } = {
name: 'radarMetricMaxValue',
Expand All @@ -72,6 +64,7 @@ const config: ControlPanelConfig = {
['metrics'],
['timeseries_limit_metric'],
['adhoc_filters'],
emitFilterControl,
[
{
name: 'row_limit',
Expand All @@ -88,20 +81,6 @@ const config: ControlPanelConfig = {
expanded: true,
controlSetRows: [
['color_scheme'],
isFeatureEnabled(FeatureFlag.DASHBOARD_CROSS_FILTERS)
? [
{
name: 'emit_filter',
config: {
type: 'CheckboxControl',
label: t('Enable emitting filters'),
default: emitFilter,
renderTrigger: true,
description: t('Enable emmiting filters.'),
},
},
]
: [],
...legendSection,
[<h1 className="section-header">{t('Labels')}</h1>],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,14 @@
* under the License.
*/
import React from 'react';
import {
FeatureFlag,
isFeatureEnabled,
legacyValidateInteger,
legacyValidateNumber,
t,
} from '@superset-ui/core';
import { legacyValidateInteger, legacyValidateNumber, t } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlPanelsContainerProps,
D3_TIME_FORMAT_DOCS,
sections,
sharedControls,
emitFilterControl,
} from '@superset-ui/chart-controls';

import {
Expand All @@ -43,7 +38,6 @@ const {
area,
annotationLayers,
contributionMode,
emitFilter,
forecastEnabled,
forecastInterval,
forecastPeriods,
Expand Down Expand Up @@ -90,6 +84,7 @@ const config: ControlPanelConfig = {
},
],
['adhoc_filters'],
emitFilterControl,
['limit'],
['timeseries_limit_metric'],
[
Expand Down Expand Up @@ -326,20 +321,6 @@ const config: ControlPanelConfig = {
},
},
],
isFeatureEnabled(FeatureFlag.DASHBOARD_CROSS_FILTERS)
? [
{
name: 'emit_filter',
config: {
type: 'CheckboxControl',
label: t('Enable emitting filters'),
default: emitFilter,
renderTrigger: true,
description: t('Enable emmiting filters.'),
},
},
]
: [],
...legendSection,
[<h1 className="section-header">{t('X Axis')}</h1>],
[
Expand Down

0 comments on commit 5633007

Please sign in to comment.