1
1
import { InspectorControls } from '@wordpress/block-editor' ;
2
- import { PanelBody , ToggleControl } from '@wordpress/components' ;
2
+ import { PanelBody , ToggleControl , BaseControl , TextControl } from '@wordpress/components' ;
3
+ import { useInstanceId } from '@wordpress/compose' ;
3
4
import { __ } from '@wordpress/i18n' ;
5
+ import { getValidatedAttributes } from '../../shared/get-validated-attributes' ;
6
+ import metadata from './block.json' ;
4
7
5
8
function SubscriberLoginEdit ( { attributes, setAttributes, className } ) {
6
- const { redirectToCurrent } = attributes ;
9
+ const logInInputId = useInstanceId ( TextControl , 'inspector-text-control' ) ;
10
+ const logOutInputId = useInstanceId ( TextControl , 'inspector-text-control' ) ;
11
+ const manageSubscriptionsInputId = useInstanceId ( TextControl , 'inspector-text-control' ) ;
12
+ const validatedAttributes = getValidatedAttributes ( metadata . attributes , attributes ) ;
13
+ const { redirectToCurrent, logInLabel, logOutLabel, manageSubscriptionsLabel } =
14
+ validatedAttributes ;
7
15
8
16
return (
9
17
< >
@@ -14,10 +22,37 @@ function SubscriberLoginEdit( { attributes, setAttributes, className } ) {
14
22
checked = { redirectToCurrent }
15
23
onChange = { ( ) => setAttributes ( { redirectToCurrent : ! redirectToCurrent } ) }
16
24
/>
25
+ < BaseControl label = { __ ( 'Log in label' , 'jetpack' ) } id = { logInInputId } >
26
+ < TextControl
27
+ placeholder = { __ ( 'Log in' , 'jetpack' ) }
28
+ onChange = { value => setAttributes ( { logInLabel : value } ) }
29
+ value = { logInLabel }
30
+ id = { logInInputId }
31
+ />
32
+ </ BaseControl >
33
+ < BaseControl label = { __ ( 'Log out label' , 'jetpack' ) } id = { logOutInputId } >
34
+ < TextControl
35
+ placeholder = { __ ( 'Log out' , 'jetpack' ) }
36
+ onChange = { value => setAttributes ( { logOutLabel : value } ) }
37
+ value = { logOutLabel }
38
+ id = { logOutInputId }
39
+ />
40
+ </ BaseControl >
41
+ < BaseControl
42
+ label = { __ ( 'Manage subscriptions label' , 'jetpack' ) }
43
+ id = { manageSubscriptionsInputId }
44
+ >
45
+ < TextControl
46
+ placeholder = { __ ( 'Manage subscriptions' , 'jetpack' ) }
47
+ onChange = { value => setAttributes ( { manageSubscriptionsLabel : value } ) }
48
+ value = { manageSubscriptionsLabel }
49
+ id = { manageSubscriptionsInputId }
50
+ />
51
+ </ BaseControl >
17
52
</ PanelBody >
18
53
</ InspectorControls >
19
54
< div className = { className } >
20
- < a href = "#logout-pseudo-link" > { __ ( 'Log out' , 'jetpack' ) } </ a >
55
+ < a href = "#logout-pseudo-link" > { logOutLabel || __ ( 'Log out' , 'jetpack' ) } </ a >
21
56
</ div >
22
57
</ >
23
58
) ;
0 commit comments