Skip to content

Commit

Permalink
fix(frontend): prevent json editor setting undefined value
Browse files Browse the repository at this point in the history
  • Loading branch information
634750802 committed Aug 6, 2024
1 parent fc75861 commit 1f2ddb0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export function CreateEmbeddingModelForm ({ transitioning, onCreated }: { transi
...form.getValues(),
model: provider.default_embedding_model,
credentials: provider.credentials_type === 'dict' ? undefined : '',
config: '{}'
});
} else {
const { name } = form.getValues();
Expand All @@ -74,6 +75,7 @@ export function CreateEmbeddingModelForm ({ transitioning, onCreated }: { transi
provider: '',
credentials: '',
model: '',
config: '{}'
});
}
}, [provider]);
Expand Down
5 changes: 3 additions & 2 deletions frontend/app/src/components/form/widgets/CodeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ export const CodeInput = forwardRef<any, CodeInputProps>(({

useEffect(() => {
if (editor) {
if (value !== editor.getValue()) {
editor.setValue(value);
const rValue = value || '';
if (rValue !== editor.getValue()) {
editor.setValue(rValue);
}
}
}, [editor, value]);
Expand Down
4 changes: 3 additions & 1 deletion frontend/app/src/components/graph/components/JsonEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export const JsonEditor = forwardRef<monaco.editor.IStandaloneCodeEditor | undef

useEffect(() => {
if (editor) {
editor.setValue(defaultValue);
if (defaultValue != null) {
editor.setValue(defaultValue);
}
}
}, [editor, defaultValue]);

Expand Down

0 comments on commit 1f2ddb0

Please sign in to comment.