Skip to content

Commit

Permalink
Consolidate when showing revisions link or action (#60194)
Browse files Browse the repository at this point in the history
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: kathrynwp <zoonini@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: annezazu <annezazu@git.wordpress.org>
  • Loading branch information
6 people committed Apr 2, 2024
1 parent 6f2e542 commit cee2fde
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 cee2fde

Please sign in to comment.