From 069d45af87baed79faf9b8ad8efb3043a648c53c Mon Sep 17 00:00:00 2001 From: xusongfu Date: Thu, 29 Sep 2022 15:22:24 +0800 Subject: [PATCH] Fix the name of Bare Metal Nodes When create or edit, fill in name of node, then clear it, creating and editing nodes throws an error Closes-Bug: #1991208 Change-Id: Ia2ad3fb1f9f4a5fa38e59df68386caf5c0c74d3d --- .../BareMetalNode/actions/Create/index.jsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pages/compute/containers/BareMetalNode/actions/Create/index.jsx b/src/pages/compute/containers/BareMetalNode/actions/Create/index.jsx index abe65e60..a6121688 100644 --- a/src/pages/compute/containers/BareMetalNode/actions/Create/index.jsx +++ b/src/pages/compute/containers/BareMetalNode/actions/Create/index.jsx @@ -150,7 +150,8 @@ export class Create extends StepAction { body[key] = newValue; } } else { - body[key] = values[key]; + const isEmptyName = key === 'name' && values[key] === ''; + body[key] = isEmptyName ? null : values[key]; } }); body.driver_info = driverInfo; @@ -186,8 +187,13 @@ export class Create extends StepAction { } else { const oldValue = originData[key]; if (!isEqual(oldValue, value) && (oldValue || value)) { - obj.op = 'replace'; - replaces.push(obj); + if (key === 'name' && value === '') { + obj.op = 'remove'; + dels.push(obj); + } else { + obj.op = 'replace'; + replaces.push(obj); + } } } });