From 4066b69c7d494f80c63ec11814a94707b9b1ee93 Mon Sep 17 00:00:00 2001 From: Emily Samoylov <93456589+emilys314@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:17:06 -0500 Subject: [PATCH] Check and use response of connection saving (#3462) --- .../connections/ConnectionsFormSection.tsx | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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} />