Skip to content

Commit

Permalink
Don't use LegacyURI Redirect if in screenshot mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey Robertson committed Sep 14, 2021
1 parent d98ad63 commit 33e8fdb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/plugins/dashboard/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
"presentationUtil",
"visualizations"
],
"optionalPlugins": ["home", "spaces", "savedObjectsTaggingOss", "usageCollection"],
"optionalPlugins": [
"home",
"spaces",
"savedObjectsTaggingOss",
"screenshotMode",
"usageCollection"
],
"server": true,
"ui": true,
"requiredBundles": ["home", "kibanaReact", "kibanaUtils", "presentationUtil"]
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/dashboard/public/application/dashboard_router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export async function mountApp({
savedObjectsTaggingOss,
visualizations,
presentationUtil,
screenshotMode,
} = pluginsStart;

const activeSpaceId =
Expand Down Expand Up @@ -130,6 +131,7 @@ export async function mountApp({
activeSpaceId || 'default'
),
spacesService: spacesApi,
screenshotModeService: screenshotMode,
};

const getUrlStateStorage = (history: RouteComponentProps['history']) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const useDashboardAppState = ({
dashboardSessionStorage,
scopedHistory,
spacesService,
screenshotModeService,
} = services;
const { docTitle } = chrome;
const { notifications } = core;
Expand Down Expand Up @@ -151,7 +152,11 @@ export const useDashboardAppState = ({

// If the saved dashboard is an alias match, then we will redirect
if (savedDashboard.outcome === 'aliasMatch') {
spacesService?.ui.redirectLegacyUrl(savedDashboard.getFullPath());
if (screenshotModeService?.isScreenshotMode()) {
scopedHistory().replace(savedDashboard.getFullPath());
} else {
spacesService?.ui.redirectLegacyUrl(savedDashboard.getFullPath());
}
}

/**
Expand Down Expand Up @@ -344,6 +349,7 @@ export const useDashboardAppState = ({
query,
data,
spacesService?.ui,
screenshotModeService,
]);

/**
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/dashboard/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { filter, map } from 'rxjs/operators';

import { Start as InspectorStartContract } from 'src/plugins/inspector/public';
import { UrlForwardingSetup, UrlForwardingStart } from 'src/plugins/url_forwarding/public';
import { ScreenshotModePluginStart } from 'src/plugins/screenshot_mode/public';
import { APP_WRAPPER_CLASS } from '../../../core/public';
import {
App,
Expand Down Expand Up @@ -118,6 +119,7 @@ export interface DashboardStartDependencies {
savedObjects: SavedObjectsStart;
presentationUtil: PresentationUtilPluginStart;
savedObjectsTaggingOss?: SavedObjectTaggingOssPluginStart;
screenshotMode?: ScreenshotModePluginStart;
spaces?: SpacesPluginStart;
visualizations: VisualizationsStart;
}
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/dashboard/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type {
import { History } from 'history';
import { AnyAction, Dispatch } from 'redux';
import { BehaviorSubject, Subject } from 'rxjs';
import { ScreenshotModePluginStart } from 'src/plugins/screenshot_mode/public';
import { Query, Filter, IndexPattern, RefreshInterval, TimeRange } from './services/data';
import { ContainerInput, EmbeddableInput, ViewMode } from './services/embeddable';
import { SharePluginStart } from './services/share';
Expand Down Expand Up @@ -205,4 +206,5 @@ export interface DashboardAppServices {
setHeaderActionMenu: AppMountParameters['setHeaderActionMenu'];
savedQueryService: DataPublicPluginStart['query']['savedQueries'];
spacesService?: SpacesPluginStart;
screenshotModeService?: ScreenshotModePluginStart;
}

0 comments on commit 33e8fdb

Please sign in to comment.