Skip to content

Commit

Permalink
refactor: Use only one provider
Browse files Browse the repository at this point in the history
  • Loading branch information
ptbrowne committed May 16, 2024
1 parent de49861 commit 90367c1
Showing 1 changed file with 60 additions and 56 deletions.
116 changes: 60 additions & 56 deletions app/components/chart-published.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,66 +82,70 @@ export const ChartPublished = (props: ChartPublishedProps) => {
[configKey, dataSource, state]
);

return state.layout.type === "dashboard" ? (
return (
<InteractiveFiltersProvider chartConfigs={state.chartConfigs}>
<Box
sx={{
mb:
state.layout.meta.title[locale] ||
state.layout.meta.description[locale]
? 4
: 0,
}}
>
{state.layout.meta.title[locale] && (
<Title text={state.layout.meta.title[locale]} />
)}
{state.layout.meta.description[locale] && (
<Description text={state.layout.meta.description[locale]} />
)}
</Box>
{state.layout.layout === "tall" ? (
<ChartPanelLayoutTall
chartConfigs={state.chartConfigs}
renderChart={renderChart}
/>
{state.layout.type === "dashboard" ? (
<>
<Box
sx={{
mb:
state.layout.meta.title[locale] ||
state.layout.meta.description[locale]
? 4
: 0,
}}
>
{state.layout.meta.title[locale] && (
<Title text={state.layout.meta.title[locale]} />
)}
{state.layout.meta.description[locale] && (
<Description text={state.layout.meta.description[locale]} />
)}
</Box>
{state.layout.layout === "tall" ? (
<ChartPanelLayoutTall
chartConfigs={state.chartConfigs}
renderChart={renderChart}
/>
) : (
<ChartPanelLayoutVertical
chartConfigs={state.chartConfigs}
renderChart={renderChart}
/>
)}
</>
) : (
<ChartPanelLayoutVertical
chartConfigs={state.chartConfigs}
renderChart={renderChart}
/>
<>
<Flex
sx={{
flexDirection: "column",
mb:
state.layout.meta.title[locale] ||
state.layout.meta.description[locale]
? 4
: 0,
}}
>
{state.layout.meta.title[locale] && (
<Title text={state.layout.meta.title[locale]} />
)}
{state.layout.meta.description[locale] && (
<Description text={state.layout.meta.description[locale]} />
)}
</Flex>
<ChartTablePreviewProvider>
<ChartWrapper layoutType={state.layout.type}>
<ChartPublishedInner
dataSource={dataSource}
state={state}
chartConfig={getChartConfig(state)}
configKey={configKey}
/>
</ChartWrapper>
</ChartTablePreviewProvider>
</>
)}
</InteractiveFiltersProvider>
) : (
<InteractiveFiltersProvider chartConfigs={state.chartConfigs}>
<Flex
sx={{
flexDirection: "column",
mb:
state.layout.meta.title[locale] ||
state.layout.meta.description[locale]
? 4
: 0,
}}
>
{state.layout.meta.title[locale] && (
<Title text={state.layout.meta.title[locale]} />
)}
{state.layout.meta.description[locale] && (
<Description text={state.layout.meta.description[locale]} />
)}
</Flex>
<ChartTablePreviewProvider>
<ChartWrapper layoutType={state.layout.type}>
<ChartPublishedInner
dataSource={dataSource}
state={state}
chartConfig={getChartConfig(state)}
configKey={configKey}
/>
</ChartWrapper>
</ChartTablePreviewProvider>
</InteractiveFiltersProvider>
);
};

Expand Down

0 comments on commit 90367c1

Please sign in to comment.