-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Add Page Versions #2022
Merged
Merged
Add Page Versions #2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tvdeyen
force-pushed
the
page-versions-2020
branch
2 times, most recently
from
February 15, 2021 10:48
bb8287c
to
676ea3b
Compare
mamhoff
approved these changes
Feb 15, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow wow wow.
tvdeyen
force-pushed
the
page-versions-2020
branch
4 times, most recently
from
February 16, 2021 12:21
11d483a
to
04fae2a
Compare
and associate with page
Points to the gem and allows to run webpacker in the dummy app
Create a public version as well and copy the public elements over.
The element trash has been removed recently.
While loading a page tree from the API include elements from public page version.
and use the page version instead.
Instead of passing the page_id we use the page_version_id to create, update and order elements in the Admin.
Only elements that have a public version should be returned by the API.
It turned out that using .find_each messed with the order of elements during copy.
We want to make sure that we only have one published version at a given time. Ideally we would also have a database constraint, but for now this works fine. Otherwise we would get duplicated elements on pages with several published versions.
Instead of the current page the ElementsFinder now uses the given page version to load elements. The render_elements and Page#find_elements methods use the pages public_version by default, while supporting to pass/set a custome page version instead.
Since we load the draft version elements in the elements window, we need to load the pages draft version in the preview frame as well.
In render_elements we use either a `@page_version` or the pages public version to load elements from.
Instead of creating a new public version every time we publish a page, we re-use the already published version and copy all elements over. Creating a new one if no published version exists yet. That way we are sure that we always only have one public version per page.
A page is considered public? if a public version exists and this is published.
Any page that does not have any published version is considered not public
These timestamps now live on the page version. The values still exists on the table for historical reasons and to make upgrades easer, but they are set to read only and delegate to the public version.
Only use the assigned page version if there is no page given via the `:from_page` option, so that elements are loaded from a layout page is ensured even in the page edit preview.
This reverts commit 9bddcd2.
Always use the draft version of the page set or passed into render_elements if we are in preview_mode.
tvdeyen
force-pushed
the
page-versions-2020
branch
from
February 22, 2021 17:16
3e10e16
to
7e801d5
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is this pull request for?
Adds page versions in order to fix a fundamental issue we are having for a long time now:
Once a page is published all further changes to elements on that page are immediately public as well.
Although we have the "Publish" button this really never was a stable fix to that problem, since this relied on a cached version of that page that not always is guaranteed to exist.
This now is fixed by associating elements to a page version and moving the publication timestamps from the page to the page version model.
Every page has at least one draft version (a not published version) and - once published - a public version.
A page is considered public if the page has a public page version. Elements are always loaded from the public version of a page. The preview always shows the draft version and updates to elements are always only made on the draft version.
When publishing the page the currently visible elements are copied to the public version and never get touched again.
For now subsequent publishes will re-create the public version and does not - yet - store a version history. This way we do not create too many versions (and elements/contents/essences , etc.) that would needed to be cleaned up ans such.
There are lots of opportunities with this new layer, but we want to keep the impact as limited as possible right now.
For instance there is currently no change in the UI. What we consider a good thing for now.
So there is currently no version management or switching possible (say necessary), but this is lays the foundation for it.
Checklist
TODO