Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Workspace] Refactor the style of recent items card in the header #7805

Conversation

Qxisylolo
Copy link
Contributor

@Qxisylolo Qxisylolo commented Aug 22, 2024

Description

In this pr, I refactor the style of recent items card in the header by

  1. Enable maxHeight; if exceeded, the menu will become scrollable.
  2. Display associated icons.
  3. The workspace name will be attached to the asset.
  4. Allow setting preferences for the number of recent items displayed.

Screenshot

Screen.Recording.2024-08-22.at.17.11.50.mov

empty state
Screenshot 2024-08-22 at 17 40 35

Changelog

  • feat: refractor the style of recent items card

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

opensearch-changeset-bot bot added a commit to Qxisylolo/OpenSearch-Dashboards that referenced this pull request Aug 22, 2024
Copy link

codecov bot commented Aug 22, 2024

Codecov Report

Attention: Patch coverage is 86.11111% with 5 lines in your changes missing coverage. Please review.

Project coverage is 64.30%. Comparing base (a59f8ab) to head (69fb6d5).
Report is 59 commits behind head on main.

Files with missing lines Patch % Lines
src/core/public/chrome/ui/header/recent_items.tsx 86.11% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7805      +/-   ##
==========================================
+ Coverage   63.83%   64.30%   +0.47%     
==========================================
  Files        3658     3674      +16     
  Lines       81284    81166     -118     
  Branches    12972    12932      -40     
==========================================
+ Hits        51884    52197     +313     
+ Misses      26216    25756     -460     
- Partials     3184     3213      +29     
Flag Coverage Δ
Linux_1 30.20% <8.33%> (+0.04%) ⬆️
Linux_2 56.22% <86.11%> (+0.34%) ⬆️
Linux_3 40.59% <8.33%> (+0.17%) ⬆️
Linux_4 31.39% <8.33%> (+0.10%) ⬆️
Windows_1 30.22% <8.33%> (+0.04%) ⬆️
Windows_2 56.17% <86.11%> (+0.34%) ⬆️
Windows_3 40.60% <8.33%> (+0.18%) ⬆️
Windows_4 31.39% <8.33%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Qxisylolo Qxisylolo force-pushed the feature/refractor-style-of-recent-items branch from c2b4652 to 451ff49 Compare August 22, 2024 09:40
workspaceName?: string;
};

export const bulkGetDetail = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about move this into a utils file and rename to some others like bulkGetSavedObjectsDetail, which could better indicate the effect of this function. And we don't need to export if nowhere imports this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, I delete export and I think it's better to keep it here as the required type SavedObjectWithMetadata has the import restriction. Here I just simply duplicate it in the file. [ Unexpected path "src/plugins/saved_objects_management/common/types" imported in restricted zone.]

src/core/public/chrome/ui/header/recent_items.tsx Outdated Show resolved Hide resolved
src/core/public/chrome/ui/header/recent_items.tsx Outdated Show resolved Hide resolved
src/core/public/chrome/ui/header/recent_items.tsx Outdated Show resolved Hide resolved
Signed-off-by: Qxisylolo <qianxisy@amazon.com>
Signed-off-by: Qxisylolo <qianxisy@amazon.com>
Signed-off-by: Qxisylolo <qianxisy@amazon.com>
Signed-off-by: Qxisylolo <qianxisy@amazon.com>
Signed-off-by: Qxisylolo <qianxisy@amazon.com>
@Qxisylolo Qxisylolo force-pushed the feature/refractor-style-of-recent-items branch from 8802d75 to d9d1ff6 Compare August 23, 2024 05:39
}));

if (savedObjects.length) {
bulkGetDetail(savedObjects, http).then((res) => {
Copy link
Member

@ruanyl ruanyl Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should it call this API to get the details? Isn't items from recentlyAccessed$ already have saved object title, type and workspace id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Thanks for your review, we call the API to get the associated icon

// Only display five most recent items
return recentlyAccessedItems.slice(0, 5).map((item) => {
return {
link: createRecentNavLink(item, navLinks, basePath, navigateToUrl).href,
Copy link
Member

@SuZhou-Joe SuZhou-Joe Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we removed the createRecentNavLink import, but the link should be generated from it. It handles with the workspace id in path.

Copy link
Contributor Author

@Qxisylolo Qxisylolo Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for your review,I delete it since we could directly access link from recentlyAccessedItems

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that link is not correct as it does not contain workspace info.

Copy link
Contributor Author

@Qxisylolo Qxisylolo Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated. Thank you

Signed-off-by: Qxisylolo <qianxisy@amazon.com>
Signed-off-by: Qxisylolo <qianxisy@amazon.com>
Signed-off-by: Qxisylolo <qianxisy@amazon.com>
@Qxisylolo Qxisylolo changed the title [Workspace] refractor the style of recent items card in the header [Workspace] Refactor the style of recent items card in the header Aug 29, 2024
savedObjects.map((obj) =>
http
.get<SavedObjectWithMetadata>(
`/api/opensearch-dashboards/management/saved_objects/${encodeURIComponent(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not fully "comfortable" with calling a plugin API from a core module though the API is exposed by a core plugin.

But I've seen the saved object management API path /management/opensearch-dashboards has already been used in multiple places, so I'm fine with it now.

In my opinion, perhaps this recent visited button should be owned by saved object management plugin because it's all about recently visited saved objects, I don't see a strong correlation between chrome module and the recently visited items, to my understanding, it's just another registration point that saved objects management plugin contributes to.

cc @SuZhou-Joe @AMoo-Miki

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, things will look more in place if we can register the recent items to the left of the breadcrumbs within saved objects management plugin.

@SuZhou-Joe SuZhou-Joe merged commit a7024e6 into opensearch-project:main Sep 3, 2024
73 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 3, 2024
)

* feature/refractor-style-of-recent-items

Signed-off-by: Qxisylolo <qianxisy@amazon.com>

* solve bugs and delete annotation

Signed-off-by: Qxisylolo <qianxisy@amazon.com>

* solve bugs

Signed-off-by: Qxisylolo <qianxisy@amazon.com>

* fix bugs

Signed-off-by: Qxisylolo <qianxisy@amazon.com>

* fix bugs-1

Signed-off-by: Qxisylolo <qianxisy@amazon.com>

* fix bugs-delete-lines

Signed-off-by: Qxisylolo <qianxisy@amazon.com>

* fix refine-popover-padding

Signed-off-by: Qxisylolo <qianxisy@amazon.com>

* fix, add createRecentNavLink

Signed-off-by: Qxisylolo <qianxisy@amazon.com>

* Changeset file for PR #7805 created/updated

---------

Signed-off-by: Qxisylolo <qianxisy@amazon.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit a7024e6)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
ruanyl pushed a commit that referenced this pull request Sep 3, 2024
) (#7966)

* feature/refractor-style-of-recent-items



* solve bugs and delete annotation



* solve bugs



* fix bugs



* fix bugs-1



* fix bugs-delete-lines



* fix refine-popover-padding



* fix, add createRecentNavLink



* Changeset file for PR #7805 created/updated

---------



(cherry picked from commit a7024e6)

Signed-off-by: Qxisylolo <qianxisy@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants