Skip to content

Commit d61b5b3

Browse files
committed
UI: support skipGroupAction
1 parent 2075918 commit d61b5b3

File tree

5 files changed

+54
-5
lines changed

5 files changed

+54
-5
lines changed

ui/public/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,7 @@
19291929
"label.site.to.site.vpn.connections": "Site-to-site VPN Connections",
19301930
"label.size": "Size",
19311931
"label.sizegb": "Size",
1932+
"label.skipped": "Skipped",
19321933
"label.smb.domain": "SMB domain",
19331934
"label.smb.password": "SMB password",
19341935
"label.smb.username": "SMB username",

ui/src/components/view/BulkActionProgress.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
</template>
4343
<a-card :bordered="false" style="background:#f1f1f1">
4444
<div><check-circle-outlined style="color: #52c41a; margin-right: 8px"/> {{ $t('label.success') + ': ' + succeededCount }}</div>
45+
<div><check-circle-outlined style="color: #6e6e6e; margin-right: 8px"/> {{ $t('label.skipped') + ': ' + skippedCount }}</div>
4546
<div><close-circle-outlined style="color: #f5222d; margin-right: 8px"/> {{ $t('state.failed') + ': ' + failedCount }}</div>
4647
<div><sync-outlined style="color: #1890ff; margin-right: 8px"/> {{ $t('state.inprogress') + ': ' + selectedItems.filter(item => item.status === 'InProgress').length || 0 }}</div>
4748
</a-card>
@@ -144,6 +145,9 @@ export default {
144145
succeededCount () {
145146
return this.selectedItems.filter(item => item.status === 'success').length || 0
146147
},
148+
skippedCount () {
149+
return this.selectedItems.filter(item => item.status === 'skipped').length || 0
150+
},
147151
failedCount () {
148152
return this.selectedItems.filter(item => item.status === 'failed').length || 0
149153
}

ui/src/config/section/compute.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,16 @@ export default {
119119
dataView: true,
120120
groupAction: true,
121121
popup: true,
122-
groupMap: (selection, values) => { return selection.map(x => { return { id: x, considerlasthost: values.considerlasthost } }) },
122+
groupMap: (selection, values, record) => {
123+
return selection.map(x => {
124+
const data = record.filter(y => { return y.id === x })
125+
return {
126+
id: x,
127+
considerlasthost: values.considerlasthost,
128+
skipGroupAction: data[0].state !== 'Stopped'
129+
}
130+
})
131+
},
123132
args: (record, store) => {
124133
if (['Admin'].includes(store.userInfo.roletype)) {
125134
return ['considerlasthost']
@@ -138,7 +147,16 @@ export default {
138147
docHelp: 'adminguide/virtual_machines.html#stopping-and-starting-vms',
139148
dataView: true,
140149
groupAction: true,
141-
groupMap: (selection, values) => { return selection.map(x => { return { id: x, forced: values.forced } }) },
150+
groupMap: (selection, values, record) => {
151+
return selection.map(x => {
152+
const data = record.filter(y => { return y.id === x })
153+
return {
154+
id: x,
155+
forced: values.forced,
156+
skipGroupAction: data[0].state !== 'Running'
157+
}
158+
})
159+
},
142160
args: ['forced'],
143161
show: (record) => { return ['Running'].includes(record.state) }
144162
},
@@ -163,7 +181,16 @@ export default {
163181
},
164182
groupAction: true,
165183
popup: true,
166-
groupMap: (selection, values) => { return selection.map(x => { return { id: x, forced: values.forced } }) }
184+
groupMap: (selection, values, record) => {
185+
return selection.map(x => {
186+
const data = record.filter(y => { return y.id === x })
187+
return {
188+
id: x,
189+
forced: values.forced,
190+
skipGroupAction: data[0].state !== 'Running'
191+
}
192+
})
193+
}
167194
},
168195
{
169196
api: 'restoreVirtualMachine',

ui/src/config/section/network.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,16 @@ export default {
857857
show: (record) => { return record.state === 'Reserved' },
858858
groupAction: true,
859859
popup: true,
860-
groupMap: (selection) => { return selection.map(x => { return { id: x } }) }
860+
groupMap: (selection, values, record) => {
861+
return selection.map(x => {
862+
const data = record.filter(y => { return y.id === x })
863+
return {
864+
id: x,
865+
forced: values.forced,
866+
skipGroupAction: data[0].state !== 'Reserved'
867+
}
868+
})
869+
}
861870
}
862871
]
863872
},

ui/src/views/AutogenView.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ export default {
896896
897897
this.chosenColumns = this.columns.filter(column => {
898898
return ![this.$t('label.state'), this.$t('label.hostname'), this.$t('label.hostid'), this.$t('label.zonename'),
899-
this.$t('label.zone'), this.$t('label.zoneid'), this.$t('label.ip'), this.$t('label.ipaddress'), this.$t('label.privateip'),
899+
this.$t('label.zone'), this.$t('label.zoneid'), this.$t('label.ip'), this.$t('label.privateip'),
900900
this.$t('label.linklocalip'), this.$t('label.size'), this.$t('label.sizegb'), this.$t('label.current'),
901901
this.$t('label.created'), this.$t('label.order')].includes(column.title)
902902
})
@@ -1423,6 +1423,7 @@ export default {
14231423
filters: [
14241424
{ text: 'In Progress', value: 'InProgress' },
14251425
{ text: 'Success', value: 'success' },
1426+
{ text: 'Skipped', value: 'skipped' },
14261427
{ text: 'Failed', value: 'failed' }
14271428
]
14281429
})
@@ -1461,6 +1462,13 @@ export default {
14611462
},
14621463
callGroupApi (params, resourceName) {
14631464
return new Promise((resolve, reject) => {
1465+
if (params.skipGroupAction) {
1466+
eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource: this.getDataIdentifier(params), state: 'skipped' })
1467+
this.actionLoading = false
1468+
this.showAction = false
1469+
return
1470+
}
1471+
delete params.skipGroupAction
14641472
const action = this.currentAction
14651473
api(action.api, params).then(json => {
14661474
resolve(this.handleResponse(json, resourceName, this.getDataIdentifier(params), action, false))

0 commit comments

Comments
 (0)