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

feat(React): Ownership component of user profile #2173

Merged
merged 6 commits into from
Mar 8, 2021
Merged

feat(React): Ownership component of user profile #2173

merged 6 commits into from
Mar 8, 2021

Conversation

brendansun93
Copy link
Contributor

@brendansun93 brendansun93 commented Mar 4, 2021

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
image

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable)


const ownershipResult: any = {};

ownershipResult[EntityType.Chart] = useGetSearchResultsQuery({
Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 to wrapping this

@brendansun93
Copy link
Contributor Author

@jjoyce0510 @gabe-lyons @shirshanka Please review

Copy link
Contributor

@gabe-lyons gabe-lyons left a 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

@gabe-lyons
Copy link
Contributor

@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?

@brendansun93
Copy link
Contributor Author

@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?

@gabe-lyons
Copy link
Contributor

@brendansun I see- feel free to change the UserOwnership component as you need to make them look the same

@jjoyce0510
Copy link
Collaborator

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?

@brendansun93
Copy link
Contributor Author

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

@shirshanka shirshanka added the pending-submitter-response Issue/request has been reviewed but requires a response from the submitter label Mar 5, 2021
@brendansun93
Copy link
Contributor Author

@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 😄

@gabe-lyons
Copy link
Contributor

@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={{
Copy link
Collaborator

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?

Copy link
Contributor Author

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) {
Copy link
Collaborator

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"

Copy link
Contributor Author

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,
Copy link
Collaborator

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 :)

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you! Looks great.

@brendansun93
Copy link
Contributor Author

@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?

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 ul html element. Therefore I moved the Title out of list header with a divider under it now. Please see the screenshot i have just uploaded to description. If there should be more margin, please let me know and it will be a easy fix :)

@gabe-lyons
Copy link
Contributor

@brendansun looks good to me 🚀

import { EntityType } from '../../types.generated';
import { useGetSearchResultsQuery } from '../../graphql/search.generated';

export function useGetAllEntitySearchResults(input: any) {
Copy link
Contributor

@gabe-lyons gabe-lyons Mar 8, 2021

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

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

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 this information about Partial

@@ -1,5 +1,5 @@
# Server Port
PORT=9001
PORT=9002
Copy link
Contributor

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!

Copy link
Contributor Author

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

Copy link
Contributor

@shirshanka shirshanka left a 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!

@shirshanka shirshanka merged commit e3ad0ed into datahub-project:master Mar 8, 2021
Copy link
Collaborator

@jjoyce0510 jjoyce0510 left a 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 }>) {
Copy link
Collaborator

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-submitter-response Issue/request has been reviewed but requires a response from the submitter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants