Skip to content

Commit

Permalink
Code Quality: Update: Reuse view revisions action on templates and pa…
Browse files Browse the repository at this point in the history
…ges. (#57208)
  • Loading branch information
jorgefilipecosta authored and artemiomorales committed Jan 4, 2024
1 parent 1cce8f7 commit 2266df4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/page-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import {
useResetTemplateAction,
deleteTemplateAction,
renameTemplateAction,
seeRevisionsAction,
} from './template-actions';
import { postRevisionsAction } from '../actions';
import usePatternSettings from '../page-patterns/use-pattern-settings';
import { unlock } from '../../lock-unlock';
import PostPreview from '../post-preview';
Expand Down Expand Up @@ -333,7 +333,7 @@ export default function DataviewsTemplates() {
resetTemplateAction,
deleteTemplateAction,
renameTemplateAction,
seeRevisionsAction,
postRevisionsAction,
],
[ resetTemplateAction ]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
__experimentalHStack as HStack,
__experimentalVStack as VStack,
} from '@wordpress/components';
import { addQueryArgs } from '@wordpress/url';

/**
* Internal dependencies
Expand Down Expand Up @@ -208,23 +207,3 @@ export const renameTemplateAction = {
);
},
};

export const seeRevisionsAction = {
id: 'see-revisions',
label: __( 'See revisions' ),
isEligible: ( template ) => {
if ( template?._links && template?._links[ 'predecessor-version' ] ) {
const predecessorVersions =
template._links[ 'predecessor-version' ];
return predecessorVersions.length > 0;
}
return false;
},
callback( template ) {
const lastRevisionId =
template?._links[ 'predecessor-version' ][ 0 ].id;
document.location.href = addQueryArgs( 'revision.php', {
revision: lastRevisionId,
} );
},
};

0 comments on commit 2266df4

Please sign in to comment.