-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Template revisions: require 2 revisions before showing the revisions UI #50762
Conversation
…k. Removing the `+ 1` ensures this.
Size Change: -5 B (0%) Total Size: 1.38 MB
ℹ️ View Unchanged
|
Flaky tests detected in 62058ea. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5019984469
|
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.
Thank you for fixing this in the UI @ramonjd 🙏🏻 As you mentioned it's a partial fix - we should still aim to fix this so that after 1 change users get the button saying "1 revision". I think this system of loading the file in the DB needsa bit of tweaking in terms of when the "loading" happens. Not it only happens when we edit, but maybe it should be loaded when it's 1st opened? |
Good point, thanks for sharing @draganescu It sounds like a tricky one to solve. I tried to find a place in the code to try it out, but got a bit stuck and spent too much time on it 😄 What would we class as "first opened"?
I'm guessing the first option might be better? If we detect that the template record doesn't exist we can create a new one in the database. I admit I did hack around to create a POC but couldn't come up with the right way to interact with the entityRecords. Note, this problem doesn't appear to affect custom template, since a database record is inserted as soon as the custom template is created, and every modification thereafter is a "revision". Edit: this is in the context of the WordPress code diff revisions.php page. I suppose we could manipulate the "first" revision if we developed an in-editor revisions UI like we have done for the global styles. |
Yes if that's the path I guess we should not do anything and wait. Not sure.
The templates API endpoint calls |
Resolves #50675 (at least partially)
What?
We want to have at least 2 revisions before showing the revisions UI for templates and template parts.
Why?
Quoting @talldan from #50675 (comment)
Because of this, it takes another 2 edits to create 2 "revisions". Without that crucial second edit the revisions UI will not display an empty pane as it has nothing with which to compare the first.
How?
Removing the
+ 1
on the revisions count.Testing Instructions
In the site editor, make three changes to a template.
The revisions button should display.
Now check out the revisions UI and ensure that there is no blank revision on the right hand side.
Repeat for a template part.
cc @georgeh for review as well
Screenshots or screencast
2023-05-19.11.47.00.mp4