Create an endpoint to publish all auto-saved entities

Created on 26 November 2024, 8 days ago

Overview

For šŸŒ± Milestone 0.2.0: Experience Builder-rendered nodes Active we will not be using Workspaces.

All work in XB will be auto-saved and then the user will click a "Publish all" button that will convert all the auto-saves into real entity saves.

We have already done šŸ“Œ Autosave PoC Active and šŸ“Œ Create AutoSave service and HTTP API to retrieve all entities with pending changes Active is in progress to implement the rest of the functionality we will need

This issue will provide an endpoint to the client that will convert all the auto-save states into actual entity revisions.

Proposed resolution

  1. Extract most of the logic in ApiContentUpdateController into a new ClientToEntityConverter service
  2. Temporarily add a getAllAutoSaves to NotTheGoodAutoSaveTrait. We may not end up needing this if šŸ“Œ Create AutoSave service and HTTP API to retrieve all entities with pending changes Active is committed first
  3. Create a new PublishAllController. This controller will:
    • call getAllAutoSaves, then for each auto-save data it will....
    • convert to an entity using the new ClientToEntityConverter service
    • If the conversion doesn't not have errors.....
    • validate the entity
    • save the entity

As mentioned in #3488368-8: Save metadata (page data) field with the content entity revision ā†’ once we are using Workspaces, after 0.2, the logic inside the PublishAllController may change. This controller may not be dealing with auto-save to entity conversion to entity saves. It may just moving entities to from 1 workspace to another like regular workspaces

Therefore I don't think we should worry too much about what would happen in 0.2 if you had 100 entities being saved in 1 request.
Since 0.2 is truley a preview I think it would be reasonable to put some limit on the number entity changes we support in XB at once. Because otherwise we likely will be solving performance problems that might go away when using Workspaces.

Follow-ups

Once the above is done we can re-open šŸ“Œ Save metadata(page data) field with the entity revision Active but instead add the logic to the ClientToEntityConverter

User interface changes

None the "Publish all" button on the UI will be added in another issue.

šŸ“Œ Task
Status

Active

Version

0.0

Component

Page builder

Created by

