-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
DataViews: Adds a control to the views actions to switch layouts #55311
Conversation
} ) { | ||
const columns = useMemo( () => { |
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.
Basically all the tanstack initialization have move to the "view-list.js" file instead because we don't need it in other views like Grid, Kanban...
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.
Why we don't need them in the other views? Do you think all the callbacks to change the view like sorting, per page, etc.. would be different in some way?
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.
Well, I'm not entirely sure what you want to reuse here? by callbacks you mean things like onChangeView( { perPage: value } )
something else? These are very small callbacks that don't need to be shared.
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.
I meant the callbacks like onColumnVisibilityChange
etc.. that use onChangeView
. But I guess the whole point here is that we define our own API with fields, etc.., use them with setView
and that tanstack can probably be more useful only in list
view, right?
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.
It's not by principle or something I'm fine reusing tanstack wherever I can, I'm just not seeing where it can be useful elsewhere. Let's move forward and see. Maybe I'm missing something.
paginationInfo, | ||
options: { pageCount }, |
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 prop duplicated an info we already had in paginationInfo so I just removed it.
getPaginationRowModel: getPaginationRowModel(), | ||
pageCount, | ||
} ); | ||
const ViewComponent = view.type === 'list' ? ViewList : ViewGrid; |
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.
Obviously we need something more advanced than this to switch view types, but this should work for now. (Like a ViewType registry)
return ( | ||
<div className="dataviews-wrapper"> | ||
<VStack spacing={ 4 }> | ||
<HStack justify="space-between"> | ||
<TextFilter onChange={ dataView.setGlobalFilter } /> | ||
<TextFilter view={ view } onChangeView={ onChangeView } /> |
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.
I made this text filter independent of tanstack APIs.
actions={ actions } | ||
data={ data } | ||
isLoading={ isLoading } | ||
/> | ||
<Pagination |
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.
I made this text filter independent of tanstack APIs.
Size Change: +27 B (0%) Total Size: 1.65 MB
ℹ️ View Unchanged
|
Flaky tests detected in 1d22382. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6496929082
|
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.
Nothing to add — WFM and seems like a good base to build on.
Related #55083
What?
This PR adds a layout (view type) switcher to the view actions menu and updates the code to add an empty "grid view". The idea is that this PR forces us to make all the necessary refactoring that are necessary in order to support multiple layouts.
In a follow-up I'll work on the "grid view" itself to actually implement it.
Testing instructions