sanity-io / sanity-plugin-media

Asset management plugin for Sanity
MIT License
159 stars 51 forks source link

TypeError: Cannot set properties of undefined (setting 'error') #225

Open hari-houdini opened 4 months ago

hari-houdini commented 4 months ago

Describe the bug I logged in as a user with read-only permissions (Viewer role). I still have the option to upload a new media file and delete one. When I perform any of those actions, it throws an error.

To Reproduce Steps to reproduce the behavior:

  1. Create a user and assign Viewer role to it.
  2. Upload any media asset through the Upload assets button on the top-right corner.
  3. It would throw an error: TypeError: Cannot set properties of undefined (setting 'error')
  4. Then click on any media and delete it through the Delete button on the bottom-left corner.
  5. It would set the media in a constant loading state and throw an error: Insufficient permissions: permission "create" required

Expected behavior Either the button should be disabled as it is across the rest of Sanity (or) some way to pass user permissions as part of the config

Screenshots Screenshot 2024-07-23 at 12 06 54 Screenshot 2024-07-23 at 12 07 37 Screenshot 2024-07-23 at 12 16 11

Plugin and environment information: