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

Combine siblings in autocomplete #8610

Merged
merged 21 commits into from
Aug 16, 2023

Conversation

joshuaeilers
Copy link
Contributor

@joshuaeilers joshuaeilers commented Aug 10, 2023

This PR merges autocomplete results similar to how we do it in the frontend for things like search cards.

Changes

  • Makes a combineSiblingsInAutoComplete and combineSiblingsInSearchResults that both share a reusable function.
  • Break the separate combine use cases out into their own files and ported the test for them out of siblingUtils as well. This way we can add new types that need to combine siblings without having to continue to bloat siblingUtils.
  • Tightened up combineSiblingEntities a little bit, using a Set, less any types, etc
  • The home page header / search results will combine siblings in the autocomplete including a vertical stack of platform icons, and I try to find a parentContainers set on one of the siblings to display (the case when dbt is primary but bigquery has the parentContainers we'll still show the path). This doesn't work for search cards yet, it only shows the parentContainers sometimes.
  • A new AutoCompleteEntityIcon component that takes care of the icon-specific rendering logic
  • Modifications to the autocomplete graphql response to include siblings along with parentContainers so we can display all that good stuff for each pair of siblings.

Siblings
Screenshot 2023-08-10 at 1 58 14 PM

Single
Screenshot 2023-08-10 at 1 58 23 PM

@github-actions github-actions bot added the product PR or Issue related to the DataHub UI/UX label Aug 10, 2023
@joshuaeilers joshuaeilers marked this pull request as ready for review August 10, 2023 20:48
combineSiblingsInSearchResults,
shouldEntityBeTreatedAsPrimary,
} from '../siblingUtils';
import { combineEntityDataWithSiblings, shouldEntityBeTreatedAsPrimary } from '../siblingUtils';
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 stuff was ported to combineSiblingsInSearchResults.test.ts

@@ -202,53 +203,56 @@ export const combineEntityDataWithSiblings = <T>(baseEntity: T): T => {
return { [baseEntityKey]: combinedBaseEntity } as unknown as T;
};

export type CombinedSearchResult = {
export type CombinedEntityResult = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

combineSiblingEntities is now more generalized and less about search specifically so other use cases can just pass in some entities and combine siblings (as long as you provided a gql entity that actually had siblings). Should make it more reusable.

): Array<CombinedSearchResult> {
return combineSiblingEntities(input?.map((value) => value.entity)).map((combinedResult) => ({
...combinedResult,
matchedFields: [],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oversight on my part, gotta make sure this is preserved.

Copy link
Collaborator

@chriscollins3456 chriscollins3456 left a comment

Choose a reason for hiding this comment

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

looking solid! a couple of minor questions and just a warning about the conflict

@@ -2,7 +2,8 @@ import merge from 'deepmerge';
import { unionBy, keyBy, values } from 'lodash';
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like we have a conflict from my changes to display consistent combined search results for sibling entities in this PR: https://github.com/datahub-project/datahub/pull/8602/files#diff-dbeb733a628595000d108fe2f57b5c464d52b6da55f57d57ad4bc6e246af3914

so let's make sure we keep that functionlity! the main thing I did is simply combine the siblings entity data in combineSiblingsInSearchResults and refactored a function above it to make it reusable between its two uses

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Think I got the conflict resolved 👍

Comment on lines 78 to 85
const parentContainers =
entities
.map((ent) => {
const genericPropsForEnt = entityRegistry.getGenericEntityProperties(ent.type, ent);
const entParentContainers = genericPropsForEnt?.parentContainers?.containers || [];
return [...entParentContainers].reverse();
})
.find((containers) => containers.length > 0) ?? [];
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like this should be taken care of when we combine sibling data so we end up just getting one parentContainers based on the combined data.

In fact, with my changes in #8602 we can now get proper parentContainers combined so you can just use the combined entity 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.

Awesome. So like if one sibling had no parentContainers and another one missed them, it would automatically choose the one that had them present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does seem to work thought! Shows the bigquery containers even on the dbt primary.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yup exactly! so it'll choose the primary if both fields are filled out, but if one is filled out and not the other, it'll take the non-empty one

Comment on lines 68 to 76
const platformNames = entities
.map((ent) => {
const genericPropsForEnt = entityRegistry.getGenericEntityProperties(ent.type, ent);
const platform = genericPropsForEnt?.platform;
if (platform?.properties?.displayName) return platform.properties.displayName;
if (platform?.name) return capitalizeFirstLetterOnly(platform.name) || '';
return '';
})
.filter(Boolean);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: i feel like this could be pulled out into its own function. Also I see elsewhere that we have siblingPlatforms on genericProperties that you can maybe use 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.

Updated! I left the iteration in this component but reused an existing helper function we already have.

@@ -149,6 +142,7 @@ export const SearchBar = ({
hideRecommendations,
showQuickFilters,
viewsEnabled = false,
combineSiblings = false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

so we default want to not combine siblings in our search bar? is there somewhere where we particularly don't want them combined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right the idea was to make siblings an opt-in behavior, where the home/searchResults pages have that behavior but not assume that all use cases in the UI would get that behavior was my thought.

Copy link
Collaborator

@chriscollins3456 chriscollins3456 left a comment

Choose a reason for hiding this comment

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

nice man looking good!

@joshuaeilers joshuaeilers merged commit 7c2fd7b into datahub-project:master Aug 16, 2023
34 checks passed
@joshuaeilers joshuaeilers deleted the feature/prd-498 branch August 16, 2023 15:53
asikowitz pushed a commit to asikowitz/datahub that referenced this pull request Aug 23, 2023
yoonhyejin pushed a commit that referenced this pull request Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product PR or Issue related to the DataHub UI/UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants