From 72c0b81994d28f3983c2d21d662bd025653054fa Mon Sep 17 00:00:00 2001 From: Henry Liu <645599166@qq.com> Date: Fri, 25 Oct 2024 04:49:39 +0800 Subject: [PATCH] [Dashboard] show fullscreen mode when url has fullScreenMode param (#196275) ## Summary Closes #174561 Show fullscreen mode when url has fullScreenMode param `&_a=(fullScreenMode:!t)` ### Screenshot ![20241015-184503](https://github.com/user-attachments/assets/fae01dcc-f081-4314-84f9-3923adc76e5b) --------- Co-authored-by: Elastic Machine Co-authored-by: Hannah Mudge --- .../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);