-
Notifications
You must be signed in to change notification settings - Fork 1k
[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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -41,6 +41,8 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
label: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
id: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
workspaceId?: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
type?: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
updatedAt?: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
interface StartDeps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -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 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
link, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
label, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
...(currentWorkspaceId && { workspaceId: currentWorkspaceId }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
updatedAt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
history.add({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
link, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
label, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
...(currentWorkspaceId && { workspaceId: currentWorkspaceId }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+71
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
What about we simplifying the code like this? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
/** Gets the current array of history items. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -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. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,7 @@ export const useSearch = (services: DiscoverViewServices) => { | |
core, | ||
toastNotifications, | ||
osdUrlStateStorage, | ||
chrome, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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<{ | ||
|
@@ -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(), | ||
} | ||
); | ||
} | ||
})(); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
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.