Skip to content

Commit 1b2f6c9

Browse files
authored
Hide register template, create/upload volume and create vpc buttons when zone is not created. (#10243)
1 parent 37c29f8 commit 1b2f6c9

File tree

5 files changed

+49
-11
lines changed

5 files changed

+49
-11
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',
@@ -99,6 +100,7 @@ export default {
99100
label: 'label.vm.add',
100101
docHelp: 'adminguide/virtual_machines.html#creating-vms',
101102
listView: true,
103+
show: () => { isZoneCreated() },
102104
component: () => import('@/views/compute/DeployVM.vue')
103105
},
104106
{
@@ -567,6 +569,7 @@ export default {
567569
docHelp: 'plugins/cloudstack-kubernetes-service.html#creating-a-new-kubernetes-cluster',
568570
listView: true,
569571
popup: true,
572+
show: () => { isZoneCreated() },
570573
component: shallowRef(defineAsyncComponent(() => import('@/views/compute/CreateKubernetesCluster.vue')))
571574
},
572575
{
@@ -695,6 +698,7 @@ export default {
695698
icon: 'plus-outlined',
696699
label: 'label.new.autoscale.vmgroup',
697700
listView: true,
701+
show: () => { isZoneCreated() },
698702
component: () => import('@/views/compute/CreateAutoScaleVmGroup.vue')
699703
},
700704
{
@@ -785,6 +789,7 @@ export default {
785789
icon: 'plus-outlined',
786790
label: 'label.new.instance.group',
787791
listView: true,
792+
show: () => { isZoneCreated() },
788793
args: ['name']
789794
},
790795
{

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: 9 additions & 8 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',
@@ -123,7 +124,7 @@ export default {
123124
listView: true,
124125
popup: true,
125126
show: () => {
126-
if (!store.getters.zones || store.getters.zones.length === 0) {
127+
if (!isZoneCreated()) {
127128
return false
128129
}
129130
const AdvancedZones = store.getters.zones.filter(zone => zone.networktype === 'Advanced')
@@ -245,6 +246,7 @@ export default {
245246
icon: 'plus-outlined',
246247
label: 'label.add.vpc',
247248
docHelp: 'adminguide/networking_and_traffic.html#adding-a-virtual-private-cloud',
249+
show: () => { isZoneCreated() },
248250
listView: true,
249251
popup: true,
250252
component: shallowRef(defineAsyncComponent(() => import('@/views/network/CreateVpc.vue')))
@@ -306,7 +308,7 @@ export default {
306308
component: shallowRef(defineAsyncComponent(() => import('@/views/network/IngressEgressRuleConfigure.vue')))
307309
}],
308310
show: () => {
309-
if (!store.getters.zones || store.getters.zones.length === 0) {
311+
if (!isZoneCreated()) {
310312
return false
311313
}
312314
const listZoneHaveSGEnabled = store.getters.zones.filter(zone => zone.securitygroupsenabled === true)
@@ -394,6 +396,7 @@ export default {
394396
label: 'label.vnf.appliance.add',
395397
docHelp: 'adminguide/networking/vnf_templates_appliances.html#deploying-vnf-appliances',
396398
listView: true,
399+
show: () => { isZoneCreated() },
397400
component: () => import('@/views/compute/DeployVnfAppliance.vue')
398401
},
399402
{
@@ -941,6 +944,7 @@ export default {
941944
label: 'label.add.vpn.gateway',
942945
docHelp: 'adminguide/networking_and_traffic.html#creating-a-vpn-gateway-for-the-vpc',
943946
listView: true,
947+
show: () => { isZoneCreated() },
944948
args: ['vpcid']
945949
},
946950
{
@@ -1116,6 +1120,7 @@ export default {
11161120
icon: 'plus-outlined',
11171121
label: 'label.add.vpn.user',
11181122
listView: true,
1123+
show: () => { isZoneCreated() },
11191124
args: (record, store) => {
11201125
if (store.userInfo.roletype === 'User') {
11211126
return ['username', 'password']
@@ -1195,6 +1200,7 @@ export default {
11951200
docHelp: 'adminguide/networking_and_traffic.html#creating-and-updating-a-vpn-customer-gateway',
11961201
listView: true,
11971202
popup: true,
1203+
show: () => { isZoneCreated() },
11981204
component: shallowRef(defineAsyncComponent(() => import('@/views/network/CreateVpnCustomerGateway.vue')))
11991205
},
12001206
{
@@ -1384,12 +1390,7 @@ export default {
13841390
component: shallowRef(defineAsyncComponent(() => import('@/views/network/GuestVlanNetworksTab.vue'))),
13851391
show: (record) => { return (record.allocationstate === 'Allocated') }
13861392
}],
1387-
show: () => {
1388-
if (!store.getters.zones || store.getters.zones.length === 0) {
1389-
return false
1390-
}
1391-
return true
1392-
}
1393+
show: () => { isZoneCreated() }
13931394
}
13941395
]
13951396
}

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',
@@ -103,6 +104,7 @@ export default {
103104
icon: 'plus-outlined',
104105
docHelp: 'adminguide/storage.html#creating-a-new-volume',
105106
label: 'label.action.create.volume',
107+
show: () => { isZoneCreated() },
106108
listView: true,
107109
popup: true,
108110
component: shallowRef(defineAsyncComponent(() => import('@/views/storage/CreateVolume.vue')))
@@ -112,7 +114,7 @@ export default {
112114
icon: 'cloud-upload-outlined',
113115
docHelp: 'adminguide/storage.html#uploading-an-existing-volume-to-a-virtual-machine',
114116
label: 'label.upload.volume.from.local',
115-
show: () => { return 'getUploadParamsForVolume' in store.getters.apis },
117+
show: () => { return isZoneCreated() && 'getUploadParamsForVolume' in store.getters.apis },
116118
listView: true,
117119
popup: true,
118120
component: shallowRef(defineAsyncComponent(() => import('@/views/storage/UploadLocalVolume.vue')))
@@ -122,6 +124,7 @@ export default {
122124
icon: 'link-outlined',
123125
docHelp: 'adminguide/storage.html#uploading-an-existing-volume-to-a-virtual-machine',
124126
label: 'label.upload.volume.from.url',
127+
show: () => { isZoneCreated() },
125128
listView: true,
126129
popup: true,
127130
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)