Merge "Hide button "delete subnet" on the network topology for shared networks"

This commit is contained in:
Zuul 2018-03-18 09:13:54 +00:00 committed by Gerrit Code Review
commit 4a84a66d51
5 changed files with 16 additions and 0 deletions

View File

@ -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>

View File

@ -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]]

View File

@ -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,

View File

@ -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',

View File

@ -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');