Skip to content
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

Featured Image: Refactor "settings" panel to use ToolsPanel #67968

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 71 additions & 32 deletions packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
@@ -11,11 +11,12 @@ import { useEntityProp, store as coreStore } from '@wordpress/core-data';
import { useSelect, useDispatch } from '@wordpress/data';
import {
ToggleControl,
PanelBody,
Placeholder,
Button,
Spinner,
TextControl,
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
} from '@wordpress/components';
import {
InspectorControls,
@@ -201,45 +202,83 @@ export default function PostFeaturedImageEdit( {
/>
</InspectorControls>
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={
postType?.labels.singular_name
? sprintf(
// translators: %s: Name of the post type e.g: "post".
__( 'Link to %s' ),
postType.labels.singular_name
)
: __( 'Link to post' )
}
onChange={ () => setAttributes( { isLink: ! isLink } ) }
checked={ isLink }
/>
<ToolsPanel
label={ __( 'Settings' ) }
resetAll={ () => {
setAttributes( {
isLink: true,
linkTarget: '_self',
rel: '',
} );
} }
>
<ToolsPanelItem
label={ __( 'Link to post' ) }
isShownByDefault
hasValue={ () => ! isLink }
onDeselect={ () => setAttributes( { isLink: true } ) }
>
<ToggleControl
__nextHasNoMarginBottom
label={
postType?.labels.singular_name
? sprintf(
// translators: %s: Name of the post type e.g: "post".
__( 'Link to %s' ),
postType.labels.singular_name
)
: __( 'Link to post' )
}
onChange={ () =>
setAttributes( { isLink: ! isLink } )
}
checked={ isLink }
/>
</ToolsPanelItem>
{ isLink && (
<>
<ToggleControl
__nextHasNoMarginBottom
<ToolsPanelItem
label={ __( 'Open in new tab' ) }
onChange={ ( value ) =>
setAttributes( {
linkTarget: value ? '_blank' : '_self',
} )
isShownByDefault
hasValue={ () => linkTarget === '_blank' }
onDeselect={ () =>
setAttributes( { linkTarget: '_self' } )
}
checked={ linkTarget === '_blank' }
/>
<TextControl
__next40pxDefaultSize
__nextHasNoMarginBottom
>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Open in new tab' ) }
onChange={ ( value ) =>
setAttributes( {
linkTarget: value
? '_blank'
: '_self',
} )
}
checked={ linkTarget === '_blank' }
/>
</ToolsPanelItem>
<ToolsPanelItem
label={ __( 'Link rel' ) }
value={ rel }
onChange={ ( newRel ) =>
setAttributes( { rel: newRel } )
isShownByDefault
hasValue={ () => !! rel }
onDeselect={ () =>
setAttributes( { rel: '' } )
}
/>
>
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Link rel' ) }
value={ rel }
onChange={ ( newRel ) =>
setAttributes( { rel: newRel } )
}
/>
</ToolsPanelItem>
</>
) }
</PanelBody>
</ToolsPanel>
</InspectorControls>
</>
);

Unchanged files with check annotations Beta

// Wait for the canvas loader to appear first, so that the locator that
// waits for the hidden state doesn't resolve prematurely.
await canvasLoader.waitFor( { state: 'visible', timeout: 60_000 } );

Check failure on line 57 in packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts

GitHub Actions / Playwright - 8

[firefox] › editor/blocks/navigation-frontend-interactivity.spec.js:378:3 › Navigation block - Frontend interactivity › Submenus (Arrow setting) (@firefox

1) [firefox] › editor/blocks/navigation-frontend-interactivity.spec.js:378:3 › Navigation block - Frontend interactivity › Submenus (Arrow setting) (@Firefox, @WebKit) › submenu click on the arrow interactions TimeoutError: locator.waitFor: Timeout 60000ms exceeded. Call log: - waiting for locator('.edit-site-canvas-loader, .edit-site-canvas-spinner') to be visible at ../../../packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts:57 55 | // Wait for the canvas loader to appear first, so that the locator that 56 | // waits for the hidden state doesn't resolve prematurely. > 57 | await canvasLoader.waitFor( { state: 'visible', timeout: 60_000 } ); | ^ 58 | await canvasLoader.waitFor( { 59 | state: 'hidden', 60 | // Bigger timeout is needed for larger entities, like the Large Post at Admin.visitSiteEditor (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts:57:22) at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js:353:4

Check failure on line 57 in packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts

GitHub Actions / Playwright - 8

[firefox] › editor/blocks/navigation-frontend-interactivity.spec.js:378:3 › Navigation block - Frontend interactivity › Submenus (Arrow setting) (@firefox

1) [firefox] › editor/blocks/navigation-frontend-interactivity.spec.js:378:3 › Navigation block - Frontend interactivity › Submenus (Arrow setting) (@Firefox, @WebKit) › submenu click on the arrow interactions Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.waitFor: Timeout 60000ms exceeded. Call log: - waiting for locator('.edit-site-canvas-loader, .edit-site-canvas-spinner') to be visible at ../../../packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts:57 55 | // Wait for the canvas loader to appear first, so that the locator that 56 | // waits for the hidden state doesn't resolve prematurely. > 57 | await canvasLoader.waitFor( { state: 'visible', timeout: 60_000 } ); | ^ 58 | await canvasLoader.waitFor( { 59 | state: 'hidden', 60 | // Bigger timeout is needed for larger entities, like the Large Post at Admin.visitSiteEditor (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts:57:22) at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js:353:4
await canvasLoader.waitFor( {
state: 'hidden',
// Bigger timeout is needed for larger entities, like the Large Post