Skip to content
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

[WIP] Widgets editor integration with batch processing #26205

Conversation

adamziel
Copy link
Contributor

@adamziel adamziel commented Oct 16, 2020

🚧 UNDER CONSTRUCTION 🚧

Integration of data layer with #26164

This is super rudimentary, a better approach is coming

@adamziel adamziel added [Package] Core data /packages/core-data [Package] Data Controls /packages/data-controls labels Oct 16, 2020
@adamziel adamziel self-assigned this Oct 16, 2020
@github-actions
Copy link

github-actions bot commented Oct 16, 2020

Size Change: +497 B (0%)

Total Size: 1.19 MB

Filename Size Change
build/autop/index.js 2.72 kB -1 B
build/blob/index.js 668 B +1 B
build/block-directory/index.js 8.65 kB +1 B
build/block-editor/index.js 130 kB +3 B (0%)
build/components/index.js 169 kB +4 B (0%)
build/compose/index.js 9.63 kB +3 B (0%)
build/data-controls/index.js 684 B +1 B
build/data/index.js 8.63 kB -2 B (0%)
build/edit-navigation/index.js 10.6 kB +1 B
build/edit-post/index.js 306 kB -4 B (0%)
build/edit-site/index.js 21.1 kB -1 B
build/edit-widgets/index.js 21.9 kB +486 B (2%)
build/editor/index.js 42.5 kB +2 B (0%)
build/i18n/index.js 3.54 kB -1 B
build/is-shallow-equal/index.js 711 B +1 B
build/keyboard-shortcuts/index.js 2.39 kB +2 B (0%)
build/primitives/index.js 1.34 kB -1 B
build/redux-routine/index.js 2.85 kB +1 B
build/reusable-blocks/index.js 3.04 kB -1 B
build/server-side-render/index.js 2.6 kB +2 B (0%)
build/token-list/index.js 1.24 kB -1 B
build/url/index.js 4.06 kB -1 B
build/warning/index.js 1.14 kB +1 B
build/wordcount/index.js 1.17 kB +1 B
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.54 kB 0 B
build/api-fetch/index.js 3.35 kB 0 B
build/batch-processing/index.js 3.99 kB 0 B
build/block-directory/style-rtl.css 943 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-editor/style-rtl.css 10.9 kB 0 B
build/block-editor/style.css 10.9 kB 0 B
build/block-library/editor-rtl.css 8.65 kB 0 B
build/block-library/editor.css 8.65 kB 0 B
build/block-library/index.js 142 kB 0 B
build/block-library/style-rtl.css 7.71 kB 0 B
build/block-library/style.css 7.71 kB 0 B
build/block-library/theme-rtl.css 741 B 0 B
build/block-library/theme.css 741 B 0 B
build/block-serialization-default-parser/index.js 1.78 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/blocks/index.js 47.6 kB 0 B
build/components/style-rtl.css 15.4 kB 0 B
build/components/style.css 15.4 kB 0 B
build/core-data/index.js 12.1 kB 0 B
build/date/index.js 31.9 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 568 B 0 B
build/dom/index.js 4.42 kB 0 B
build/edit-navigation/style-rtl.css 868 B 0 B
build/edit-navigation/style.css 871 B 0 B
build/edit-post/style-rtl.css 6.3 kB 0 B
build/edit-post/style.css 6.29 kB 0 B
build/edit-site/style-rtl.css 3.77 kB 0 B
build/edit-site/style.css 3.77 kB 0 B
build/edit-widgets/style-rtl.css 2.97 kB 0 B
build/edit-widgets/style.css 2.97 kB 0 B
build/editor/editor-styles-rtl.css 480 B 0 B
build/editor/editor-styles.css 482 B 0 B
build/editor/style-rtl.css 3.85 kB 0 B
build/editor/style.css 3.84 kB 0 B
build/element/index.js 4.45 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/index.js 7.49 kB 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.js 1.74 kB 0 B
build/html-entities/index.js 622 B 0 B
build/keycodes/index.js 1.85 kB 0 B
build/list-reusable-blocks/index.js 3.02 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/media-utils/index.js 5.12 kB 0 B
build/notices/index.js 1.69 kB 0 B
build/nux/index.js 3.27 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/plugins/index.js 2.44 kB 0 B
build/priority-queue/index.js 789 B 0 B
build/rich-text/index.js 13 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/viewport/index.js 1.75 kB 0 B

compressed-size-action

@adamziel adamziel force-pushed the update/integrate-batch-processing-with-data-layer branch from 192e827 to 83f8427 Compare October 16, 2020 16:00
@adamziel adamziel force-pushed the update/integrate-batch-processing-with-data-layer branch from 4ef39e7 to 358e5f3 Compare October 16, 2020 16:04
@@ -131,7 +131,7 @@ public function serve_batch_request( WP_REST_Request $batch_request ) {
$allow_batch = ! empty( rest_get_server()->get_route_options( $route )['allow_batch'] );
}

if ( ! $allow_batch ) {
if ( 0 && ! $allow_batch ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

temporary to make the endpoint work for testing

@adamziel adamziel force-pushed the update/integrate-batch-processing-with-data-layer branch from 358e5f3 to 83532bf Compare October 16, 2020 16:39
@adamziel adamziel force-pushed the update/integrate-batch-processing-with-data-layer branch from 83532bf to cc54114 Compare October 16, 2020 16:41
@adamziel adamziel changed the title [WIP] Core data integration with batch processing [WIP] Widgets editor integration with batch processing Oct 16, 2020
} );

if ( response.failed ) {
throw response.responses.map( ( { body } ) => body );
Copy link
Contributor Author

@adamziel adamziel Oct 16, 2020

Choose a reason for hiding this comment

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

if the error is general and we don't have granular responses this function could just throw it as it is and batch-processing will propagate it to each caller

Comment on lines +36 to +40
return dispatch( 'core/batch-processing' ).enqueueItemAndAutocommit(
'WIDGETS_API_FETCH',
'default',
request
);
Copy link
Contributor Author

@adamziel adamziel Oct 16, 2020

Choose a reason for hiding this comment

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

Alternatively this could call something like enqueueItemAndWaitForResults and get a promise that would be resolved once processBatch is called explicitly and finishes running.

Comment on lines +19 to +22
dispatch( 'core/batch-processing' ).registerProcessor(
'WIDGETS_API_FETCH',
batchProcessor
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have mixed feelings about storing callbacks in redux state. That may not be a problem we need to solve now, or may not be a problem at all.

@@ -70,7 +70,7 @@ export function* commitTransaction( batchId, transactionId ) {
exception,
results;
try {
results = yield* processTransaction( batch, transactionId );
results = yield processTransaction( batch, transactionId );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

missing rebase

@TimothyBJacobs TimothyBJacobs force-pushed the update/data-layer-batch-requests-use-state branch from b40cf06 to e36d90e Compare October 18, 2020 22:28
@TimothyBJacobs
Copy link
Member

I've integrated these changes into #26086. I think we should consolidate into that PR since there isn't much point of supporting batching without using the new endpoints.

adamziel pushed a commit that referenced this pull request Oct 19, 2020
@adamziel adamziel force-pushed the update/data-layer-batch-requests-use-state branch from e36d90e to 3c3b2e7 Compare October 19, 2020 12:52
adamziel added a commit that referenced this pull request Oct 19, 2020
* Draft batch-processing module

* committing/rudimentary API_FETCH integration

* Make batch processing functional!

* Roll back integration changes

* Cleanup package.json

* Update package-lock.json

* Update terminology

* yield from commitTransaction

* Correct yield from

* Move the comment where it belongs

* First pass at enqueueItemAndWaitForResults.

* First pass at using the new sidebars and widget endpoints.

* Add test for saving multiple widgets in a row

* Generate better error message when creating fails

* Add basic batch integration.

Works off of #26205.

* Allow mixing HTTP methods in a batch.

* Fix disappearing data, add basic error handling.

We need to get the full list of widget ids from the client, we can't use the
returned widget ids from the batch because not all widgets will be dirty.

Also implements basic error handling for when the batch fails. A snackbar is
added with the names of the widgets that failed to save. We also now propagate
a dummy error to the apiFetch callers for the requests that didn't have a
validation error, but need something to short circuit their handling.

* yield from the widget area saving.

* Move batch-processing into edit-widgets package

Co-authored-by: Adam Zieliński <[email protected]>
@adamziel adamziel closed this Oct 19, 2020
adamziel added a commit that referenced this pull request Oct 19, 2020
* Draft batch-processing module

* committing/rudimentary API_FETCH integration

* Make batch processing functional!

* Roll back integration changes

* Cleanup package.json

* Update package-lock.json

* Update terminology

* yield from commitTransaction

* Correct yield from

* Move the comment where it belongs

* First pass at enqueueItemAndWaitForResults.

* Draft batch-processing module

* committing/rudimentary API_FETCH integration

* Make batch processing functional!

* Roll back integration changes

* Cleanup package.json

* Update package-lock.json

* Update terminology

* yield from commitTransaction

* Correct yield from

* Move the comment where it belongs

* update package-lock.json

* First pass at using the new sidebars and widget endpoints. (#26086)

* Draft batch-processing module

* committing/rudimentary API_FETCH integration

* Make batch processing functional!

* Roll back integration changes

* Cleanup package.json

* Update package-lock.json

* Update terminology

* yield from commitTransaction

* Correct yield from

* Move the comment where it belongs

* First pass at enqueueItemAndWaitForResults.

* First pass at using the new sidebars and widget endpoints.

* Add test for saving multiple widgets in a row

* Generate better error message when creating fails

* Add basic batch integration.

Works off of #26205.

* Allow mixing HTTP methods in a batch.

* Fix disappearing data, add basic error handling.

We need to get the full list of widget ids from the client, we can't use the
returned widget ids from the batch because not all widgets will be dirty.

Also implements basic error handling for when the batch fails. A snackbar is
added with the names of the widgets that failed to save. We also now propagate
a dummy error to the apiFetch callers for the requests that didn't have a
validation error, but need something to short circuit their handling.

* yield from the widget area saving.

* Move batch-processing into edit-widgets package

Co-authored-by: Adam Zieliński <[email protected]>

* remove separate batch-processing package

* Update batch processing tests

* Resolve batch errors in a safe, well-ordered way

* Fix unit tests

* Wire progress indicator to specific widgets

* Fix authorship after merge/rebase (1/2)

* Fix authorship after merge/rebase (2/2)

* Don't mark the method property as required.

We don't evaluate nested defaults yet, so this caused errors.

* Allow updating widgets without including the id_base or number.

* Don't start GET /wp/v2/widgets?per_page=-1 if there are batch requests already in progress

* Process newWidgetClientIds in correct order

* Fix package.json

* remove batch-processing package

Co-authored-by: Timothy Jacobs <[email protected]>
@aristath aristath deleted the update/integrate-batch-processing-with-data-layer branch November 10, 2020 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Core data /packages/core-data [Package] Data Controls /packages/data-controls
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants