From 63eba716b847d16ae6177a768930109beb61db33 Mon Sep 17 00:00:00 2001 From: xusongfu Date: Tue, 16 Aug 2022 14:30:51 +0800 Subject: [PATCH] fix: fix code editor and edit image 1. Show full error message in code editor 2. Fix params when update image if os_distro is empty Change-Id: Ifac477ce28758e737291789b85e5e4c481e8729d --- src/components/CodeEditor/index.jsx | 5 +++-- .../compute/containers/Image/actions/Edit.jsx | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/components/CodeEditor/index.jsx b/src/components/CodeEditor/index.jsx index 4192f162..47c479d9 100644 --- a/src/components/CodeEditor/index.jsx +++ b/src/components/CodeEditor/index.jsx @@ -25,10 +25,11 @@ const parseValue = (value) => { return value; } if (value.includes('')) { - const reg = /<\/h1>[\r\n]([\s\S]*)

/; + const reg = /<\/h1>[\r\n]([\s\S]*)<\/body>/; const results = reg.exec(value); if (results) { - return results[1]; + const newValue = results[1].replace(/
/g, ''); + return newValue; } } try { diff --git a/src/pages/compute/containers/Image/actions/Edit.jsx b/src/pages/compute/containers/Image/actions/Edit.jsx index b41a37d0..8aabf5b5 100644 --- a/src/pages/compute/containers/Image/actions/Edit.jsx +++ b/src/pages/compute/containers/Image/actions/Edit.jsx @@ -209,22 +209,26 @@ export class Edit extends ModalAction { newValues.min_ram = min_ram * 1024; } if (hw_cpu_policy !== NoSetValue) { - newValues.hw_cpu_policy = hw_cpu_policy || this.item.hw_cpu_policy; + newValues.hw_cpu_policy = + hw_cpu_policy || this.item.originData.hw_cpu_policy; } if (hw_cpu_thread_policy !== NoSetValue) { newValues.hw_cpu_thread_policy = - hw_cpu_thread_policy || this.item.hw_cpu_thread_policy; + hw_cpu_thread_policy || this.item.originData.hw_cpu_thread_policy; } const changeValues = []; Object.keys(newValues).forEach((key) => { - if (has(this.item, key) && get(this.item, key) !== newValues[key]) { + if ( + has(this.item.originData, key) && + get(this.item.originData, key) !== newValues[key] + ) { const item = { op: 'replace', path: `/${key}`, value: newValues[key], }; changeValues.push(item); - } else if (!has(this.item, key) && newValues[key]) { + } else if (!has(this.item.originData, key) && newValues[key]) { const item = { op: 'add', path: `/${key}`, @@ -233,13 +237,16 @@ export class Edit extends ModalAction { changeValues.push(item); } }); - if (this.item.hw_cpu_policy && hw_cpu_policy === NoSetValue) { + if (this.item.originData.hw_cpu_policy && hw_cpu_policy === NoSetValue) { changeValues.push({ op: 'remove', path: '/hw_cpu_policy', }); } - if (this.item.hw_cpu_thread_policy && hw_cpu_thread_policy === NoSetValue) { + if ( + this.item.originData.hw_cpu_thread_policy && + hw_cpu_thread_policy === NoSetValue + ) { changeValues.push({ op: 'remove', path: '/hw_cpu_thread_policy',