Skip to content

Commit

Permalink
fix(designer): Fix code editor when non-string gets uploaded to custo…
Browse files Browse the repository at this point in the history
…m code file (#4587)

* remove outputs if not included

* bug

* prevent crash if an invalid file is sent
  • Loading branch information
Eric-B-Wu authored Apr 10, 2024
1 parent 57869ac commit 620f685
Showing 1 changed file with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,27 @@ export const TokenField = ({
/>
);
case constants.PARAMETER.EDITOR.CODE:
return (() => {
const customCodeEditor = isCustomCode(editor, editorOptions?.language);
const initialValue =
editorOptions?.language && customCodeEditor ? [createLiteralValueSegment(editorViewModel?.customCodeData?.fileData)] : value;
const language = editorOptions.language ?? EditorLanguage.javascript;
const customCodeEditor = isCustomCode(editor, editorOptions?.language);
let customCodeData = editorViewModel?.customCodeData?.fileData ?? '';
if (typeof customCodeData !== 'string') {
customCodeData = JSON.stringify(customCodeData);
}
const initialValue = editorOptions?.language && customCodeEditor ? [createLiteralValueSegment(customCodeData)] : value;
const language = editorOptions.language ?? EditorLanguage.javascript;

return (
<CodeEditor
labelId={labelId}
initialValue={initialValue}
getTokenPicker={getTokenPicker}
language={language}
onChange={onValueChange}
readonly={readOnly}
placeholder={placeholder}
customCodeEditor={customCodeEditor}
nodeTitle={nodeTitle}
/>
);
})();
return (
<CodeEditor
labelId={labelId}
initialValue={initialValue}
getTokenPicker={getTokenPicker}
language={language}
onChange={onValueChange}
readonly={readOnly}
placeholder={placeholder}
customCodeEditor={customCodeEditor}
nodeTitle={nodeTitle}
/>
);

case constants.PARAMETER.EDITOR.COMBOBOX:
return (
Expand Down

0 comments on commit 620f685

Please sign in to comment.