Merge "Hide button "delete subnet" on the network topology for shared networks"
This commit is contained in:
commit
4a84a66d51
|
@ -22,6 +22,7 @@
|
||||||
[[/console]]
|
[[/console]]
|
||||||
</div>
|
</div>
|
||||||
[[#type]]
|
[[#type]]
|
||||||
|
[[#allow_delete_subnet]]
|
||||||
<div class="cell delete">
|
<div class="cell delete">
|
||||||
<button class="delete-device btn btn-danger btn-xs [[type]]"
|
<button class="delete-device btn btn-danger btn-xs [[type]]"
|
||||||
data-type="[[type]]" data-device-id="[[id]]"
|
data-type="[[type]]" data-device-id="[[id]]"
|
||||||
|
@ -29,6 +30,7 @@
|
||||||
[[delete_label]]
|
[[delete_label]]
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
[[/allow_delete_subnet]]
|
||||||
[[/type]]
|
[[/type]]
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,11 +26,13 @@
|
||||||
</th>
|
</th>
|
||||||
<td>[[cidr]]</td>
|
<td>[[cidr]]</td>
|
||||||
<td class="delete">
|
<td class="delete">
|
||||||
|
[[#allow_delete_subnet]]
|
||||||
<button class="delete-port btn btn-danger btn-xs"
|
<button class="delete-port btn btn-danger btn-xs"
|
||||||
data-router-id="[[router_id]]" data-network-id="[[network_id]]"
|
data-router-id="[[router_id]]" data-network-id="[[network_id]]"
|
||||||
data-port-id="[[id]]" help_text="{% trans "This action cannot be undone." %}">
|
data-port-id="[[id]]" help_text="{% trans "This action cannot be undone." %}">
|
||||||
[[delete_subnet_label]]
|
[[delete_subnet_label]]
|
||||||
</button>
|
</button>
|
||||||
|
[[/allow_delete_subnet]]
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
[[/subnet]]
|
[[/subnet]]
|
||||||
|
|
|
@ -148,6 +148,7 @@ class NetworkTopologyTests(test.TestCase):
|
||||||
'name': net.name,
|
'name': net.name,
|
||||||
'router:external': net.router__external,
|
'router:external': net.router__external,
|
||||||
'status': net.status.title(),
|
'status': net.status.title(),
|
||||||
|
'allow_delete_subnet': True,
|
||||||
'original_status': net.status,
|
'original_status': net.status,
|
||||||
'subnets': [{
|
'subnets': [{
|
||||||
'cidr': subnet.cidr,
|
'cidr': subnet.cidr,
|
||||||
|
|
|
@ -75,6 +75,7 @@ from openstack_dashboard.dashboards.project.routers.tables import \
|
||||||
STATUS_DISPLAY_CHOICES as routers_status_choices
|
STATUS_DISPLAY_CHOICES as routers_status_choices
|
||||||
from openstack_dashboard.dashboards.project.routers import\
|
from openstack_dashboard.dashboards.project.routers import\
|
||||||
views as r_views
|
views as r_views
|
||||||
|
from openstack_dashboard import policy
|
||||||
|
|
||||||
# List of known server statuses that wont connect to the console
|
# List of known server statuses that wont connect to the console
|
||||||
console_invalid_status = {
|
console_invalid_status = {
|
||||||
|
@ -270,12 +271,19 @@ class JSONView(View):
|
||||||
neutron_networks = []
|
neutron_networks = []
|
||||||
networks = []
|
networks = []
|
||||||
for network in neutron_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,
|
obj = {'name': network.name_or_id,
|
||||||
'id': network.id,
|
'id': network.id,
|
||||||
'subnets': [{'id': subnet.id,
|
'subnets': [{'id': subnet.id,
|
||||||
'cidr': subnet.cidr}
|
'cidr': subnet.cidr}
|
||||||
for subnet in network.subnets],
|
for subnet in network.subnets],
|
||||||
'status': self.trans.network[network.status],
|
'status': self.trans.network[network.status],
|
||||||
|
'allow_delete_subnet': allow_delete_subnet,
|
||||||
'original_status': network.status,
|
'original_status': network.status,
|
||||||
'router:external': network['router:external']}
|
'router:external': network['router:external']}
|
||||||
self.add_resource_url('horizon:project:networks:subnets:detail',
|
self.add_resource_url('horizon:project:networks:subnets:detail',
|
||||||
|
|
|
@ -1066,6 +1066,9 @@ horizon.network_topology = {
|
||||||
htmlData.subnet = subnets;
|
htmlData.subnet = subnets;
|
||||||
if (d instanceof Network) {
|
if (d instanceof Network) {
|
||||||
htmlData.delete_label = gettext('Delete 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_url = 'network/' + d.id + '/subnet/create';
|
||||||
htmlData.add_subnet_label = gettext('Create Subnet');
|
htmlData.add_subnet_label = gettext('Create Subnet');
|
||||||
|
|
Loading…
Reference in New Issue