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

[search ui] Display asset search on asset landing page #20373

Merged

Conversation

clairelin135
Copy link
Contributor

@clairelin135 clairelin135 commented Mar 8, 2024

Walkthrough of the UI: https://www.loom.com/share/182595e3ba40415694343c6d786720d7?sid=ecb71bf9-0a87-44e4-bb78-4673d6d06495

Changes included:

  • Allows the SearchDialog to accept a prop indicating whether the search displays as an overlay, or on the page
  • Displays the fuzzy matches in the label in bold
  • Displays filter results, alongside the # of assets

Next steps:

  • Handle typeaheads (i.e. asset is:/sensor is:/etc)

@clairelin135
Copy link
Contributor Author

clairelin135 commented Mar 8, 2024

Copy link

github-actions bot commented Mar 8, 2024

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-dj5bmshpf-elementl.vercel.app
https://03-07-claire-styling-display-search-on-asset-catalog-page.core-storybook.dagster-docs.io

Built with commit 457bb25.
This pull request is being automatically deployed with vercel-action

@clairelin135 clairelin135 force-pushed the 03-07-claire/asset-search-ui branch from c5d9429 to 9ce9f77 Compare March 8, 2024 22:05
@clairelin135 clairelin135 force-pushed the 03-07-claire/styling-display-search-on-asset-catalog-page branch 3 times, most recently from efb1513 to 8755137 Compare March 9, 2024 00:13
@clairelin135 clairelin135 force-pushed the 03-07-claire/asset-search-ui branch 2 times, most recently from 445969c to 104a5dd Compare March 9, 2024 01:04
@clairelin135 clairelin135 force-pushed the 03-07-claire/styling-display-search-on-asset-catalog-page branch from 8755137 to 9de78a1 Compare March 9, 2024 01:06
@clairelin135 clairelin135 changed the base branch from 03-07-claire/asset-search-ui to master March 9, 2024 01:08
@clairelin135 clairelin135 changed the base branch from master to 03-07-claire/asset-search-ui March 9, 2024 01:08
@clairelin135 clairelin135 force-pushed the 03-07-claire/styling-display-search-on-asset-catalog-page branch 2 times, most recently from 1bdc7f9 to e477c43 Compare March 9, 2024 01:23
@clairelin135 clairelin135 marked this pull request as ready for review March 9, 2024 01:24
Copy link
Member

@hellendag hellendag left a comment

Choose a reason for hiding this comment

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

I think the approach of reusing SearchDialog with a separate render branch for each use case isn't quite right.

I think instead, SearchDialog and this new UI should share common components.

isAssetSearch: boolean;
displayAsOverlay?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

The addition of isAssetSearch is an indication that this isn't really the right component for this UI to use. I see that that's from another branch, so I'll take a look at that one.

);

if (displayAsOverlay) {
Copy link
Member

@hellendag hellendag Mar 11, 2024

Choose a reason for hiding this comment

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

I don't think reusing SearchDialog with overriding props is quite the right approach. There are some similarities between global search and this UI, but I think the way to approach this is to have separate components that share common components and hooks.

That is, I would suggest that SearchDialog be left effectively as-is, without additional props or rendering branches, and some of its pieces could be factored out to be used by both (existing) global search and a new asset search component.

@clairelin135 clairelin135 force-pushed the 03-07-claire/asset-search-ui branch from 104a5dd to 2c06f1d Compare March 11, 2024 19:08
@clairelin135 clairelin135 force-pushed the 03-07-claire/styling-display-search-on-asset-catalog-page branch 2 times, most recently from b6ce9a5 to 0fec26d Compare March 11, 2024 19:13
@clairelin135 clairelin135 force-pushed the 03-07-claire/asset-search-ui branch from 2c06f1d to 1010eea Compare March 11, 2024 19:15
@clairelin135 clairelin135 force-pushed the 03-07-claire/styling-display-search-on-asset-catalog-page branch from 0fec26d to 4c23fcf Compare March 11, 2024 19:15
searchAndHandleSecondary(queryString);
}, DEBOUNCE_MSEC);
return (queryString: string) => {
if (!firstSearchTrace.current && isFirstSearch.current) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure what this trace logic is, but it existed in the global search dialog so I added similar logic here?

@clairelin135
Copy link
Contributor Author

clairelin135 commented Mar 11, 2024

@hellendag thanks for the feedback and the explanation here. I agree that it's cleaner to make asset search live in its own component. I added this refactor and I think this logic is looking better :)

I wasn't entirely sure whether callbacks that mutate state should exist as shared functions or not, but aired on not sharing to make the state transitions per component clearer, though this does create some duplicate logic.

The new changes include:

  • Asset search now no longer executes the primary search query
  • Asset search now has a separate reducer, since it only uses a subset of the actions in global search.
  • Subsequently a copy of the dispatch callbacks to update search results and handle key events exist in SearchDialog and AssetSearch, since their behavior is slightly different (the global search version also handles closing the dialog)

Let me know how this looks.

@clairelin135 clairelin135 requested a review from hellendag March 11, 2024 19:27
@clairelin135 clairelin135 force-pushed the 03-07-claire/asset-search-ui branch from 1010eea to ecffd16 Compare March 11, 2024 19:41
@clairelin135 clairelin135 force-pushed the 03-07-claire/styling-display-search-on-asset-catalog-page branch from 4c23fcf to 5f2434c Compare March 11, 2024 19:42
@clairelin135 clairelin135 force-pushed the 03-07-claire/asset-search-ui branch from ecffd16 to ce41857 Compare March 11, 2024 21:35
@clairelin135 clairelin135 force-pushed the 03-07-claire/styling-display-search-on-asset-catalog-page branch from 8ea6b1f to eeea70d Compare March 11, 2024 23:38
return (queryString: string) => {
if (!firstSearchTrace.current && isFirstSearch.current) {
isFirstSearch.current = false;
const trace = createTrace('SearchDialog:FirstSearch');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you rename this to AssetSearch:FirstSearch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 238 to 247
font-weight: 500;
`;

const SearchResultBoldedLabel = styled.span`
font-weight: 800;
`;

const SearchResultLabel = styled.span`
font-weight: 300;
`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally you should not need to set font-weight in CSS. All of the styles used in figma should be defined here

The figma should specify whether it's Body2, Subheading2, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, updated

@clairelin135 clairelin135 force-pushed the 03-07-claire/asset-search-ui branch 2 times, most recently from c92d186 to 1cdabc9 Compare March 12, 2024 18:53
@clairelin135 clairelin135 force-pushed the 03-07-claire/styling-display-search-on-asset-catalog-page branch from eeea70d to e30c186 Compare March 12, 2024 18:53
@clairelin135 clairelin135 requested a review from salazarm March 12, 2024 19:11
Copy link

github-actions bot commented Mar 12, 2024

Deploy preview for dagit-storybook ready!

✅ Preview
https://dagit-storybook-gm5mz9leo-elementl.vercel.app
https://03-07-claire-styling-display-search-on-asset-catalog-page.components-storybook.dagster-docs.io

Built with commit 457bb25.
This pull request is being automatically deployed with vercel-action

export const CaptionBolded = styled(Text)`
font-family: ${FontFamily.default};
font-size: 12px;
font-weight: 900;
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this comes from figma?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

<Label isHighlight={isHighlight}>{item.label}</Label>
<Description isHighlight={isHighlight}>{item.description}</Description>
</div>
<Box flex={{direction: 'row', alignItems: 'center'}} style={{width: '100%'}}>
Copy link
Contributor

Choose a reason for hiding this comment

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

i think you want grow: 1 instead of width: 100%

@@ -249,6 +249,7 @@ const fuseOptions = {
keys: ['label', 'segments', 'tags', 'type'],
threshold: 0.3,
useExtendedSearch: true,
includeMatches: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice find

@clairelin135 clairelin135 force-pushed the 03-07-claire/asset-search-ui branch from 1cdabc9 to 289c094 Compare March 12, 2024 20:10
@clairelin135 clairelin135 force-pushed the 03-07-claire/styling-display-search-on-asset-catalog-page branch 2 times, most recently from 49feb08 to 3c7a44f Compare March 12, 2024 20:18
Base automatically changed from 03-07-claire/asset-search-ui to master March 12, 2024 21:31
@clairelin135 clairelin135 force-pushed the 03-07-claire/styling-display-search-on-asset-catalog-page branch from 3c7a44f to 457bb25 Compare March 12, 2024 21:32
@clairelin135 clairelin135 dismissed hellendag’s stale review March 12, 2024 21:34

Feedback addressed

@clairelin135 clairelin135 merged commit dd8fb52 into master Mar 12, 2024
3 checks passed
@clairelin135 clairelin135 deleted the 03-07-claire/styling-display-search-on-asset-catalog-page branch March 12, 2024 21:44
jamiedemaria pushed a commit that referenced this pull request Mar 12, 2024
Walkthrough of the UI:
https://www.loom.com/share/182595e3ba40415694343c6d786720d7?sid=ecb71bf9-0a87-44e4-bb78-4673d6d06495

Changes included:
- Allows the `SearchDialog` to accept a prop indicating whether the
search displays as an overlay, or on the page
- Displays the fuzzy matches in the label in bold
- Displays filter results, alongside the # of assets

Next steps:
- Handle typeaheads (i.e. `asset is:`/`sensor is:`/etc)
PedramNavid pushed a commit that referenced this pull request Mar 28, 2024
Walkthrough of the UI:
https://www.loom.com/share/182595e3ba40415694343c6d786720d7?sid=ecb71bf9-0a87-44e4-bb78-4673d6d06495

Changes included:
- Allows the `SearchDialog` to accept a prop indicating whether the
search displays as an overlay, or on the page
- Displays the fuzzy matches in the label in bold
- Displays filter results, alongside the # of assets

Next steps:
- Handle typeaheads (i.e. `asset is:`/`sensor is:`/etc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants