-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Block Library - Site Title, Site Tagline] - Readonly view when user has no the right permissions #32817
Conversation
…has no the right permissions
Size Change: +250 B (0%) Total Size: 1.04 MB
ℹ️ View Unchanged
|
<RichText | ||
allowedFormats={ [] } | ||
onChange={ setSiteTagline } | ||
aria-label={ __( 'Site tagline text' ) } | ||
placeholder={ __( 'Write site tagline…' ) } | ||
tagName="p" | ||
value={ siteTagline } | ||
{ ...blockProps } | ||
/> | ||
) : ( | ||
<p { ...blockProps }> | ||
{ readOnlySiteTagLine || __( 'Site Tagline placeholder' ) } | ||
</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes me wonder if in the long term, we should add readOnly
bool props to some of our components 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you expand a bit on this with a 'dummy' example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Nik, LGTM!
…has no the right permissions (#32817) * [Block Library - Site Title, Site Tagline] - Readonly view when user has no the right permissions * fix multi-entity-save tests * Fallback value during init of RichText until title is loaded
…has no the right permissions (#32817) * [Block Library - Site Title, Site Tagline] - Readonly view when user has no the right permissions * fix multi-entity-save tests * Fallback value during init of RichText until title is loaded
Description
Part of: #26573
Currently when a user with no right permissions to edit
Site Title
andSite Tagline
has a broken experience for these blocks due to the permissions check happening at the REST API.This PR fixes that by checking the rights and adding a
readonly
view for these blocks, for those users.In addition I have added a check to both blocks to bail early and print nothing in the front-end, if the respective values are
empty
.Testing instructions
admin
user insert these two blocks and observe that everything works as expected.author
,editor
, etc...), insert the blocks and observe that arereadonly
, but can be moved and their block attributes can be changed (ex.text align
).empty
, where theadmin
can still edit, but the other users see aplaceholder text
, so they can still apply changes for when/if a value is set.Checklist:
*.native.js
files for terms that need renaming or removal).