fix(table): only show increase/decrease color options when time comparison enabled (#37362)

This commit is contained in:
Jamile Celento
2026-01-28 09:32:30 -03:00
committed by GitHub
parent 6663709a23
commit 3347b9bf6c
4 changed files with 455 additions and 29 deletions

View File

@@ -683,16 +683,6 @@ const config: ControlPanelConfig = {
type: 'ConditionalFormattingControl',
renderTrigger: true,
label: t('Custom conditional formatting'),
extraColorChoices: [
{
value: ColorSchemeEnum.Green,
label: t('Green for increase, red for decrease'),
},
{
value: ColorSchemeEnum.Red,
label: t('Red for increase, green for decrease'),
},
],
description: t(
'Apply conditional color formatting to numeric columns',
),
@@ -705,6 +695,22 @@ const config: ControlPanelConfig = {
)
? (explore?.datasource as Dataset)?.verbose_map
: (explore?.datasource?.columns ?? {});
const timeCompareValue = explore?.controls?.time_compare?.value;
const hasTimeComparison = !isEmpty(timeCompareValue);
const extraColorChoices = hasTimeComparison
? [
{
value: ColorSchemeEnum.Green,
label: t('Green for increase, red for decrease'),
},
{
value: ColorSchemeEnum.Red,
label: t('Red for increase, green for decrease'),
},
]
: [];
const chartStatus = chart?.chartStatus;
const { colnames, coltypes } =
chart?.queriesResponse?.[0] ?? {};
@@ -724,12 +730,10 @@ const config: ControlPanelConfig = {
colnames && coltypes[colnames?.indexOf(colname)],
}))
: [];
const columnOptions = explore?.controls?.time_compare?.value
const columnOptions = hasTimeComparison
? processComparisonColumns(
numericColumns || [],
ensureIsArray(
explore?.controls?.time_compare?.value,
)[0]?.toString() || '',
ensureIsArray(timeCompareValue)[0]?.toString() || '',
)
: numericColumns;
@@ -737,6 +741,7 @@ const config: ControlPanelConfig = {
removeIrrelevantConditions: chartStatus === 'success',
columnOptions,
verboseMap,
extraColorChoices,
};
},
},