Skip to content

Commit 0f6a6b2

Browse files
committed
fix: fix initialization of Superset embedded dashboard
1 parent adeb17e commit 0f6a6b2

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/charts/SupersetReport/SupersetReport.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export const SupersetReport = ({
3434
if (!report?.id || !options?.supersetUrl) return;
3535

3636
const loadSuperset = async () => {
37+
if (isEmbedded || guestToken === '') return;
38+
3739
try {
3840
const embedded = await embedDashboard({
3941
id: report.id,
@@ -60,7 +62,7 @@ export const SupersetReport = ({
6062
if (dashboard?.destroy) dashboard.destroy();
6163
};
6264
// eslint-disable-next-line react-hooks/exhaustive-deps
63-
}, [report.id, options.supersetUrl]);
65+
}, [report.id, options.supersetUrl, guestToken]);
6466

6567
const placeholder = useMemo(() => {
6668
const scenarioDTO = PowerBIUtils.constructScenarioDTO(scenario, visibleScenarios);
@@ -78,7 +80,8 @@ export const SupersetReport = ({
7880
}, [alwaysShowReports, disabled, downloadLogsFile, report, scenario, visibleScenarios, labels]);
7981

8082
const isReportVisible = isEmbedded && placeholder == null;
81-
const display = isReportVisible ? undefined : 'none';
83+
const reportContainerDisplay = isReportVisible ? undefined : 'none';
84+
const showLoadingSpinner = placeholder == null && (isLoading || !isEmbedded)
8285
return (
8386
<Box
8487
sx={{
@@ -90,10 +93,17 @@ export const SupersetReport = ({
9093
}}
9194
>
9295
{placeholder}
93-
<Backdrop open={isLoading || !isEmbedded} sx={{ color: '#fff', zIndex: (theme) => theme.zIndex.drawer + 1 }}>
96+
<Backdrop
97+
open={showLoadingSpinner}
98+
sx={{ position: 'absolute', color: '#fff', zIndex: (theme) => theme.zIndex.drawer + 1 }}
99+
>
94100
<CircularProgress color="inherit" sx={{ position: 'absolute' }} />
95101
</Backdrop>
96-
<Box data-cy="superset-report-container" ref={containerRef} sx={{ width: '100%', height: '100%', display }} />
102+
<Box
103+
data-cy="superset-report-container"
104+
ref={containerRef}
105+
sx={{ width: '100%', height: '100%', display: reportContainerDisplay }}
106+
/>
97107
</Box>
98108
);
99109
};

0 commit comments

Comments
 (0)