-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Refactor types in CollectionPicker #40377
Conversation
@@ -26,6 +24,12 @@ const canSelectItem = (item: CollectionPickerItem | null): boolean => { | |||
return !!item && item?.can_write !== false; | |||
}; | |||
|
|||
const searchFilter = ( |
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 change is not type-related.
This function does not need to be a hook.
This reverts commit b762d0f.
|
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.
Very nice work 👏 Thanks! As you can see, we struggled a bit with the types 🥴
I think that the complexity of these types is actually a smell that the diversity of API responses we get for the same things from the backend could use some work. I'm hopeful that the openAPI docs the backend has recently put in, along with some of the code gen features of RTK Query can help us simplify this in the future.
@kamilmielnik Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone? |
Needed for #40298
Description
EntityPicker
contains a search component which has been build to support all types of models (seeSearchModelType
).However - depending on the context - it will usually be used only with a subset of models, for example:
Up until now
EntityPicker
type declarations were tightly coupled with Collections.This PR removes this coupling and makes the component generic so that we can have type safety in various context without type casting. It's mostly about moving files and extending the types, but I'm sneaking in a few small code changes as well.
Short summary of changes:
metabase/common/components/EntityPicker
tometabase/common/components/CollectionPicker
metabase/common/components/EntityPicker/
generic, so that it can be used in various contextsEntityPickerSearch
and 1 in a unit testany
ssearchFilter
function (it didn't have to be a hook)NestedItemPicker
storybook page - it didn't work and was using an outdated interface ofNestedItemPicker
. Maybe it used to deserve a storybook page at the time of creation, but I don't think it does anymore as its UI part now lives inItemList
.How to verify
metabase/common/components/CollectionPicker
CollectionPicker
is Collections-specific