šŸ‡ŗšŸ‡øUnited States tedbow Ithaca, NY, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @tedbow
  • šŸ‡§šŸ‡ŖBelgium wim leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    @tedbow just discovered most delicious can of worms šŸ¤£

    What if one content entity was modified by Ted, another by Wim, and they have different permissions granted? What if Ted is unable to edit what Wim was able to edit and vice versa? Who is then actually authorized to publish those accumulated changes in tempstore?

    How does the workspaces module handle this?

    Whatever XB does here MUST match however Workspaces handles it.

    Let's not derail this issue with that problem and create a follow-up issue to investigate how Workspaces handles it, to determine if keeping things simple here creates more work for when XB adopts Workspaces entirely.

  • šŸ‡§šŸ‡ŖBelgium wim leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ
  • Merge request !430Issue #3489994 create publish all endpoint ā†’ (Merged) created by tedbow
  • First commit to issue fork.
  • Pipeline finished with Success
    7 days ago
    Total: 748s
    #351403
  • Pipeline finished with Canceled
    6 days ago
    Total: 432s
    #352656
  • Pipeline finished with Failed
    6 days ago
    Total: 707s
    #352662
  • Pipeline finished with Failed
    6 days ago
    #352694
  • Pipeline finished with Failed
    6 days ago
    Total: 558s
    #352701
  • Pipeline finished with Failed
    6 days ago
    Total: 529s
    #352720
  • Pipeline finished with Success
    6 days ago
    Total: 705s
    #352728
  • Pipeline finished with Failed
    5 days ago
    Total: 755s
    #353591
  • Pipeline finished with Success
    5 days ago
    Total: 841s
    #353753
  • šŸ‡¦šŸ‡ŗAustralia larowlan šŸ‡¦šŸ‡ŗšŸ.au GMT+10

    I've expanded the tests here and also improved the error response to include meta about the entity type and ID that the issue exists in, which I think (based on the designs) the FE will need.

    I will see if we can easily include the component ID in the meta too, although I suspect that will need something that extends ConstraintViolation to add the additional data - so that's likely into follow-up territory

  • šŸ‡¦šŸ‡ŗAustralia larowlan šŸ‡¦šŸ‡ŗšŸ.au GMT+10

    I will see if we can easily include the component ID in the meta too, although I suspect that will need something that extends ConstraintViolation to add the additional data - so that's likely into follow-up territory

    šŸ¤¦ this is already in the source.pointer output šŸ˜Ž

  • Pipeline finished with Failed
    5 days ago
    Total: 791s
    #353833
  • šŸ‡¦šŸ‡ŗAustralia larowlan šŸ‡¦šŸ‡ŗšŸ.au GMT+10

    The CI fail is coming from \Drupal\Core\Template\ComponentsTwigExtension::doValidateProps which indicates we have an issue with XBPreviewRenderer when there's an invalid entry in the auto-save storage

    We will want these items to render without validation I suspect, or rather without taking out the whole page.

  • šŸ‡¦šŸ‡ŗAustralia larowlan šŸ‡¦šŸ‡ŗšŸ.au GMT+10

    Added an extension to ComponentValidator with a method to opt-out of validation during preview

  • Pipeline finished with Failed
    5 days ago
    Total: 637s
    #353871
  • Pipeline finished with Canceled
    5 days ago
    Total: 151s
    #353888
  • Pipeline finished with Success
    5 days ago
    Total: 994s
    #353892
  • šŸ‡§šŸ‡ŖBelgium wim leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    I'm surprised by the changes in ApiPreviewController: based on the issue title + summary I didn't expect those in this MR.

    @larowlan articulated why this is necessary in #8 + #9: because CI was failing without those changes. Okay! šŸ‘

    But ā€¦ I'm concerned about disabling SDC's validator, because AFAICT it can result in SDCs failing to render, triggering PHP errors. That would make šŸ“Œ Improve server-side error handling Active critical based on @lauriii's statements in that issue.

  • šŸ‡ŗšŸ‡øUnited States tedbow Ithaca, NY, USA

    Assigning back to @wim leers , re #10 I think this is unrelated issue and pushed up a change that removes a need for the changes to `XBPreviewRenderer`

    I think the rest of @wim leers comments on the MR are about changes to the files that are no longer needed

  • Pipeline finished with Skipped
    1 day ago
    #356872
  • First commit to issue fork.
  • Pipeline finished with Skipped
    1 day ago
    #356874
  • šŸ‡«šŸ‡®Finland lauriii Finland

    Got a +1 from @larowlan on Slack that this is ready to merge.

  • Pipeline finished with Success
    1 day ago
    Total: 838s
    #357015
  • First commit to issue fork.
  • šŸ‡ŗšŸ‡øUnited States tedbow Ithaca, NY, USA

    @larowlan and @lauriii thanks for finishing this off!

    One thing, I noticed is that we have todo to remove ApiContentUpdateForDemoController which also means in that issue we will probably also remove ApiContentUpdateForDemoControllerTest.

    The problem is that ApiContentUpdateForDemoControllerTest covers a lot of the logic that is now in ClientDataToEntityConverter. We have the new ApiPublishAllControllerTest but that doesn't cover all the cases we cover in <code>ApiContentUpdateForDemoControllerTest

    for instance the logic around creating 'pointer' => "layout.children[1]", but I am pretty sure there is more.

    so we can't just remove ApiContentUpdateForDemoControllerTest when we remove ApiContentUpdateForDemoController or we lose our indirect test coverage for ClientDataToEntityConverter.

    So we should probably make a follow-up to create ClientDataToEntityConverterTest and move most of the error test cases from ApiContentUpdateForDemoControllerTest into that leaving ApiContentUpdateForDemoControllerTest to be just a small test to cover the logic in the controller that can be removed when we remove the controller.

  • šŸ‡ŗšŸ‡øUnited States tedbow Ithaca, NY, USA

    @traviscarden also made a follow-up šŸ› Add missing response to `/xb/api/publish-all` in `openapi.yml` Active

  • šŸ‡¦šŸ‡ŗAustralia larowlan šŸ‡¦šŸ‡ŗšŸ.au GMT+10

    That follow up could perhaps be https://www.drupal.org/project/experience_builder/issues/3489772 šŸ“Œ Add a param converter and DTO for XB data model Active

  • šŸ‡§šŸ‡ŖBelgium wim leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    @larowlan

    šŸ§ We can be explicit here (PNX coding standard has banned the use of empty and isset for some time so this is jarring for me, but feel free to ignore).

    Feel free to open an issue to enforce this on this project too, using PHPStan presumably? šŸ¤“

    @tedbow: Superb simplification of this issue, along with a thorough explanation ā€” well done! šŸ‘šŸ¤©

  • šŸ‡§šŸ‡ŖBelgium wim leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    Per

    After 0.2.0, we'll work on Workspaces integration. The requirements and approach for that are being discussed in šŸŒ± Research: Possible backend implementations of auto-save, drafts, and publishing Active

    ā€” point 1 in šŸŒ± Milestone 0.2.0: Experience Builder-rendered nodes Active .

    Workspaces support is for post-0.2, and the issue for it is #3475672.

    So, untagging.

Production build 0.71.5 2024