chore: change Sort-by and Sort-Descending controls for Bar Chart v2 (#20868)

This commit is contained in:
Stephen Liu 2022-08-03 04:36:21 +08:00 committed by GitHub
parent 9362e27ce2
commit 7beda3bbdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 0 deletions

View File

@ -328,6 +328,35 @@ const config: ControlPanelConfig = {
row_limit: {
default: rowLimit,
},
limit: {
rerender: ['timeseries_limit_metric', 'order_desc'],
},
timeseries_limit_metric: {
label: t('Series Limit Sort By'),
description: t(
'Metric used to order the limit if a series limit is present. ' +
'If undefined reverts to the first metric (where appropriate).',
),
visibility: ({ controls }) => Boolean(controls?.limit.value),
mapStateToProps: (state, controlState) => {
const timeserieslimitProps =
sharedControls.timeseries_limit_metric.mapStateToProps?.(
state,
controlState,
) || {};
timeserieslimitProps.value = state.controls?.limit?.value
? controlState.value
: [];
return timeserieslimitProps;
},
},
order_desc: {
label: t('Series Limit Sort Descending'),
default: false,
description: t(
'Whether to sort descending or ascending if a series limit is present',
),
},
},
formDataOverrides: formData => ({
...formData,