Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Move cross filters to Dashboard #22785

Merged
merged 16 commits into from
Jan 25, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ function prepareDashboardFilters(
label_colors: {},
shared_label_colors: {},
color_scheme_domain: [],
cross_filters_enabled: false,
positions: {
DASHBOARD_VERSION_KEY: 'v2',
ROOT_ID: { type: 'ROOT', id: 'ROOT_ID', children: ['GRID_ID'] },
Expand Down Expand Up @@ -203,9 +204,10 @@ function openVerticalFilterBar() {
function setFilterBarOrientation(orientation: 'vertical' | 'horizontal') {
cy.getBySel('filterbar-orientation-icon').click();
cy.wait(250);
cy.getBySel('dropdown-selectable-info')
cy.getBySel('dropdown-selectable-icon-submenu')
.contains('Orientation of filter bar')
.should('exist');
.should('exist')
.trigger('mouseover');

if (orientation === 'vertical') {
cy.get('.ant-dropdown-menu-item-selected')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { hasGenericChartAxes, t } from '@superset-ui/core';
import { ControlPanelSectionConfig, ControlSetRow } from '../types';
import {
contributionModeControl,
emitFilterControl,
xAxisSortControl,
xAxisSortAscControl,
} from '../shared-controls';
Expand All @@ -30,7 +29,6 @@ const controlsWithoutXAxis: ControlSetRow[] = [
['groupby'],
[contributionModeControl],
['adhoc_filters'],
emitFilterControl,
['limit'],
['timeseries_limit_metric'],
['order_desc'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export type ColumnConfigControlProps<T extends ColumnConfig> =
queryResponse?: ChartDataResponseResult;
configFormLayout?: ColumnConfigFormLayout;
appliedColumnNames?: string[];
emitFilter: boolean;
};

/**
Expand All @@ -57,24 +56,8 @@ export default function ColumnConfigControl<T extends ColumnConfig>({
value,
onChange,
configFormLayout = DEFAULT_CONFIG_FORM_LAYOUT,
emitFilter,
...props
}: ColumnConfigControlProps<T>) {
if (emitFilter) {
Object.values(configFormLayout).forEach(array_of_array => {
if (!array_of_array.some(arr => arr.includes('emitTarget'))) {
array_of_array.push(['emitTarget']);
}
});
} else {
Object.values(configFormLayout).forEach(array_of_array => {
const index = array_of_array.findIndex(arr => arr.includes('emitTarget'));
if (index > -1) {
array_of_array.splice(index, 1);
}
});
}

const { colnames: _colnames, coltypes: _coltypes } = queryResponse || {};
let colnames: string[] = [];
let coltypes: GenericDataType[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,13 @@ export type SharedColumnConfigProp =
| 'colorPositiveNegative'
| 'columnWidth'
| 'fractionDigits'
| 'emitTarget'
| 'd3NumberFormat'
| 'd3SmallNumberFormat'
| 'd3TimeFormat'
| 'horizontalAlign'
| 'truncateLongCells'
| 'showCellBars';

const emitTarget: ControlFormItemSpec<'Input'> = {
controlType: 'Input',
label: t('Emit Target'),
description: t(
'If you wish to specify a different target column than the original column, it can be entered here',
),
defaultValue: '',
debounceDelay: 500,
validators: undefined,
};

const d3NumberFormat: ControlFormItemSpec<'Select'> = {
controlType: 'Select',
label: t('D3 format'),
Expand Down Expand Up @@ -156,7 +144,6 @@ const truncateLongCells: ControlFormItemSpec<'Checkbox'> = {
*/
export const SHARED_COLUMN_CONFIG_PROPS = {
d3NumberFormat,
emitTarget,
d3SmallNumberFormat: {
...d3NumberFormat,
label: t('Small number format'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,17 @@
import {
ContributionType,
ensureIsArray,
FeatureFlag,
getColumnLabel,
getMetricLabel,
isDefined,
isEqualArray,
isFeatureEnabled,
QueryFormColumn,
QueryFormMetric,
t,
} from '@superset-ui/core';
import { ControlPanelState, ControlState, ControlStateMapping } from '../types';
import { isTemporalColumn } from '../utils';

export const emitFilterControl = isFeatureEnabled(
FeatureFlag.DASHBOARD_CROSS_FILTERS,
)
? [
{
name: 'emit_filter',
config: {
type: 'CheckboxControl',
label: t('Enable dashboard cross filters'),
default: false,
renderTrigger: true,
description: t('Enable dashboard cross filters'),
},
},
]
: [];

export const contributionModeControl = {
name: 'contributionMode',
config: {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ export default class ChartProps<FormData extends RawFormData = RawFormData> {

inContextMenu?: boolean;

emitCrossFilters?: boolean;

theme: SupersetTheme;

constructor(config: ChartPropsConfig & { formData?: FormData } = {}) {
Expand All @@ -164,6 +166,7 @@ export default class ChartProps<FormData extends RawFormData = RawFormData> {
isRefreshing,
inputRef,
inContextMenu = false,
emitCrossFilters = false,
theme,
} = config;
this.width = width;
Expand All @@ -184,6 +187,7 @@ export default class ChartProps<FormData extends RawFormData = RawFormData> {
this.isRefreshing = isRefreshing;
this.inputRef = inputRef;
this.inContextMenu = inContextMenu;
this.emitCrossFilters = emitCrossFilters;
this.theme = theme;
}
}
Expand All @@ -207,6 +211,7 @@ ChartProps.createSelector = function create(): ChartPropsSelector {
input => input.isRefreshing,
input => input.inputRef,
input => input.inContextMenu,
input => input.emitCrossFilters,
input => input.theme,
(
annotationData,
Expand All @@ -225,6 +230,7 @@ ChartProps.createSelector = function create(): ChartPropsSelector {
isRefreshing,
inputRef,
inContextMenu,
emitCrossFilters,
theme,
) =>
new ChartProps({
Expand All @@ -244,6 +250,7 @@ ChartProps.createSelector = function create(): ChartPropsSelector {
isRefreshing,
inputRef,
inContextMenu,
emitCrossFilters,
theme,
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export default function EchartsBoxPlot(props: BoxPlotChartTransformedProps) {
labelMap,
groupby,
selectedValues,
formData,
refs,
emitCrossFilters,
} = props;
const handleChange = useCallback(
(values: string[]) => {
if (!formData.emitFilter) {
if (!emitCrossFilters) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
sections,
emitFilterControl,
ControlPanelConfig,
getStandardizedControls,
ControlState,
Expand Down Expand Up @@ -77,7 +76,6 @@ const config: ControlPanelConfig = {
['groupby'],
['metrics'],
['adhoc_filters'],
emitFilterControl,
['series_limit'],
['series_limit_metric'],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default function transformProps(
filterState,
queriesData,
inContextMenu,
emitCrossFilters,
} = chartProps;
const { data = [] } = queriesData[0];
const { setDataMask = () => {}, onContextMenu } = hooks;
Expand All @@ -64,7 +65,6 @@ export default function transformProps(
numberFormat,
dateFormat,
xTicksLayout,
emitFilter,
legendOrientation = 'top',
xAxisTitle,
yAxisTitle,
Expand Down Expand Up @@ -291,7 +291,7 @@ export default function transformProps(
height,
echartOptions,
setDataMask,
emitFilter,
emitCrossFilters,
labelMap,
groupby,
selectedValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export type BoxPlotQueryFormData = QueryFormData & {
numberFormat?: string;
whiskerOptions?: BoxPlotFormDataWhiskerOptions;
xTickLayout?: BoxPlotFormXTickLayout;
emitFilter: boolean;
} & TitleFormData;

export type BoxPlotFormDataWhiskerOptions =
Expand All @@ -48,7 +47,6 @@ export type BoxPlotFormXTickLayout =

// @ts-ignore
export const DEFAULT_FORM_DATA: BoxPlotQueryFormData = {
emitFilter: false,
...DEFAULT_TITLE_FORM_DATA,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export default function EchartsFunnel(props: FunnelChartTransformedProps) {
labelMap,
groupby,
selectedValues,
formData,
emitCrossFilters,
refs,
} = props;
const handleChange = useCallback(
(values: string[]) => {
if (!formData.emitFilter) {
if (!emitCrossFilters) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
sections,
sharedControls,
ControlStateMapping,
emitFilterControl,
getStandardizedControls,
} from '@superset-ui/chart-controls';
import { DEFAULT_FORM_DATA, EchartsFunnelLabelTypeType } from './types';
Expand All @@ -45,7 +44,6 @@ const config: ControlPanelConfig = {
['groupby'],
['metric'],
['adhoc_filters'],
emitFilterControl,
[
{
name: 'row_limit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default function transformProps(
width,
theme,
inContextMenu,
emitCrossFilters,
} = chartProps;
const data: DataRecord[] = queriesData[0].data || [];

Expand All @@ -110,7 +111,6 @@ export default function transformProps(
numberFormat,
showLabels,
showLegend,
emitFilter,
sliceId,
}: EchartsFunnelFormData = {
...DEFAULT_LEGEND_FORM_DATA,
Expand Down Expand Up @@ -238,7 +238,7 @@ export default function transformProps(
height,
echartOptions,
setDataMask,
emitFilter,
emitCrossFilters,
labelMap,
groupby,
selectedValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export type EchartsFunnelFormData = QueryFormData &
gap: number;
sort: 'descending' | 'ascending' | 'none' | undefined;
orient: 'vertical' | 'horizontal' | undefined;
emitFilter: boolean;
};

export enum EchartsFunnelLabelTypeType {
Expand Down Expand Up @@ -70,7 +69,6 @@ export const DEFAULT_FORM_DATA: EchartsFunnelFormData = {
sort: 'descending',
orient: 'vertical',
gap: 0,
emitFilter: false,
};

export type FunnelChartTransformedProps =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export default function EchartsGauge(props: GaugeChartTransformedProps) {
labelMap,
groupby,
selectedValues,
formData: { emitFilter },
emitCrossFilters,
refs,
} = props;
const handleChange = useCallback(
(values: string[]) => {
if (!emitFilter) {
if (!emitCrossFilters) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
ControlPanelConfig,
D3_FORMAT_OPTIONS,
sections,
emitFilterControl,
getStandardizedControls,
} from '@superset-ui/chart-controls';
import { DEFAULT_FORM_DATA } from './types';
Expand All @@ -46,7 +45,6 @@ const config: ControlPanelConfig = {
],
['metric'],
['adhoc_filters'],
emitFilterControl,
[
{
name: 'row_limit',
Expand Down
Loading