Skip to content

Commit

Permalink
Check and use response of connection saving (#3462)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilys314 authored Nov 12, 2024
1 parent c575d1f commit 4066b69
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) =>
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}
/>
Expand Down

0 comments on commit 4066b69

Please sign in to comment.