Skip to content

Commit ad89855

Browse files
committed
fix: fix placeholder and refresh button visibility in BI reports
1 parent ec98206 commit ad89855

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/charts/DashboardPlaceholder/useDashboardPlaceholder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const forgeDashboardPlaceholder = ({
4242
const hasError = scenarioLastRunStatus === RUNNER_RUN_STATE.FAILED;
4343
const hasUnknownStatus = scenarioLastRunStatus === RUNNER_RUN_STATE.UNKNOWN;
4444

45-
if (alwaysShowReports) return null;
45+
if (alwaysShowReports && !disabled) return null;
4646
if (noScenario) return <DashboardPlaceholderLayout label={labels.noScenario.label} title={labels.noScenario.title} />;
4747
if (noRun) return <DashboardPlaceholderLayout label={labels.noRun.label} title={labels.noRun.title} />;
4848
if (runInProgress)

src/charts/PowerBIReport/PowerBIReport.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const PowerBIReport = ({
7070
const tokenType = useAAD ? 0 : 1;
7171
// PowerBI Report object (received via callback)
7272
const [report, setReport] = useState();
73-
const [disabled, setDisabled] = useState(false);
73+
const [canTriggerRefresh, setCanTriggerRefresh] = useState(true);
7474
const [embedConfig, setEmbedConfig] = useState({
7575
type: 'report',
7676
id: reportId,
@@ -91,10 +91,11 @@ export const PowerBIReport = ({
9191
[dynamicFilters, scenarioDTO]
9292
);
9393

94+
const disabled = useMemo(() => reports?.status === 'DISABLED', [reports]);
9495
const { placeholder } = useMemo(() => {
9596
return getDashboardPlaceholder({
9697
alwaysShowReports,
97-
disabled: reports?.status === 'DISABLED',
98+
disabled,
9899
downloadLogsFile,
99100
noDashboardConfigured: reportConfiguration[index] == null,
100101
scenario,
@@ -140,10 +141,8 @@ export const PowerBIReport = ({
140141
report.refresh();
141142

142143
if (triggerTimeout) {
143-
setDisabled(true);
144-
setTimeout(() => {
145-
setDisabled(false);
146-
}, refreshTimeout);
144+
setCanTriggerRefresh(false);
145+
setTimeout(() => setCanTriggerRefresh(true), refreshTimeout);
147146
}
148147
},
149148
[refreshTimeout, report]
@@ -164,7 +163,7 @@ export const PowerBIReport = ({
164163
<PowerBIEmbed cssClassName={classes.report} embedConfig={embedConfig} getEmbeddedComponent={setReport} />
165164
);
166165
} catch (error) {
167-
console.log('Error when intializing the PowerBIEmbed component.');
166+
console.log('Error when initializing the PowerBIEmbed component.');
168167
console.error(error);
169168
return null;
170169
}
@@ -176,7 +175,7 @@ export const PowerBIReport = ({
176175
(scenarioLastRunStatus === undefined || scenarioLastRunStatus === RUNNER_RUN_STATE.SUCCESSFUL) && !noScenario;
177176

178177
const divContainerStyle = {};
179-
if (!isReady && !alwaysShowReports) {
178+
if (disabled || (!isReady && !alwaysShowReports)) {
180179
divContainerStyle.display = 'none';
181180
}
182181

@@ -195,7 +194,7 @@ export const PowerBIReport = ({
195194
<FadingTooltip title={labels.refreshTooltip}>
196195
<IconButton
197196
aria-label="refresh"
198-
disabled={!report || disabled}
197+
disabled={!report || !canTriggerRefresh}
199198
color="primary"
200199
onClick={refreshReport}
201200
size="large"

0 commit comments

Comments
 (0)