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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/6277.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Add recent work section and additional styling for home page ([#6277](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6277))
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
label: string;
id: string;
workspaceId?: string;
type?: string;
updatedAt?: number;
Comment on lines +44 to +45
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.

}

interface StartDeps {
Expand All @@ -59,15 +61,32 @@

return {
/** Adds a new item to the history. */
add: (link: string, label: string, id: string) => {
add: (
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?

) => {
const currentWorkspaceId = workspaces.currentWorkspaceId$.getValue();

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

Check warning on line 74 in src/core/public/chrome/recently_accessed/recently_accessed_service.ts

View check run for this annotation

Codecov / codecov/patch

src/core/public/chrome/recently_accessed/recently_accessed_service.ts#L72-L74

Added lines #L72 - L74 were not covered by tests
link,
label,
id,
...(currentWorkspaceId && { workspaceId: currentWorkspaceId }),
type,
updatedAt,
});
} else {
history.add({
link,
label,
id,
...(currentWorkspaceId && { workspaceId: currentWorkspaceId }),
});
}
Comment on lines +71 to +89
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?

},

/** Gets the current array of history items. */
Expand Down Expand Up @@ -95,8 +114,15 @@
* @param link a relative URL to the resource (not including the {@link HttpStart.basePath | `http.basePath`})
* @param label the label to display in the UI
* @param id a unique string used to de-duplicate the recently accessed list.
* @param type the item type
* @param updatedAt the time that the item is last updated at
*/
add(link: string, label: string, id: string): void;
add(
link: string,
label: string,
id: string,
extraProps?: { type?: string; updatedAt?: number }
): void;

/**
* Gets an Array of the current recently accessed history.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('useSavedDashboardInstance', () => {
getFilters: () => dashboardAppStateStub.filters,
optionsJSON: JSON.stringify(dashboardAppStateStub.options),
getFullPath: () => `/${dashboardIdFromUrl}`,
getOpenSearchType: () => 'dashboard',
},
} as unknown) as SavedObjectDashboard;
dashboard = new Dashboard(convertToSerializedDashboard(savedDashboardInstance));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ export const useSavedDashboardInstance = ({
chrome.recentlyAccessed.add(
savedDashboard.getFullPath(),
savedDashboard.title,
dashboardIdFromUrl
dashboardIdFromUrl,
{ type: savedDashboard.getOpenSearchType(), updatedAt: Date.now() }
);
setSavedDashboardInstance(dashboardInstance);
} catch (error: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

} = services;
const timefilter = data.query.timefilter.timefilter;
const fetchStateRef = useRef<{
Expand Down Expand Up @@ -308,7 +309,11 @@ export const useSearch = (services: DiscoverViewServices) => {
chrome.recentlyAccessed.add(
savedSearchInstance.getFullPath(),
savedSearchInstance.title,
savedSearchInstance.id
savedSearchInstance.id,
{
type: savedSearchInstance.getOpenSearchType(),
updatedAt: Date.now(),
}
);
}
})();
Expand Down
9 changes: 8 additions & 1 deletion src/plugins/discover/public/saved_searches/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ export type SortOrder = [string, SortDirection];
export interface SavedSearch
extends Pick<
SavedObject,
'id' | 'title' | 'copyOnSave' | 'destroy' | 'lastSavedTitle' | 'save' | 'getFullPath'
| 'id'
| 'title'
| 'copyOnSave'
| 'destroy'
| 'lastSavedTitle'
| 'save'
| 'getFullPath'
| 'getOpenSearchType'
> {
searchSource: ISearchSource; // This is optional in SavedObject, but required for SavedSearch
description?: string;
Expand Down

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 @@ -7,3 +7,19 @@
.home-homepage-body--fill {
min-height: $euiSize * 50;
}

.learn-basics-links {
font-size: 15px;
}

.popover-title-icon {
padding-left: 2px;
}

.empty-recent-work {
text-align: center;
}

.recent-work-title-icon {
padding-right: 4px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,38 +68,6 @@ export const Footer: React.FC = () => {
return (
<EuiFlexGroup direction="row" wrap>
{isAdvancedSettingsEnabled && <EuiFlexItem grow={false}>{defaultRouteButton}</EuiFlexItem>}

<EuiFlexItem grow={false}>
<RedirectAppLinks application={application}>
<EuiButtonEmpty
flush="both"
href={getUrlForApp('home', { path: '#/feature_directory' })}
iconType="apps"
size="xs"
>
<FormattedMessage
id="home.footer.appDirectoryButtonLabel"
defaultMessage="View app directory"
/>
</EuiButtonEmpty>
</RedirectAppLinks>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<RedirectAppLinks application={application}>
<EuiButtonEmpty
flush="both"
href={getUrlForApp('opensearch_dashboards_overview')}
iconType="visualizeApp"
size="xs"
>
<FormattedMessage
id="home.footer.visualizeAndAnalyze"
defaultMessage="Visualize & Analyze"
/>
</EuiButtonEmpty>
</RedirectAppLinks>
</EuiFlexItem>
</EuiFlexGroup>
);
};
Loading
Loading