Skip to content

Commit 05e7e30

Browse files
committed
fix: fix placeholder layout and missing case when authentication failed
1 parent ad89855 commit 05e7e30

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/charts/DashboardPlaceholder/useDashboardPlaceholder.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@ const DEFAULT_LABELS = {
1414
inProgress: { label: 'Scenario run in progress...' },
1515
hasErrors: { label: 'An error occured during the scenario run' },
1616
hasUnknownStatus: {
17-
label: 'This scenario has an unknown state, if the problem persists, please, contact your administrator',
17+
label: 'This scenario has an unknown state. If the problem persists, please contact your administrator.',
1818
},
1919
resultsDisplayDisabled: 'Display of results is disabled',
2020
downloadButton: 'Download logs',
21-
errors: {
22-
unknown: 'Unknown error',
23-
details: 'Something went wrong when fetching PowerBI reports info',
24-
},
21+
noTokenForBI: 'Authentication failed. If the problem persists, please contact your administrator.',
2522
};
2623

2724
const forgeDashboardPlaceholder = ({
@@ -32,6 +29,7 @@ const forgeDashboardPlaceholder = ({
3229
labels: tmpLabels,
3330
scenario,
3431
scenarioDTO,
32+
hasTokenForBI,
3533
}) => {
3634
const labels = { ...DEFAULT_LABELS, ...tmpLabels };
3735

@@ -44,21 +42,20 @@ const forgeDashboardPlaceholder = ({
4442

4543
if (alwaysShowReports && !disabled) return null;
4644
if (noScenario) return <DashboardPlaceholderLayout label={labels.noScenario.label} title={labels.noScenario.title} />;
47-
if (noRun) return <DashboardPlaceholderLayout label={labels.noRun.label} title={labels.noRun.title} />;
48-
if (runInProgress)
49-
return <DashboardPlaceholderLayout label={labels.inProgress.label} title={labels.inProgress.title} inProgress />;
45+
if (noRun) return <DashboardPlaceholderLayout label={labels.noRun.label} />;
46+
if (runInProgress) return <DashboardPlaceholderLayout label={labels.inProgress.label} inProgress />;
5047
if (hasError)
5148
return (
5249
<DashboardPlaceholderLayout
5350
label={labels.hasErrors.label}
54-
title={labels.hasErrors.title}
5551
downloadLogsFile={downloadLogsFile}
5652
downloadLabel={labels.downloadButton}
5753
/>
5854
);
5955
if (hasUnknownStatus) return <DashboardPlaceholderLayout label={labels.hasUnknownStatus.label} />;
6056
if (disabled) return <DashboardPlaceholderLayout label={labels.resultsDisplayDisabled} />;
6157
if (noDashboardConfigured) return <DashboardPlaceholderLayout label={labels.noDashboard.label} />;
58+
if (!hasTokenForBI) return <DashboardPlaceholderLayout label={labels.noTokenForBI} />;
6259
return null;
6360
};
6461

src/charts/PowerBIReport/PowerBIReport.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const PowerBIReport = ({
9292
);
9393

9494
const disabled = useMemo(() => reports?.status === 'DISABLED', [reports]);
95+
const hasTokenFetchFailed = useMemo(() => reports?.status === 'ERROR', [reports]);
9596
const { placeholder } = useMemo(() => {
9697
return getDashboardPlaceholder({
9798
alwaysShowReports,
@@ -101,11 +102,13 @@ export const PowerBIReport = ({
101102
scenario,
102103
scenarioDTO,
103104
labels,
105+
hasTokenForBI: embedConfig?.accessToken != null && embedConfig.accessToken.length > 0,
104106
});
105107
}, [
108+
disabled,
109+
embedConfig.accessToken,
106110
getDashboardPlaceholder,
107111
alwaysShowReports,
108-
reports,
109112
downloadLogsFile,
110113
reportConfiguration,
111114
index,
@@ -175,7 +178,7 @@ export const PowerBIReport = ({
175178
(scenarioLastRunStatus === undefined || scenarioLastRunStatus === RUNNER_RUN_STATE.SUCCESSFUL) && !noScenario;
176179

177180
const divContainerStyle = {};
178-
if (disabled || (!isReady && !alwaysShowReports)) {
181+
if (disabled || hasTokenFetchFailed || (!isReady && !alwaysShowReports)) {
179182
divContainerStyle.display = 'none';
180183
}
181184

@@ -330,6 +333,7 @@ PowerBIReport.propTypes = {
330333
label: PropTypes.string,
331334
}),
332335
resultsDisplayDisabled: PropTypes.string,
336+
noTokenForBI: PropTypes.string,
333337
downloadButton: PropTypes.string.isRequired,
334338
refreshTooltip: PropTypes.string.isRequired,
335339
errors: PropTypes.shape({

src/charts/SupersetReport/SupersetReport.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ export const SupersetReport = ({
9191
scenario,
9292
scenarioDTO,
9393
labels,
94+
hasTokenForBI: guestToken?.status === SUPERSET_GUEST_TOKEN_STATUS.SUCCESS,
9495
});
9596
}, [
97+
guestToken?.status,
9698
getDashboardPlaceholder,
9799
alwaysShowReports,
98100
disabled,

0 commit comments

Comments
 (0)