-
Notifications
You must be signed in to change notification settings - Fork 116
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
Save/ Publish actions don't reflect state of modified block page #790
Comments
I actually thought that this was an existing issue, as I expect it's been around for sometime. However I couldn't find an open issue, so have raised this! |
@brynwhyman I can confirm that this is a missing feature. I'm familiar with a solution from one of the large projects that I worked on. I will outline the solution here to kick off a discussion. Happy to create a follow up PR for it if needed ;-) Non-technical descriptionWe implemented a feature which allows each block to provide the block page with information if it needs to be published or not. The block page collects this information from all its blocks and renders correct publish button state based on that. This also covers objects which are under the blocks, i.e. This feature is very useful because we can't expect the content author to go through all objects which are under a block page and publish them individually. In fact, most projects I worked on did not even have the option to publish individual objects, the only option was to publish the whole page. This makes this feature even more valuable. Technical descriptionThe feature consists of multiple parts. Note that these code snippets are meant to be used as examples only.
Performance considerations
Interface
Helper
Block page
Carousel block
|
Hey @mfendeksilverstripe thank you for the in-depth comment, that definitely makes sense to me but I'll let others chime in on your suggested implementation before go ahead and raise a PR. I vaguely recall that when the in-line editing functionality was developed that there was something built at the React/Redux level to kind of work around this limitation and force the change of the Save/Publish actions? For example, we can see that the block area is aware of the state of each block (modified in this case): I could definitely be wrong though :) |
I think this works only with blocks, but not with objects nested below the blocks @brynwhyman. I pointed out a need to have some block interface to indicate if block needs to be published or not possibly taking other objects in consideration. For example, a very common block is a carousel block which has many items. Each item represents one slide of the carousel. If any of the carousel items need publishing the block should indicate that it needs publishing as well (even though the block model is already published). |
Noting here that the modified state indicator colours are wrong here and were fixed in: silverstripe/silverstripe-admin#1021 |
Noting that the workaround for this is to use the versioned-snapshots module which does a better job at recording versions of child objects of a page (like blocks and blocks within blocks). There are migration issues to consider so it's not necessarily and easy workaround but it's definitely recommended. |
Hey @chrispenny thanks for reporting that issue. If you haven't already, do you mind please recording that as an issue over on the snapshots module as well? |
Have you considered not storing blocks into a database table(s) and just serialising and storing them in Content field? Something like WordPress/Gutenberg does. I think it would be great even as a lower level option in Silverstripe to be able to decide whether has_one and has_many relations should be stored in parent data object field or in separate tables. This would solve change tracking, search indexing (given a "good" serialisation is used - Gutenberg uses html with comments, I can imagine a second *_Index field where block would serialise only searchable content, etc.), performance (no need to do multilevel sql queries), page duplication, etc. Generally I would recommend to study Gutenberg and take an inspiration from it. |
Overview
The Publish action is not correctly reflecting the state of a 'modified' block page.
Here's my attempt at showing the flow (✅ = expected behaviour; ❌ = unexpected behaviour):
Other notes
At the point of the unexpected behaviour, the site tree also is not correctly reflecting that the block page is in a 'Modified' state, see:
However, the block status icon highlights the modified state correctly, see:
Versions:
CMS 4.5.0
Elemental 4.3.0
Potential workaround
See: #790 (comment)
The text was updated successfully, but these errors were encountered: