fix(plugins): Fix dashboard filter for Table and Big Number with Time Comparison (#29517)

This commit is contained in:
Antonio Rivero
2024-07-08 23:07:35 +02:00
committed by GitHub
parent 1682994b7e
commit 9052f9fbb4
7 changed files with 37 additions and 9 deletions

View File

@@ -81,6 +81,7 @@ export default function PopKPI(props: PopKPIProps) {
currentTimeRangeFilter,
startDateOffset,
shift,
dashboardTimeRange,
} = props;
const [comparisonRange, setComparisonRange] = useState<string>('');
@@ -90,12 +91,16 @@ export default function PopKPI(props: PopKPIProps) {
setComparisonRange('');
} else if (!isEmpty(shift) || startDateOffset) {
const newShift = getTimeOffset({
timeRangeFilter: currentTimeRangeFilter,
timeRangeFilter: {
...currentTimeRangeFilter,
comparator:
dashboardTimeRange ?? (currentTimeRangeFilter as any).comparator,
},
shifts: ensureIsArray(shift),
startDate: startDateOffset || '',
});
const promise: any = fetchTimeRange(
(currentTimeRangeFilter as any).comparator,
dashboardTimeRange ?? (currentTimeRangeFilter as any).comparator,
currentTimeRangeFilter.subject,
newShift || [],
);
@@ -108,7 +113,7 @@ export default function PopKPI(props: PopKPIProps) {
);
});
}
}, [currentTimeRangeFilter, shift, startDateOffset]);
}, [currentTimeRangeFilter, shift, startDateOffset, dashboardTimeRange]);
const theme = useTheme();
const flexGap = theme.gridUnit * 5;