Skip to content

Commit

Permalink
fix: app shows blank when repeater vis miss columns
Browse files Browse the repository at this point in the history
JIRA: F1-196
  • Loading branch information
hackerstanislav committed Apr 5, 2024
1 parent 53017b7 commit 5d60091
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions libs/sdk-ui-charts/src/charts/repeater/CoreRepeater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import {
IntlWrapper,
convertError,
ErrorCodes,
BucketNames,
} from "@gooddata/sdk-ui";
import { ITheme } from "@gooddata/sdk-model";
import { ITheme, bucketsFind } from "@gooddata/sdk-model";
import { ThemeContextProvider, useTheme, withTheme } from "@gooddata/sdk-ui-theme-provider";
import { IChartConfig, ICoreChartProps } from "../../interfaces/index.js";
import { RepeaterChart } from "./internal/RepeaterChart.js";
Expand Down Expand Up @@ -124,6 +125,18 @@ export const CoreRepeaterImpl: React.FC<ICoreRepeaterChartProps> = (props) => {
return <LoadingComponent />;
}

const columns = bucketsFind(result.definition.buckets, BucketNames.COLUMNS);
if (!columns || columns.items.length === 0) {
const err = new Error("Repeater chart requires at least one column") as any;
const convertedError = convertError(err);
const errorMessage = convertedError.getMessage();
const errorMap = newErrorMapping(intl);
const errorProps =
errorMap[Object.prototype.hasOwnProperty.call(errorMap, err) ? err : ErrorCodes.UNKNOWN_ERROR];

return <ErrorComponent code={errorMessage} {...errorProps} />;
}

return (
<RepeaterChart
dataView={result}
Expand All @@ -132,7 +145,6 @@ export const CoreRepeaterImpl: React.FC<ICoreRepeaterChartProps> = (props) => {
onColumnResized={onColumnResized}
/>
);
return <RepeaterChart dataView={result} config={configWithColorPalette} onError={onError} />;
};

const CoreRepeaterWithIntl = injectIntl(withTheme(CoreRepeaterImpl));
Expand Down

0 comments on commit 5d60091

Please sign in to comment.