From 41db6a03f475b539a50ced38af1bf1cf0441a309 Mon Sep 17 00:00:00 2001 From: Oliwia Gowor <72342415+OliwiaGowor@users.noreply.github.com> Date: Thu, 28 Mar 2024 12:56:49 +0100 Subject: [PATCH] fix: edit Nodejs function dependencies in JSON format (#2864) * fix deps formatting * get rid of formatting JSON --- .../Extensibility/components-form/MonacoRenderer.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/components/Extensibility/components-form/MonacoRenderer.js b/src/components/Extensibility/components-form/MonacoRenderer.js index 77678f0f5d..0dfe1072c8 100644 --- a/src/components/Extensibility/components-form/MonacoRenderer.js +++ b/src/components/Extensibility/components-form/MonacoRenderer.js @@ -1,4 +1,4 @@ -import React, { useCallback } from 'react'; +import { useCallback } from 'react'; import jsyaml from 'js-yaml'; import { Editor } from 'shared/components/MonacoEditorESM/Editor'; @@ -18,9 +18,7 @@ function getValue(storeKeys, resource) { } function formatValue(value, language) { - if (language === 'json') { - return JSON.stringify(value, null, 2); - } else if (language === 'yaml') { + if (language === 'yaml') { return typeof value === 'undefined' ? '' : jsyaml.dump(value); } else { return value; @@ -60,11 +58,7 @@ export function MonacoRenderer({ const handleChange = useCallback( value => { let parsedValue = value; - if (language === 'json') { - try { - parsedValue = JSON.parse(value); - } catch (e) {} - } else if (language === 'yaml') { + if (language === 'yaml') { try { parsedValue = jsyaml.load(value); } catch (e) {}