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

Allow plugins to add columns to tables #14173

Closed
rixx opened this issue Nov 2, 2023 · 4 comments
Closed

Allow plugins to add columns to tables #14173

rixx opened this issue Nov 2, 2023 · 4 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation topic: plugins Relates to the plugins framework type: feature Introduction of new functionality to the application
Milestone

Comments

@rixx
Copy link

rixx commented Nov 2, 2023

NetBox version

dev / v3.6.3

Feature type

New functionality

Proposed functionality

Allow plugins to register columns for built-in NetBox tables.

Use case

NetBox comes with admirably configurable tables and filters for all its built-in models, and makes it easy for plugins to provide tables like that, too. Some plugins manage fairly separate data, like DNS. However, when plugins connect to built-in models (instead of just providing separate models), the additional data cannot be seen from the built-in tables.

This is especially jarring for users when the data can be shown on the detail pages (by way of the template_extensions mechanism). Naturally, users tend to ask for ways to use the data displayed on the detail pages in the list/table views. As a plugin developer, I frequently build models that attach to existing NetBox models, and I get those requests a lot ("why do I have to go to the detail page of the Tenant to see the new data, can't you show it in the Tenant list?").

(I realise that there are technically ways to add columns to the tables right now: You can subclass/extend the built-in tables and provide them at a different URL, or, worst-of-all-worlds, patch something in. However, I think both of these are terrible in terms of maintainability and generally not good practice.)

An example could be a plugin that extends the customer management side of NetBox with additional data on Contacts, Tenants, or Sites, and would like to a) show the added data in those tables (e.g. the Site table), but also in other tables that can show Site information, e.g. the Device table.

I realise this isn't a trivial request. If you think this is generally worthwhile, I'd be happy to work on this feature!

Database changes

No response

External dependencies

No response

@rixx rixx added the type: feature Introduction of new functionality to the application label Nov 2, 2023
@jeremystretch
Copy link
Member

Thank you for your interest in extending NetBox. Unfortunately, the information you have provided does not constitute an actionable feature request. Per our contributing guide, a feature request must include a thorough description of the proposed functionality, including any database changes, new views or API endpoints, and so on. It must also include a detailed use case justifying its implementation. If you would like to elaborate on your proposal, please modify your post above. If sufficient detail is not added, this issue will be closed.

@jeremystretch jeremystretch added the status: revisions needed This issue requires additional information to be actionable label Nov 6, 2023
@rixx
Copy link
Author

rixx commented Nov 6, 2023

Apologies – updated the ticket with a longer description.

@ITJamie
Copy link
Contributor

ITJamie commented Nov 9, 2023

to give a very specific example of how this could be used for the netbox-gateways plugin.

the plugin could "register" that It should show related gateways objects on the prefix core module.
so it would add a "gateway" column to the prefix tables and maybe even a "gateway" field on the prefix API serializer for general API use.

being able to virtually extend the core module tables/api replys with extra data (possibly similar to how custom fields are presented in their own small dictionary) would be a fantastic feature to make plugins feel more connected to the core models they are integrating with.

@jeremystretch jeremystretch added status: under review Further discussion is needed to determine this issue's scope and/or implementation and removed status: revisions needed This issue requires additional information to be actionable labels Nov 10, 2023
@jeremystretch
Copy link
Member

jeremystretch commented Nov 10, 2023

I did some quick digging and the base Table class from django-tables2 supports an extra_columns keyword argument that can be used to add, well, extra columns to a table. (This is the same mechanism we leverage to register columns for custom fields today.) We can override this in the init method of our own NetBoxTable class and inject columns that have been registered by plugins.

@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 Nov 10, 2023
@jeremystretch jeremystretch added this to the v3.7 milestone Nov 10, 2023
@jeremystretch jeremystretch self-assigned this Nov 10, 2023
@jeremystretch jeremystretch added the topic: plugins Relates to the plugins framework label Nov 10, 2023
jeremystretch added a commit that referenced this issue Nov 16, 2023
)

* Closes #14173: Enable plugins to register columns on core tables

* Support translation for column name

* Document new registry store
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2024
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 topic: plugins Relates to the plugins framework type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

3 participants