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.
This commit is contained in:
Jarrod Flesch
2024-11-26 10:50:21 -05:00
committed by GitHub
parent 910b68154e
commit 44c0cdb75f
3 changed files with 9 additions and 0 deletions

View File

@@ -39,6 +39,7 @@ export const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props)
}, },
hasGenerateDescriptionFn, hasGenerateDescriptionFn,
path, path,
readOnly,
} = props } = props
const { const {
@@ -139,6 +140,7 @@ export const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props)
<React.Fragment> <React.Fragment>
&nbsp; &mdash; &nbsp; &nbsp; &mdash; &nbsp;
<button <button
disabled={readOnly}
onClick={() => { onClick={() => {
void regenerateDescription() void regenerateDescription()
}} }}
@@ -185,6 +187,7 @@ export const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props)
Error={errorMessage} Error={errorMessage}
onChange={setValue} onChange={setValue}
path={path} path={path}
readOnly={readOnly}
required={required} required={required}
showError={showError} showError={showError}
style={{ style={{

View File

@@ -31,6 +31,7 @@ export const MetaImageComponent: React.FC<MetaImageProps> = (props) => {
field: { label, localized, relationTo, required }, field: { label, localized, relationTo, required },
hasGenerateImageFn, hasGenerateImageFn,
path, path,
readOnly,
} = props || {} } = props || {}
const { const {
@@ -133,6 +134,7 @@ export const MetaImageComponent: React.FC<MetaImageProps> = (props) => {
<React.Fragment> <React.Fragment>
&nbsp; &mdash; &nbsp; &nbsp; &mdash; &nbsp;
<button <button
disabled={readOnly}
onClick={() => { onClick={() => {
void regenerateImage() void regenerateImage()
}} }}
@@ -186,6 +188,7 @@ export const MetaImageComponent: React.FC<MetaImageProps> = (props) => {
} }
}} }}
path={path} path={path}
readOnly={readOnly}
relationTo={relationTo} relationTo={relationTo}
required={required} required={required}
serverURL={serverURL} serverURL={serverURL}

View File

@@ -34,6 +34,7 @@ export const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {
field: { label, maxLength: maxLengthFromProps, minLength: minLengthFromProps, required }, field: { label, maxLength: maxLengthFromProps, minLength: minLengthFromProps, required },
hasGenerateTitleFn, hasGenerateTitleFn,
path, path,
readOnly,
} = props || {} } = props || {}
const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>() const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()
@@ -127,6 +128,7 @@ export const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {
<React.Fragment> <React.Fragment>
&nbsp; &mdash; &nbsp; &nbsp; &mdash; &nbsp;
<button <button
disabled={readOnly}
onClick={() => { onClick={() => {
void regenerateTitle() void regenerateTitle()
}} }}
@@ -174,6 +176,7 @@ export const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {
Error={errorMessage} Error={errorMessage}
onChange={setValue} onChange={setValue}
path={path} path={path}
readOnly={readOnly}
required={required} required={required}
showError={showError} showError={showError}
style={{ style={{