From 1ef990e532d977f4953a999778414a3e46d72683 Mon Sep 17 00:00:00 2001 From: Hashan Tharanga Gamage <109969514+HashanTG@users.noreply.github.com> Date: Thu, 16 Oct 2025 17:17:32 +0530 Subject: [PATCH 1/2] chanege the file name index.js inside the APIform folder in Forms --- workspaces/mi/mi-visualizer/src/views/Forms/APIform/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspaces/mi/mi-visualizer/src/views/Forms/APIform/index.tsx b/workspaces/mi/mi-visualizer/src/views/Forms/APIform/index.tsx index 5e2ebfb3303..8711348282c 100644 --- a/workspaces/mi/mi-visualizer/src/views/Forms/APIform/index.tsx +++ b/workspaces/mi/mi-visualizer/src/views/Forms/APIform/index.tsx @@ -373,7 +373,7 @@ export function APIWizard({ apiData, path }: APIWizardProps) { } const lastHandler = handlers[handlers.length - 1]; - if (lastHandler.name === "" || lastHandler.properties.length === 0) return; + if (lastHandler.name === "") return; setValue("handlers", [...handlers, { name: "", properties: [] }], { shouldValidate: true, shouldDirty: true }); } From 009537d97300cebdef842a137917dd316ad15f7c Mon Sep 17 00:00:00 2001 From: Hashan Tharanga Gamage <109969514+HashanTG@users.noreply.github.com> Date: Tue, 21 Oct 2025 08:43:20 +0530 Subject: [PATCH 2/2] i change index file in mi/mivisualizer/froms/apiform so i fix when adding properties that button also not visible i made it --- .../src/views/Forms/APIform/index.tsx | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/workspaces/mi/mi-visualizer/src/views/Forms/APIform/index.tsx b/workspaces/mi/mi-visualizer/src/views/Forms/APIform/index.tsx index 8711348282c..09de5027402 100644 --- a/workspaces/mi/mi-visualizer/src/views/Forms/APIform/index.tsx +++ b/workspaces/mi/mi-visualizer/src/views/Forms/APIform/index.tsx @@ -367,14 +367,13 @@ export function APIWizard({ apiData, path }: APIWizardProps) { }; const addNewHandler = () => { - if (handlers.length === 0) { + // Always allow adding a new handler row (even if previous is empty) + // We will sanitize empty handlers on save. + if (!handlers || handlers.length === 0) { setValue("handlers", [{ name: "", properties: [] }], { shouldValidate: true, shouldDirty: true }); - return; + } else { + setValue("handlers", [...handlers, { name: "", properties: [] }], { shouldValidate: true, shouldDirty: true }); } - - const lastHandler = handlers[handlers.length - 1]; - if (lastHandler.name === "") return; - setValue("handlers", [...handlers, { name: "", properties: [] }], { shouldValidate: true, shouldDirty: true }); } const handleCreateAPI = async (values: any) => { @@ -440,14 +439,21 @@ export function APIWizard({ apiData, path }: APIWizardProps) { } const xml = getXML(ARTIFACT_TEMPLATES.EDIT_API, formValues); // Combine regular handlers with CORS handler if enabled and version supports it - const allHandlers = [...handlers]; + // Prepare handlers: allow editing UI to have empty rows but filter them out for XML + const allHandlers = [...(handlers || [])]; + const cleanedHandlers = allHandlers + .filter((h: any) => (h?.name ?? '').toString().trim() !== "") + .map((h: any) => ({ + name: h.name, + properties: (h.properties || []).filter((p: any) => ((p?.name ?? '').toString().trim() !== "" && (p?.value ?? '').toString().trim() !== "")) + })); if (shouldShowCORSSettings) { const corsHandler = createCORSHandler(values.corsSettings); if (corsHandler) { - allHandlers.push(corsHandler); + cleanedHandlers.push(corsHandler); } } - const handlersXML = getXML(ARTIFACT_TEMPLATES.EDIT_HANDLERS, { show: allHandlers.length > 0, handlers: allHandlers }); + const handlersXML = getXML(ARTIFACT_TEMPLATES.EDIT_HANDLERS, { show: cleanedHandlers.length > 0, handlers: cleanedHandlers }); const editAPIParams = { documentUri: path, apiName: values.apiName,