-
Notifications
You must be signed in to change notification settings - Fork 917
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Workspace] search use case overview page (#7877)
* search overview Signed-off-by: Hailong Cui <[email protected]> * add unit test for search use case overview page Signed-off-by: Hailong Cui <[email protected]> * Changeset file for PR #7877 created/updated * fix merge issue Signed-off-by: Hailong Cui <[email protected]> * udpate breadcrumbs for workspace overview page Signed-off-by: Hailong Cui <[email protected]> * fix failed ut Signed-off-by: Hailong Cui <[email protected]> * fix merge issue Signed-off-by: Hailong Cui <[email protected]> * fix ut Signed-off-by: Hailong Cui <[email protected]> --------- Signed-off-by: Hailong Cui <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Co-authored-by: Yulong Ruan <[email protected]> (cherry picked from commit 9697f33) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
999bc05
commit 1a44ce7
Showing
17 changed files
with
664 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feat: | ||
- [Workspace] Add search use case overview page ([#7877](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7877)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/plugins/home/public/application/components/usecase_overview/search_use_case_app.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { coreMock } from '../../../../../../core/public/mocks'; | ||
import { OpenSearchDashboardsContextProvider } from '../../../../../opensearch_dashboards_react/public'; | ||
import { contentManagementPluginMocks } from '../../../../../content_management/public/mocks'; | ||
import { SearchUseCaseOverviewApp } from './search_use_case_app'; | ||
import { ContentManagementPluginStart } from '../../../../../content_management/public'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { WorkspaceObject } from 'opensearch-dashboards/public'; | ||
|
||
describe('<SearchUseCaseOverviewApp />', () => { | ||
const renderPageMock = jest.fn(); | ||
renderPageMock.mockReturnValue('dummy page'); | ||
const mock = { | ||
...contentManagementPluginMocks.createStartContract(), | ||
renderPage: renderPageMock, | ||
}; | ||
const coreStartMocks = coreMock.createStart(); | ||
|
||
function renderSearchUseCaseOverviewApp( | ||
contentManagement: ContentManagementPluginStart, | ||
services = { ...coreStartMocks } | ||
) { | ||
return ( | ||
<OpenSearchDashboardsContextProvider services={services}> | ||
<SearchUseCaseOverviewApp contentManagement={contentManagement} /> | ||
</OpenSearchDashboardsContextProvider> | ||
); | ||
} | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('render for workspace disabled case', () => { | ||
const { container } = render(renderSearchUseCaseOverviewApp(mock, coreStartMocks)); | ||
|
||
expect(container).toMatchInlineSnapshot(` | ||
<div> | ||
dummy page | ||
</div> | ||
`); | ||
|
||
expect(coreStartMocks.chrome.setBreadcrumbs).toHaveBeenCalledWith([ | ||
{ text: 'Search overview' }, | ||
]); | ||
expect(mock.renderPage).toBeCalledWith('search_overview'); | ||
}); | ||
|
||
it('render for workspace enabled case', () => { | ||
const coreStartMocksWithWorkspace = { | ||
...coreStartMocks, | ||
workspaces: { | ||
...coreStartMocks.workspaces, | ||
currentWorkspace$: new BehaviorSubject({ | ||
id: 'foo', | ||
name: 'foo ws', | ||
}), | ||
}, | ||
}; | ||
|
||
const { container } = render(renderSearchUseCaseOverviewApp(mock, coreStartMocksWithWorkspace)); | ||
|
||
expect(container).toMatchInlineSnapshot(` | ||
<div> | ||
dummy page | ||
</div> | ||
`); | ||
|
||
expect(coreStartMocks.chrome.setBreadcrumbs).toHaveBeenCalledWith([{ text: 'foo ws' }]); | ||
expect(mock.renderPage).toBeCalledWith('search_overview'); | ||
}); | ||
}); |
45 changes: 45 additions & 0 deletions
45
src/plugins/home/public/application/components/usecase_overview/search_use_case_app.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React, { useEffect } from 'react'; | ||
import { useObservable } from 'react-use'; | ||
import { CoreStart } from 'opensearch-dashboards/public'; | ||
import { EuiBreadcrumb } from '@elastic/eui'; | ||
import { I18nProvider } from '@osd/i18n/react'; | ||
import { i18n } from '@osd/i18n'; | ||
import { useOpenSearchDashboards } from '../../../../../opensearch_dashboards_react/public'; | ||
import { | ||
ContentManagementPluginStart, | ||
SEARCH_OVERVIEW_PAGE_ID, | ||
} from '../../../../../content_management/public'; | ||
|
||
interface Props { | ||
contentManagement: ContentManagementPluginStart; | ||
} | ||
|
||
export const SearchUseCaseOverviewApp = ({ contentManagement }: Props) => { | ||
const { | ||
services: { workspaces, chrome }, | ||
} = useOpenSearchDashboards<CoreStart>(); | ||
|
||
const currentWorkspace = useObservable(workspaces.currentWorkspace$); | ||
|
||
const title = i18n.translate('home.usecase.search.title', { defaultMessage: 'Search overview' }); | ||
|
||
useEffect(() => { | ||
const breadcrumbs: EuiBreadcrumb[] = [ | ||
{ | ||
text: currentWorkspace?.name || title, | ||
}, | ||
]; | ||
chrome.setBreadcrumbs(breadcrumbs); | ||
}, [chrome, currentWorkspace, title]); | ||
|
||
return ( | ||
<I18nProvider> | ||
{contentManagement ? contentManagement.renderPage(SEARCH_OVERVIEW_PAGE_ID) : null} | ||
</I18nProvider> | ||
); | ||
}; |
Oops, something went wrong.