Skip to content
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

Consider a "Save history" option on "Clear Customizations" #52221

Open
nickpagz opened this issue Jul 2, 2023 · 5 comments
Open

Consider a "Save history" option on "Clear Customizations" #52221

nickpagz opened this issue Jul 2, 2023 · 5 comments
Labels
[Feature] History History, undo, redo, revisions, autosave. [Focus] Blocks Adoption For issues that directly impact the ability to adopt features of Gutenberg. [Type] Enhancement A suggestion for improvement.

Comments

@nickpagz
Copy link

nickpagz commented Jul 2, 2023

What problem does this address?

The new revisions option is a great tool, but at the moment there is no way to revert to the original theme file version of a template or template part, using the revisions tool. The closest you can get is the second save. As a result, users are forced to either manually edit the template (and therefore creating another revision), or use the "clear customizations" option.

The issue with clearing customizations is that it wipes all revisions from the database, so at this point there's no going back, and a potential heart breaking scenario for an un-seasoned user. There's also no second chances with this action - clicking the button does not bring up a warning or modal window to confirm the action or consequence.

What is your proposed solution?

There's likely a few possibilities around this, here's a few options:

  • Add a second button, "Clear Customizations and save revision history", wordy, but something along those lines.
  • Make it very clear what happens. Add a modal or popup to indicate the consequences of clearing customizations.
  • Per the above, add a "Save revisions" checkbox in the modal/pop-up. Internally, a new revision with content copied from the theme file is created.
  • Make it transparent to the user and always create a new revision per the above point, by default. For devs or theme creators, potentially create a dev mode, or hook, to disable that action.
@annezazu annezazu added [Type] Enhancement A suggestion for improvement. [Feature] History History, undo, redo, revisions, autosave. [Focus] Blocks Adoption For issues that directly impact the ability to adopt features of Gutenberg. labels Jul 5, 2023
@talldan
Copy link
Contributor

talldan commented Sep 17, 2024

I closed #65369 as a duplicate. I think the suggestion is to make Clear Customizations always keep the history and perhaps reset to the first revision?

#49164 is a relevant issue as template parts don't have the correct first revision.

@nickpagz
Copy link
Author

I think the suggestion is to make Clear Customizations always keep the history and perhaps reset to the first revision?

Right, I think at least a warning advising the consequences of clicking on "Clear customizations". In addition, instead of clearing all the revisions, make the very last revision the new "1st revision", (optionally remove all other previous revisions), and copy the template contents from the theme files as the latest revision. This gives users an "undo" option in case they made a mistake.

@Andrew-Starr
Copy link

Parity with the global styles would be great. One can reset global styles, and the previous revisions are not deleted, so it is possible to revert back to any revision even after doing a reset. I think it could be confusing for users why template/part revisions are not available in the same way.

As I understand it, this is because on theme activation an empty global styles post is created, and when resetting the global styles its post is not trashed, rather it is emptied and so the post and its revisions still exist.

Would it be possible for the template post content to be emptied when doing a reset, rather than the post being trashed? This way the revisions would still exist. But then how do we ensure an empty template is not rendered?

To add some context to my issue; I was working on an importer to import templates. This was working quite well until said template was reset by the user after being further edited. Maybe they thought that resetting would bring back the originally imported template. When that happens the imported template no longer exists and then defaults back to the default theme (or plugin) template.

I worked around this by duplicating the imported template as a pattern that can be accessed via Template > Design. This works really well for 1 pattern per template, so I thought about duplicating every revision as a pattern, but the presentation of it in the Design area of the template editor became unwieldy after more than 2 or 3 revisions.

@nickpagz
Copy link
Author

But then how do we ensure an empty template is not rendered?

If I'm following you correctly, this is the part where we would want to copy-paste the markup from the original theme file into the now latest revision - which then looks like a "reset".

@Andrew-Starr
Copy link

If I'm following you correctly, this is the part where we would want to copy-paste the markup from the original theme file into the now latest revision - which then looks like a "reset".

Yes I think that would work 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] History History, undo, redo, revisions, autosave. [Focus] Blocks Adoption For issues that directly impact the ability to adopt features of Gutenberg. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants