@@ -20,38 +20,38 @@ import { store as editSiteStore } from '../../store';
20
20
* (using useMergeRefs()) to
21
21
* the editor iframe canvas.
22
22
*/
23
- export function usePageContentLockNotifications ( ) {
23
+ export function usePageContentFocusNotifications ( ) {
24
24
const ref = useEditTemplateNotification ( ) ;
25
25
useBackToPageNotification ( ) ;
26
26
return ref ;
27
27
}
28
28
29
29
/**
30
30
* Hook that displays a 'Edit your template to edit this block' notification
31
- * when the user is focusing on editing page content and clicks on a locked
31
+ * when the user is focusing on editing page content and clicks on a disabled
32
32
* template block.
33
33
*
34
34
* @return {import('react').RefObject<HTMLElement> } Ref which should be passed
35
35
* (using useMergeRefs()) to
36
36
* the editor iframe canvas.
37
37
*/
38
38
function useEditTemplateNotification ( ) {
39
- const hasPageContentLock = useSelect (
40
- ( select ) => select ( editSiteStore ) . hasPageContentLock ( ) ,
39
+ const hasPageContentFocus = useSelect (
40
+ ( select ) => select ( editSiteStore ) . hasPageContentFocus ( ) ,
41
41
[ ]
42
42
) ;
43
43
44
44
const alreadySeen = useRef ( false ) ;
45
45
46
46
const { createInfoNotice } = useDispatch ( noticesStore ) ;
47
- const { setHasPageContentLock } = useDispatch ( editSiteStore ) ;
47
+ const { setHasPageContentFocus } = useDispatch ( editSiteStore ) ;
48
48
49
49
return useRefEffect (
50
50
( node ) => {
51
51
const handleClick = ( event ) => {
52
52
if (
53
53
! alreadySeen . current &&
54
- hasPageContentLock &&
54
+ hasPageContentFocus &&
55
55
event . target . classList . contains ( 'is-root-container' )
56
56
) {
57
57
createInfoNotice (
@@ -63,7 +63,7 @@ function useEditTemplateNotification() {
63
63
{
64
64
label : __ ( 'Edit template' ) ,
65
65
onClick : ( ) =>
66
- setHasPageContentLock ( false ) ,
66
+ setHasPageContentFocus ( false ) ,
67
67
} ,
68
68
] ,
69
69
}
@@ -75,10 +75,10 @@ function useEditTemplateNotification() {
75
75
return ( ) => node . removeEventListener ( 'click' , handleClick ) ;
76
76
} ,
77
77
[
78
- hasPageContentLock ,
78
+ hasPageContentFocus ,
79
79
alreadySeen ,
80
80
createInfoNotice ,
81
- setHasPageContentLock ,
81
+ setHasPageContentFocus ,
82
82
]
83
83
) ;
84
84
}
@@ -88,41 +88,41 @@ function useEditTemplateNotification() {
88
88
* switches from focusing on editing page content to editing a template.
89
89
*/
90
90
function useBackToPageNotification ( ) {
91
- const hasPageContentLock = useSelect (
92
- ( select ) => select ( editSiteStore ) . hasPageContentLock ( ) ,
91
+ const hasPageContentFocus = useSelect (
92
+ ( select ) => select ( editSiteStore ) . hasPageContentFocus ( ) ,
93
93
[ ]
94
94
) ;
95
95
96
96
const alreadySeen = useRef ( false ) ;
97
- const prevHasPageContentLock = useRef ( false ) ;
97
+ const prevHasPageContentFocus = useRef ( false ) ;
98
98
99
99
const { createInfoNotice } = useDispatch ( noticesStore ) ;
100
- const { setHasPageContentLock } = useDispatch ( editSiteStore ) ;
100
+ const { setHasPageContentFocus } = useDispatch ( editSiteStore ) ;
101
101
102
102
useEffect ( ( ) => {
103
103
if (
104
104
! alreadySeen . current &&
105
- prevHasPageContentLock . current &&
106
- ! hasPageContentLock
105
+ prevHasPageContentFocus . current &&
106
+ ! hasPageContentFocus
107
107
) {
108
108
createInfoNotice ( __ ( 'You are editing a template' ) , {
109
109
isDismissible : true ,
110
110
type : 'snackbar' ,
111
111
actions : [
112
112
{
113
113
label : __ ( 'Back to page' ) ,
114
- onClick : ( ) => setHasPageContentLock ( true ) ,
114
+ onClick : ( ) => setHasPageContentFocus ( true ) ,
115
115
} ,
116
116
] ,
117
117
} ) ;
118
118
alreadySeen . current = true ;
119
119
}
120
- prevHasPageContentLock . current = hasPageContentLock ;
120
+ prevHasPageContentFocus . current = hasPageContentFocus ;
121
121
} , [
122
122
alreadySeen ,
123
- prevHasPageContentLock ,
124
- hasPageContentLock ,
123
+ prevHasPageContentFocus ,
124
+ hasPageContentFocus ,
125
125
createInfoNotice ,
126
- setHasPageContentLock ,
126
+ setHasPageContentFocus ,
127
127
] ) ;
128
128
}
0 commit comments