Skip to content

Commit

Permalink
Editor: Make revisions more prominent (#62323)
Browse files Browse the repository at this point in the history
Unlinked contributors: ppolo99, smithjw1.

Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: creativecoder <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: jasmussen <[email protected]>
Co-authored-by: annezazu <[email protected]>
Co-authored-by: aaronjorbin <[email protected]>
Co-authored-by: hrkhal <[email protected]>
  • Loading branch information
8 people authored Jun 10, 2024
1 parent 5ca6eed commit b0c9f4b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
37 changes: 30 additions & 7 deletions packages/editor/src/components/post-last-revision/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,27 @@ import { addQueryArgs } from '@wordpress/url';
* Internal dependencies
*/
import PostLastRevisionCheck from './check';
import PostPanelRow from '../post-panel-row';
import { store as editorStore } from '../../store';

/**
* Renders the component for displaying the last revision of a post.
*
* @return {Component} The component to be rendered.
*/
function PostLastRevision() {
const { lastRevisionId, revisionsCount } = useSelect( ( select ) => {
function usePostLastRevisionInfo() {
return useSelect( ( select ) => {
const { getCurrentPostLastRevisionId, getCurrentPostRevisionsCount } =
select( editorStore );
return {
lastRevisionId: getCurrentPostLastRevisionId(),
revisionsCount: getCurrentPostRevisionsCount(),
};
}, [] );
}

/**
* Renders the component for displaying the last revision of a post.
*
* @return {Component} The component to be rendered.
*/
function PostLastRevision() {
const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo();

return (
<PostLastRevisionCheck>
Expand All @@ -47,4 +52,22 @@ function PostLastRevision() {
);
}

export function PrivatePostLastRevision() {
const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo();
return (
<PostLastRevisionCheck>
<PostPanelRow label={ __( 'Revisions' ) }>
<Button
href={ addQueryArgs( 'revision.php', {
revision: lastRevisionId,
} ) }
className="editor-private-post-last-revision__button"
text={ revisionsCount }
variant="tertiary"
/>
</PostPanelRow>
</PostLastRevisionCheck>
);
}

export default PostLastRevision;
4 changes: 4 additions & 0 deletions packages/editor/src/components/post-last-revision/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@
padding: $grid-unit-20;
}
}

.editor-private-post-last-revision__button {
display: inline-block;
}
2 changes: 2 additions & 0 deletions packages/editor/src/components/sidebar/post-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import PostsPerPage from '../posts-per-page';
import SiteDiscussion from '../site-discussion';
import { store as editorStore } from '../../store';
import TemplateAreas from '../template-areas';
import { PrivatePostLastRevision } from '../post-last-revision';

/**
* Module Constants
Expand Down Expand Up @@ -76,6 +77,7 @@ export default function PostSummary( { onActionPerformed } ) {
<PostAuthorPanel />
<PostTemplatePanel />
<PostDiscussionPanel />
<PrivatePostLastRevision />
<PageAttributesPanel />
<PostSyncStatus />
<BlogTitle />
Expand Down

0 comments on commit b0c9f4b

Please sign in to comment.