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

[CLDN-1829] fixing principle filter logic with state #234

Merged
merged 2 commits into from
Nov 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,6 @@ const validateAggControlValues = (
: [];
};

const validateAggColumnValues = (
controls: ControlStateMapping,
values: any[],
state: ControlPanelState,
) => {
const result = validateAggControlValues(controls, values);
if (result.length === 0 && isAggMode({ controls })) {
return [];
}
return result;
};

// function isIP(v: unknown) {
// if (typeof v === 'string' && v.trim().length > 0) {
Expand Down Expand Up @@ -212,20 +201,11 @@ const config: ControlPanelConfig = {
[
{
name: 'groupby',
config: {
type: 'SelectControl',
label: t('Group by'),
description: sharedControls.groupby.description,
multi: true,
freeForm: true,
allowAll: true,
default: [],
valueKey: 'column_name',
includeTime: false,
canSelectAll: true,
optionRenderer: c => <StyledColumnOption showType column={c} />,
valueRenderer: c => <StyledColumnOption column={c} />,
override: {
visibility: isAggMode,
resetOnHide: false,
canCopy: true,
canSelectAll: true,
mapStateToProps: (
state: ControlPanelState,
controlState: ControlState,
Expand All @@ -235,24 +215,19 @@ const config: ControlPanelConfig = {
sharedControls?.groupby?.mapStateToProps;
const newState =
originalMapStateToProps?.(state, controlState) ?? {};
newState.externalValidationErrors = validateAggColumnValues(
newState.externalValidationErrors = validateAggControlValues(
controls,
[
controls.metrics?.value,
controlState.value,
controls.percent_metrics?.value,
controlState.value,
],
state,
);

return newState;
},
rerender: [
'metrics',
'percent_metrics',
'principalEmitFilterColumn',
],
canCopy: true,
} as typeof sharedControls.groupby,
rerender: ['metrics', 'percent_metrics', ],
},
},
],
[
Expand Down Expand Up @@ -317,15 +292,22 @@ const config: ControlPanelConfig = {
name: 'columns',
config: {
type: 'SelectControl',
label: t('Columns'),
label: t('Dimensions'),
description: t('Columns to display'),
multi: true,
freeForm: true,
allowAll: true,
default: [],
canSelectAll: true,
optionRenderer: c => <StyledColumnOption showType column={c} />,
valueRenderer: c => <StyledColumnOption column={c} />,
optionRenderer: (c: ColumnMeta) => (
// eslint-disable-next-line react/react-in-jsx-scope
<StyledColumnOption showType column={c} />
),
// eslint-disable-next-line react/react-in-jsx-scope
valueRenderer: (c: ColumnMeta) => (
// eslint-disable-next-line react/react-in-jsx-scope
<StyledColumnOption column={c} />
),
valueKey: 'column_name',
mapStateToProps: (
state: ControlPanelState,
Expand All @@ -347,7 +329,7 @@ const config: ControlPanelConfig = {
rerender: ['principalColumns'],
visibility: isRawMode,
canCopy: true,
} as typeof sharedControls.groupby,
}
},
],
[
Expand Down Expand Up @@ -437,8 +419,9 @@ const config: ControlPanelConfig = {
controlState: ControlState,
) => {
const { controls } = state;
const originalMapStateToProps =
sharedControls?.columns?.mapStateToProps;
const originalMapStateToProps = isRawMode({ controls }) ?
sharedControls?.columns?.mapStateToProps :
sharedControls?.groupby?.mapStateToProps;
const newState =
originalMapStateToProps?.(state, controlState) ?? {};
const choices = isRawMode({ controls })
Expand Down