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

Closes #7679: Object table actions menus #8303

Merged
merged 9 commits into from
Jan 10, 2022
1 change: 1 addition & 0 deletions docs/release-notes/version-3.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Inventory item templates can be arranged hierarchically within a device type, an
### Enhancements

* [#7650](https://github.com/netbox-community/netbox/issues/7650) - Add support for local account password validation
* [#7679](https://github.com/netbox-community/netbox/issues/7679) - Add actions menu to all object tables
* [#7681](https://github.com/netbox-community/netbox/issues/7681) - Add `service_id` field for provider networks
* [#7759](https://github.com/netbox-community/netbox/issues/7759) - Improved the user preferences form
* [#7784](https://github.com/netbox-community/netbox/issues/7784) - Support cluster type assignment for config contexts
Expand Down
5 changes: 2 additions & 3 deletions netbox/circuits/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django_tables2.utils import Accessor

from tenancy.tables import TenantColumn
from utilities.tables import BaseTable, ButtonsColumn, ChoiceFieldColumn, MarkdownColumn, TagColumn, ToggleColumn
from utilities.tables import BaseTable, ChoiceFieldColumn, MarkdownColumn, TagColumn, ToggleColumn
from .models import *


Expand Down Expand Up @@ -88,12 +88,11 @@ class CircuitTypeTable(BaseTable):
circuit_count = tables.Column(
verbose_name='Circuits'
)
actions = ButtonsColumn(CircuitType)

class Meta(BaseTable.Meta):
model = CircuitType
fields = ('pk', 'id', 'name', 'circuit_count', 'description', 'slug', 'tags', 'actions')
default_columns = ('pk', 'name', 'circuit_count', 'description', 'slug', 'actions')
default_columns = ('pk', 'name', 'circuit_count', 'description', 'slug')


#
Expand Down
90 changes: 31 additions & 59 deletions netbox/dcim/tables/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)
from tenancy.tables import TenantColumn
from utilities.tables import (
BaseTable, BooleanColumn, ButtonsColumn, ChoiceFieldColumn, ColorColumn, ColoredLabelColumn, LinkedCountColumn,
ActionsColumn, BaseTable, BooleanColumn, ChoiceFieldColumn, ColorColumn, ColoredLabelColumn, LinkedCountColumn,
MarkdownColumn, TagColumn, TemplateColumn, ToggleColumn,
)
from .template_code import *
Expand Down Expand Up @@ -94,15 +94,14 @@ class DeviceRoleTable(BaseTable):
tags = TagColumn(
url_name='dcim:devicerole_list'
)
actions = ButtonsColumn(DeviceRole)

class Meta(BaseTable.Meta):
model = DeviceRole
fields = (
'pk', 'id', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'description', 'slug', 'tags',
'actions',
)
default_columns = ('pk', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'description', 'actions')
default_columns = ('pk', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'description')


#
Expand All @@ -127,7 +126,6 @@ class PlatformTable(BaseTable):
tags = TagColumn(
url_name='dcim:platform_list'
)
actions = ButtonsColumn(Platform)

class Meta(BaseTable.Meta):
model = Platform
Expand All @@ -136,7 +134,7 @@ class Meta(BaseTable.Meta):
'description', 'tags', 'actions',
)
default_columns = (
'pk', 'name', 'manufacturer', 'device_count', 'vm_count', 'napalm_driver', 'description', 'actions',
'pk', 'name', 'manufacturer', 'device_count', 'vm_count', 'napalm_driver', 'description',
)


Expand Down Expand Up @@ -324,10 +322,8 @@ class DeviceConsolePortTable(ConsolePortTable):
order_by=Accessor('_name'),
attrs={'td': {'class': 'text-nowrap'}}
)
actions = ButtonsColumn(
model=ConsolePort,
buttons=('edit', 'delete'),
prepend_template=CONSOLEPORT_BUTTONS
actions = ActionsColumn(
extra_buttons=CONSOLEPORT_BUTTONS
)

class Meta(DeviceComponentTable.Meta):
Expand All @@ -336,7 +332,7 @@ class Meta(DeviceComponentTable.Meta):
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'speed', 'description', 'mark_connected',
'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'actions'
)
default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection', 'actions')
default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection')
row_attrs = {
'class': get_cabletermination_row_class
}
Expand Down Expand Up @@ -369,10 +365,8 @@ class DeviceConsoleServerPortTable(ConsoleServerPortTable):
order_by=Accessor('_name'),
attrs={'td': {'class': 'text-nowrap'}}
)
actions = ButtonsColumn(
model=ConsoleServerPort,
buttons=('edit', 'delete'),
prepend_template=CONSOLESERVERPORT_BUTTONS
actions = ActionsColumn(
extra_buttons=CONSOLESERVERPORT_BUTTONS
)

class Meta(DeviceComponentTable.Meta):
Expand All @@ -381,7 +375,7 @@ class Meta(DeviceComponentTable.Meta):
'pk', 'id', 'name', 'module_bay', 'module', 'label', 'type', 'speed', 'description', 'mark_connected',
'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'actions',
)
default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection', 'actions')
default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection')
row_attrs = {
'class': get_cabletermination_row_class
}
Expand Down Expand Up @@ -414,10 +408,8 @@ class DevicePowerPortTable(PowerPortTable):
order_by=Accessor('_name'),
attrs={'td': {'class': 'text-nowrap'}}
)
actions = ButtonsColumn(
model=PowerPort,
buttons=('edit', 'delete'),
prepend_template=POWERPORT_BUTTONS
actions = ActionsColumn(
extra_buttons=POWERPORT_BUTTONS
)

class Meta(DeviceComponentTable.Meta):
Expand All @@ -428,7 +420,6 @@ class Meta(DeviceComponentTable.Meta):
)
default_columns = (
'pk', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description', 'cable', 'connection',
'actions',
)
row_attrs = {
'class': get_cabletermination_row_class
Expand Down Expand Up @@ -464,10 +455,8 @@ class DevicePowerOutletTable(PowerOutletTable):
order_by=Accessor('_name'),
attrs={'td': {'class': 'text-nowrap'}}
)
actions = ButtonsColumn(
model=PowerOutlet,
buttons=('edit', 'delete'),
prepend_template=POWEROUTLET_BUTTONS
actions = ActionsColumn(
extra_buttons=POWEROUTLET_BUTTONS
)

class Meta(DeviceComponentTable.Meta):
Expand All @@ -477,7 +466,7 @@ class Meta(DeviceComponentTable.Meta):
'mark_connected', 'cable', 'cable_color', 'link_peer', 'connection', 'tags', 'actions',
)
default_columns = (
'pk', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description', 'cable', 'connection', 'actions',
'pk', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description', 'cable', 'connection',
)
row_attrs = {
'class': get_cabletermination_row_class
Expand Down Expand Up @@ -554,10 +543,8 @@ class DeviceInterfaceTable(InterfaceTable):
linkify=True,
verbose_name='LAG'
)
actions = ButtonsColumn(
model=Interface,
buttons=('edit', 'delete'),
prepend_template=INTERFACE_BUTTONS
actions = ActionsColumn(
extra_buttons=INTERFACE_BUTTONS
)

class Meta(DeviceComponentTable.Meta):
Expand All @@ -572,7 +559,7 @@ class Meta(DeviceComponentTable.Meta):
order_by = ('name',)
default_columns = (
'pk', 'name', 'label', 'enabled', 'type', 'parent', 'lag', 'mtu', 'mode', 'description', 'ip_addresses',
'cable', 'connection', 'actions',
'cable', 'connection',
)
row_attrs = {
'class': get_interface_row_class,
Expand Down Expand Up @@ -617,10 +604,8 @@ class DeviceFrontPortTable(FrontPortTable):
order_by=Accessor('_name'),
attrs={'td': {'class': 'text-nowrap'}}
)
actions = ButtonsColumn(
model=FrontPort,
buttons=('edit', 'delete'),
prepend_template=FRONTPORT_BUTTONS
actions = ActionsColumn(
extra_buttons=FRONTPORT_BUTTONS
)

class Meta(DeviceComponentTable.Meta):
Expand All @@ -631,7 +616,6 @@ class Meta(DeviceComponentTable.Meta):
)
default_columns = (
'pk', 'name', 'label', 'type', 'rear_port', 'rear_port_position', 'description', 'cable', 'link_peer',
'actions',
)
row_attrs = {
'class': get_cabletermination_row_class
Expand Down Expand Up @@ -666,10 +650,8 @@ class DeviceRearPortTable(RearPortTable):
order_by=Accessor('_name'),
attrs={'td': {'class': 'text-nowrap'}}
)
actions = ButtonsColumn(
model=RearPort,
buttons=('edit', 'delete'),
prepend_template=REARPORT_BUTTONS
actions = ActionsColumn(
extra_buttons=REARPORT_BUTTONS
)

class Meta(DeviceComponentTable.Meta):
Expand All @@ -679,7 +661,7 @@ class Meta(DeviceComponentTable.Meta):
'cable', 'cable_color', 'link_peer', 'tags', 'actions',
)
default_columns = (
'pk', 'name', 'label', 'type', 'positions', 'description', 'cable', 'link_peer', 'actions',
'pk', 'name', 'label', 'type', 'positions', 'description', 'cable', 'link_peer',
)
row_attrs = {
'class': get_cabletermination_row_class
Expand Down Expand Up @@ -717,20 +699,16 @@ class DeviceDeviceBayTable(DeviceBayTable):
order_by=Accessor('_name'),
attrs={'td': {'class': 'text-nowrap'}}
)
actions = ButtonsColumn(
model=DeviceBay,
buttons=('edit', 'delete'),
prepend_template=DEVICEBAY_BUTTONS
actions = ActionsColumn(
extra_buttons=DEVICEBAY_BUTTONS
)

class Meta(DeviceComponentTable.Meta):
model = DeviceBay
fields = (
'pk', 'id', 'name', 'label', 'status', 'installed_device', 'description', 'tags', 'actions',
)
default_columns = (
'pk', 'name', 'label', 'status', 'installed_device', 'description', 'actions',
)
default_columns = ('pk', 'name', 'label', 'status', 'installed_device', 'description')


class ModuleBayTable(DeviceComponentTable):
Expand All @@ -755,16 +733,14 @@ class Meta(DeviceComponentTable.Meta):


class DeviceModuleBayTable(ModuleBayTable):
actions = ButtonsColumn(
model=DeviceBay,
buttons=('edit', 'delete'),
prepend_template=MODULEBAY_BUTTONS
actions = ActionsColumn(
extra_buttons=MODULEBAY_BUTTONS
)

class Meta(DeviceComponentTable.Meta):
model = ModuleBay
fields = ('pk', 'id', 'name', 'label', 'description', 'installed_module', 'tags', 'actions')
default_columns = ('pk', 'name', 'label', 'description', 'installed_module', 'actions')
default_columns = ('pk', 'name', 'label', 'description', 'installed_module')


class InventoryItemTable(DeviceComponentTable):
Expand Down Expand Up @@ -809,10 +785,7 @@ class DeviceInventoryItemTable(InventoryItemTable):
order_by=Accessor('_name'),
attrs={'td': {'class': 'text-nowrap'}}
)
actions = ButtonsColumn(
model=InventoryItem,
buttons=('edit', 'delete')
)
actions = ActionsColumn()

class Meta(BaseTable.Meta):
model = InventoryItem
Expand All @@ -821,7 +794,7 @@ class Meta(BaseTable.Meta):
'description', 'discovered', 'tags', 'actions',
)
default_columns = (
'pk', 'name', 'label', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'component', 'actions',
'pk', 'name', 'label', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'component',
)


Expand All @@ -839,14 +812,13 @@ class InventoryItemRoleTable(BaseTable):
tags = TagColumn(
url_name='dcim:inventoryitemrole_list'
)
actions = ButtonsColumn(InventoryItemRole)

class Meta(BaseTable.Meta):
model = InventoryItemRole
fields = (
'pk', 'id', 'name', 'inventoryitem_count', 'color', 'description', 'slug', 'tags', 'actions',
)
default_columns = ('pk', 'name', 'inventoryitem_count', 'color', 'description', 'actions')
default_columns = ('pk', 'name', 'inventoryitem_count', 'color', 'description')


#
Expand Down
Loading