forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…Press#66937) Co-authored-by: oandregal <[email protected]> Co-authored-by: youknowriad <[email protected]>
- Loading branch information
1 parent
37b5b55
commit 2bacb50
Showing
6 changed files
with
118 additions
and
78 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
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,32 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import type { Field } from '@wordpress/dataviews'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { BasePost } from '../../types'; | ||
import StatusView from './status-view'; | ||
import STATUSES from './status-elements'; | ||
|
||
const OPERATOR_IS_ANY = 'isAny'; | ||
|
||
const statusField: Field< BasePost > = { | ||
label: __( 'Status' ), | ||
id: 'status', | ||
type: 'text', | ||
elements: STATUSES, | ||
render: StatusView, | ||
Edit: 'radio', | ||
enableSorting: false, | ||
filterBy: { | ||
operators: [ OPERATOR_IS_ANY ], | ||
}, | ||
}; | ||
|
||
/** | ||
* Status field for BasePost. | ||
*/ | ||
export default statusField; |
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,50 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
trash, | ||
drafts, | ||
published, | ||
scheduled, | ||
pending, | ||
notAllowed, | ||
} from '@wordpress/icons'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
// See https://github.com/WordPress/gutenberg/issues/55886 | ||
// We do not support custom statutes at the moment. | ||
const STATUSES = [ | ||
{ | ||
value: 'draft', | ||
label: __( 'Draft' ), | ||
icon: drafts, | ||
description: __( 'Not ready to publish.' ), | ||
}, | ||
{ | ||
value: 'future', | ||
label: __( 'Scheduled' ), | ||
icon: scheduled, | ||
description: __( 'Publish automatically on a chosen date.' ), | ||
}, | ||
{ | ||
value: 'pending', | ||
label: __( 'Pending Review' ), | ||
icon: pending, | ||
description: __( 'Waiting for review before publishing.' ), | ||
}, | ||
{ | ||
value: 'private', | ||
label: __( 'Private' ), | ||
icon: notAllowed, | ||
description: __( 'Only visible to site admins and editors.' ), | ||
}, | ||
{ | ||
value: 'publish', | ||
label: __( 'Published' ), | ||
icon: published, | ||
description: __( 'Visible to everyone.' ), | ||
}, | ||
{ value: 'trash', label: __( 'Trash' ), icon: trash }, | ||
]; | ||
|
||
export default STATUSES; |
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,28 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __experimentalHStack as HStack, Icon } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { BasePost } from '../../types'; | ||
import STATUSES from './status-elements'; | ||
|
||
function StatusView( { item }: { item: BasePost } ) { | ||
const status = STATUSES.find( ( { value } ) => value === item.status ); | ||
const label = status?.label || item.status; | ||
const icon = status?.icon; | ||
return ( | ||
<HStack alignment="left" spacing={ 0 }> | ||
{ icon && ( | ||
<div className="edit-site-post-list__status-icon"> | ||
<Icon icon={ icon } /> | ||
</div> | ||
) } | ||
<span>{ label }</span> | ||
</HStack> | ||
); | ||
} | ||
|
||
export default StatusView; |