Skip to content

Commit

Permalink
console: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Feb 18, 2025
1 parent 8216605 commit 5910457
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 9 additions & 5 deletions webapps/console/components/ConfigObjectEditor/ConfigEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,21 @@ const EditorComponent: React.FC<EditorComponentProps> = props => {
(typeof testConnectionEnabled === "undefined" || testConnectionEnabled(formData || object) === true)
) {
setTesting(true);
const testRes = testResult || (await onTest(formState?.formData || object));
setTesting(false);
if (!testRes.ok) {
let testRes: any;
try {
testRes = testResult || (await onTest(formState?.formData || object));
} finally {
setTesting(false);
}
if (!testRes?.ok) {
modal.confirm({
title: "Check failed",
content: testRes.error,
content: testRes?.error,
okText: "Save anyway",
okType: "danger",
cancelText: "Cancel",
onOk: () => {
withLoading(() => onSave({ ...formData, testConnectionError: testRes.error }))();
withLoading(() => onSave({ ...formData, testConnectionError: testRes?.error }))();
},
});
return;
Expand Down
5 changes: 5 additions & 0 deletions webapps/console/components/ServiceEditor/ServiceEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const ServiceEditor: React.FC<ServiceEditorProps> = props => {
const [testResult, setTestResult] = useState<any>(undefined);
const [showErrors, setShowErrors] = useState<boolean>(false);
const [loading, setLoading] = useState<boolean>(false);
const [testing, setTesting] = useState<boolean>(false);
const [nangoLoading, setNangoLoading] = useState<boolean>(false);
const [nangoError, setNangoError] = useState<string | undefined>(undefined);
const [loadingSpecs, setLoadingSpecs] = useState<boolean>(true);
Expand Down Expand Up @@ -192,7 +193,9 @@ export const ServiceEditor: React.FC<ServiceEditorProps> = props => {
if (!validate()) {
return;
}
setTesting(true);
const testRes = testResult || (await onTest!({ ...obj, credentials: credentials }));
setTesting(false);
if (!testRes.ok) {
modal.confirm({
title: "Connection test failed",
Expand All @@ -212,6 +215,7 @@ export const ServiceEditor: React.FC<ServiceEditorProps> = props => {
} catch (error) {
feedbackError(`Can't save service`, { error });
} finally {
setTesting(false);
setLoading(false);
}
}, [obj, credentials, workspace.id, props.isNew, push, validate, testResult, onTest, modal]);
Expand Down Expand Up @@ -357,6 +361,7 @@ export const ServiceEditor: React.FC<ServiceEditorProps> = props => {
<EditorButtons
isNew={isNew}
loading={loading}
testing={testing}
onDelete={onDelete}
onCancel={() => onCancel(isTouched)}
onSave={save}
Expand Down

0 comments on commit 5910457

Please sign in to comment.