Skip to content

Commit 43c9463

Browse files
authored
Fixed issues where cross database dashboard sharing always reverted back to the default database (#873)
* Fixed issues where cross database dashboard sharing always reverted back to the default database * Fix code smell from SonarQube
1 parent 308afde commit 43c9463

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/application/ApplicationActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export const setStandaloneEnabled = (
178178

179179
export const SET_STANDALONE_MODE = 'APPLICATION/SET_STANDALONE_MODE';
180180
export const setStandaloneMode = (standalone: boolean) => ({
181-
type: SET_STANDALONE_ENABLED,
181+
type: SET_STANDALONE_MODE,
182182
payload: { standalone },
183183
});
184184

src/application/ApplicationThunks.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,10 @@ export const handleSharedDashboardsThunk = () => (dispatch: any) => {
259259
const skipConfirmation = urlParams.get('skipConfirmation') == 'Yes';
260260

261261
const dashboardDatabase = urlParams.get('dashboardDatabase');
262-
dispatch(setStandaloneDashboardDatabase(dashboardDatabase));
262+
if (dashboardDatabase) {
263+
dispatch(setStandaloneDashboardDatabase(dashboardDatabase));
264+
}
265+
263266
if (urlParams.get('credentials')) {
264267
setWelcomeScreenOpen(false);
265268
const connection = decodeURIComponent(urlParams.get('credentials'));
@@ -363,6 +366,8 @@ export const onConfirmLoadSharedDashboardThunk = () => (dispatch: any, getState:
363366

364367
if (shareDetails.dashboardDatabase) {
365368
dispatch(setStandaloneDashboardDatabase(shareDetails.dashboardDatabase));
369+
} else if (!state.application.standaloneDashboardDatabase) {
370+
// No standalone dashboard database configured, fall back to default
366371
dispatch(setStandaloneDashboardDatabase(shareDetails.database));
367372
}
368373
if (shareDetails.url) {
@@ -452,6 +457,9 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
452457
dispatch(setSSOProviders(config.ssoProviders));
453458

454459
const { standalone } = config;
460+
// if a dashboard database was previously set, remember to use it.
461+
const dashboardDatabase = state.application.standaloneDashboardDatabase;
462+
455463
dispatch(
456464
setStandaloneEnabled(
457465
standalone,
@@ -460,7 +468,7 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
460468
config.standalonePort,
461469
config.standaloneDatabase,
462470
config.standaloneDashboardName,
463-
config.standaloneDashboardDatabase,
471+
dashboardDatabase || config.standaloneDashboardDatabase,
464472
config.standaloneDashboardURL,
465473
config.standaloneUsername,
466474
config.standalonePassword,

0 commit comments

Comments
 (0)