From 56947c9962e6c46b2437d04b9c213e0edb156855 Mon Sep 17 00:00:00 2001 From: Sergio Betanzos Date: Fri, 13 May 2022 12:01:18 +0200 Subject: [PATCH] F #5422: Fix notifications on instantion form (#2044) --- .../Forms/VmTemplate/InstantiateForm/Steps/index.js | 3 ++- .../client/containers/VmTemplates/Instantiate.js | 13 ++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/fireedge/src/client/components/Forms/VmTemplate/InstantiateForm/Steps/index.js b/src/fireedge/src/client/components/Forms/VmTemplate/InstantiateForm/Steps/index.js index 3e2aa9fc62..c03424d564 100644 --- a/src/fireedge/src/client/components/Forms/VmTemplate/InstantiateForm/Steps/index.js +++ b/src/fireedge/src/client/components/Forms/VmTemplate/InstantiateForm/Steps/index.js @@ -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 }, } ) diff --git a/src/fireedge/src/client/containers/VmTemplates/Instantiate.js b/src/fireedge/src/client/containers/VmTemplates/Instantiate.js index 2250457374..3debab1f87 100644 --- a/src/fireedge/src/client/containers/VmTemplates/Instantiate.js +++ b/src/fireedge/src/client/containers/VmTemplates/Instantiate.js @@ -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 {} }