diff --git a/frontend/src/pages/projects/screens/spawner/connections/ConnectionsFormSection.tsx b/frontend/src/pages/projects/screens/spawner/connections/ConnectionsFormSection.tsx index 990ee0790b..4037f18eeb 100644 --- a/frontend/src/pages/projects/screens/spawner/connections/ConnectionsFormSection.tsx +++ b/frontend/src/pages/projects/screens/spawner/connections/ConnectionsFormSection.tsx @@ -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'; @@ -264,12 +265,23 @@ export const ConnectionsFormSection: React.FC = ({ 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) => + c.metadata.name === response.metadata.name ? response : c, + ), + ); + } + return response; + } + const response = await createSecret(connection); + if (isConnection(response)) { + setSelectedConnections([...selectedConnections, response]); } - setSelectedConnections([...selectedConnections, connection]); - return createSecret(connection); + return response; }} isEdit={manageConnectionModal.isEdit} />