Skip to content

Commit 248621f

Browse files
committed
fix: fix app crash when no dashboard for a run template and add unknownScenario placeholder
1 parent f618a45 commit 248621f

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/charts/SimplePowerBIReportEmbed/SimplePowerBIReportEmbed.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export const SimplePowerBIReportEmbed = ({
107107
useAAD,
108108
iframeRatio,
109109
}) => {
110-
const { reportId, settings, staticFilters, dynamicFilters, pageName } = reportConfiguration[index];
110+
const { reportId, settings, staticFilters, dynamicFilters, pageName } = reportConfiguration[index] || {};
111111
const hasNavContentPane = settings?.navContentPaneEnabled;
112112
const iframeHeightOffset = hasNavContentPane ? '35px' : '0px';
113113
const classes = useStyles({ hasNavContentPane });
@@ -130,12 +130,14 @@ export const SimplePowerBIReportEmbed = ({
130130
() => PowerBIUtils.constructDynamicFilters(dynamicFilters, scenarioDTO),
131131
[dynamicFilters, scenarioDTO]
132132
);
133+
const noDashboardConfigured = reportConfiguration[index] === undefined;
133134
const noScenario = scenario === null;
134135
const scenarioState = noScenario ? 'Created' : scenarioDTO.state;
135136
const noRun = scenarioState === 'Created' || scenarioState === null;
136137
const runInProgress = scenarioState === 'Running';
137138
const hasError = scenarioState === 'Failed';
138139
const isReady = (scenarioState === undefined || scenarioState === 'Successful') && !noScenario;
140+
const hasUnknownStatus = scenarioState === 'Unknown';
139141

140142
useEffect(() => {
141143
const newConfig = {
@@ -193,6 +195,7 @@ export const SimplePowerBIReportEmbed = ({
193195
<div className={classes.errorTitle}>{errorCode}</div>
194196
<div className={classes.errorDescription}>{errorDescription}</div>
195197
</div>
198+
{noDashboardConfigured && <DashboardPlaceholder label={labels.noDashboard.label} />}
196199
{noScenario && <DashboardPlaceholder label={labels.noScenario.label} title={labels.noScenario.title} />}
197200
{!noScenario && noRun && !alwaysShowReports && (
198201
<DashboardPlaceholder label={labels.noRun.label} title={labels.noRun.title} />
@@ -212,6 +215,7 @@ export const SimplePowerBIReportEmbed = ({
212215
downloadLabel={labels.downloadButton}
213216
/>
214217
)}
218+
{hasUnknownStatus && <DashboardPlaceholder label={labels.hasUnknownStatus.label} />}
215219
<div className={classes.divContainer} style={!isReady && !alwaysShowReports ? { display: 'none' } : {}}>
216220
{refreshable && (
217221
<div className={classes.toolbar}>
@@ -311,6 +315,10 @@ SimplePowerBIReportEmbed.propTypes = {
311315
title: PropTypes.string,
312316
label: PropTypes.string.isRequired,
313317
}).isRequired,
318+
noDashboard: PropTypes.shape({
319+
title: PropTypes.string,
320+
label: PropTypes.string,
321+
}),
314322
noRun: PropTypes.shape({
315323
title: PropTypes.string,
316324
label: PropTypes.string.isRequired,
@@ -323,6 +331,10 @@ SimplePowerBIReportEmbed.propTypes = {
323331
title: PropTypes.string,
324332
label: PropTypes.string.isRequired,
325333
}).isRequired,
334+
hasUnknownStatus: PropTypes.shape({
335+
title: PropTypes.string,
336+
label: PropTypes.string,
337+
}),
326338
downloadButton: PropTypes.string.isRequired,
327339
refreshTooltip: PropTypes.string.isRequired,
328340
errors: PropTypes.shape({
@@ -342,6 +354,9 @@ SimplePowerBIReportEmbed.defaultProps = {
342354
title: 'No scenario yet',
343355
label: 'You can create a scenario by clicking on Create new scenario',
344356
},
357+
noDashboard: {
358+
label: "There isn't any dashboard configured for this run template",
359+
},
345360
noRun: {
346361
label: 'The scenario has not been run yet',
347362
},
@@ -351,6 +366,9 @@ SimplePowerBIReportEmbed.defaultProps = {
351366
hasErrors: {
352367
label: 'An error occured during the scenario run',
353368
},
369+
hasUnknownStatus: {
370+
label: 'This scenario has an unknown state, if the problem persists, please, contact your administrator',
371+
},
354372
downloadButton: 'Download logs',
355373
refreshTooltip: 'Refresh',
356374
errors: {

0 commit comments

Comments
 (0)