Skip to content

Commit

Permalink
fix: edit Nodejs function dependencies in JSON format (#2864)
Browse files Browse the repository at this point in the history
* fix deps formatting

* get rid of formatting JSON
  • Loading branch information
OliwiaGowor authored Mar 28, 2024
1 parent 39c2c06 commit 41db6a0
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/components/Extensibility/components-form/MonacoRenderer.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -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) {}
Expand Down

0 comments on commit 41db6a0

Please sign in to comment.