-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DataViews Extensibility: Allow unregistering the view post action (#6…
…4467) Co-authored-by: youknowriad <[email protected]> Co-authored-by: Mamaduka <[email protected]>
- Loading branch information
1 parent
64643ed
commit e8b45da
Showing
4 changed files
with
42 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { external } from '@wordpress/icons'; | ||
import { __ } from '@wordpress/i18n'; | ||
import type { Action } from '@wordpress/dataviews'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { BasePost } from '../types'; | ||
|
||
const viewPost: Action< BasePost > = { | ||
id: 'view-post', | ||
label: __( 'View' ), | ||
isPrimary: true, | ||
icon: external, | ||
isEligible( post ) { | ||
return post.status !== 'trash'; | ||
}, | ||
callback( posts, { onActionPerformed } ) { | ||
const post = posts[ 0 ]; | ||
window.open( post?.link, '_blank' ); | ||
if ( onActionPerformed ) { | ||
onActionPerformed( posts ); | ||
} | ||
}, | ||
}; | ||
|
||
export default viewPost; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters