Skip to content

Commit

Permalink
Check and use response of connection saving
Browse files Browse the repository at this point in the history
  • Loading branch information
emilys314 committed Nov 12, 2024
1 parent e85d7a1 commit 43045d5
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Connection, ConnectionTypeConfigMapObj } from '~/concepts/connectionTyp
import {
filterEnabledConnectionTypes,
getConnectionTypeDisplayName,
isConnection,
} from '~/concepts/connectionTypes/utils';
import { useWatchConnectionTypes } from '~/utilities/useWatchConnectionTypes';
import { useNotebooksStates } from '~/pages/projects/notebook/useNotebooksStates';
Expand Down Expand Up @@ -264,12 +265,23 @@ export const ConnectionsFormSection: React.FC<Props> = ({
refreshProjectConnections();
}
}}
onSubmit={(connection: Connection) => {
onSubmit={async (connection: Connection) => {
if (manageConnectionModal.isEdit) {
return replaceSecret(connection);
const response = await replaceSecret(connection);
if (isConnection(response)) {
setSelectedConnections(
selectedConnections.map((c) =>

Check warning on line 273 in frontend/src/pages/projects/screens/spawner/connections/ConnectionsFormSection.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/pages/projects/screens/spawner/connections/ConnectionsFormSection.tsx#L271-L273

Added lines #L271 - L273 were not covered by tests
c.metadata.name === response.metadata.name ? response : c,
),
);
}
return response;

Check warning on line 278 in frontend/src/pages/projects/screens/spawner/connections/ConnectionsFormSection.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/pages/projects/screens/spawner/connections/ConnectionsFormSection.tsx#L278

Added line #L278 was not covered by tests
}
const response = await createSecret(connection);
if (isConnection(response)) {
setSelectedConnections([...selectedConnections, response]);

Check warning on line 282 in frontend/src/pages/projects/screens/spawner/connections/ConnectionsFormSection.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/pages/projects/screens/spawner/connections/ConnectionsFormSection.tsx#L281-L282

Added lines #L281 - L282 were not covered by tests
}
setSelectedConnections([...selectedConnections, connection]);
return createSecret(connection);
return response;

Check warning on line 284 in frontend/src/pages/projects/screens/spawner/connections/ConnectionsFormSection.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/pages/projects/screens/spawner/connections/ConnectionsFormSection.tsx#L284

Added line #L284 was not covered by tests
}}
isEdit={manageConnectionModal.isEdit}
/>
Expand Down

0 comments on commit 43045d5

Please sign in to comment.