fix(select): make to consider the case sensitive in case of d3 format selector (#19159)

This commit is contained in:
smileydev 2022-03-17 13:04:03 -04:00 committed by GitHub
parent 3230415e22
commit d099f5ed4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 22 deletions

View File

@ -94,6 +94,11 @@ type Control = {
default?: unknown; default?: unknown;
}; };
type SelectDefaultOption = {
label: string;
value: string;
};
const groupByControl: SharedControlConfig<'SelectControl', ColumnMeta> = { const groupByControl: SharedControlConfig<'SelectControl', ColumnMeta> = {
type: 'SelectControl', type: 'SelectControl',
label: t('Group by'), label: t('Group by'),
@ -430,29 +435,36 @@ const size: SharedControlConfig<'MetricsControl'> = {
default: null, default: null,
}; };
const y_axis_format: SharedControlConfig<'SelectControl'> = { const y_axis_format: SharedControlConfig<'SelectControl', SelectDefaultOption> =
type: 'SelectControl', {
freeForm: true, type: 'SelectControl',
label: t('Y Axis Format'), freeForm: true,
renderTrigger: true, label: t('Y Axis Format'),
default: DEFAULT_NUMBER_FORMAT, renderTrigger: true,
choices: D3_FORMAT_OPTIONS, default: DEFAULT_NUMBER_FORMAT,
description: D3_FORMAT_DOCS, choices: D3_FORMAT_OPTIONS,
mapStateToProps: state => { description: D3_FORMAT_DOCS,
const showWarning = state.controls?.comparison_type?.value === 'percentage'; filterOption: ({ data: option }, search) =>
return { option.label.includes(search) || option.value.includes(search),
warning: showWarning mapStateToProps: state => {
? t( const showWarning =
'When `Calculation type` is set to "Percentage change", the Y ' + state.controls?.comparison_type?.value === 'percentage';
'Axis Format is forced to `.1%`', return {
) warning: showWarning
: null, ? t(
disabled: showWarning, 'When `Calculation type` is set to "Percentage change", the Y ' +
}; 'Axis Format is forced to `.1%`',
}, )
}; : null,
disabled: showWarning,
};
},
};
const x_axis_time_format: SharedControlConfig<'SelectControl'> = { const x_axis_time_format: SharedControlConfig<
'SelectControl',
SelectDefaultOption
> = {
type: 'SelectControl', type: 'SelectControl',
freeForm: true, freeForm: true,
label: t('Time format'), label: t('Time format'),
@ -460,6 +472,8 @@ const x_axis_time_format: SharedControlConfig<'SelectControl'> = {
default: DEFAULT_TIME_FORMAT, default: DEFAULT_TIME_FORMAT,
choices: D3_TIME_FORMAT_OPTIONS, choices: D3_TIME_FORMAT_OPTIONS,
description: D3_TIME_FORMAT_DOCS, description: D3_TIME_FORMAT_DOCS,
filterOption: ({ data: option }, search) =>
option.label.includes(search) || option.value.includes(search),
}; };
const adhoc_filters: SharedControlConfig<'AdhocFilterControl'> = { const adhoc_filters: SharedControlConfig<'AdhocFilterControl'> = {