From 04c540b41caabf5765f04df10f5b2af4706fdaaf Mon Sep 17 00:00:00 2001 From: Zzde Date: Thu, 5 Sep 2024 11:41:14 +0800 Subject: [PATCH] fix dashboard config reset (#1110) Signed-off-by: Xuhui zhang --- dashboard-ui-v2/src/components/config-modal.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dashboard-ui-v2/src/components/config-modal.tsx b/dashboard-ui-v2/src/components/config-modal.tsx index 026cf0d2c2..8f81e026b5 100644 --- a/dashboard-ui-v2/src/components/config-modal.tsx +++ b/dashboard-ui-v2/src/components/config-modal.tsx @@ -77,12 +77,13 @@ const ConfigModal: React.FC<{ onClick={() => { mutate() if (data?.data) { - setConfig( - YAML.stringify(data?.data?.['config.yaml']) - .split('\n') - .slice(1) - .join('\n'), - ) + try { + setConfig( + YAML.stringify(YAML.parse(data?.data?.['config.yaml'])), + ) + } catch (e) { + setConfig((e as YAMLParseError).message) + } setUpdated(false) } }}