Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Labels for Custom Field Selection Choices #13241

Closed
arhamansarii opened this issue Jul 21, 2023 · 2 comments
Closed

Labels for Custom Field Selection Choices #13241

arhamansarii opened this issue Jul 21, 2023 · 2 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Milestone

Comments

@arhamansarii
Copy link

NetBox version

v3.2.2

Feature type

Change to existing functionality

Proposed functionality

Apologies in advance if this issue/feature was discussed previously or addressed in a subsequent Netbox version.

For selection-type custom fields, it would help if we can have the option of adding labels to selection choices. The labels would be human-friendly and appear in the web interface, similar to custom field labels. Meanwhile, the actual value of the selection choice is more database friendly (integer, underscores etc.).

For example, in a Netbox web interface, on a custom field of a device named "SNMP Auth Protocol" of type selection. Users are able to add labels to the selection choices. The labels would be MD5, SHA1, SHA256. The values would be 0, 1, 2 respectively.

If a user chooses selection MD5, the custom field maps MD5 (label) to value of 0.

Use case

This would be useful for accommodating different software API requirements when syncing with Netbox.

For example, our team currently uses Zabbix to monitor devices, where Netbox is source of truth inventory. We sync a lot of values from device custom fields into Zabbix using pynetbox and Zabbix API.

Currently, if I read a custom field value of "MD5" and try passing it into Zabbix API, it will throw an error. That is because MD5 in Zabbix API is represented by a value of "0" instead of "MD5". In this case, a label of "MD5" that maps to a value of "0" would be a useful feature for selection choices. It would prevent us from creating a dictionary to map values in our sync script.

Database changes

No response

External dependencies

No response

@arhamansarii arhamansarii added the type: feature Introduction of new functionality to the application label Jul 21, 2023
@jeremystretch
Copy link
Member

#12988 introduces custom field choice sets for the upcoming v3.6 release, which makes the proposed functionality much more feasible than the current implementation. IMO if we're going to consider this change, now is the time to do it.

@jeremystretch jeremystretch added the status: under review Further discussion is needed to determine this issue's scope and/or implementation label Jul 26, 2023
@jeremystretch jeremystretch self-assigned this Jul 26, 2023
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Jul 26, 2023
@jeremystretch jeremystretch added this to the v3.6 milestone Jul 26, 2023
@jeremystretch
Copy link
Member

Because this is so closely intertwined with the implementation of #12988 and #12194, I've committed the changes under PR #13219.

jeremystretch added a commit that referenced this issue Jul 28, 2023
* Initial work on custom field choice sets

* Rename choices to extra_choices (prep for #12194)

* Remove CustomField.choices

* Add & update tests

* Clean up table columns

* Add order_alphanetically boolean for choice sets

* Introduce ArrayColumn for choice lists

* Show dependent custom fields on choice set view

* Update custom fields documentation

* Introduce ArrayWidget for more convenient editing of choices

* Incorporate PR feedback

* Misc cleanup

* Initial work on predefined choices for custom fields

* Misc cleanup

* Add IATA airport codes

* #13241: Add support for custom field choice labels

* Restore ArrayColumn

* Misc cleanup

* Change extra_choices back to a nested ArrayField to preserve choice ordering

* Hack to bypass GraphQL API test utility absent support for nested ArrayFields
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

2 participants