-
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.
Add header to the quick edit when bulk editing (#67390)
* Add quick edit bulk header * Updating styling of header * Moved header to post-edit folder * Make use of mixin for the post title * Pass postId to the pageTypeBadge hook, for use outside editor * Fix formatting issues * Move parseInt up * Remove title field Co-authored-by: louwie17 <[email protected]> Co-authored-by: jameskoster <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: oandregal <[email protected]>
- Loading branch information
1 parent
6c312f7
commit 32cbb04
Showing
9 changed files
with
118 additions
and
25 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,88 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
__experimentalHStack as HStack, | ||
__experimentalVStack as VStack, | ||
Icon, | ||
__experimentalText as Text, | ||
} from '@wordpress/components'; | ||
import { useMemo } from '@wordpress/element'; | ||
import { | ||
privateApis as editorPrivateApis, | ||
store as editorStore, | ||
} from '@wordpress/editor'; | ||
import { store as coreStore } from '@wordpress/core-data'; | ||
import { useSelect } from '@wordpress/data'; | ||
import { sprintf, __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { unlock } from '../../lock-unlock'; | ||
|
||
const { PostCardPanel } = unlock( editorPrivateApis ); | ||
|
||
export default function PostEditHeader( { postType, postId } ) { | ||
const ids = useMemo( () => postId.split( ',' ), [ postId ] ); | ||
const { icon, labels } = useSelect( | ||
( select ) => { | ||
const { getEditedEntityRecord, getPostType } = select( coreStore ); | ||
const { getPostIcon } = unlock( select( editorStore ) ); | ||
const _record = getEditedEntityRecord( | ||
'postType', | ||
postType, | ||
ids[ 0 ] | ||
); | ||
|
||
return { | ||
icon: getPostIcon( postType, { | ||
area: _record?.area, | ||
} ), | ||
labels: getPostType( postType )?.labels, | ||
}; | ||
}, | ||
[ ids, postType ] | ||
); | ||
|
||
if ( ids.length === 1 ) { | ||
return ( | ||
<PostCardPanel | ||
postType={ postType } | ||
postId={ parseInt( ids[ 0 ], 10 ) } | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<VStack spacing={ 1 } className="edit-site-post-edit-header"> | ||
<HStack spacing={ 2 } align="center" justify="normal"> | ||
<Icon | ||
className="edit-site-post-edit-header__icon" | ||
icon={ icon } | ||
/> | ||
<Text | ||
numberOfLines={ 2 } | ||
truncate | ||
className="edit-site-post-edit-header__title" | ||
as="h2" | ||
> | ||
{ labels?.name && | ||
sprintf( | ||
// translators: %i number of selected items %s: Name of the plural post type e.g: "Posts". | ||
__( '%i %s' ), | ||
ids.length, | ||
labels?.name | ||
) } | ||
</Text> | ||
</HStack> | ||
<Text className="edit-site-post-edit-header__description"> | ||
{ sprintf( | ||
// translators: %s: Name of the plural post type e.g: "Posts". | ||
__( 'Changes will be applied to all selected %s.' ), | ||
labels?.name.toLowerCase() | ||
) } | ||
</Text> | ||
</VStack> | ||
); | ||
} |
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 |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
mix-blend-mode: normal; | ||
display: block; | ||
} | ||
|
||
/* stylelint-enable */ | ||
|
||
body.js #wpadminbar { | ||
|
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
32cbb04
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 32cbb04.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12195143759
📝 Reported issues:
/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js