-
Notifications
You must be signed in to change notification settings - Fork 967
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[navigation-next] feat: add recent works in new homepage (#7237)
* feat: update Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: update Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: update Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: update Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: update Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * Changeset file for PR #7237 created/updated * feat: remove the euispacer Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: update empty state Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: update Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: update Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: update i18n key Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: update Signed-off-by: SuZhou-Joe <suzhou@amazon.com> --------- Signed-off-by: SuZhou-Joe <suzhou@amazon.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
e64de15
commit 46afb96
Showing
20 changed files
with
479 additions
and
10 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: | ||
- [navigation-next] add recent works in new homepage ([#7237](/~https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7237)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,5 @@ export { | |
NavType, | ||
RightNavigationButton, | ||
RightNavigationButtonProps, | ||
createRecentNavLink, | ||
} from './header'; |
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
98 changes: 98 additions & 0 deletions
98
src/plugins/saved_objects_management/public/management_section/recent_work.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,98 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { fireEvent, render } from '@testing-library/react'; | ||
import { RecentWork } from './recent_work'; | ||
import { coreMock } from '../../../../core/public/mocks'; | ||
import { ChromeRecentlyAccessedHistoryItem } from 'opensearch-dashboards/public'; | ||
import { SavedObjectWithMetadata } from '../types'; | ||
|
||
const mockedRecentItems: ChromeRecentlyAccessedHistoryItem[] = [ | ||
{ | ||
link: '/app/visualize', | ||
label: 'visualize', | ||
id: 'visualize', | ||
meta: { | ||
type: 'visualize', | ||
}, | ||
}, | ||
{ | ||
link: '/app/dashboard', | ||
label: 'dashboard', | ||
id: 'dashboard-in-workspace', | ||
workspaceId: 'workspace-id', | ||
meta: { | ||
type: 'dashboard', | ||
}, | ||
}, | ||
]; | ||
|
||
const savedObjectsFromServer: SavedObjectWithMetadata[] = [ | ||
{ | ||
type: 'visualize', | ||
id: 'visualize', | ||
attributes: {}, | ||
references: [], | ||
updated_at: '2024-07-20T00:00:00.000Z', | ||
meta: {}, | ||
}, | ||
{ | ||
type: 'dashboard', | ||
id: 'dashboard-in-workspace', | ||
attributes: {}, | ||
references: [], | ||
updated_at: '2024-07-20T00:00:01.000Z', | ||
meta: {}, | ||
}, | ||
]; | ||
|
||
const getStartMockForRecentWork = () => { | ||
const coreStartMock = coreMock.createStart(); | ||
coreStartMock.chrome.recentlyAccessed.get$.mockReturnValue(new BehaviorSubject([])); | ||
coreStartMock.chrome.navLinks.getNavLinks$.mockReturnValue(new BehaviorSubject([])); | ||
return coreStartMock; | ||
}; | ||
|
||
describe('<RecentWork />', () => { | ||
it('render with emty recent work', async () => { | ||
const { findByText } = render(<RecentWork core={getStartMockForRecentWork()} />); | ||
await findByText('No recent work'); | ||
}); | ||
|
||
it('render with recent works', async () => { | ||
const coreStartMock = getStartMockForRecentWork(); | ||
coreStartMock.http.get.mockImplementation((url) => { | ||
if (typeof url === 'string') { | ||
if ((url as string).includes(mockedRecentItems[0].id)) { | ||
return Promise.resolve(savedObjectsFromServer[0]); | ||
} else { | ||
return Promise.resolve(savedObjectsFromServer[1]); | ||
} | ||
} | ||
|
||
return Promise.reject({}); | ||
}); | ||
|
||
coreStartMock.chrome.recentlyAccessed.get$.mockReturnValue( | ||
new BehaviorSubject(mockedRecentItems) | ||
); | ||
|
||
const { findAllByTestId, getByTestId } = render(<RecentWork core={coreStartMock} />); | ||
const allCards = await findAllByTestId('recentlyCard'); | ||
expect(allCards.length).toBe(2); | ||
expect(allCards[0].querySelector('.euiCard__titleAnchor')?.textContent).toEqual( | ||
mockedRecentItems[0].label | ||
); | ||
|
||
// click the filter button | ||
fireEvent.click(getByTestId('filterButton-recently%20updated')); | ||
const allCardsAfterSort = await findAllByTestId('recentlyCard'); | ||
expect(allCardsAfterSort[0].querySelector('.euiCard__titleAnchor')?.textContent).toEqual( | ||
mockedRecentItems[1].label | ||
); | ||
}); | ||
}); |
Oops, something went wrong.