From bc34449053ee3d4bf12d299e8c40bdfb94e1f995 Mon Sep 17 00:00:00 2001 From: "Qingyang(Abby) Hu" Date: Wed, 5 Jul 2023 12:33:00 -0700 Subject: [PATCH] [Dashboard De-Angular] Fix remaining functional test (#4496) * fix dashboard state function test in group 4 Signed-off-by: abbyhu2000 * fix expanding panel Signed-off-by: abbyhu2000 --------- Signed-off-by: abbyhu2000 --- .../public/application/components/dashboard_editor.tsx | 1 + .../public/application/components/dashboard_top_nav.tsx | 4 ++++ .../application/embeddable/grid/_dashboard_grid.scss | 3 ++- .../public/application/embeddable/grid/dashboard_grid.tsx | 1 + .../dashboard/public/application/lib/save_dashboard.ts | 1 + .../dashboard/public/application/utils/get_nav_actions.tsx | 7 ++++++- 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/plugins/dashboard/public/application/components/dashboard_editor.tsx b/src/plugins/dashboard/public/application/components/dashboard_editor.tsx index 76ffa0479e7a..b6a52a9250c6 100644 --- a/src/plugins/dashboard/public/application/components/dashboard_editor.tsx +++ b/src/plugins/dashboard/public/application/components/dashboard_editor.tsx @@ -112,6 +112,7 @@ export const DashboardEditor = () => { isEmbeddableRendered={isEmbeddableRendered} indexPatterns={indexPatterns} dashboardContainer={dashboardContainer} + dashboardIdFromUrl={dashboardIdFromUrl} /> )} diff --git a/src/plugins/dashboard/public/application/components/dashboard_top_nav.tsx b/src/plugins/dashboard/public/application/components/dashboard_top_nav.tsx index 3282dad1f3cf..2d37676a5c37 100644 --- a/src/plugins/dashboard/public/application/components/dashboard_top_nav.tsx +++ b/src/plugins/dashboard/public/application/components/dashboard_top_nav.tsx @@ -23,6 +23,7 @@ interface DashboardTopNavProps { isEmbeddableRendered: boolean; indexPatterns: IndexPattern[]; dashboardContainer?: DashboardContainer; + dashboardIdFromUrl?: string; } export enum UrlParams { @@ -42,6 +43,7 @@ const TopNav = ({ isEmbeddableRendered, dashboardContainer, indexPatterns, + dashboardIdFromUrl, }: DashboardTopNavProps) => { const [topNavMenu, setTopNavMenu] = useState(); const [isFullScreenMode, setIsFullScreenMode] = useState(); @@ -80,6 +82,7 @@ const TopNav = ({ savedDashboardInstance, services, dashboard, + dashboardIdFromUrl, dashboardContainer ); setTopNavMenu( @@ -99,6 +102,7 @@ const TopNav = ({ stateContainer, isEmbeddableRendered, dashboard, + dashboardIdFromUrl ]); useEffect(() => { diff --git a/src/plugins/dashboard/public/application/embeddable/grid/_dashboard_grid.scss b/src/plugins/dashboard/public/application/embeddable/grid/_dashboard_grid.scss index 7259ab9d9f66..c7f801102cad 100644 --- a/src/plugins/dashboard/public/application/embeddable/grid/_dashboard_grid.scss +++ b/src/plugins/dashboard/public/application/embeddable/grid/_dashboard_grid.scss @@ -81,7 +81,8 @@ &:hover, &:focus { - background-color: $embEditingModeHoverColor; + // TODO: this is a sass error, $embEditingModeHoverColor is undefined, comment it out for now + //background-color: $embEditingModeHoverColor; } } diff --git a/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.tsx b/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.tsx index e49999383712..633c4f7428c2 100644 --- a/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.tsx +++ b/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.tsx @@ -30,6 +30,7 @@ import 'react-grid-layout/css/styles.css'; import 'react-resizable/css/styles.css'; +import './_dashboard_grid.scss' // @ts-ignore import sizeMe from 'react-sizeme'; diff --git a/src/plugins/dashboard/public/application/lib/save_dashboard.ts b/src/plugins/dashboard/public/application/lib/save_dashboard.ts index 871c8d62b286..4887707e12be 100644 --- a/src/plugins/dashboard/public/application/lib/save_dashboard.ts +++ b/src/plugins/dashboard/public/application/lib/save_dashboard.ts @@ -51,6 +51,7 @@ export function saveDashboard( updateSavedDashboard(savedDashboard, appState, timeFilter, dashboard); + // TODO: should update Dashboard class in the if(id) block return savedDashboard.save(saveOptions).then((id: string) => { if (id) { return id; diff --git a/src/plugins/dashboard/public/application/utils/get_nav_actions.tsx b/src/plugins/dashboard/public/application/utils/get_nav_actions.tsx index da0b7da7a8c5..649f86cd93b1 100644 --- a/src/plugins/dashboard/public/application/utils/get_nav_actions.tsx +++ b/src/plugins/dashboard/public/application/utils/get_nav_actions.tsx @@ -48,6 +48,7 @@ export const getNavActions = ( savedDashboard: any, services: DashboardServices, dashboard: Dashboard, + dashboardIdFromUrl?: string, dashboardContainer?: DashboardContainer ) => { const { @@ -390,7 +391,11 @@ export const getNavActions = ( 'data-test-subj': 'saveDashboardSuccess', }); - chrome.docTitle.change(savedDashboard.lastSavedTitle); + if (id !== dashboardIdFromUrl) { + history.replace(createDashboardEditUrl(id)); + } + + chrome.docTitle.change(savedDashboard.title); stateContainer.transitions.set('viewMode', ViewMode.VIEW); } return { id };