-
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.
[Fields] Migrate store and actions from editor package to fields pack…
…age (#65261) Co-authored-by: gigitux <[email protected]> Co-authored-by: youknowriad <[email protected]>
- Loading branch information
1 parent
eba5eb7
commit d329bfb
Showing
30 changed files
with
376 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
File renamed without changes.
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,5 @@ | ||
export { default as viewPost } from './view-post'; | ||
export { default as reorderPage } from './reorder-page'; | ||
export { default as reorderPageNative } from './reorder-page.native'; | ||
export { default as duplicatePost } from './duplicate-post'; | ||
export { default as duplicatePostNative } from './duplicate-post.native'; |
File renamed without changes.
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,2 @@ | ||
export { default as viewPostRevisions } from './view-post-revisions'; | ||
export { default as permanentlyDeletePost } from './permanently-delete-post'; |
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,3 @@ | ||
export * from './base-post'; | ||
export * from './common'; | ||
export * from './pattern'; |
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
File renamed without changes.
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,3 @@ | ||
export { default as duplicatePattern } from './duplicate-pattern'; | ||
export { default as exportPattern } from './export-pattern'; | ||
export { default as exportPatternNative } from './export-pattern.native'; |
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,66 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { decodeEntities } from '@wordpress/html-entities'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { Post, TemplatePart, Template } from '../types'; | ||
|
||
export const TEMPLATE_POST_TYPE = 'wp_template'; | ||
export const TEMPLATE_PART_POST_TYPE = 'wp_template_part'; | ||
export const TEMPLATE_ORIGINS = { | ||
custom: 'custom', | ||
theme: 'theme', | ||
plugin: 'plugin', | ||
}; | ||
|
||
export function isTemplate( post: Post ): post is Template { | ||
return post.type === TEMPLATE_POST_TYPE; | ||
} | ||
|
||
export function isTemplatePart( post: Post ): post is TemplatePart { | ||
return post.type === TEMPLATE_PART_POST_TYPE; | ||
} | ||
|
||
export function isTemplateOrTemplatePart( | ||
p: Post | ||
): p is Template | TemplatePart { | ||
return p.type === TEMPLATE_POST_TYPE || p.type === TEMPLATE_PART_POST_TYPE; | ||
} | ||
|
||
export function getItemTitle( item: Post ) { | ||
if ( typeof item.title === 'string' ) { | ||
return decodeEntities( item.title ); | ||
} | ||
if ( 'rendered' in item.title ) { | ||
return decodeEntities( item.title.rendered ); | ||
} | ||
if ( 'raw' in item.title ) { | ||
return decodeEntities( item.title.raw ); | ||
} | ||
return ''; | ||
} | ||
|
||
/** | ||
* Check if a template is removable. | ||
* | ||
* @param template The template entity to check. | ||
* @return Whether the template is removable. | ||
*/ | ||
export function isTemplateRemovable( template: Template | TemplatePart ) { | ||
if ( ! template ) { | ||
return false; | ||
} | ||
// In patterns list page we map the templates parts to a different object | ||
// than the one returned from the endpoint. This is why we need to check for | ||
// two props whether is custom or has a theme file. | ||
return ( | ||
[ template.source, template.source ].includes( | ||
TEMPLATE_ORIGINS.custom | ||
) && | ||
! Boolean( template.type === 'wp_template' && template?.plugin ) && | ||
! template.has_theme_file | ||
); | ||
} |
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,2 @@ | ||
export { default as titleField } from './title'; | ||
export { default as orderField } from './order'; |
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,18 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import type { Field } from '@wordpress/dataviews'; | ||
import { __ } from '@wordpress/i18n'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { BasePost } from '../../types'; | ||
|
||
const orderField: Field< BasePost > = { | ||
type: 'integer', | ||
id: 'menu_order', | ||
label: __( 'Order' ), | ||
description: __( 'Determines the order of pages.' ), | ||
}; | ||
|
||
export default orderField; |
Oops, something went wrong.