clay / amphora

Middleware for Express that composes components into renderable pages
https://claycms.gitbooks.io/amphora/
MIT License
31 stars 23 forks source link

"model.save" is not called when publishing a layout #700

Closed macgyver closed 2 years ago

macgyver commented 2 years ago

Description

When publishing a page, all components in the page are saved as new published versions and the model.save hook is called for each of them. The same is not true of layouts - the data from the draft versions of each component is saved as a published version without passing through model.save

Steps to Reproduce

Steps to reproduce the behavior:

  1. find a component that exists on a layout and put some innocuous logging into that component's model.save hook
  2. Go to any page using that layout and edit the layout
  3. publish the layout
  4. view the logs and verify you do not see the logging you added in step 1.

Expected Behavior

a component's model.save hook should be fired any time that component is saved

Next Steps

I'm not super familar with the amphora architecture but when publishing a page, there is a reference to the component's PUT behavior (components.cmptPut) in the publishing process https://github.com/clay/amphora/blob/master/lib/services/pages.js#L157

and I don't see a similar reference in the publishing process for a layout https://github.com/clay/amphora/blob/master/lib/services/layouts.js#L76

I tried simply replacing put there with components.cmptPut and my use case seems to be resolved, but I'm not sure what other effects this might have - do you think that is a decent solution?