Custom Posts: Add Set as Homepage / Posts Page actions#25575
Custom Posts: Add Set as Homepage / Posts Page actions#25575crazytonyli wants to merge 9 commits into
Conversation
Consolidate homepage and posts page tracking into a single PageRole enum. Update HomepageSetting to track both homepage and posts page IDs from site settings.
Add view model methods that update site settings via the WordPress core REST API with optimistic local state updates and rollback on failure.
Show Set as Homepage, Set as Posts Page, and Set as Regular Page actions in a Page Attributes submenu for published pages. Add a "Posts page" badge alongside the existing "Homepage" badge using the consolidated pageRole property.
Add currentUserCan(_:) to WordPressClient for checking user capabilities via the cached current user data. Only show the Page Attributes submenu when the user has the manage_options capability.
WordPressClient.fetchSiteSettings now takes a forceRefresh flag that bypasses the loadSiteSettingsTask cache and re-runs the network fetch. CustomPostListViewModel passes forceRefresh through from pullToRefresh, so the Pages list picks up homepage and posts-page assignments changed outside the app without requiring an app relaunch.
The mark-page-roles guard checked for .custom("any"), a legacy form
that predates the .any case wordpress-rs now exposes. The All tab
uses .any, so the predicate never matched and the Homepage / Posts
page badges never rendered there.
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 32504 | |
| Version | PR #25575 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | c09db1b | |
| Installation URL | 2n9vf8k45e6h8 |
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 32504 | |
| Version | PR #25575 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | c09db1b | |
| Installation URL | 79d6un86q89f0 |
| @@ -0,0 +1,63 @@ | |||
| import Testing | |||
There was a problem hiding this comment.
This test doesn't seem to be executed by anything – it doesn't show up in Buildkite and Claude is indicating it's not wired up by the Xcode project file
| /// Pass `forceRefresh: true` to bypass the cache and refetch from the server — | ||
| /// callers should do this when they know the server-side settings may have changed | ||
| /// outside this client (e.g. on pull-to-refresh). | ||
| public func fetchSiteSettings(forceRefresh: Bool = false) async throws -> SiteSettingsWithEditContext { |
There was a problem hiding this comment.
If we do this, I think we need to invalidate (or reassign) loadSiteSettingsTask (or make an async accessor?)
There was a problem hiding this comment.
Sorry, I don't quite understand the issue. Do you mean explicty cancel the task like:
if forceRefresh {
self.loadSiteSettingsTask?.cancel()
self.loadSiteSettingsTask = ...
...
}There was a problem hiding this comment.
That would work, though it's probably better to just let the original finish and await the result?
The idea is that if the user pulls to refresh more than once, do we want multiple in-flight network requests?
| value: "Settings", | ||
| comment: "Menu action to open post settings" | ||
| ) | ||
| static let setHomepageSuccess = NSLocalizedString( |
There was a problem hiding this comment.
Do we need three copies of this?


Note
I recommend reviewing by commits. The first commit is code-format changes and can be ignored.
Description
Fix https://linear.app/a8c/issue/CMM-1981
Mirror the existing Pages: showing "Page Attributes" menus on published Pages.