Hide button "delete subnet" on the network topology for shared networks
Co-Authored-By: Ameed Ashour <Ameed.Ashour.ext@nokia.com> Co-Authored-By: Artem Tiumentcev <darland.maik@gmail.com> Change-Id: Ia1bd3b231a039adef9be92a873e65bfd476088a5 Closes-Bug: #1703021
This commit is contained in:
parent
666762956a
commit
e049609f88
@ -22,6 +22,7 @@
|
||||
[[/console]]
|
||||
</div>
|
||||
[[#type]]
|
||||
[[#allow_delete_subnet]]
|
||||
<div class="cell delete">
|
||||
<button class="delete-device btn btn-danger btn-xs [[type]]"
|
||||
data-type="[[type]]" data-device-id="[[id]]"
|
||||
@ -29,6 +30,7 @@
|
||||
[[delete_label]]
|
||||
</button>
|
||||
</div>
|
||||
[[/allow_delete_subnet]]
|
||||
[[/type]]
|
||||
</div>
|
||||
</div>
|
||||
|
@ -26,11 +26,13 @@
|
||||
</th>
|
||||
<td>[[cidr]]</td>
|
||||
<td class="delete">
|
||||
[[#allow_delete_subnet]]
|
||||
<button class="delete-port btn btn-danger btn-xs"
|
||||
data-router-id="[[router_id]]" data-network-id="[[network_id]]"
|
||||
data-port-id="[[id]]" help_text="{% trans "This action cannot be undone." %}">
|
||||
[[delete_subnet_label]]
|
||||
</button>
|
||||
[[/allow_delete_subnet]]
|
||||
</td>
|
||||
</tr>
|
||||
[[/subnet]]
|
||||
|
@ -148,6 +148,7 @@ class NetworkTopologyTests(test.TestCase):
|
||||
'name': net.name,
|
||||
'router:external': net.router__external,
|
||||
'status': net.status.title(),
|
||||
'allow_delete_subnet': True,
|
||||
'original_status': net.status,
|
||||
'subnets': [{
|
||||
'cidr': subnet.cidr,
|
||||
|
@ -75,6 +75,7 @@ from openstack_dashboard.dashboards.project.routers.tables import \
|
||||
STATUS_DISPLAY_CHOICES as routers_status_choices
|
||||
from openstack_dashboard.dashboards.project.routers import\
|
||||
views as r_views
|
||||
from openstack_dashboard import policy
|
||||
|
||||
# List of known server statuses that wont connect to the console
|
||||
console_invalid_status = {
|
||||
@ -270,12 +271,19 @@ class JSONView(View):
|
||||
neutron_networks = []
|
||||
networks = []
|
||||
for network in neutron_networks:
|
||||
allow_delete_subnet = policy.check(
|
||||
(("network", "delete_subnet"),),
|
||||
request,
|
||||
target={'network:tenant_id': getattr(network,
|
||||
'tenant_id', None)}
|
||||
)
|
||||
obj = {'name': network.name_or_id,
|
||||
'id': network.id,
|
||||
'subnets': [{'id': subnet.id,
|
||||
'cidr': subnet.cidr}
|
||||
for subnet in network.subnets],
|
||||
'status': self.trans.network[network.status],
|
||||
'allow_delete_subnet': allow_delete_subnet,
|
||||
'original_status': network.status,
|
||||
'router:external': network['router:external']}
|
||||
self.add_resource_url('horizon:project:networks:subnets:detail',
|
||||
|
@ -1066,6 +1066,9 @@ horizon.network_topology = {
|
||||
htmlData.subnet = subnets;
|
||||
if (d instanceof Network) {
|
||||
htmlData.delete_label = gettext('Delete Network');
|
||||
if (d.allow_delete_subnet){
|
||||
htmlData.allow_delete_subnet = d.allow_delete_subnet;
|
||||
}
|
||||
}
|
||||
htmlData.add_subnet_url = 'network/' + d.id + '/subnet/create';
|
||||
htmlData.add_subnet_label = gettext('Create Subnet');
|
||||
|
Loading…
Reference in New Issue
Block a user