From 97de35be00d67ab59cd8b4e41907ec2fc2eb0927 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 25 Oct 2024 09:55:50 +1100 Subject: [PATCH] [8.x] [Dashboard] show fullscreen mode when url has fullScreenMode param (#196275) (#197729) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Backport This will backport the following commits from `main` to `8.x`: - [[Dashboard] show fullscreen mode when url has fullScreenMode param (#196275)](https://github.com/elastic/kibana/pull/196275) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Henry Liu <645599166@qq.com> --- .../dashboard/public/dashboard_api/get_dashboard_api.ts | 3 ++- src/plugins/dashboard/public/dashboard_api/types.ts | 1 + .../dashboard/public/dashboard_app/dashboard_app.tsx | 3 +++ .../embeddable/create/create_dashboard.ts | 1 + .../embeddable/dashboard_container.test.tsx | 1 + .../dashboard_container/embeddable/dashboard_container.tsx | 1 + .../dashboard_top_nav/internal_dashboard_top_nav.tsx | 7 ------- src/plugins/dashboard/public/mocks.tsx | 1 + 8 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/plugins/dashboard/public/dashboard_api/get_dashboard_api.ts b/src/plugins/dashboard/public/dashboard_api/get_dashboard_api.ts index 3db6129c7c6f9..2af37846eecdb 100644 --- a/src/plugins/dashboard/public/dashboard_api/get_dashboard_api.ts +++ b/src/plugins/dashboard/public/dashboard_api/get_dashboard_api.ts @@ -19,6 +19,7 @@ export interface InitialComponentState { lastSavedInput: DashboardContainerInput; lastSavedId: string | undefined; managed: boolean; + fullScreenMode: boolean; } export function getDashboardApi( @@ -26,7 +27,7 @@ export function getDashboardApi( untilEmbeddableLoaded: (id: string) => Promise ) { const animatePanelTransforms$ = new BehaviorSubject(false); // set panel transforms to false initially to avoid panels animating on initial render. - const fullScreenMode$ = new BehaviorSubject(false); + const fullScreenMode$ = new BehaviorSubject(initialComponentState.fullScreenMode); const managed$ = new BehaviorSubject(initialComponentState.managed); const savedObjectId$ = new BehaviorSubject(initialComponentState.lastSavedId); diff --git a/src/plugins/dashboard/public/dashboard_api/types.ts b/src/plugins/dashboard/public/dashboard_api/types.ts index e0b6b8d3e4824..ec89a93dcd66e 100644 --- a/src/plugins/dashboard/public/dashboard_api/types.ts +++ b/src/plugins/dashboard/public/dashboard_api/types.ts @@ -68,6 +68,7 @@ export interface DashboardCreationOptions { validateLoadedSavedObject?: (result: LoadDashboardReturn) => 'valid' | 'invalid' | 'redirected'; + fullScreenMode?: boolean; isEmbeddedExternally?: boolean; getEmbeddableAppContext?: (dashboardId?: string) => EmbeddableAppContext; diff --git a/src/plugins/dashboard/public/dashboard_app/dashboard_app.tsx b/src/plugins/dashboard/public/dashboard_app/dashboard_app.tsx index f7ca6b552893b..400d56e97df09 100644 --- a/src/plugins/dashboard/public/dashboard_app/dashboard_app.tsx +++ b/src/plugins/dashboard/public/dashboard_app/dashboard_app.tsx @@ -157,6 +157,9 @@ export function DashboardApp({ }, getInitialInput, validateLoadedSavedObject: validateOutcome, + fullScreenMode: + kbnUrlStateStorage.get<{ fullScreenMode?: boolean }>(DASHBOARD_STATE_STORAGE_KEY) + ?.fullScreenMode ?? false, isEmbeddedExternally: Boolean(embedSettings), // embed settings are only sent if the dashboard URL has `embed=true` getEmbeddableAppContext: (dashboardId) => ({ currentAppId: DASHBOARD_APP_ID, diff --git a/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts b/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts index 3eab6c641ee87..2510f2e015dfb 100644 --- a/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts +++ b/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts @@ -110,6 +110,7 @@ export const createDashboard = async ( }, lastSavedId: savedObjectId, managed: savedObjectResult.managed ?? false, + fullScreenMode: creationOptions?.fullScreenMode ?? false, }; const dashboardContainer = new DashboardContainer( diff --git a/src/plugins/dashboard/public/dashboard_container/embeddable/dashboard_container.test.tsx b/src/plugins/dashboard/public/dashboard_container/embeddable/dashboard_container.test.tsx index 4805c890f5e95..167ee26055166 100644 --- a/src/plugins/dashboard/public/dashboard_container/embeddable/dashboard_container.test.tsx +++ b/src/plugins/dashboard/public/dashboard_container/embeddable/dashboard_container.test.tsx @@ -178,6 +178,7 @@ test('searchSessionId propagates to children', async () => { lastSavedInput: sampleInput, lastSavedId: undefined, managed: false, + fullScreenMode: false, } ); container?.setControlGroupApi(mockControlGroupApi); diff --git a/src/plugins/dashboard/public/dashboard_container/embeddable/dashboard_container.tsx b/src/plugins/dashboard/public/dashboard_container/embeddable/dashboard_container.tsx index e508e511d41cb..a6765732c064c 100644 --- a/src/plugins/dashboard/public/dashboard_container/embeddable/dashboard_container.tsx +++ b/src/plugins/dashboard/public/dashboard_container/embeddable/dashboard_container.tsx @@ -314,6 +314,7 @@ export class DashboardContainer isEmbeddedExternally: false, lastSavedInput: initialInput, lastSavedId: undefined, + fullScreenMode: false, managed: false, }, (id: string) => this.untilEmbeddableLoaded(id) diff --git a/src/plugins/dashboard/public/dashboard_top_nav/internal_dashboard_top_nav.tsx b/src/plugins/dashboard/public/dashboard_top_nav/internal_dashboard_top_nav.tsx index 6ca2298272c08..bf2be799dcc1f 100644 --- a/src/plugins/dashboard/public/dashboard_top_nav/internal_dashboard_top_nav.tsx +++ b/src/plugins/dashboard/public/dashboard_top_nav/internal_dashboard_top_nav.tsx @@ -123,13 +123,6 @@ export function InternalDashboardTopNav({ dashboardTitleRef.current?.focus(); }, [title, viewMode]); - /** - * Manage chrome visibility when dashboard is embedded. - */ - useEffect(() => { - if (!embedSettings) coreServices.chrome.setIsVisible(viewMode !== 'print'); - }, [embedSettings, viewMode]); - /** * populate recently accessed, and set is chrome visible. */ diff --git a/src/plugins/dashboard/public/mocks.tsx b/src/plugins/dashboard/public/mocks.tsx index 17081084d5dec..2374788e60ea8 100644 --- a/src/plugins/dashboard/public/mocks.tsx +++ b/src/plugins/dashboard/public/mocks.tsx @@ -99,6 +99,7 @@ export function buildMockDashboard({ lastSavedInput: initialInput, lastSavedId: savedObjectId, managed: false, + fullScreenMode: false, } ); dashboardContainer?.setControlGroupApi(mockControlGroupApi);