Skip to content

Commit 39b388d

Browse files
abh1sardhslove
authored andcommitted
Hide register template, create/upload volume and create vpc buttons when zone is not created. (apache#10243)
1 parent 7e93363 commit 39b388d

File tree

5 files changed

+52
-50
lines changed

5 files changed

+52
-50
lines changed

ui/src/config/section/compute.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import { shallowRef, defineAsyncComponent } from 'vue'
1919
import store from '@/store'
20+
import { isZoneCreated } from '@/utils/zone'
2021

2122
export default {
2223
name: 'compute',
@@ -107,6 +108,7 @@ export default {
107108
label: 'label.vm.add',
108109
docHelp: 'adminguide/virtual_machines.html#creating-vms',
109110
listView: true,
111+
show: () => { isZoneCreated() },
110112
component: () => import('@/views/compute/DeployVM.vue')
111113
},
112114
{
@@ -658,6 +660,7 @@ export default {
658660
docHelp: 'plugins/cloudstack-kubernetes-service.html#creating-a-new-kubernetes-cluster',
659661
listView: true,
660662
popup: true,
663+
show: () => { isZoneCreated() },
661664
component: shallowRef(defineAsyncComponent(() => import('@/views/compute/CreateKubernetesCluster.vue')))
662665
},
663666
{
@@ -786,6 +789,7 @@ export default {
786789
icon: 'plus-outlined',
787790
label: 'label.new.autoscale.vmgroup',
788791
listView: true,
792+
show: () => { isZoneCreated() },
789793
component: () => import('@/views/compute/CreateAutoScaleVmGroup.vue')
790794
},
791795
{
@@ -876,6 +880,7 @@ export default {
876880
icon: 'plus-outlined',
877881
label: 'label.new.instance.group',
878882
listView: true,
883+
show: () => { isZoneCreated() },
879884
args: ['name']
880885
},
881886
{

ui/src/config/section/image.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import { shallowRef, defineAsyncComponent } from 'vue'
1919
import store from '@/store'
20+
import { isZoneCreated } from '@/utils/zone'
2021

2122
export default {
2223
name: 'image',
@@ -110,16 +111,17 @@ export default {
110111
docHelp: 'adminguide/templates.html#uploading-templates-from-a-remote-http-server',
111112
listView: true,
112113
popup: true,
114+
show: () => { isZoneCreated() },
113115
component: shallowRef(defineAsyncComponent(() => import('@/views/image/RegisterOrUploadTemplate.vue')))
114116
},
115117
{
116118
api: 'registerTemplate',
117119
icon: 'cloud-upload-outlined',
118120
label: 'label.upload.template.from.local',
119-
show: () => { return 'getUploadParamsForTemplate' in store.getters.apis },
120121
docHelp: 'adminguide/templates.html#uploading-templates-and-isos-from-a-local-computer',
121122
listView: true,
122123
popup: true,
124+
show: () => { return isZoneCreated() && 'getUploadParamsForTemplate' in store.getters.apis },
123125
component: shallowRef(defineAsyncComponent(() => import('@/views/image/RegisterOrUploadTemplate.vue')))
124126
},
125127
{
@@ -270,13 +272,14 @@ export default {
270272
docHelp: 'adminguide/templates.html#id10',
271273
listView: true,
272274
popup: true,
275+
show: () => { isZoneCreated() },
273276
component: shallowRef(defineAsyncComponent(() => import('@/views/image/RegisterOrUploadIso.vue')))
274277
},
275278
{
276279
api: 'registerIso',
277280
icon: 'cloud-upload-outlined',
278281
label: 'label.upload.iso.from.local',
279-
show: () => { return 'getUploadParamsForIso' in store.getters.apis },
282+
show: () => { return isZoneCreated() && 'getUploadParamsForIso' in store.getters.apis },
280283
docHelp: 'adminguide/templates.html#id10',
281284
listView: true,
282285
popup: true,
@@ -389,6 +392,7 @@ export default {
389392
label: 'label.kubernetes.version.add',
390393
listView: true,
391394
popup: true,
395+
show: () => { isZoneCreated() },
392396
component: shallowRef(defineAsyncComponent(() => import('@/views/image/AddKubernetesSupportedVersion.vue')))
393397
},
394398
{

ui/src/config/section/network.js

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { shallowRef, defineAsyncComponent } from 'vue'
1919
import store from '@/store'
2020
import tungsten from '@/assets/icons/tungsten.svg?inline'
2121
import { isAdmin } from '@/role'
22+
import { isZoneCreated } from '@/utils/zone'
2223

2324
export default {
2425
name: 'network',
@@ -131,6 +132,10 @@ export default {
131132
listView: true,
132133
popup: true,
133134
show: () => {
135+
if (!isZoneCreated()) {
136+
return false
137+
}
138+
const AdvancedZones = store.getters.zones.filter(zone => zone.networktype === 'Advanced')
134139
const AdvancedZonesWithoutSG = store.getters.zones.filter(zone => zone.securitygroupsenabled === false)
135140
if (isAdmin() || (AdvancedZonesWithoutSG && AdvancedZonesWithoutSG.length > 0)) {
136141
return true
@@ -249,6 +254,7 @@ export default {
249254
icon: 'plus-outlined',
250255
label: 'label.add.vpc',
251256
docHelp: 'adminguide/networking_and_traffic.html#adding-a-virtual-private-cloud',
257+
show: () => { isZoneCreated() },
252258
listView: true,
253259
popup: true,
254260
component: shallowRef(defineAsyncComponent(() => import('@/views/network/CreateVpc.vue')))
@@ -310,7 +316,7 @@ export default {
310316
component: shallowRef(defineAsyncComponent(() => import('@/views/network/IngressEgressRuleConfigure.vue')))
311317
}],
312318
show: () => {
313-
if (!store.getters.zones || store.getters.zones.length === 0) {
319+
if (!isZoneCreated()) {
314320
return false
315321
}
316322
const listZoneHaveSGEnabled = store.getters.zones.filter(zone => zone.securitygroupsenabled === true)
@@ -395,6 +401,7 @@ export default {
395401
label: 'label.vnf.appliance.add',
396402
docHelp: 'adminguide/networking/vnf_templates_appliances.html#deploying-vnf-appliances',
397403
listView: true,
404+
show: () => { isZoneCreated() },
398405
component: () => import('@/views/compute/DeployVnfAppliance.vue')
399406
},
400407
{
@@ -990,6 +997,7 @@ export default {
990997
label: 'label.add.vpn.gateway',
991998
docHelp: 'adminguide/networking_and_traffic.html#creating-a-vpn-gateway-for-the-vpc',
992999
listView: true,
1000+
show: () => { isZoneCreated() },
9931001
args: ['vpcid']
9941002
},
9951003
{
@@ -1165,6 +1173,7 @@ export default {
11651173
icon: 'plus-outlined',
11661174
label: 'label.add.vpn.user',
11671175
listView: true,
1176+
show: () => { isZoneCreated() },
11681177
args: (record, store) => {
11691178
if (store.userInfo.roletype === 'User') {
11701179
return ['username', 'password']
@@ -1244,6 +1253,7 @@ export default {
12441253
docHelp: 'adminguide/networking_and_traffic.html#creating-and-updating-a-vpn-customer-gateway',
12451254
listView: true,
12461255
popup: true,
1256+
show: () => { isZoneCreated() },
12471257
component: shallowRef(defineAsyncComponent(() => import('@/views/network/CreateVpnCustomerGateway.vue')))
12481258
},
12491259
{
@@ -1434,52 +1444,7 @@ export default {
14341444
component: shallowRef(defineAsyncComponent(() => import('@/views/network/GuestVlanNetworksTab.vue'))),
14351445
show: (record) => { return (record.allocationstate === 'Allocated') }
14361446
}],
1437-
show: () => {
1438-
if (!store.getters.zones || store.getters.zones.length === 0) {
1439-
return false
1440-
}
1441-
return true
1442-
}
1443-
},
1444-
{
1445-
name: 'ipv4subnets',
1446-
title: 'label.ipv4.subnets',
1447-
icon: 'pic-center-outlined',
1448-
permission: ['listIpv4SubnetsForGuestNetwork'],
1449-
columns: ['subnet', 'zonename', 'parentsubnet', 'networkname', 'vpcname', 'created', 'allocated'],
1450-
details: ['subnet', 'zonename', 'zoneid', 'parentsubnet', 'networkname', 'networkid', 'vpcname', 'vpcid', 'created', 'allocated', 'state'],
1451-
searchFilters: ['zoneid'],
1452-
show: () => {
1453-
if (!store.getters.zones || store.getters.zones.length === 0) {
1454-
return false
1455-
}
1456-
const AdvancedZonesWithRoutedmode = store.getters.zones.filter(zone => zone.routedmodeenabled)
1457-
if (isAdmin() && (AdvancedZonesWithRoutedmode && AdvancedZonesWithRoutedmode.length > 0)) {
1458-
return true
1459-
}
1460-
return false
1461-
},
1462-
actions: [
1463-
{
1464-
api: 'createIpv4SubnetForGuestNetwork',
1465-
icon: 'plus-outlined',
1466-
label: 'label.add.ipv4.subnet',
1467-
listView: true,
1468-
popup: true,
1469-
component: shallowRef(defineAsyncComponent(() => import('@/views/network/CreateIpv4SubnetForNetwork.vue')))
1470-
},
1471-
{
1472-
api: 'deleteIpv4SubnetForGuestNetwork',
1473-
icon: 'delete-outlined',
1474-
label: 'label.delete.ipv4.subnet',
1475-
message: 'message.action.delete.ipv4.subnet',
1476-
dataView: true,
1477-
show: (record) => { return !record.networkid },
1478-
groupAction: true,
1479-
popup: true,
1480-
groupMap: (selection) => { return selection.map(x => { return { id: x } }) }
1481-
}
1482-
]
1447+
show: isZoneCreated
14831448
}
14841449
]
14851450
}

ui/src/config/section/storage.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import { shallowRef, defineAsyncComponent } from 'vue'
1919
import store from '@/store'
20+
import { isZoneCreated } from '@/utils/zone'
2021

2122
export default {
2223
name: 'storage',
@@ -105,6 +106,7 @@ export default {
105106
icon: 'plus-outlined',
106107
docHelp: 'adminguide/storage.html#creating-a-new-volume',
107108
label: 'label.action.create.volume',
109+
show: () => { isZoneCreated() },
108110
listView: true,
109111
popup: true,
110112
component: shallowRef(defineAsyncComponent(() => import('@/views/storage/CreateVolume.vue')))
@@ -114,7 +116,7 @@ export default {
114116
icon: 'cloud-upload-outlined',
115117
docHelp: 'adminguide/storage.html#uploading-an-existing-volume-to-a-virtual-machine',
116118
label: 'label.upload.volume.from.local',
117-
show: () => { return 'getUploadParamsForVolume' in store.getters.apis },
119+
show: () => { return isZoneCreated() && 'getUploadParamsForVolume' in store.getters.apis },
118120
listView: true,
119121
popup: true,
120122
component: shallowRef(defineAsyncComponent(() => import('@/views/storage/UploadLocalVolume.vue')))
@@ -124,6 +126,7 @@ export default {
124126
icon: 'link-outlined',
125127
docHelp: 'adminguide/storage.html#uploading-an-existing-volume-to-a-virtual-machine',
126128
label: 'label.upload.volume.from.url',
129+
show: () => { isZoneCreated() },
127130
listView: true,
128131
popup: true,
129132
component: shallowRef(defineAsyncComponent(() => import('@/views/storage/UploadVolume.vue')))

ui/src/utils/zone.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
import store from '@/store'
19+
20+
export function isZoneCreated () {
21+
if (!store.getters.zones || store.getters.zones.length === 0) {
22+
return false
23+
}
24+
return true
25+
}

0 commit comments

Comments
 (0)