-
Notifications
You must be signed in to change notification settings - Fork 4.7k
DataViews: Move template and pattern title fields #67449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f6d947a
DataViews: Move template title field
ntsekouras 25b09d3
patternTitle field and update classNames
ntsekouras f019829
add classNameto BaseTitleView
ntsekouras 46143aa
update e2e tests
ntsekouras 88c8219
fix tests
ntsekouras 0902cea
perf tests
ntsekouras ac7de7e
update tests
ntsekouras 2bae755
update classNames + description docs for title fields
ntsekouras beed46c
update class names
ntsekouras b2a5369
update actions
ntsekouras 1fa1eec
use TitleView
ntsekouras File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
DataViews: Move template title field
- Loading branch information
commit f6d947a4b09663089ba0209ff901ab024acfecfb
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import type { Field } from '@wordpress/dataviews'; | ||
| import { __ } from '@wordpress/i18n'; | ||
|
|
||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import type { Template } from '../../types'; | ||
| import { getItemTitle } from '../../actions/utils'; | ||
| import TitleView from '../title/view'; | ||
|
|
||
| const templateTitleField: Field< Template > = { | ||
| label: __( 'Template' ), | ||
| id: 'title', | ||
ntsekouras marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| getValue: ( { item } ) => getItemTitle( item ), | ||
| render: TitleView, | ||
| enableHiding: false, | ||
| enableGlobalSearch: true, | ||
ntsekouras marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| export default templateTitleField; | ||
ntsekouras marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,8 +1,12 @@ | ||
| /** | ||
| * External dependencies | ||
| */ | ||
| import type { ReactNode } from 'react'; | ||
|
|
||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import { __experimentalHStack as HStack } from '@wordpress/components'; | ||
| import { decodeEntities } from '@wordpress/html-entities'; | ||
| import { __ } from '@wordpress/i18n'; | ||
| import { useSelect } from '@wordpress/data'; | ||
| import { store as coreStore } from '@wordpress/core-data'; | ||
|
|
@@ -11,10 +15,10 @@ import type { Settings } from '@wordpress/core-data'; | |
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import type { BasePost } from '../../types'; | ||
| import type { CommonPost } from '../../types'; | ||
| import { getItemTitle } from '../../actions/utils'; | ||
|
|
||
| const TitleView = ( { item }: { item: BasePost } ) => { | ||
| export function PostTitleView( { item }: { item: CommonPost } ) { | ||
| const { frontPageId, postsPageId } = useSelect( ( select ) => { | ||
| const { getEntityRecord } = select( coreStore ); | ||
| const siteSettings = getEntityRecord( | ||
|
|
@@ -26,9 +30,6 @@ const TitleView = ( { item }: { item: BasePost } ) => { | |
| postsPageId: siteSettings?.page_for_posts, | ||
| }; | ||
| }, [] ); | ||
|
|
||
| const renderedTitle = getItemTitle( item ); | ||
|
|
||
| let suffix; | ||
| if ( item.id === frontPageId ) { | ||
| suffix = ( | ||
|
|
@@ -43,19 +44,29 @@ const TitleView = ( { item }: { item: BasePost } ) => { | |
| </span> | ||
| ); | ||
| } | ||
| return <BaseTitleView item={ item }>{ suffix }</BaseTitleView>; | ||
| } | ||
|
|
||
| export function BaseTitleView( { | ||
| item, | ||
| children, | ||
| }: { | ||
| item: CommonPost; | ||
| children?: ReactNode; | ||
| } ) { | ||
| const renderedTitle = getItemTitle( item ); | ||
| return ( | ||
| <HStack | ||
| className="edit-site-post-list__title" | ||
| alignment="center" | ||
| justify="flex-start" | ||
| > | ||
| <span> | ||
| { decodeEntities( renderedTitle ) || __( '(no title)' ) } | ||
| </span> | ||
| { suffix } | ||
| <span>{ renderedTitle || __( '(no title)' ) }</span> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| { children } | ||
| </HStack> | ||
| ); | ||
| }; | ||
| } | ||
|
|
||
| export default TitleView; | ||
| export default function TitleView( { item }: { item: CommonPost } ) { | ||
ntsekouras marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return <BaseTitleView item={ item } />; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.