-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add header to the quick edit when bulk editing #67390
Changes from all commits
2995afd
503fc4b
6a69d9f
1bdc379
031625d
a0c5fa9
5e2d674
58e34e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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"> | ||
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. Part of me wonders if 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. Yeah I could move it there, I initially decided not to given that |
||
<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> | ||
); | ||
} |
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 { | ||
|
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.
Ah, nice catch. It looks like these weren't working since #65418 ?
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.
Yeah correct, although I don't think the Mixin's where being used anywhere within GB yet.