-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat(React): Ownership component of user profile #2173
feat(React): Ownership component of user profile #2173
Conversation
|
||
const ownershipResult: any = {}; | ||
|
||
ownershipResult[EntityType.Chart] = useGetSearchResultsQuery({ |
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.
Since hook cannot be called inside any loop, not sure if there is a way in Typescript that can make it dynamic, i.e. looping through all enum values and get search query
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.
We'd like to add support for an all
endpoint in the future. In the meantime, I'd recommend encapsulating this all in a 2nd hook useGetEachEntitySearchResults
so that the UserProfile render function isn't so large
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.
+1 to wrapping this
@jjoyce0510 @gabe-lyons @shirshanka Please review |
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.
Nice! Looks good, although i do think it would benefit from encapsulating the multiplex search into its own helper util
@brendansun I also noticed that the preview card looks squashed in your screenshot, do you know why that is? Does it looks the same as the dataset preview in search? |
No, the search result page shows ok. I think it is because the left side menu? |
@brendansun I see- feel free to change the UserOwnership component as you need to make them look the same |
It looks like there should be more padding / margin on the individual list items that are rendered within the ownership details component... Can we include in this PR? |
OK got it, I can do that, will let you guys know when I am done with it |
@gabe-lyons @jjoyce0510 I have made requested changes, please take a look again; also, the screenshot is updated with some vertical margin to look better 😄 |
@brendansun looks better- can you apply some extra padding on the first element so it is spaced out from the header equally to the element below it? |
return entityRegistry.renderPreview(entityType, PreviewType.PREVIEW, item); | ||
return ( | ||
<div | ||
style={{ |
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: can we extract out styles into a const
variable at the top of the file?
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.
Removed inline style
import { EntityType } from '../../types.generated'; | ||
import { useGetSearchResultsQuery } from '../../graphql/search.generated'; | ||
|
||
export function useGetEachEntitySearchResults(input: any) { |
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.
nice!
very minor nit:
can we call this "useGetAllEntitySearchResults"
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.
Done!
result[EntityType.Chart] = useGetSearchResultsQuery({ | ||
variables: { | ||
input: { | ||
type: EntityType.Chart, |
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.
can we pass a "start" and "count" variable into this method and add it here? That way we can control how many results we get for each entity easily. I will likely replace my current entity loading in the "all" tab with what you've added here :)
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.
This is already handled by the input
object passed in to keep it generic, i.e. if we pass an object with start and count, then this query will get it. Do we want to explicitly mark these 2 parameters?
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.
Please see latest change, I have implemented the input
using Partial<SearchInput>
so that start
and count
are checked when compile
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.
Thank you! Looks great.
I have changed the code of this page a bit because Ant component doesnt allow us to style the margin for first item or the entire |
@brendansun looks good to me 🚀 |
import { EntityType } from '../../types.generated'; | ||
import { useGetSearchResultsQuery } from '../../graphql/search.generated'; | ||
|
||
export function useGetAllEntitySearchResults(input: any) { |
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.
we should be able to get this type from types.generated- you don't need to leave this as an any
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.
Specifically it should be SearchInput
from src/types.generated.ts
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.
If you want to allow any subset of fields from the type you could consider using Partial<SearchInput>
as the type
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.
Done!
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.
Thanks for this information about Partial
datahub-frontend/run/frontend.env
Outdated
@@ -1,5 +1,5 @@ | |||
# Server Port | |||
PORT=9001 | |||
PORT=9002 |
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.
make sure to change this back to 9001 before merging!
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.
Reverted, thanks for the reminder
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.
LGTM! Thanks @brendansun93 for the contrib and @gabe-lyons for the review!
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.
LGTM. Thank you so much!
|
||
type AllEntityInput<T, K> = Pick<T, Exclude<keyof T, keyof K>> & K; | ||
|
||
export function useGetAllEntitySearchResults(input: AllEntityInput<SearchInput, { type?: EntityType }>) { |
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.
Hey just realized we should use the Entity Registry here. Will raise another PR...
Scope
This PR only changes User profile component of React-web.
Changes
This PR adds existing UserOwnership component to UserDetail component and adds data to display coming from GraphQL search query.
Below screenshot is taken from visiting http://localhost:3000/user/urn:li:corpuser:datahub/ownership/dataset
Checklist