williamiommi / sanity-plugin-icon-manager

A Sanity plugin for selecting, managing, and customizing icons. Powered by Iconify
https://www.npmjs.com/package/sanity-plugin-icon-manager
MIT License
12 stars 2 forks source link

Feature request: Configuration Options availability/visibility #19

Open brentrobbins opened 3 months ago

brentrobbins commented 3 months ago

Is there anyway to add the ability in the plugin's configuration to:

Possibly something like:


IconManager({
  configurationOptions?: [
      hide?: boolean // if false would completely hide the configuration panel
      options?: [
       flipHide?: boolean,
       rotateHide?: boolean,
       sizeHide?: boolean,
       inlineSvgHide?: boolean,
       colorHide?: boolean,
       previewHide?: boolean
      ]
  ],
  ...
})
dumle11 commented 1 month ago

Would love to see option to disable color picker and only allow user to select pre-defined values.

williamiommi commented 1 month ago

Hi, sorry for my late response. I'm currently working on a UI update and on adding i18n capabilities to the plugin. This involves a breaking change, and a v2 of the plugin will be released.

After that, I can consider the feature. In the meantime, could you give me more context on this? What could be the benefits, and do you have specific use cases in mind?

On my side, I see value in switching off the entire configuration if you want to just select an icon (perhaps using also user roles and not just a boolean flag). On the other hand, I'm not sure (at the moment) about switching off individual options.

notflip commented 4 weeks ago

Hi, sorry for my late response. I'm currently working on a UI update and on adding i18n capabilities to the plugin. This involves a breaking change, and a v2 of the plugin will be released.

After that, I can consider the feature. In the meantime, could you give me more context on this? What could be the benefits, and do you have specific use cases in mind?

On my side, I see value in switching off the entire configuration if you want to just select an icon (perhaps using also user roles and not just a boolean flag). On the other hand, I'm not sure (at the moment) about switching off individual options.

I would love to be able to hide all customization options, keep it dead simple for clients to work in, since the colors of the icons will mostly be predefined by the design.

Thanks for this repo by the way! Looking really good so far

brentrobbins commented 3 weeks ago

Hi, sorry for my late response. I'm currently working on a UI update and on adding i18n capabilities to the plugin. This involves a breaking change, and a v2 of the plugin will be released.

After that, I can consider the feature. In the meantime, could you give me more context on this? What could be the benefits, and do you have specific use cases in mind?

On my side, I see value in switching off the entire configuration if you want to just select an icon (perhaps using also user roles and not just a boolean flag). On the other hand, I'm not sure (at the moment) about switching off individual options.

I like the options, but many of my clients are non-tech savvy and do not need the control/access to modify their site's icon's size, color etc. They just would like the ability to choose the icon and that's it. Also seeing those configurations would just overwhelm them and just avoiding displaying those options would be ideal.

I do see other apps/sites needing this control/access, but I feel it would be a great feature to be able to hide/show these advanced settings.

williamiommi commented 3 weeks ago

Ok, so let's start with the easiest one: hiding the entire configuration dialog.

Looking at the example from @brentrobbins, I was thinking of something like this in the plugin's options:

configurationDialog?: {
  hideFor?: 'all' | string[]
},

The idea here is that with the 'all' value, you completely disable the configuration. On the other hand, with an array of strings, you can pass an array of roles that won't be able to configure the icon. (NOTE: If you pass an array of strings, the admin role will always be able to see the configuration modal.) Here are a few examples:

// Nobody can configure the icon
configurationDialog: {
  hideFor: 'all'
}

// Hidden for the 'role-a' role. Every other user with a different role can configure the icon.
// NOTE: if users have both 'role-a' and 'role-b', they can configure the icon.
configurationDialog: {
  hideFor: ['role-a']
}

// Hidden for the 'role-a' and 'role-b' roles. Every other user with a different role can configure the icon.
configurationDialog: {
  hideFor: ['role-a', 'role-b']
}

// Hidden for everyone who is not an administrator (using the ! operator)
configurationDialog: {
  hideFor: ['!administrator']
}

// No effect. When hideFor is an array, the admin will always see the dialog.
configurationDialog: {
  hideFor: ['administrator']
}

Using the configurationDialog option, it's possible to consider adding similar configurations for individual options in the future (as in Brent's example).

Final Note: With the new UI in v2, the 'quick' configuration CTA will be completely hidden. However, if you open the new context menu, the Configure CTA will be visible but disabled (this might change, I'm not sure yet).

williamiommi commented 1 week ago

just released version 2.1 with the new option described above