Skip to content

Custom Posts: Show published pages with hierarchy#25353

Open
crazytonyli wants to merge 5 commits intotrunkfrom
task/page-hierarchy
Open

Custom Posts: Show published pages with hierarchy#25353
crazytonyli wants to merge 5 commits intotrunkfrom
task/page-hierarchy

Conversation

@crazytonyli
Copy link
Contributor

Description

In the existing Pages screen, all pages are fetched and reorganized into a tree. This PR implements the same on the custom post list.

Testing instructions

Compare the existing Pages screen with the one backed by the wordpress-rs library. They should show the same list of pages.

@crazytonyli crazytonyli added this to the 26.8 milestone Mar 9, 2026
@crazytonyli crazytonyli requested a review from kean March 9, 2026 02:09
@dangermattic
Copy link
Collaborator

1 Warning
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 9, 2026

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number31404
VersionPR #25353
Bundle IDorg.wordpress.alpha
Commitcc5e308
Installation URL7q5o7imqhuiv0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 9, 2026

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number31404
VersionPR #25353
Bundle IDcom.jetpack.alpha
Commitcc5e308
Installation URL5t7h5mrqmq5t0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 9, 2026

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

Copy link
Contributor

@kean kean left a comment

Choose a reason for hiding this comment

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

I've tested the changes on one of my sites and was not able to get the new screens to show the hierarchy. In addition, some of the pages appear to be missing.

Screenshot 2026-03-10 at 9 03 41 AM Screenshot 2026-03-10 at 9 04 02 AM

}
} else {
ForEach(Array(items.enumerated()), id: \.element.id) { index, item in
let showSubdirectoryIcon: Bool = {
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) I'd suggest extracting showSubdirectoryIcon and also extracting the two branches for flat/hierarchal data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. Updated in cc5e308.

/// built once from the complete dataset.
private func fetchAllPages() async {
isBatchSyncing = true
defer { isBatchSyncing = false }
Copy link
Contributor

Choose a reason for hiding this comment

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

The web version bails if there are too many pages. If a site has more than 100 pages, a hierarchal view would be unusable as it would require too much scrolling, so there is no point attempting to show the hierarchy as it would only make the user experience worse. For a site that has a large number of pages, this would also become a performance issue. wdyt about following how the web approaches it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wdyt about following how the web approaches it?

This PR reused the existing Pages screen display: fetching all pages and displaying the page hierarchy. And this only happens on the Published tab. Maybe we can defer the refactor to later if needed?

If a site has more than 100 pages, a hierarchal view would be unusable as it would require too much scrolling, so there is no point attempting to show the hierarchy as it would only make the user experience worse.

This is how it works in this PR:

  1. Show the cached pages if available. This will almost instantly show a hierarchy view.
  2. Start to fetch all the pages. At the moment, the pagination size is 20, which I will change to 100 later (pending Allow changing the per_page argument Automattic/wordpress-rs#1220). That means we should be able to make a few HTTP requests to fetch all pages.
  3. While the pages are fetching in the background and new pages come in, the page list is not updated.
  4. After all pages are fetched, the page list is updated to show the hierarchy view.

I think this UX should be okay?

@crazytonyli
Copy link
Contributor Author

@kean The hierarchy view is only shown in the "Published" tab. I think it makes sense to show it in the "All" tab too, which I'll update.

I'll look into why posts are missing from the "All" tab, though. That probably uncovers some other issues.

@crazytonyli
Copy link
Contributor Author

I have created a Linear issue https://linear.app/a8c/issue/CMM-1941 to track the post missing issue.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants