Skip to content

Commit

Permalink
fix controls hiden
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyongjie committed Apr 27, 2022
1 parent d0a9d0c commit 5299fde
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,16 @@ export const advancedAnalyticsControls: ControlPanelSectionConfig = {
'Defines the size of the rolling window function, ' +
'relative to the time granularity selected',
),
visibility: ({ controls }) =>
Boolean(controls?.rolling_type?.value) &&
controls.rolling_type.value !== RollingType.Cumsum,
visibility: ({ controls }, { name }) => {
// `rolling_type_b` refer to rolling_type in mixed timeseries Query B
const rollingTypeControlName = name.endsWith('_b')
? 'rolling_type_b'
: 'rolling_type';
return (
Boolean(controls[rollingTypeControlName]?.value) &&
controls[rollingTypeControlName]?.value !== RollingType.Cumsum
);
},
},
},
],
Expand All @@ -79,9 +86,16 @@ export const advancedAnalyticsControls: ControlPanelSectionConfig = {
'shown are the total of 7 periods. This will hide the "ramp up" ' +
'taking place over the first 7 periods',
),
visibility: ({ controls }) =>
Boolean(controls?.rolling_type?.value) &&
controls.rolling_type.value !== RollingType.Cumsum,
visibility: ({ controls }, { name }) => {
// `rolling_type_b` refer to rolling_type in mixed timeseries Query B
const rollingTypeControlName = name.endsWith('_b')
? 'rolling_type_b'
: 'rolling_type';
return (
Boolean(controls[rollingTypeControlName]?.value) &&
controls[rollingTypeControlName]?.value !== RollingType.Cumsum
);
},
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ export interface BaseControlConfig<
// TODO: add strict `chartState` typing (see superset-frontend/src/explore/types)
chartState?: AnyDict,
) => ExtraControlProps;
visibility?: (props: ControlPanelsContainerProps) => boolean;
visibility?: (
props: ControlPanelsContainerProps,
controlData: AnyDict,
) => boolean;
}

export interface ControlValueValidator<
Expand Down

0 comments on commit 5299fde

Please sign in to comment.