-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[RNMobile] Add Reusable blocks to the inserter menu #25383
[RNMobile] Add Reusable blocks to the inserter menu #25383
Conversation
Update `master` branch from original repo.
const perPage = Platform.select( { | ||
// Unbounded queries don't work on native so we can only fetch the maximum items for now | ||
native: 100, | ||
web: -1, | ||
} ); |
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.
As far as I checked if per_page=-1
query parameter is included in the request, one of the api-fetch
middleware items (fetch-all-middleware
) consider it as an unbounded query. This means that it will try to fetch all the available items of this resource by potentially doing multiple requests with the maximum items per page until it reaches the end.
As stated in the code:
// The REST API enforces an upper limit on the per_page option. To handle large
// collections, apiFetch consumers can pass `per_page=-1`; this middleware will
// then recursively assemble a full response array from all available pages.
The problem is that this middleware requires the full response object to apply its logic, for example it needs to read the link
header to know the next page. Unfortunately the mobile version of api-fetch
doesn't return the full response, it only returns the response's body so we can't rely on this logic, which means that we can't use that query parameter because it raises an exception.
My first approach was to find a workaround in the Gutenberg project but for the mobile version the request logic is handled in the native side, maybe in the future that part should be reviewed because this could be a limitation if we need to do unbounded queries.
For now, as a workaround, what I've done is fetch the maximum items per page that should be enough for Reusable blocks.
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 also wrote (internal reference p9ugOq-1in-p2) about this just in case we want to tackle it in the future.
</> | ||
); | ||
const getHeader = () => | ||
header || ( |
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 component only allowed for the header a text, this new prop will allows to add anything we might need to render in the header.
@@ -75,6 +76,7 @@ export { default as Gradient } from './mobile/gradient'; | |||
export { default as ColorSettings } from './mobile/color-settings'; | |||
export { LinkPicker } from './mobile/link-picker'; | |||
export { default as LinkSettings } from './mobile/link-settings'; | |||
export { default as SegmentedControl } from './mobile/segmented-control'; |
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.
Surprisingly this component was not exported I saw that it was only used in another component).
packages/block-editor/src/components/inserter/style.native.scss
Outdated
Show resolved
Hide resolved
Update master branch from original repo
Update master branch from original repo.
Update master branch from original repo
Here I'm resuming the pending things to do in this PR:
Apart from the feedback this PR was ready. |
Update master branch from original repo.
Update master branch from original repo
Update master branch from original repo
Update master branch from original repo
It's not required by Reusable blocks fetch.
The value is now the same as the missing component since they behave the same, this way the UI tests can follow the same flow.
Block name's field was being used which is not unique so it has been changed to id field.
The work on this PR will continue in #28495. |
Gutenberg-mobile PR
-> wordpress-mobile/gutenberg-mobile#2644Description
This PR includes the changes from #25265
Add support to insert existing Reusable blocks from the editor in the mobile version. For this purpose the inserter menu now could show 2 tabs in case this kind of blocks have been previously created in the site.
The Reusable blocks tab will show all the blocks created of this type in the site.
How has this been tested?
I tested this feature in the following 3 different scenarios:
WordPress.com site
Create a WordPress.com site or use an already created one.
+
icon to pop up the inserter menuSelf-hosted site with Jetpack
Create a self-hosted site with Jetpack (I used https://jurassic.ninja/create/) or use an already created one.
+
icon to pop up the inserter menuSelf-hosted site without Jetpack
Create a self-hosted site without Jetpack (I created a local one using this instructions) or use your own.
+
icon to pop up the inserter menuScreenshots
iOS Screenshots
iPhone 8
Android Screenshots
Nexus 5
Types of changes
New feature
Checklist: