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

Entity picker/new search item component #42009

Merged
merged 9 commits into from
May 6, 2024

Conversation

iethree
Copy link
Contributor

@iethree iethree commented Apr 29, 2024

Part of #39528

Description

Adds a new search results component that we will use for both recents and search. This implements it in search first so it can get into master while we work on some backend changes for recents.

When picking a collection (new > dashboard)

Screen Shot 2024-04-30 at 9 25 57 AM

When picking a question (any dashboard > edit > hover a card > replace question)
Screen Shot 2024-05-02 at 3 40 32 PM

Checklist

  • Tests have been added/updated to cover changes in this PR

@metabase-bot metabase-bot bot added the .Team/AdminWebapp Admin and Webapp team label Apr 29, 2024
@iethree iethree changed the title Entity picker/new search item component [WIP] Entity picker/new search item component Apr 29, 2024
@iethree iethree added the no-backport Do not backport this PR to any branch label Apr 30, 2024
@iethree iethree changed the title [WIP] Entity picker/new search item component Entity picker/new search item component Apr 30, 2024
@iethree iethree marked this pull request as ready for review April 30, 2024 16:53
@iethree iethree force-pushed the entity-picker/new-search-item-component branch from 8fc53eb to cb642f7 Compare April 30, 2024 16:53
@iethree iethree force-pushed the entity-picker/new-search-item-component branch from cb642f7 to 56de155 Compare April 30, 2024 16:54
Comment on lines +33 to +34
PLUGIN_COLLECTIONS.getIcon = getIcon;

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 should be part of verified collections rather than audit app

Copy link

github-actions bot commented Apr 30, 2024

Codenotify: Notifying subscribers in CODENOTIFY files for diff 6065763...f9ac80d.

No notifications.

@@ -59,7 +59,7 @@ export const getIcon = (item: ObjectWithModel): IconData => {
};
}

if (item.model === "dataset" && item.authority_level === "official") {
if (item.model === "dataset" && item.moderated_status === "verified") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

models are verified, collections are official 🥴

Comment on lines +23 to +24
${({ isLast }) =>
!isLast ? `border-bottom: 1px solid ${color("border")}` : ""};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unfortunately we need to do this programmatically, because the virtualizer adds some wrapping divs so we can't just check last-of-type in css 😢

Comment on lines 60 to 61
// required to get the tooltip to show up over the entity picker modal 😢
zIndex: "450 !important" as any,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel very bad about this, but the default zIndex for tooltips is 300, and the entity picker modal is at z-index 400 so it doesn't get overlapped by notifications that should be underneath it. Open to alternative ideas!

Copy link
Contributor

Choose a reason for hiding this comment

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

nit and proof that i'm a fuddy duddy, i've seen emojis break tooling in the past and prefer to avoid using them in code.

Copy link
Contributor

Choose a reason for hiding this comment

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

my only real feedback about the use of a very specific z-index # is that the context gets lots. i've previously used a constants file in the past that records all z-indexes so folks can understand the hierarchy in one 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.

yeah, this is a result of a series of sins. I will

  1. remove descriptions from this PR altogether so that this can merge
  2. in a separate PR, hopefully tomorrow, fix the series of z-index sins in a separate PR
  3. open a third PR to put descriptions back into this branch

Copy link
Contributor

Choose a reason for hiding this comment

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

Or can't you merge and just improve z-index sins in a follow up? That does sound like a lot only to avoid a magic number 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hooray! i haven't had an opportunity to post my favorite meme lately.
backlog

Copy link
Contributor Author

Choose a reason for hiding this comment

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

key={item.model + item.id}
result={Search.wrapEntity(item, dispatch)}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

very happy that we no longer need redux involved here, just to get an icon

@iethree iethree requested a review from a team April 30, 2024 17:01
Copy link

replay-io bot commented Apr 30, 2024

Status Complete ↗︎
Commit f9ac80d
Results
⚠️ 9 Flaky
2456 Passed

@iethree iethree force-pushed the entity-picker/new-search-item-component branch from 2102cde to c9bcbe6 Compare May 2, 2024 22:24
Copy link
Contributor

@sloansparger sloansparger left a comment

Choose a reason for hiding this comment

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

Code looks good! I am noticing though that the UI flashes the loading spinner crazy fast before showing results. I think you could introduce a small delay before showing the spinner or show the stale results with a loading indicator elsewhere. Doing so would make this feel really polished! Great work!

Comment on lines 60 to 61
// required to get the tooltip to show up over the entity picker modal 😢
zIndex: "450 !important" as any,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit and proof that i'm a fuddy duddy, i've seen emojis break tooling in the past and prefer to avoid using them in code.

Comment on lines 60 to 61
// required to get the tooltip to show up over the entity picker modal 😢
zIndex: "450 !important" as any,
Copy link
Contributor

Choose a reason for hiding this comment

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

my only real feedback about the use of a very specific z-index # is that the context gets lots. i've previously used a constants file in the past that records all z-indexes so folks can understand the hierarchy in one file.

@iethree iethree requested a review from sloansparger May 3, 2024 22:32
@iethree
Copy link
Contributor Author

iethree commented May 3, 2024

I am noticing though that the UI flashes the loading spinner crazy fast before showing results. I think you could introduce a small delay before showing the spinner or show the stale results with a loading indicator elsewhere. Doing so would make this feel really polished! Great work!

I updated this to use the delayed loading spinner, but I think the real problem is that the old search hook goes into loading mode and doesn't distinguish between refetching. I'd rather punt that to other planned work to use RTK query in this component, rather than enlarging the scope of this small PR.

@iethree iethree force-pushed the entity-picker/new-search-item-component branch from b25b0f5 to f9ac80d Compare May 3, 2024 23:01
@iethree iethree mentioned this pull request May 6, 2024
1 task
@iethree iethree merged commit 0f8beaf into master May 6, 2024
110 checks passed
@iethree iethree deleted the entity-picker/new-search-item-component branch May 6, 2024 22:50
Copy link

github-actions bot commented May 6, 2024

@iethree Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone?

@@ -57,4 +59,9 @@ export const getIconBase = (
return { name: modelIconMap?.[item.model] ?? "unknown" };
};

export const getIcon = PLUGIN_COLLECTIONS.getIcon ?? getIconBase;
export const getIcon = (item: ObjectWithModel, options: IconOptions = {}) => {
if (PLUGIN_COLLECTIONS) {
Copy link
Contributor

@kamilmielnik kamilmielnik May 7, 2024

Choose a reason for hiding this comment

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

Should we also take PLUGIN_MODERATION into account?

It also seems that getCollectionIcon has not been fully ported. Was this intentional?

@iethree iethree mentioned this pull request May 9, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-backport Do not backport this PR to any branch .Team/AdminWebapp Admin and Webapp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants