Skip to content

Commit 44c0cdb

Browse files
fix(plugin-seo): enforce readonly on the client (#9536)
### What? Plugin-seo fields were not set to disabled when a user did not have permissions. ### Why? The `readOnly` property was not being used. ### How? Uses the `readOnly` property to disable buttons and set inputs to readOnly.
1 parent 910b681 commit 44c0cdb

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

packages/plugin-seo/src/fields/MetaDescription/MetaDescriptionComponent.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props)
3939
},
4040
hasGenerateDescriptionFn,
4141
path,
42+
readOnly,
4243
} = props
4344

4445
const {
@@ -139,6 +140,7 @@ export const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props)
139140
<React.Fragment>
140141
&nbsp; &mdash; &nbsp;
141142
<button
143+
disabled={readOnly}
142144
onClick={() => {
143145
void regenerateDescription()
144146
}}
@@ -185,6 +187,7 @@ export const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props)
185187
Error={errorMessage}
186188
onChange={setValue}
187189
path={path}
190+
readOnly={readOnly}
188191
required={required}
189192
showError={showError}
190193
style={{

packages/plugin-seo/src/fields/MetaImage/MetaImageComponent.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const MetaImageComponent: React.FC<MetaImageProps> = (props) => {
3131
field: { label, localized, relationTo, required },
3232
hasGenerateImageFn,
3333
path,
34+
readOnly,
3435
} = props || {}
3536

3637
const {
@@ -133,6 +134,7 @@ export const MetaImageComponent: React.FC<MetaImageProps> = (props) => {
133134
<React.Fragment>
134135
&nbsp; &mdash; &nbsp;
135136
<button
137+
disabled={readOnly}
136138
onClick={() => {
137139
void regenerateImage()
138140
}}
@@ -186,6 +188,7 @@ export const MetaImageComponent: React.FC<MetaImageProps> = (props) => {
186188
}
187189
}}
188190
path={path}
191+
readOnly={readOnly}
189192
relationTo={relationTo}
190193
required={required}
191194
serverURL={serverURL}

packages/plugin-seo/src/fields/MetaTitle/MetaTitleComponent.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {
3434
field: { label, maxLength: maxLengthFromProps, minLength: minLengthFromProps, required },
3535
hasGenerateTitleFn,
3636
path,
37+
readOnly,
3738
} = props || {}
3839

3940
const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()
@@ -127,6 +128,7 @@ export const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {
127128
<React.Fragment>
128129
&nbsp; &mdash; &nbsp;
129130
<button
131+
disabled={readOnly}
130132
onClick={() => {
131133
void regenerateTitle()
132134
}}
@@ -174,6 +176,7 @@ export const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {
174176
Error={errorMessage}
175177
onChange={setValue}
176178
path={path}
179+
readOnly={readOnly}
177180
required={required}
178181
showError={showError}
179182
style={{

0 commit comments

Comments
 (0)