From fc570f3b336643fb47bdd9b613d490db6de9669e Mon Sep 17 00:00:00 2001 From: SuZhou-Joe Date: Wed, 20 Mar 2024 13:41:40 +0800 Subject: [PATCH] feat: jump to landing page Signed-off-by: SuZhou-Joe --- .../workspace_fatal_error.test.tsx.snap | 8 ++++---- .../workspace_fatal_error.test.tsx | 4 ++-- .../workspace_fatal_error/workspace_fatal_error.tsx | 13 +++++-------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/plugins/workspace/public/components/workspace_fatal_error/__snapshots__/workspace_fatal_error.test.tsx.snap b/src/plugins/workspace/public/components/workspace_fatal_error/__snapshots__/workspace_fatal_error.test.tsx.snap index 594066e959f7..01403b9bc33c 100644 --- a/src/plugins/workspace/public/components/workspace_fatal_error/__snapshots__/workspace_fatal_error.test.tsx.snap +++ b/src/plugins/workspace/public/components/workspace_fatal_error/__snapshots__/workspace_fatal_error.test.tsx.snap @@ -41,7 +41,7 @@ exports[` render error with callout 1`] = ` >

- The workspace you want to go can not be found, try go back to home. + The workspace you are trying to access cannot be found. Please return to the homepage and try again.

@@ -66,7 +66,7 @@ exports[` render error with callout 1`] = ` class="euiButton__text" > - Go back to home + Go back to homepage @@ -140,7 +140,7 @@ exports[` render normally 1`] = ` >

- The workspace you want to go can not be found, try go back to home. + The workspace you are trying to access cannot be found. Please return to the homepage and try again.

@@ -165,7 +165,7 @@ exports[` render normally 1`] = ` class="euiButton__text" > - Go back to home + Go back to homepage diff --git a/src/plugins/workspace/public/components/workspace_fatal_error/workspace_fatal_error.test.tsx b/src/plugins/workspace/public/components/workspace_fatal_error/workspace_fatal_error.test.tsx index d98e0063dcfa..11b229c9ccac 100644 --- a/src/plugins/workspace/public/components/workspace_fatal_error/workspace_fatal_error.test.tsx +++ b/src/plugins/workspace/public/components/workspace_fatal_error/workspace_fatal_error.test.tsx @@ -31,7 +31,7 @@ describe('', () => { expect(container).toMatchSnapshot(); }); - it('click go back to home', async () => { + it('click go back to homepage', async () => { const { location } = window; const setHrefSpy = jest.fn((href) => href); if (window.location) { @@ -57,7 +57,7 @@ describe('', () => { ); - fireEvent.click(getByText('Go back to home')); + fireEvent.click(getByText('Go back to homepage')); await waitFor( () => { expect(setHrefSpy).toBeCalledTimes(1); diff --git a/src/plugins/workspace/public/components/workspace_fatal_error/workspace_fatal_error.tsx b/src/plugins/workspace/public/components/workspace_fatal_error/workspace_fatal_error.tsx index 42cdf4df51a0..604dec277553 100644 --- a/src/plugins/workspace/public/components/workspace_fatal_error/workspace_fatal_error.tsx +++ b/src/plugins/workspace/public/components/workspace_fatal_error/workspace_fatal_error.tsx @@ -13,20 +13,17 @@ import { } from '@elastic/eui'; import React from 'react'; import { FormattedMessage } from '@osd/i18n/react'; -import { IBasePath } from 'opensearch-dashboards/public'; +import { HttpSetup } from 'opensearch-dashboards/public'; import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public'; -import { formatUrlWithWorkspaceId } from '../../../../../core/public/utils'; export function WorkspaceFatalError(props: { error?: string }) { const { - services: { application, http }, + services: { http }, } = useOpenSearchDashboards(); const goBackToHome = () => { - window.location.href = formatUrlWithWorkspaceId( - application?.getUrlForApp('home') || '', - '', - http?.basePath as IBasePath - ); + window.location.href = (http as HttpSetup).basePath.prepend('/', { + withoutClientBasePath: true, + }); }; return (