Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return graph null when datalist is null #393

Merged
merged 4 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/core/src/dashboards/view/DashboardScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ export const DashboardScreen = ({dashboardId}) => {
}));
}, [dashboard]);

if (dashboard?.id !== dashboardId) {
return <ActivityIndicator size="large" />;
}

if (!Array.isArray(dashboardData) || dashboardData.length === 0) {
return (
<WarningCard errorMessage={I18n.t('Base_Dashboard_Misconfigured')} />
);
}

if (dashboard?.id !== dashboardId) {
return <ActivityIndicator size="large" />;
}

return <Dashboard lineList={dashboardData} />;
};
12 changes: 8 additions & 4 deletions packages/ui/src/components/templates/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,20 @@ const Dashboard = ({style, lineList}: DashboardProps) => {
return (
<ScrollView style={[styles.container, style]}>
{lineList?.map((line, indexLine) => {
const nbGraphInLine = Math.min(
line.graphList?.length,
MAX_GRAPH_PER_LINE,
const validGraphs = line.graphList.filter(
graph => graph.dataList?.[0]?.length > 0,
);
const nbGraphInLine = Math.min(validGraphs.length, MAX_GRAPH_PER_LINE);

const limitedGraphList = line.graphList?.slice(0, MAX_GRAPH_PER_LINE);

return (
<View style={styles.lineContainer} key={indexLine}>
{limitedGraphList?.map((graph, indexGraph) => {
return renderChart(graph, indexGraph, nbGraphInLine);
if (graph.dataList?.[0]?.length > 0) {
return renderChart(graph, indexGraph, nbGraphInLine);
}
return null;
})}
</View>
);
Expand Down
Loading