Commit 8a906e29 authored by Joel's avatar Joel

fix: http nodes update error and support json

parent 9839b5cb
...@@ -15,6 +15,12 @@ type Props = { ...@@ -15,6 +15,12 @@ type Props = {
readOnly?: boolean readOnly?: boolean
} }
const languageMap = {
[CodeLanguage.javascript]: 'javascript',
[CodeLanguage.python3]: 'python',
[CodeLanguage.json]: 'json',
}
const CodeEditor: FC<Props> = ({ const CodeEditor: FC<Props> = ({
value, value,
onChange, onChange,
...@@ -70,7 +76,8 @@ const CodeEditor: FC<Props> = ({ ...@@ -70,7 +76,8 @@ const CodeEditor: FC<Props> = ({
{/* https://www.npmjs.com/package/@monaco-editor/react */} {/* https://www.npmjs.com/package/@monaco-editor/react */}
<Editor <Editor
className='h-full' className='h-full'
defaultLanguage={language === CodeLanguage.javascript ? 'javascript' : 'python'} // language={language === CodeLanguage.javascript ? 'javascript' : 'python'}
language={languageMap[language] || 'javascript'}
theme={isFocus ? 'focus-theme' : 'blur-theme'} theme={isFocus ? 'focus-theme' : 'blur-theme'}
value={value} value={value}
onChange={handleEditorChange} onChange={handleEditorChange}
......
...@@ -57,7 +57,6 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({ ...@@ -57,7 +57,6 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
/> />
</Field> </Field>
<Split /> <Split />
{inputs.code_language}
<CodeEditor <CodeEditor
readOnly={readOnly} readOnly={readOnly}
title={ title={
......
...@@ -3,6 +3,7 @@ import type { CommonNodeType, Variable } from '@/app/components/workflow/types' ...@@ -3,6 +3,7 @@ import type { CommonNodeType, Variable } from '@/app/components/workflow/types'
export enum CodeLanguage { export enum CodeLanguage {
python3 = 'python3', python3 = 'python3',
javascript = 'javascript', javascript = 'javascript',
json = 'json',
} }
export type OutputVar = { export type OutputVar = {
......
...@@ -73,7 +73,7 @@ const EditBody: FC<Props> = ({ ...@@ -73,7 +73,7 @@ const EditBody: FC<Props> = ({
}) })
onChange(newBody) onChange(newBody)
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [body, isCurrentKeyValue]) }, [isCurrentKeyValue])
const handleBodyValueChange = useCallback((value: string) => { const handleBodyValueChange = useCallback((value: string) => {
const newBody = produce(payload, (draft: Body) => { const newBody = produce(payload, (draft: Body) => {
...@@ -127,7 +127,7 @@ const EditBody: FC<Props> = ({ ...@@ -127,7 +127,7 @@ const EditBody: FC<Props> = ({
readOnly={readonly} readOnly={readonly}
title={<div className='uppercase'>JSON</div>} title={<div className='uppercase'>JSON</div>}
value={payload.data} onChange={handleBodyValueChange} value={payload.data} onChange={handleBodyValueChange}
language={CodeLanguage.javascript} language={CodeLanguage.json}
/> />
)} )}
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment