|
1 | 1 | /** |
2 | 2 | * WordPress dependencies |
3 | 3 | */ |
4 | | -import { PanelBody, ToggleControl } from '@wordpress/components'; |
5 | | -import { __ } from '@wordpress/i18n'; |
6 | 4 | import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; |
| 5 | +import { |
| 6 | + ToggleControl, |
| 7 | + __experimentalToolsPanel as ToolsPanel, |
| 8 | + __experimentalToolsPanelItem as ToolsPanelItem, |
| 9 | +} from '@wordpress/components'; |
| 10 | +import { __ } from '@wordpress/i18n'; |
7 | 11 |
|
8 | 12 | export default function LoginOutEdit( { attributes, setAttributes } ) { |
9 | 13 | const { displayLoginAsForm, redirectToCurrent } = attributes; |
10 | 14 |
|
11 | 15 | return ( |
12 | 16 | <> |
13 | 17 | <InspectorControls> |
14 | | - <PanelBody title={ __( 'Settings' ) }> |
15 | | - <ToggleControl |
16 | | - __nextHasNoMarginBottom |
| 18 | + <ToolsPanel |
| 19 | + label={ __( 'Settings' ) } |
| 20 | + resetAll={ () => { |
| 21 | + setAttributes( { |
| 22 | + displayLoginAsForm: false, |
| 23 | + redirectToCurrent: true, |
| 24 | + } ); |
| 25 | + } } |
| 26 | + > |
| 27 | + <ToolsPanelItem |
17 | 28 | label={ __( 'Display login as form' ) } |
18 | | - checked={ displayLoginAsForm } |
19 | | - onChange={ () => |
20 | | - setAttributes( { |
21 | | - displayLoginAsForm: ! displayLoginAsForm, |
22 | | - } ) |
| 29 | + isShownByDefault |
| 30 | + hasValue={ () => displayLoginAsForm } |
| 31 | + onDeselect={ () => |
| 32 | + setAttributes( { displayLoginAsForm: false } ) |
23 | 33 | } |
24 | | - /> |
25 | | - <ToggleControl |
26 | | - __nextHasNoMarginBottom |
| 34 | + > |
| 35 | + <ToggleControl |
| 36 | + __nextHasNoMarginBottom |
| 37 | + label={ __( 'Display login as form' ) } |
| 38 | + checked={ displayLoginAsForm } |
| 39 | + onChange={ () => |
| 40 | + setAttributes( { |
| 41 | + displayLoginAsForm: ! displayLoginAsForm, |
| 42 | + } ) |
| 43 | + } |
| 44 | + /> |
| 45 | + </ToolsPanelItem> |
| 46 | + <ToolsPanelItem |
27 | 47 | label={ __( 'Redirect to current URL' ) } |
28 | | - checked={ redirectToCurrent } |
29 | | - onChange={ () => |
30 | | - setAttributes( { |
31 | | - redirectToCurrent: ! redirectToCurrent, |
32 | | - } ) |
| 48 | + isShownByDefault |
| 49 | + hasValue={ () => ! redirectToCurrent } |
| 50 | + onDeselect={ () => |
| 51 | + setAttributes( { redirectToCurrent: true } ) |
33 | 52 | } |
34 | | - /> |
35 | | - </PanelBody> |
| 53 | + > |
| 54 | + <ToggleControl |
| 55 | + __nextHasNoMarginBottom |
| 56 | + label={ __( 'Redirect to current URL' ) } |
| 57 | + checked={ redirectToCurrent } |
| 58 | + onChange={ () => |
| 59 | + setAttributes( { |
| 60 | + redirectToCurrent: ! redirectToCurrent, |
| 61 | + } ) |
| 62 | + } |
| 63 | + /> |
| 64 | + </ToolsPanelItem> |
| 65 | + </ToolsPanel> |
36 | 66 | </InspectorControls> |
37 | 67 | <div |
38 | 68 | { ...useBlockProps( { |
|
0 commit comments