From b769f0fed881038348eb7ccc6d2fd03790a0fb21 Mon Sep 17 00:00:00 2001 From: abbyhu2000 Date: Tue, 4 Jul 2023 23:11:48 +0000 Subject: [PATCH 1/2] fix dashboard state function test in group 4 Signed-off-by: abbyhu2000 --- .../public/application/components/dashboard_editor.tsx | 1 + .../public/application/components/dashboard_top_nav.tsx | 4 ++++ .../dashboard/public/application/lib/save_dashboard.ts | 1 + .../dashboard/public/application/utils/get_nav_actions.tsx | 7 ++++++- 4 files changed, 12 insertions(+), 1 deletion(-) 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/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 }; From 70a3b2704493bd1e32617c29414379015ca2bd6b Mon Sep 17 00:00:00 2001 From: abbyhu2000 Date: Wed, 5 Jul 2023 00:01:00 +0000 Subject: [PATCH 2/2] fix expanding panel Signed-off-by: abbyhu2000 --- .../public/application/embeddable/grid/_dashboard_grid.scss | 3 ++- .../public/application/embeddable/grid/dashboard_grid.tsx | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) 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';