Open jorgefilipecosta opened 3 months ago
@jorgefilipecosta, it turns out we made a couple of wrong assumptions.
kind: 'root', name: 'globalStyles'
, not as a post type.select( 'core' ).canUser( 'read', { kind: 'root', name: 'globalStyles' } )
and select( 'core' ).getEntityRecords( 'root', 'globalStyles' )
.You can only check capabilities for individual global styles entities - canUser( 'read', { kind: 'root', name: 'globalStyles', id: 41 } );
.
The id
value can be obtained using select( 'core' ).__experimentalGetCurrentGlobalStylesId()
, though I'm unsure if it works for low capability users.
Thank you for researching this @Mamaduka. I think we can close this issue. I used your findings to propose a simplification at https://github.com/WordPress/gutenberg/pull/63812.
Description
When using the canUser selector against global styles the selector always returns false even for admin users with the capability.
Step-by-step reproduction instructions
await wp.data.resolveSelect('core').canUser('read', {kind: 'postType', name: 'wp_global_styles' });
, verify it returns false when it should be true.await wp.data.resolveSelect('core').canUser( 'read', 'global_styles' );
, verify it returns false when it should be true.Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes