diff --git a/frontend/app/modals/conntypeahead.tsx b/frontend/app/modals/conntypeahead.tsx index 8be3836b2..5a9831d06 100644 --- a/frontend/app/modals/conntypeahead.tsx +++ b/frontend/app/modals/conntypeahead.tsx @@ -233,6 +233,31 @@ function getS3Suggestions( return s3Suggestions; } +function getDisconnectItem( + connection: string, + connStatusMap: Map +): SuggestionConnectionItem | null { + if (!connection) { + return null; + } + const connStatus = connStatusMap.get(connection); + if (!connStatus || connStatus.status != "connected") { + return null; + } + const disconnectSuggestionItem: SuggestionConnectionItem = { + status: "connected", + icon: "xmark", + iconColor: "var(--grey-text-color)", + label: `Disconnect ${connStatus.connection}`, + value: "", + onSelect: async (_: string) => { + const prtn = RpcApi.ConnDisconnectCommand(TabRpcClient, connection, { timeout: 60000 }); + prtn.catch((e) => console.log("error disconnecting", connStatus.connection, e)); + }, + }; + return disconnectSuggestionItem; +} + function getConnectionsEditItem( changeConnModalAtom: jotai.PrimitiveAtom, connSelected: string @@ -420,6 +445,7 @@ const ChangeConnectionBlockModal = React.memo( filterOutNowsh ); const connectionsEditItem = getConnectionsEditItem(changeConnModalAtom, connSelected); + const disconnectItem = getDisconnectItem(connection, connStatusMap); const newConnectionSuggestionItem = getNewConnectionSuggestionItem( connSelected, localName, @@ -435,6 +461,7 @@ const ChangeConnectionBlockModal = React.memo( ...(localSuggestions ? [localSuggestions] : []), ...(remoteSuggestions ? [remoteSuggestions] : []), ...(s3Suggestions ? [s3Suggestions] : []), + ...(disconnectItem ? [disconnectItem] : []), ...(connectionsEditItem ? [connectionsEditItem] : []), ...(newConnectionSuggestionItem ? [newConnectionSuggestionItem] : []), ];