plone / plone.app.mosaic

Plone Mosaic main repository
https://pypi.python.org/pypi/plone.app.mosaic
GNU General Public License v2.0
35 stars 26 forks source link

Cannot upload images in custom persistent tile. #494

Closed mauritsvanrees closed 2 years ago

mauritsvanrees commented 2 years ago

This is on Plone 6.0.0a6 with checkouts of plone.app.mosaic, plone.staticresources, plone.app.tiles.

The demo tile works in a basic edit form: http://localhost:8080/Plone/@@edit-tile/plone.app.tiles.demo.persistent/tile-1 Uploaded images are saved, and I can edit and replace them.

But in a custom tile in Mosaic it fails. The image does not get saved, and I get a validation error because the field is required. Trying to replace the image in an already existing tile does not work either: also a validation error. With the simple edit form, it works fine, in my case under this url: http://localhost:8080/nl/@@edit-tile/zeelandia.tiles.header_tile/tile-2

I tried registering the demo tiles to more easily have others test this, but that failed for me.

petschki commented 2 years ago

Maybe this is not as fixed as we thought: https://github.com/plone/mockup/issues/1166 ... I'll take a look.

mauritsvanrees commented 2 years ago

I confirm that with the demo tiles active in Mosaic they have the same problem as my custom tile.

petschki commented 2 years ago

Aha ... turns out, that module federation used the "outdated" pat-plone-modal module from mockup 5.0.0-alpha.12 delivered by mosaic. I've updated mockup here #495 (besides some minor fixes) and can now upload files within the tile modal.

petschki commented 2 years ago

tada ... and now I understand the sharing option "singleton" because it's exactly what we need here (and maybe other addon developers too). It ensures, that the highest available mockup version is loaded.

This is a nice documentation about that https://www.angulararchitects.io/en/aktuelles/getting-out-of-version-mismatch-hell-with-module-federation/ -> "Singletons"

I've added it to mosaic's webpack.config.js ... fortunately with the new @patternslib/dev version its easy to configure that. https://github.com/plone/plone.app.mosaic/pull/495/commits/ef7ac610835f7367efc203c39f45c542e7753222

/cc @thet

thet commented 2 years ago

@petschki tnx for fixing this!

Although I‌ wonder a bit about that. using the webpack.mf.js config from @patternslib/dev, mockup should already been set as singleton: https://github.com/Patternslib/dev/blob/main/webpack/webpack.mf.js#L23

Maybe it's in combination with requiredVersion that it did not work...?

petschki commented 2 years ago

that's true. @plone/mockup is set as singleton in mosaic webpack config with its requiredVersion from mosaic dependencies. So the explanation above is true for 2 dependencies with different versions set as singleton dependencies.

But in Plone we have mockup as the "base", loading mosaic via MF with its sharing dependency mockup as singleton ... how can MF know that the base mockup has a higher version than the singleton sharing dependency in mosaic? it definitely should somehow ...