Skip to content

Commit

Permalink
Merge pull request #5720 from gooddata/nen-lx-706
Browse files Browse the repository at this point in the history
fix: validate custom date filter config granularities
  • Loading branch information
pbenes authored Dec 17, 2024
2 parents 7f764d7 + 6a49bde commit ecf5359
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
DateFilterGranularity,
DateString,
idRef,
isDateFilterGranularity,
} from "@gooddata/sdk-model";

export const DefaultDateFilterConfig: IDateFilterConfig = {
Expand Down Expand Up @@ -310,9 +311,17 @@ const convertAbsoluteForm = (absoluteForm: IDateFilterBase): IAbsoluteDateFilter

const convertRelativeForm = (relativeForm: IDateFilterRelativeForm): IRelativeDateFilterForm => {
const { granularities: availableGranularities, ...other } = relativeForm;

if (!availableGranularities) {
return DefaultDateFilterConfig.relativeForm!;
}

const validGranularities: DateFilterGranularity[] =
availableGranularities.filter(isDateFilterGranularity);

return {
type: "relativeForm",
availableGranularities,
availableGranularities: validGranularities,
...other,
};
};
Expand Down

0 comments on commit ecf5359

Please sign in to comment.