-
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
Data Views: enable pinning items #65629
Conversation
Size Change: +430 B (+0.02%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
Flaky tests detected in 5029ec9. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11025167230
|
5029ec9
to
2b7019f
Compare
I've sketched out how pinning and unpinning might work in 57c995e pinning.movBefore I keep moving forward, I'd appreciate a confidence check for the whole approach. cc @oandregal @youknowriad @sirreal |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Some explanation of what's being implemented here, and thoughts for moving forward:
|
Consolidated pinning and unpinning in one action, whose label changes depending on the item's data. pinning.movIn my opinion, a couple of things would be necessary to polish this:
cc. @jameskoster |
c442ce0
to
9d9e0df
Compare
@vcanales thanks for giving this a try!
Can we scope this PR so pinning can only be done from the API? This is: users shouldn't be able to pin/unpin records. In my view, this should be done after we figure out a solution for persisting user choices. |
data={ shownData } | ||
enablePinnedItems | ||
pinnedItems={ pinnedItems } | ||
onPinItem={ ( itemId: string ) => { |
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 suggestion is that we don't allow users to pin/unpin in this PR, so we can remove the onPinItem
/onUnpinItem
props and all related code.
However, it's useful to think how that could work in the future to make sure we have the right APIs. I'm thinking that there's nothing special about pinning/unpinning: it's just another action over the dataset. It seems to me that we could model this behavior using the existing actions API — so that's another argument to not introducing these props.
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.
However, it's useful to think how that could work in the future to make sure we have the right APIs. I'm thinking that there's nothing special about pinning/unpinning: it's just another action over the dataset. It seems to me that we could model this behavior using the existing actions API — so that's another argument to not introducing these props.
More thoughts: if, in the future, we want specific affordances for pinning like we have for selection, we may actually want to introduce specific callbacks. I think this would depend on whether or not we expect the layouts to implement a specific affordances for pinning (like we have for selection) vs just listing it as another action.
In any case, that's a future concern :)
paginationInfo={ paginationInfo } | ||
data={ shownData } | ||
enablePinnedItems | ||
pinnedItems={ pinnedItems } |
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.
Providing a list of "pinned items" seems to be a good direction for this feature:
- I presume we'd want pinned items to be respected by every layout, like selection is.
- Like selection, it should be a list of ids.
getItemId={ ( item ) => item.id.toString() } | ||
paginationInfo={ paginationInfo } | ||
data={ shownData } | ||
enablePinnedItems |
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's enablePinnedItems
for? can we make it work with just the pinnedItems
prop?
@@ -199,6 +199,16 @@ function usePostFields( viewType ) { | |||
), | |||
enableSorting: false, | |||
}, | |||
{ |
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.
Do we want/expect "Pinned" to be a new field that users can toggle on/off? If we don't, we shouldn't need this to make the feature work, I presume?
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.
Feels to me that "pinned" field is a bit abstract and might not be very useful to users. I would just remove it for now.
@jameskoster do you think we need this field? I challenged this a bit as well as Riad's. Not strongly opposed, but I'm not seeing what value it provides to display that boolean for something we aim to communicate visually across layouts anyway. |
Sorry I typo'd there. The field should not be toggle-able, and always hidden :D |
👍 It doesn't seem that we'd need any field to make this work :) |
To-do
What?
Enable pinning items in the page list and data views, with pinned pages sorted at the top.
Why?
This PR is a WIP Proof of Concept for issues #65379 and #64678, which highlighted a problem where important pages like the homepage and posts page were hard to locate in the page list when not pinned to the top. By adding the ability to pin items, it becomes easier to access and manage these important pages.
How?
The implementation introduces an 'is-pinned' attribute to the post fields, determines pinned pages based on their ID, and sorts these pinned items at the top of the list in the post list component. This change helps ensure that key pages are always easily accessible.