Skip to content

Commit

Permalink
feat: jump to landing page
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Mar 20, 2024
1 parent 2e9385a commit fc570f3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('<WorkspaceFatalError />', () => {
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) {
Expand All @@ -57,7 +57,7 @@ describe('<WorkspaceFatalError />', () => {
</context.Provider>
</IntlProvider>
);
fireEvent.click(getByText('Go back to home'));
fireEvent.click(getByText('Go back to homepage'));
await waitFor(
() => {
expect(setHrefSpy).toBeCalledTimes(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<EuiPage style={{ minHeight: '100vh' }}>
Expand Down

0 comments on commit fc570f3

Please sign in to comment.