-
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: pass search
filter as global, unattached from fields
#55475
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,9 +133,6 @@ export default function PagePages() { | |
</VStack> | ||
); | ||
}, | ||
filters: [ | ||
{ id: 'search', type: 'search', name: __( 'Search' ) }, | ||
], | ||
maxWidth: 400, | ||
sortingFn: 'alphanumeric', | ||
enableHiding: false, | ||
|
@@ -200,6 +197,8 @@ export default function PagePages() { | |
[ postStatuses, authors ] | ||
); | ||
|
||
const filters = useMemo( () => [ { id: 'search', type: 'search' } ] ); | ||
|
||
const trashPostAction = useTrashPostAction(); | ||
const actions = useMemo( () => [ trashPostAction ], [ trashPostAction ] ); | ||
const onChangeView = useCallback( | ||
|
@@ -228,6 +227,7 @@ export default function PagePages() { | |
<DataViews | ||
paginationInfo={ paginationInfo } | ||
fields={ fields } | ||
filters={ filters } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this prop? What is it for? |
||
actions={ actions } | ||
data={ pages || EMPTY_ARRAY } | ||
isLoading={ isLoadingPages } | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm not sure we're expecting more global filters like that, do we? The only piece of info needed with the current architecture is the key to be used in the query, and I believe we can safely start with a
TextFilter
outside ofFilters
component(render in dataviews.js).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'd prefer not to make it a special case, to be honest. This way,
DataViews
is already future-proof for any other page/endpoint/etc.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.
Though it is a special case, no? It's a global filter. How it could affect any other page etc..?
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.
My point is that I prefer to conceptualize it as a filter and do this:
rather than making it a special case and do this:
The reason is this: what if a different page/endpoint has a global filter that is an
enumeration
or any other type of filter?The first approach is future-proof: it requires no changes in the future, it already supports any type of filter (
search
,enumeration
, and whatever we add in the future). The second approach would require us to make changes inDataViews
API (new properties, etc.) even when it already supports those other filter types.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.
No strong opinions here, but I still don't get it. We still add the
filters
prop to the API and we're trying to support a use case that we don't have right now. The concept of having a text global filter in a list or in a collection in general is the most common one, by far I think. Maybe some others can chime in, but it's not something that important for now IMO. In my mind the prop would be something likeglobalFilter="$key"
.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.
What you are suggesting would be (note we still have to pass the label as well):
And what this PR proposes is:
It's not that different :)
The only differences I see are:
globalFilter
filters
id
andlabel
I feel strongly about the shape of filters being identical between field filters and global filters: I don't think we should do anything differently.
If it helps unlock this review and merge the PR, I am open to use
globalFilter
as name and use an object instead of an array. We could change that later if needed be.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.
After thinking more about it, while I still believe the global filter is a special case and will be almost a text filter every time, passing filters array allows a consumer to have more custom filters(if they need to) that are outside the specifics of a field. Let's land this.
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.
#55722