Skip to content

Commit 2b3e2e4

Browse files
authored
ui: show zones and offerings to users (apache#7557)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 5e71cea commit 2b3e2e4

File tree

6 files changed

+77
-15
lines changed

6 files changed

+77
-15
lines changed

ui/.env.primate-qa

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CS_URL=http://primate-qa.cloudstack.cloud:8080
1+
CS_URL=https://qa.cloudstack.cloud/

ui/src/components/view/InfoCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
@click="showUploadModal(true)"
2727
v-clipboard:copy="name" >
2828
<upload-resource-icon v-if="'uploadResourceIcon' in $store.getters.apis" :visible="showUpload" :resource="resource" @handle-close="showUpload(false)"/>
29-
<div class="ant-upload-preview" v-if="$showIcon()">
29+
<div class="ant-upload-preview" v-if="$showIcon() && !$route.path.includes('zones')">
3030
<camera-outlined class="upload-icon"/>
3131
</div>
3232
<slot name="avatar">

ui/src/config/router.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import account from '@/config/section/account'
3434
import domain from '@/config/section/domain'
3535
import role from '@/config/section/role'
3636
import infra from '@/config/section/infra'
37+
import zone from '@/config/section/zone'
3738
import offering from '@/config/section/offering'
3839
import config from '@/config/section/config'
3940
import tools from '@/config/section/tools'
@@ -44,7 +45,7 @@ function generateRouterMap (section) {
4445
var map = {
4546
name: section.name,
4647
path: '/' + section.name,
47-
hidden: section.hidden,
48+
hidden: 'show' in section ? !section.show() : section.hidden,
4849
meta: {
4950
title: section.title,
5051
icon: section.icon,
@@ -235,6 +236,7 @@ export function asyncRouterMap () {
235236
generateRouterMap(account),
236237
generateRouterMap(domain),
237238
generateRouterMap(infra),
239+
generateRouterMap(zone),
238240
generateRouterMap(offering),
239241
generateRouterMap(config),
240242
generateRouterMap(tools),

ui/src/config/section/offering.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,21 @@ export default {
2121
name: 'offering',
2222
title: 'label.menu.service.offerings',
2323
icon: 'shopping-outlined',
24-
permission: ['listServiceOfferings', 'listDiskOfferings', 'listDomains'],
24+
permission: ['listServiceOfferings', 'listDiskOfferings'],
2525
children: [
2626
{
2727
name: 'computeoffering',
2828
title: 'label.compute.offerings',
2929
docHelp: 'adminguide/service_offerings.html#compute-and-disk-service-offerings',
3030
icon: 'cloud-outlined',
31-
permission: ['listServiceOfferings', 'listDomains'],
32-
params: { isrecursive: 'true' },
31+
permission: ['listServiceOfferings'],
32+
params: () => {
33+
var params = {}
34+
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
35+
params = { isrecursive: 'true' }
36+
}
37+
return params
38+
},
3339
columns: ['name', 'displaytext', 'cpunumber', 'cpuspeed', 'memory', 'domain', 'zone', 'order'],
3440
details: () => {
3541
var fields = ['name', 'id', 'displaytext', 'offerha', 'provisioningtype', 'storagetype', 'iscustomized', 'iscustomizediops', 'limitcpuuse', 'cpunumber', 'cpuspeed', 'memory', 'hosttags', 'tags', 'storagetags', 'domain', 'zone', 'created', 'dynamicscalingenabled', 'diskofferingstrictness', 'encryptroot']
@@ -51,7 +57,8 @@ export default {
5157
},
5258
{
5359
name: 'comments',
54-
component: shallowRef(defineAsyncComponent(() => import('@/components/view/AnnotationsTab.vue')))
60+
component: shallowRef(defineAsyncComponent(() => import('@/components/view/AnnotationsTab.vue'))),
61+
show: (record, route, user) => { return ['Admin', 'DomainAdmin'].includes(user.roletype) }
5562
}
5663
],
5764
related: [{
@@ -138,8 +145,14 @@ export default {
138145
title: 'label.disk.offerings',
139146
icon: 'hdd-outlined',
140147
docHelp: 'adminguide/service_offerings.html#compute-and-disk-service-offerings',
141-
permission: ['listDiskOfferings', 'listDomains'],
142-
params: { isrecursive: 'true' },
148+
permission: ['listDiskOfferings'],
149+
params: () => {
150+
var params = {}
151+
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
152+
params = { isrecursive: 'true' }
153+
}
154+
return params
155+
},
143156
columns: ['name', 'displaytext', 'disksize', 'domain', 'zone', 'order'],
144157
details: () => {
145158
var fields = ['name', 'id', 'displaytext', 'disksize', 'provisioningtype', 'storagetype', 'iscustomized', 'disksizestrictness', 'iscustomizediops', 'tags', 'domain', 'zone', 'created', 'encrypt']
@@ -157,7 +170,8 @@ export default {
157170
},
158171
{
159172
name: 'comments',
160-
component: shallowRef(defineAsyncComponent(() => import('@/components/view/AnnotationsTab.vue')))
173+
component: shallowRef(defineAsyncComponent(() => import('@/components/view/AnnotationsTab.vue'))),
174+
show: (record, route, user) => { return ['Admin', 'DomainAdmin'].includes(user.roletype) }
161175
}
162176
],
163177
related: [{
@@ -205,7 +219,7 @@ export default {
205219
title: 'label.backup.offerings',
206220
icon: 'cloud-upload-outlined',
207221
docHelp: 'adminguide/virtual_machines.html#backup-offerings',
208-
permission: ['listBackupOfferings', 'listInfrastructure'],
222+
permission: ['listBackupOfferings'],
209223
columns: ['name', 'description', 'zonename'],
210224
details: ['name', 'id', 'description', 'externalid', 'zone', 'allowuserdrivenbackups', 'created'],
211225
related: [{
@@ -246,7 +260,7 @@ export default {
246260
title: 'label.network.offerings',
247261
icon: 'wifi-outlined',
248262
docHelp: 'adminguide/networking.html#network-offerings',
249-
permission: ['listNetworkOfferings', 'listInfrastructure'],
263+
permission: ['listNetworkOfferings'],
250264
columns: ['name', 'state', 'guestiptype', 'traffictype', 'networkrate', 'domain', 'zone', 'order'],
251265
details: ['name', 'id', 'displaytext', 'guestiptype', 'traffictype', 'internetprotocol', 'networkrate', 'ispersistent', 'egressdefaultpolicy', 'availability', 'conservemode', 'specifyvlan', 'specifyipranges', 'supportspublicaccess', 'supportsstrechedl2subnet', 'service', 'tags', 'domain', 'zone'],
252266
resourceType: 'NetworkOffering',
@@ -257,7 +271,8 @@ export default {
257271
},
258272
{
259273
name: 'comments',
260-
component: shallowRef(defineAsyncComponent(() => import('@/components/view/AnnotationsTab.vue')))
274+
component: shallowRef(defineAsyncComponent(() => import('@/components/view/AnnotationsTab.vue'))),
275+
show: (record, route, user) => { return ['Admin', 'DomainAdmin'].includes(user.roletype) }
261276
}
262277
],
263278
actions: [{
@@ -337,7 +352,7 @@ export default {
337352
title: 'label.vpc.offerings',
338353
icon: 'deployment-unit-outlined',
339354
docHelp: 'plugins/nuage-plugin.html?#vpc-offerings',
340-
permission: ['listVPCOfferings', 'listInfrastructure'],
355+
permission: ['listVPCOfferings'],
341356
resourceType: 'VpcOffering',
342357
columns: ['name', 'state', 'displaytext', 'domain', 'zone', 'order'],
343358
details: ['name', 'id', 'displaytext', 'internetprotocol', 'distributedvpcrouter', 'tags', 'service', 'domain', 'zone', 'created'],

ui/src/config/section/zone.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 { shallowRef, defineAsyncComponent } from 'vue'
19+
import store from '@/store'
20+
21+
export default {
22+
name: 'zones',
23+
title: 'label.zones',
24+
icon: 'global-outlined',
25+
permission: ['listZones'],
26+
params: { showicon: true },
27+
show: () => {
28+
return ['DomainAdmin', 'User'].includes(store.getters.userInfo.roletype)
29+
},
30+
columns: () => {
31+
const fields = ['name', 'allocationstate', 'type', 'networktype']
32+
return fields
33+
},
34+
details: ['name', 'id', 'allocationstate', 'type', 'networktype', 'guestcidraddress', 'localstorageenabled', 'securitygroupsenabled', 'dns1', 'dns2', 'internaldns1', 'internaldns2'],
35+
related: [{
36+
name: 'vm',
37+
title: 'label.vms',
38+
param: 'zoneid'
39+
}],
40+
resourceType: 'Zone',
41+
tabs: [{
42+
name: 'details',
43+
component: shallowRef(defineAsyncComponent(() => import('@/components/view/DetailsTab.vue')))
44+
}]
45+
}

ui/src/utils/plugins.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export const showIconPlugin = {
345345
if (resource) {
346346
resourceType = resource
347347
}
348-
if (['zone', 'template', 'iso', 'account', 'accountuser', 'vm', 'domain', 'project', 'vpc', 'guestnetwork'].includes(resourceType)) {
348+
if (['zone', 'zones', 'template', 'iso', 'account', 'accountuser', 'vm', 'domain', 'project', 'vpc', 'guestnetwork'].includes(resourceType)) {
349349
return true
350350
} else {
351351
return false

0 commit comments

Comments
 (0)