1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-23 22:50:09 +03:00

F #5422: Fix notifications on instantion form (#2044)

This commit is contained in:
Sergio Betanzos 2022-05-13 12:01:18 +02:00 committed by GitHub
parent ecd2d1a9b4
commit 56947c9962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -66,11 +66,12 @@ const Steps = createSteps(
const data = { instances, hold, persistent, template: templateXML }
const templates = [...new Array(instances)].map((_, idx) => ({
id: vmTemplate.ID,
name: name?.replace(/%idx/gi, idx),
...data,
}))
return [vmTemplate, templates]
return templates
},
}
)

View File

@ -38,7 +38,7 @@ import { PATH } from 'client/apps/sunstone/routesOne'
*/
function InstantiateVmTemplate() {
const history = useHistory()
const { state: { ID: templateId } = {} } = useLocation()
const { state: { ID: templateId, NAME: templateName } = {} } = useLocation()
const { enqueueInfo } = useGeneralApi()
const [instantiate] = useInstantiateTemplateMutation()
@ -51,17 +51,16 @@ function InstantiateVmTemplate() {
useGetUsersQuery(undefined, { refetchOnMountOrArgChange: false })
useGetGroupsQuery(undefined, { refetchOnMountOrArgChange: false })
const onSubmit = async ([templateSelected, templates]) => {
const onSubmit = async (templates) => {
try {
const { ID, NAME } = templateSelected
const templatesWithId = templates.map((t) => ({ id: ID, ...t }))
await Promise.all(templatesWithId.map((t) => instantiate(t).unwrap()))
const promises = await Promise.all(templates.map(instantiate))
promises.map((res) => res.unwrap?.())
history.push(PATH.INSTANCE.VMS.LIST)
const total = templates.length
enqueueInfo(`VM Template instantiated x${total} - #${ID} ${NAME}`)
const templateInfo = `#${templateId} ${templateName}`
enqueueInfo(`VM Template instantiated x${total} - ${templateInfo}`)
} catch {}
}