kirby icon indicating copy to clipboard operation
kirby copied to clipboard

Options field 'preview' does not accept per-user permissions

Open herrbischoff opened this issue 3 years ago • 4 comments
trafficstars

Description

According to the page blueprint reference

Each option can be set on a per user role for fine-grained permissions

However, when I set

options:
  preview:
    admin: true
    editor: false

The panel throws the following error:

Kirby\Cms\Page::previewUrl(): Return value must be of type ?string, array returned 

The panel apparently expects either a boolean or a template string but no array of users, like the other options do.

Expected behavior

Either make the behavior consistent with the other options or change the reference documentation to reflect this inconsistency. This should affect supplying different template strings for different users as well.

Your setup

Kirby Version

3.6

herrbischoff avatar Aug 05 '22 09:08 herrbischoff

@getkirby/kirby-staff Do you think is it an intended, a bug, or an improvement that needs to be made?

Also note that preview can be a string. I'm not sure how it can be disabled for both string and some roles. Applicable for non-string values, but seems difficult for string values.

afbora avatar Aug 05 '22 19:08 afbora

I agree that ideally there should be a way to set different values per role, e.g. like this:

options:
  preview:
    admin: true
    editor: "{{ page.parent.url }}/#{{ page.slug }}"
    translator: false

The options are unfortunately inconsistent at the moment. E.g. there is also the changeTemplate option that supports an array, however not an array of roles but an array of target templates.

I think this is something to reconsider after the upcoming blueprint refactoring.

lukasbestle avatar Aug 06 '22 20:08 lukasbestle

Good to know. In the meantime, I believe the documentation should be updated to reflect the two exceptions. As currently written, one would expect all options to behave in a consistent manner. No major issue, but I ran into it and it's an unnecessary annoyance when you're new to Kirby and learning from documentation.

herrbischoff avatar Aug 06 '22 20:08 herrbischoff

You are absolutely right. I've updated the docs.

lukasbestle avatar Aug 07 '22 11:08 lukasbestle

This issue has been automatically marked as stale because it has not had recent activity. This is for us to prioritize issues that are still relevant to our community. It will be closed if no further activity occurs within the next 14 days. If this issue is still relevant to you, please leave a comment.

github-actions[bot] avatar Feb 04 '23 00:02 github-actions[bot]