Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ui/src/config/section/compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ export default {
message: 'message.reinstall.vm',
dataView: true,
args: ['virtualmachineid', 'templateid'],
filters: (record) => {
var filters = {}
var filterParams = {}
filterParams.hypervisortype = record.hypervisor
filterParams.zoneid = record.zoneid
filters.templateid = filterParams
return filters
},
show: (record) => { return ['Running', 'Stopped'].includes(record.state) },
mapping: {
virtualmachineid: {
Expand Down
52 changes: 35 additions & 17 deletions ui/src/views/AutogenView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,6 @@ export default {
this.setModalWidthByScreen()
},
execAction (action, isGroupAction) {
const self = this
this.formRef = ref()
this.form = reactive({})
this.rules = reactive({})
Expand Down Expand Up @@ -1068,13 +1067,37 @@ export default {
return 0
})
this.currentAction.paramFields = []
this.currentAction.paramFilters = []
if ('message' in action) {
var message = action.message
if (typeof action.message === 'function') {
message = action.message(action.resource)
}
action.message = message
}

this.getArgs(action, isGroupAction, paramFields)
this.getFilters(action, isGroupAction, paramFields)
this.getFirstIndexFocus()

this.showAction = true
const listIconForFillValues = ['copy-outlined', 'CopyOutlined', 'edit-outlined', 'EditOutlined', 'share-alt-outlined', 'ShareAltOutlined']
for (const param of this.currentAction.paramFields) {
if (param.type === 'list' && ['tags', 'hosttags', 'storagetags', 'files'].includes(param.name)) {
param.type = 'string'
}
this.setRules(param)
if (param.type === 'uuid' || param.type === 'list' || param.name === 'account' || (this.currentAction.mapping && param.name in this.currentAction.mapping)) {
this.listUuidOpts(param, this.currentAction.paramFilters[param.name])
}
}
this.actionLoading = false
if (action.dataView && listIconForFillValues.includes(action.icon)) {
this.fillEditFormFieldValues()
}
},
getArgs (action, isGroupAction, paramFields) {
const self = this
if ('args' in action) {
var args = action.args
if (typeof action.args === 'function') {
Expand All @@ -1096,22 +1119,14 @@ export default {
})
}
}
this.getFirstIndexFocus()

this.showAction = true
const listIconForFillValues = ['copy-outlined', 'CopyOutlined', 'edit-outlined', 'EditOutlined', 'share-alt-outlined', 'ShareAltOutlined']
for (const param of this.currentAction.paramFields) {
if (param.type === 'list' && ['tags', 'hosttags', 'storagetags', 'files'].includes(param.name)) {
param.type = 'string'
}
this.setRules(param)
if (param.type === 'uuid' || param.type === 'list' || param.name === 'account' || (this.currentAction.mapping && param.name in this.currentAction.mapping)) {
this.listUuidOpts(param)
},
getFilters (action, isGroupAction, paramFields) {
if ('filters' in action) {
var filters = action.filters
if (typeof action.filters === 'function') {
filters = action.filters(action.resource, this.$store.getters, isGroupAction)
}
}
this.actionLoading = false
if (action.dataView && listIconForFillValues.includes(action.icon)) {
this.fillEditFormFieldValues()
this.currentAction.paramFilters = filters
}
},
getFirstIndexFocus () {
Expand All @@ -1124,13 +1139,16 @@ export default {
}
}
},
listUuidOpts (param) {
listUuidOpts (param, filters) {
if (this.currentAction.mapping && param.name in this.currentAction.mapping && !this.currentAction.mapping[param.name].api) {
return
}
var paramName = param.name
var extractedParamName = paramName.replace('ids', '').replace('id', '').toLowerCase()
var params = { listall: true }
for (const filter in filters) {
params[filter] = filters[filter]
}
const possibleName = 'list' + extractedParamName + 's'
var showIcon = false
if (this.$showIcon(extractedParamName)) {
Expand Down