Skip to content

Commit

Permalink
Implement feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed Nov 22, 2024
1 parent 33d0c43 commit 409b9a3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import SidebarNavigationItem from '../sidebar-navigation-item';

export default function SidebarNavigationScreenDetailsFooter( {
record,
recordCount = 0,
revisionsCount,
...otherProps
} ) {
/*
Expand All @@ -35,10 +35,21 @@ export default function SidebarNavigationScreenDetailsFooter( {
const hrefProps = {};
const lastRevisionId =
record?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;
const revisionsCount =
recordCount || record?._links?.[ 'version-history' ]?.[ 0 ]?.count;
// Enable the revisions link if there is a last revision and there is more than one revision.
if ( lastRevisionId && revisionsCount ) {

// Use incoming prop first, then the record's version history, if available.
revisionsCount =
revisionsCount ||
record?._links?.[ 'version-history' ]?.[ 0 ]?.count ||
0;

/*
* Enable the revisions link if there is a last revision and there is more than one revision.
* This link is used for theme assets, e.g., templates, which have no database record until they're edited.
* For these files there's only a "revision" after they're edited twice,
* which means the revision.php page won't display a proper diff.
* See: https://github.com/WordPress/gutenberg/issues/49164.
*/
if ( lastRevisionId && revisionsCount > 1 ) {
hrefProps.href = addQueryArgs( 'revision.php', {
revision: record?._links[ 'predecessor-version' ][ 0 ].id,
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default function SidebarNavigationScreenGlobalStyles() {
// If there are no revisions, do not render a footer.
const modifiedDateTime = revisions?.[ 0 ]?.modified;
const shouldShowGlobalStylesFooter =
revisionsCount && ! isLoadingRevisions && modifiedDateTime;
revisionsCount > 0 && ! isLoadingRevisions && modifiedDateTime;

return (
<>
Expand All @@ -105,7 +105,7 @@ export default function SidebarNavigationScreenGlobalStyles() {
shouldShowGlobalStylesFooter && (
<SidebarNavigationScreenDetailsFooter
record={ revisions?.[ 0 ] }
recordCount={ revisionsCount }
revisionsCount={ revisionsCount }
onClick={ openRevisions }
/>
)
Expand Down

0 comments on commit 409b9a3

Please sign in to comment.