-
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
QuickEdit: Add Featured Image Control #64496
Merged
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
785085b
Page Edit View: Implement Featured image page field
gigitux dd7e0a3
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux 77f2217
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux 433e45f
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux f890963
improve flow and style
gigitux c32622e
fix list layout
gigitux 9a39fe6
improve design
gigitux 5419b0a
remove not necessary style
gigitux 68ef300
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux cd923f8
improve style
gigitux 94335a4
improve default image control
gigitux 030a28d
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux baf7a82
fix style
gigitux 4095dab
remove not necessary configuration
gigitux 23d8695
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux ec715ed
format _z-index.scss file
gigitux ea29690
improve style
gigitux 106af4d
remove not necessary code
gigitux cc46724
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux b11e923
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux c6dffd7
fix focus
gigitux 3c262d6
remove image field type
gigitux c053a9a
add comment
gigitux 57faa8f
fix warning
gigitux d2eeb0e
fix image for deleted pages
gigitux 05f0d1a
remove filename
gigitux c4db3b9
add border-radius
gigitux cd9fe2f
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux 8356977
migrate featured image to fields package
gigitux e27dec1
fix CSS
gigitux a187591
remove not necessary changes
gigitux 8815e5a
fix type
gigitux a461d85
remove empty space
gigitux fcc2e6e
fix z-index gallery
gigitux 577f836
fix overlapping and style
gigitux a3449c4
improve codestyle
gigitux 2366429
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux 1b84ac0
use same placeholder style grid/list layout
gigitux 6ca01ff
fix tsconfig
gigitux 8e612d4
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux c448c49
add type
gigitux 2b595c2
remove mediaField from layout table
gigitux 9cc6d80
update type
gigitux 01a57a8
use text as type
gigitux 7b1e40a
use media-utils package
gigitux 6592d36
fix tsconfig
gigitux c2994e0
remove view prop
gigitux b039310
revert changes
gigitux 42f90f4
generate package-lock.json
gigitux ea8e941
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/page-…
gigitux e77b93b
generate package-lock.json
gigitux 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
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
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ import clsx from 'clsx'; | |
*/ | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
import { decodeEntities } from '@wordpress/html-entities'; | ||
import { featuredImageField } from '@wordpress/fields'; | ||
import { | ||
createInterpolateElement, | ||
useMemo, | ||
|
@@ -33,11 +34,9 @@ import { useEntityRecords, store as coreStore } from '@wordpress/core-data'; | |
import { | ||
LAYOUT_GRID, | ||
LAYOUT_TABLE, | ||
LAYOUT_LIST, | ||
OPERATOR_IS_ANY, | ||
} from '../../utils/constants'; | ||
import { default as Link, useLink } from '../routes/link'; | ||
import Media from '../media'; | ||
import { default as Link } from '../routes/link'; | ||
|
||
// See https://github.com/WordPress/gutenberg/issues/55886 | ||
// We do not support custom statutes at the moment. | ||
|
@@ -81,46 +80,6 @@ const getFormattedDate = ( dateToDisplay ) => | |
getDate( dateToDisplay ) | ||
); | ||
|
||
function FeaturedImage( { item, viewType } ) { | ||
const isDisabled = item.status === 'trash'; | ||
const { onClick } = useLink( { | ||
postId: item.id, | ||
postType: item.type, | ||
canvas: 'edit', | ||
} ); | ||
const hasMedia = !! item.featured_media; | ||
const size = | ||
viewType === LAYOUT_GRID | ||
? [ 'large', 'full', 'medium', 'thumbnail' ] | ||
: [ 'thumbnail', 'medium', 'large', 'full' ]; | ||
const media = hasMedia ? ( | ||
<Media | ||
className="edit-site-post-list__featured-image" | ||
id={ item.featured_media } | ||
size={ size } | ||
/> | ||
) : null; | ||
const renderButton = viewType !== LAYOUT_LIST && ! isDisabled; | ||
return ( | ||
<div | ||
className={ `edit-site-post-list__featured-image-wrapper is-layout-${ viewType }` } | ||
> | ||
{ renderButton ? ( | ||
<button | ||
className="edit-site-post-list__featured-image-button" | ||
type="button" | ||
onClick={ onClick } | ||
aria-label={ item.title?.rendered || __( '(no title)' ) } | ||
> | ||
{ media } | ||
</button> | ||
) : ( | ||
media | ||
) } | ||
</div> | ||
); | ||
} | ||
|
||
function PostStatusField( { item } ) { | ||
const status = STATUSES.find( ( { value } ) => value === item.status ); | ||
const label = status?.label || item.status; | ||
|
@@ -190,15 +149,7 @@ function usePostFields( viewType ) { | |
|
||
const fields = useMemo( | ||
() => [ | ||
{ | ||
id: 'featured-image', | ||
label: __( 'Featured Image' ), | ||
getValue: ( { item } ) => item.featured_media, | ||
render: ( { item } ) => ( | ||
<FeaturedImage item={ item } viewType={ viewType } /> | ||
), | ||
enableSorting: false, | ||
}, | ||
featuredImageField, | ||
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. I like that we're moving the dataviews fields to the fields package one by one 👍 and fixing them (removing dependencies...) |
||
{ | ||
label: __( 'Title' ), | ||
id: 'title', | ||
|
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 @@ | ||
.components-popover.components-dropdown__content.dataforms-layouts-panel__field-dropdown { | ||
z-index: z-index(".components-popover.components-dropdown__content.dataforms-layouts-panel__field-dropdown"); | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Two questions:
render
function instead of keeping theFeaturedImage
component?