Skip to content

Commit

Permalink
Consolidate when showing revisions link or action (WordPress#60194)
Browse files Browse the repository at this point in the history
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: jameskoster <[email protected]>
Co-authored-by: kathrynwp <[email protected]>
Co-authored-by: jasmussen <[email protected]>
Co-authored-by: annezazu <[email protected]>
  • Loading branch information
6 people authored and cbravobernal committed Apr 9, 2024
1 parent ad015fc commit 5172fb4
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ export default function SidebarNavigationScreenDetailsFooter( {
* the following logic.
*/
const hrefProps = {};
if ( record?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ) {
const lastRevisionId =
record?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;
const revisionsCount =
record?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;
// Enable the revisions link if there is a last revision and there are more than one revisions.
if ( lastRevisionId && revisionsCount > 1 ) {
hrefProps.href = addQueryArgs( 'revision.php', {
revision: record?._links[ 'predecessor-version' ][ 0 ].id,
} );
hrefProps.as = 'a';
}

return (
<ItemGroup className="edit-site-sidebar-navigation-screen-details-footer">
<SidebarNavigationItem
Expand Down

0 comments on commit 5172fb4

Please sign in to comment.