From 1e3bfc26a3f80591e8c239e4aef47be9dfdbd9cb Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Fri, 10 Nov 2023 11:22:14 +0200 Subject: [PATCH] [Data views]: Update actions API (#56026) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Data views]: Update actions API * Update packages/edit-site/src/components/dataviews/README.md Co-authored-by: André <583546+oandregal@users.noreply.github.com> --------- Co-authored-by: André <583546+oandregal@users.noreply.github.com> --- .../edit-site/src/components/actions/index.js | 12 ++-- .../src/components/dataviews/README.md | 64 ++++++++++--------- .../src/components/dataviews/item-actions.js | 6 +- .../page-templates/template-actions.js | 2 +- 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/packages/edit-site/src/components/actions/index.js b/packages/edit-site/src/components/actions/index.js index 6cbe94fc6cd654..c90ffde135a01d 100644 --- a/packages/edit-site/src/components/actions/index.js +++ b/packages/edit-site/src/components/actions/index.js @@ -31,7 +31,7 @@ export function useTrashPostAction() { isEligible( { status } ) { return status !== 'trash'; }, - async perform( post ) { + async callback( post ) { try { await deleteEntityRecord( 'postType', @@ -81,7 +81,7 @@ export function usePermanentlyDeletePostAction() { isEligible( { status } ) { return status === 'trash'; }, - async perform( post ) { + async callback( post ) { try { await deleteEntityRecord( 'postType', @@ -132,7 +132,7 @@ export function useRestorePostAction() { isEligible( { status } ) { return status === 'trash'; }, - async perform( post ) { + async callback( post ) { await editEntityRecord( 'postType', post.type, post.id, { status: 'draft', } ); @@ -183,7 +183,7 @@ export const viewPostAction = { isEligible( post ) { return post.status !== 'trash'; }, - perform( post ) { + callback( post ) { document.location.href = post.link; }, }; @@ -197,7 +197,7 @@ export function useEditPostAction() { isEligible( { status } ) { return status !== 'trash'; }, - perform( post ) { + callback( post ) { history.push( { postId: post.id, postType: post.type, @@ -222,7 +222,7 @@ export const postRevisionsAction = { post?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0; return lastRevisionId && revisionsCount > 1; }, - perform( post ) { + callback( post ) { const href = addQueryArgs( 'revision.php', { revision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id, } ); diff --git a/packages/edit-site/src/components/dataviews/README.md b/packages/edit-site/src/components/dataviews/README.md index ab077b2c6c30f6..5502165f0cfdc5 100644 --- a/packages/edit-site/src/components/dataviews/README.md +++ b/packages/edit-site/src/components/dataviews/README.md @@ -5,7 +5,7 @@ This file documents the DataViews UI component, which provides an API to render ```js