-
Notifications
You must be signed in to change notification settings - Fork 179
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
Editor: Add link to revisions #12197
Conversation
For reference, if it helps, here's how WP gets the necessary data to display: https://github.com/WordPress/gutenberg/blob/7b519e482ca62a186c29d2c00e41c5947712f44f/packages/editor/src/store/selectors.js#L225-L251 Since we're only using this in |
Actually, just realized that in Gutenberg the revision count is updated automatically when saving: Screen.Recording.2022-08-31.at.17.32.46.movFor this we'd need to pass the revision count & link via the REST API. I guess we can do that too. |
Added the code to Editor.php for now to move this along a bit. Will look to move to a rest call. |
@swissspidy is there an existing REST controller I should add a route to ? Or would this be a new controller / route? |
We have Story_Controller with lots of precedence with custom additional fields. We can add these fields there, no need for a new route. |
Code has been moved to the Story_Controller pulling data in via the story. |
Plugin builds for 77ce1ab are ready 🛎️!
|
Size Change: +845 B (0%) Total Size: 2.68 MB
ℹ️ View Unchanged
|
Spent a bit of time on this PR. On the face of it, I don't like the new PHP code added. Adding these new fields is not nessary as this data is already in the REST API in another format. It is currently hidden. So I put together another PR on top of this one that get that using existing fields. It is a WIP, but if you like the idea, I recommend merging into this branch and continuing to work on it. See #12264 It is worth noting that this data is in the links field. See this screenshot. |
packages/wp-story-editor/src/components/documentPane/publish/publish.js
Outdated
Show resolved
Hide resolved
updated to use sprintf and _n
packages/wp-story-editor/src/components/documentPane/publish/publish.js
Outdated
Show resolved
Hide resolved
<Link | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
href={addQueryArgs(revisionLink, { revision: revisionId })} |
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.
We may want to have a help function to get a revision link from config. Makin this a little more compatible with other cmses. Thoughts @swissspidy
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.
The link cannot come from the config because it‘s dynamic. It should come from the REST API, which is why I‘ve originally suggested adding a new REST field to the API, so that we don‘t have to create the link here ourselves.
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.
Why can't it come from a config? How about a function like this.
getRevisionLink( revisionId )
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.
The final revision link is revision.php?revision=<id>
where <id>
changes every time you save the story in the editor.
Anyway, the current way is OK for now since this is in the wp-story-editor
package, so other CMSes are not relevant here.
I would love to see some kind of testing here. A unit test or karma test would be great. Also, I believe now, we will need to update fixtures, so include the new fields. |
…ublish.js Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
packages/wp-story-editor/src/components/documentPane/publish/publish.js
Outdated
Show resolved
Hide resolved
This comment was marked as duplicate.
This comment was marked as duplicate.
I wonder if we should up the number of revisions from 10. See web-stories-wp/includes/Story_Post_Type.php Lines 388 to 399 in e1efbf1
|
packages/wp-story-editor/src/components/documentPane/publish/publish.js
Outdated
Show resolved
Hide resolved
packages/wp-story-editor/src/components/documentPane/publish/publish.js
Outdated
Show resolved
Hide resolved
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.
Just two minor nits otherwise looks good
…ublish.js Co-authored-by: Pascal Birchler <pascalb@google.com>
Context
In Gutenberg there's a link to the revisions comparison screen in the document tab It would be nice to do the same in the story editor as well, maybe in the PublishPanel component (packages/wp-story-editor/src/components/documentPane/publish/publish.js) below the poster image / publisher logo setting
Summary
Adds revisions link / icon to publish panel
Relevant Technical Choices
To-do
User-facing changes
Testing Instructions
This PR can be tested by following these steps:
Note: improvements to the revisions page itself are not part of this ticket.
Reviews
Does this PR have a security-related impact?
No
Does this PR change what data or activity we track or use?
No
Does this PR have a legal-related impact?
No
Checklist
Type: XYZ
label to the PRFixes #85