Skip to content

[HomePage] Add recent work section and additional styling for home page #6277

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

Closed

Conversation

abbyhu2000
Copy link
Member

@abbyhu2000 abbyhu2000 commented Mar 27, 2024

Description

This PR implements:

  1. Re-styling of the home page when advanced settinghome:useNewHomePage is toggled on. Mocks are here: [Home Page] Add recently viewed section to home page #6066
  2. Add a recent work section with max 8 cards; any dashboard, visualization, saved search that are accessed will be added to the recent work. The most recent one will show up as the first. Each recent work card has work item name, type and last updated time.
  3. If observability plugin is installed, it will show an extra card for observability in Start working with data section

Issues Resolved

partially resolves #6066

Screenshot

  1. Home page toggle
    https://github.com/opensearch-project/OpenSearch-Dashboards/assets/43937633/7b700395-e1cd-4572-b81c-7f24b5aee8fd

  2. New home page without observability plugin

Screenshot 2024-07-08 at 3 01 14 PM
  1. New home page with observability plugin
Screenshot 2024-07-08 at 3 05 29 PM
  1. Section styling and links
    https://github.com/opensearch-project/OpenSearch-Dashboards/assets/43937633/821d8aa4-e988-4adf-9556-2e05a76eef08

  2. Recent work section
    https://github.com/opensearch-project/OpenSearch-Dashboards/assets/43937633/7aeaa20e-8d0a-4284-b5f7-c55dde949d4a

Changelog

  • feat: Add recent work section and additional styling for home page

@abbyhu2000 abbyhu2000 changed the title Add recent work section and additional styling for home page [HomePage] Add recent work section and additional styling for home page Mar 27, 2024
Copy link

codecov bot commented Mar 27, 2024

Codecov Report

Attention: Patch coverage is 61.29032% with 24 lines in your changes missing coverage. Please review.

Project coverage is 67.67%. Comparing base (774f64e) to head (2bfa070).

Files Patch % Lines
...tion/components/homepage/sections/learn_basics.tsx 14.28% 6 Missing ⚠️
...on/components/homepage/sections/work_with_data.tsx 57.14% 4 Missing and 2 partials ⚠️
...ome/recently_accessed/recently_accessed_service.ts 28.57% 4 Missing and 1 partial ⚠️
...ation/components/homepage/sections/recent_work.tsx 84.61% 1 Missing and 1 partial ⚠️
...ublic/application/components/homepage/homepage.tsx 0.00% 1 Missing ⚠️
src/plugins/home/public/mocks/mocks.ts 92.30% 0 Missing and 1 partial ⚠️
...application/utils/use/use_saved_vis_builder_vis.ts 0.00% 1 Missing ⚠️
..._builder/public/saved_visualizations/_saved_vis.ts 0.00% 1 Missing ⚠️
...ic/application/utils/use/use_saved_vis_instance.ts 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6277      +/-   ##
==========================================
+ Coverage   67.55%   67.67%   +0.11%     
==========================================
  Files        3469     3470       +1     
  Lines       68479    68513      +34     
  Branches    11130    11130              
==========================================
+ Hits        46264    46368     +104     
+ Misses      19512    19425      -87     
- Partials     2703     2720      +17     
Flag Coverage Δ
Linux_1 33.11% <8.69%> (-0.02%) ⬇️
Linux_2 55.25% <28.57%> (-0.02%) ⬇️
Linux_3 45.27% <7.14%> (-0.05%) ⬇️
Linux_4 34.96% <60.34%> (+0.24%) ⬆️
Windows_1 33.13% <8.69%> (-0.02%) ⬇️
Windows_2 55.20% <28.57%> (-0.02%) ⬇️
Windows_3 45.28% <7.14%> (-0.04%) ⬇️
Windows_4 34.96% <60.34%> (+0.24%) ⬆️

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.

Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

Two things i want to call out here:

  1. How do i see the recently accessed section? Pulling down the PR and loading the new homepage does not have this section. Also can you add a screenshot to the PR so that people who dont pull down the change can see it too?
  2. You are modifying the architecture of the section component. That seems unnecessary for the filter but want to hear more on why you think the option you proposed is the best way to do it and what are the other alternitives you've tried.

@abbyhu2000
Copy link
Member Author

Added a comment here about the necessity of adding a filter button on the recent work section: #6066 (comment)

Changed the rendering structure of section back to previous way.

@abbyhu2000 abbyhu2000 force-pushed the home_page_recent_work branch 2 times, most recently from c1d0d0b to ef3e843 Compare May 8, 2024 23:34
@BionIT
Copy link
Collaborator

BionIT commented Jun 5, 2024

Hi @abbyhu2000 , is this PR targeting 2.15 or 2.16?

@abbyhu2000 abbyhu2000 force-pushed the home_page_recent_work branch from ef3e843 to 8e68eef Compare June 25, 2024 23:38
opensearch-changeset-bot bot added a commit to abbyhu2000/OpenSearch-Dashboards that referenced this pull request Jun 26, 2024
@abbyhu2000 abbyhu2000 force-pushed the home_page_recent_work branch from 7d03e73 to 2fa121e Compare June 26, 2024 00:46
opensearch-changeset-bot bot added a commit to abbyhu2000/OpenSearch-Dashboards that referenced this pull request Jun 26, 2024
@abbyhu2000 abbyhu2000 requested a review from LDrago27 as a code owner June 26, 2024 21:10
@abbyhu2000 abbyhu2000 force-pushed the home_page_recent_work branch from 43d0169 to ebab353 Compare July 8, 2024 21:46
@opensearch-project opensearch-project deleted a comment from github-actions bot Jul 8, 2024
@opensearch-project opensearch-project deleted a comment from github-actions bot Jul 8, 2024
Signed-off-by: abbyhu2000 <[email protected]>
Signed-off-by: abbyhu2000 <[email protected]>
Comment on lines +71 to +89
if (extraProps) {
const type = extraProps!.type;
const updatedAt = extraProps!.updatedAt;
history.add({
link,
label,
id,
...(currentWorkspaceId && { workspaceId: currentWorkspaceId }),
type,
updatedAt,
});
} else {
history.add({
link,
label,
id,
...(currentWorkspaceId && { workspaceId: currentWorkspaceId }),
});
}
Copy link
Member

@SuZhou-Joe SuZhou-Joe Jul 9, 2024

Choose a reason for hiding this comment

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

Suggested change
if (extraProps) {
const type = extraProps!.type;
const updatedAt = extraProps!.updatedAt;
history.add({
link,
label,
id,
...(currentWorkspaceId && { workspaceId: currentWorkspaceId }),
type,
updatedAt,
});
} else {
history.add({
link,
label,
id,
...(currentWorkspaceId && { workspaceId: currentWorkspaceId }),
});
}
history.add({
link,
label,
id,
...(currentWorkspaceId && { workspaceId: currentWorkspaceId }),
...extraProps,
});

What about we simplifying the code like this?

const render = renderFn(() => {
const services = getServices();
const navigateToUrl = services.application.navigateToUrl;
const recentAccessed = useObservable(services.chrome.recentlyAccessed.get$(), []);
Copy link
Member

Choose a reason for hiding this comment

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

I suppose the correct order here should be:

  1. Filter by type
  2. Slice to no more than 8 items
  3. render the items

Comment on lines +129 to +130
savedObject.getOpenSearchType(),
moment(Date.now()).format('MM/DD/YYYY HH:mm')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
savedObject.getOpenSearchType(),
moment(Date.now()).format('MM/DD/YYYY HH:mm')
{ type: savedObject.getOpenSearchType(), updateAt: Date.now() }

Should be like this?

@@ -74,6 +74,13 @@ export const useSavedVisBuilderVis = (visualizationIdFromUrl: string | undefined
data.query.filterManager.setAppFilters(actualFilters);
data.query.queryString.setQuery(query);

chrome.recentlyAccessed.add(
Copy link
Member

Choose a reason for hiding this comment

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

Seems the call does not comply with the interface of chrome.recentlyAccessed.add.

Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

Did a cursory review. Have some questions about the implementation details but given that we are going a different direction with the homepage, do we still need this PR?

Comment on lines +44 to +45
type?: string;
updatedAt?: number;
Copy link
Member

Choose a reason for hiding this comment

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

nit: It would be nice to maintain the same shape here. Either lets use extraProps in both places or not.

Comment on lines +103 to +110
if (visualizationIdFromUrl) {
chrome.recentlyAccessed.add(
savedVisInstance.savedVis.getFullPath(),
savedVisInstance.savedVis.title,
visualizationIdFromUrl,
{ type: savedVisInstance.savedVis.getOpenSearchType(), updatedAt: Date.now() }
);
}
Copy link
Member

Choose a reason for hiding this comment

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

why do we need this? without this how does Recently Accessed work?

@@ -51,6 +51,7 @@ export function createSavedVisBuilderVisClass(services: SavedObjectOpenSearchDas
});
this.showInRecentlyAccessed = true;
this.getFullPath = () => `/app/${PLUGIN_ID}${EDIT_PATH}/${this.id}`;
this.getOpenSearchType = () => VISBUILDER_SAVED_OBJECT;
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this? I dont see any other saved object doing it this way

link: string,
label: string,
id: string,
extraProps?: { type?: string; updatedAt?: number }
Copy link
Member

Choose a reason for hiding this comment

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

Is updatedAt needed? Cant we automatically update that value when the add function is called?

@@ -82,6 +82,7 @@ export const useSearch = (services: DiscoverViewServices) => {
core,
toastNotifications,
osdUrlStateStorage,
chrome,
Copy link
Member

Choose a reason for hiding this comment

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

you arent using this in this file

@SuZhou-Joe
Copy link
Member

@ashwin-pc At least the recent items section is still needed.

@ananzh
Copy link
Member

ananzh commented Jul 23, 2024

@abbyhu2000 is this still 2.16?

@abbyhu2000
Copy link
Member Author

This doesn't target 2.16 anymore. Will close

@ananzh ananzh removed the v2.16.0 label Jul 25, 2024
@abbyhu2000 abbyhu2000 closed this Jul 25, 2024
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.

[Home Page] Add recently viewed section to home page
6 participants