netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Change permission selection to checkboxes and make the space bigger

Open gdprdatasubect opened this issue 2 years ago • 19 comments

NetBox version

v3.6.5

Feature type

Change to existing functionality

Proposed functionality

Currently the selection for permissions looks like this: grafik

This does not seem like a good design choice (A lot of options crammed in a small field, ctrl required to add things to selection) and could IMHO better be handled with individual checkboxes and not using a selection-field in the first place, e.g.:

grafik

etc.

Use case

Improve admin-user-experience, not having to press control to add things to the selection, improving accessibility due to being able to use tab to switch to next field

Database changes

No response

External dependencies

No response

gdprdatasubect avatar Nov 18 '23 00:11 gdprdatasubect

I think it would be very useful if you implement this feature. I struggled the last 15 minutes to select 10 object types. You have to press the Strg key and then scroll down ... then you select the next one and all previous selected object types are deselected.

jonasnieberle avatar Dec 19 '23 14:12 jonasnieberle

Sorry, this is non-viable straight out of the gate. We have over 100 models within NetBox that can have permissions assigned to them. We cannot generate 100+ check boxes to allow for this.

Additionally, this also doesn't take into account permissions added by plugins.

DanSheps avatar Dec 20 '23 15:12 DanSheps

I think it would be very useful if you implement this feature. I struggled the last 15 minutes to select 10 object types. You have to press the Strg key and then scroll down ... then you select the next one and all previous selected object types are deselected.

Maybe the help text could be more explicit and the widget made bigger, but the current way really is the only logical way.

jsenecal avatar Dec 20 '23 15:12 jsenecal

Ok, yeah you're right 100+ check boxes aren't good to handle. An what about the same method like the filter methods:

image

You can search for the object and can select it and then you see the selected object in the top line. And with the x you can remove the object from the selection. The same ui style is implemented by the user group assignment and the permissions.

image

So we also have the benefit that the same ui styles used 🤔

jonasnieberle avatar Dec 20 '23 15:12 jonasnieberle

You can search for the object and can select it and then you see the selected object in the top line. And with the x you can remove the object from the selection. The same ui style is implemented by the user group assignment and the permissions.

What do you do when you get 90+ permissions selected ? Wouldnt that break UX ?

jsenecal avatar Dec 20 '23 15:12 jsenecal

How about something similar to this?

image

abhi1693 avatar Dec 20 '23 15:12 abhi1693

I think #13435 brings up using a dynamic selector (not clear about it from the description IMO though).

DanSheps avatar Dec 20 '23 16:12 DanSheps

Ok, yeah you're right 100+ check boxes aren't good to handle

Well, to me the current workflow seems worse to handle than checkboxes, so that's why i suggested them.

Personally I think the whole permission workflow is counterintuitive and the ideal solution would be a Permission Constraint text field per available option, since filtering could be more fine grained and would involve creating less groups (or maybe i'm just using it wrongly)

gdprdatasubect avatar Dec 20 '23 17:12 gdprdatasubect

Well, to me the current workflow seems worse to handle than checkboxes, so that's why i suggested them.

Try checking 100 checkboxes because you need to give every permission except for a few (compared to Ctrl-A then Ctrl-click on ones you don't need)

Personally I think the whole permission workflow is counterintuitive and the ideal solution would be a Permission Constraint text field per available option, since filtering could be more fine grained and would involve creating less groups (or maybe i'm just using it wrongly)

There is a permission constraint field, but not everyone can be bothered to learn JSON or they have simpler needs.

Additionally, not every model has every field so you typically have to create multiple permissions for permission constraints anyways.

DanSheps avatar Dec 20 '23 17:12 DanSheps

Checkboxes feel untenable, but we could change this control to use a dynamic multi-select widget. That would make it work like the Content Types control from the existing Add Custom Link flow, giving type-to-filter and removing the need to hold down Ctrl / Strg.

image

jeffgdotorg avatar Dec 20 '23 18:12 jeffgdotorg

Folding #13435 into this issue. The two are similar enough that we think a common approach (dynamic multi-select, see above) will do the trick for both.

jeffgdotorg avatar Dec 20 '23 18:12 jeffgdotorg

Folding #13435 into this issue. The two are similar enough that we think a common approach (dynamic multi-select, see above) will do the trick for both.

It might be a good idea to maybe make it a DynamicModelMultipleChoiceField and see if we can get a selector widget working with it (also make the selector widget work with multi-selection by allowing Ctrl+click to select multiple items).

There would be a little work involved if we wanted to go that route. We would likely need to make ContentType a proxy model of it's own.

DanSheps avatar Dec 21 '23 14:12 DanSheps

Did we ever decide on which field we should use for this? I am kind of coming around to @abhi1693's idea as any other could get rather messy with the amount of objects we have.

DanSheps avatar Jan 09 '24 20:01 DanSheps

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

github-actions[bot] avatar May 15 '24 12:05 github-actions[bot]

Did we ever decide on which field we should use for this? I am kind of coming around to @abhi1693's idea as any other could get rather messy with the amount of objects we have.

How can we procceed with this topic? From my site the idea from @abhi1693 ist the best? The other fields can/will break the UI if you select 100+ permissions. Or maybe some other ideas from other software?

jonasnieberle avatar May 15 '24 12:05 jonasnieberle

@JonasEinfach this issue needs a volunteer to implement it. Would you like to own it?

jeremystretch avatar May 15 '24 12:05 jeremystretch

@jeremystretch Im not familar with developing in netbox, but I can try :)

At first look, it looks like that's only a change in the forms of the permission object.

jonasnieberle avatar May 15 '24 13:05 jonasnieberle

Today I checked the forms.py for the ObjectPermission.

So that's the actual python code:

    object_types = ContentTypeMultipleChoiceField(
        label=_('Object types'),
        queryset=ObjectType.objects.all(),
        limit_choices_to=OBJECTPERMISSION_OBJECT_TYPES,
        widget=forms.SelectMultiple(attrs={'size': 6})
    )

If Im right you limit the choice of form rendering with the constants OBJECTPERMISSION_OBJECT_TYPES?

In the form we use the ContentTypeMultipleChoiceField. I searched in the netbox github for all forms which use this form as well. For example I found that the CustomFieldForm also use this form. https://github.com/netbox-community/netbox/blob/103c08c2d2bc3e32d8274b8d8ec8dd2380857388/netbox/extras/forms/model_forms.py#L42

The funny thing - in the custom field form we have definitely a better UI form to select / search / remove / see the content types.

image

But the ObjectPermission Form have the "not well to handle" Form :D

image

The widget attribute forms.SelectMultiple(attrs={'size': 6}) overwrite the default form ... I commented the widget attribute and we have the better multiple select form.

image

The form can also handle >80 selected objects. Tbh who use permissions with more than 80 content type objects? It's definitley smarter to use multiple permissions and assign them to a group ...

image

From my site the UI experience is definitely better without widget attribute forms.SelectMultiple(attrs={'size': 6})

What do you think? @jeremystretch @DanSheps

jonasnieberle avatar May 26 '24 21:05 jonasnieberle

Cant his FR also include the list view of the user permissions ? Its a pretty long page when all but some objects are selected image

Maybe do the same as ip/vlans on interfaces, just display a nbr of there are more than 5

PieterL75 avatar Oct 21 '24 10:10 PieterL75

Hey was wondering if there was any update on this!

@DanSheps

Sorry, this is non-viable straight out of the gate. We have over 100 models within NetBox that can have permissions assigned to them. We cannot generate 100+ check boxes to allow for this.

Could you elaborate on this? How does adding another element to each item added to the list of entries and iterating over that to see if an entry is checked not viable? Genuinely just curious

I'd say the solution proposed by @jonasnieberle is probably the cleanest and best solution for this, but hoping there could be some feedback from a member.

thank you for netbox!

itslychee avatar Jan 29 '25 17:01 itslychee

Sorry I'm late to the game here with this comment but I've noticed over time when new object models are added we always have to explicitly add them to every relevant permission object.

Assuming you organize your permissions by the app, for example dcim.ro and dcim.rw and so on. You have to keep track on changes and modify those accordingly.

It might be possible to approach the permissions in a hierarchical way by allowing the selection of all models under a certain app (dcim, ipam, core, etc) and automatically account for all related models. For a more granular control open up the individual models for selection forgoing the app level auto select for that app.

This should allow for a more intuitive control and permission view in most use cases and still allow the fine grained controls of the current setup.

To @PieterL75's comment we should be getting a cleaner view here on the object type from:

Image

To something like

Image

Omripresent avatar May 14 '25 10:05 Omripresent

Closing this in favor of the dual-column approach currently in use for table config and suggested above. Please see FR #19968.

jeremystretch avatar Jul 28 '25 20:07 jeremystretch