Skip to content

Commit c5b8937

Browse files
committed
Use test connection button
1 parent 73f984b commit c5b8937

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

llmstack/client/src/components/connections/AddConnectionModal.jsx

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function AddConnectionModal({ open, onCancelCb, onSaveCb, connection }) {
3434
);
3535
const [localConnection, setLocalConnection] = useState(connection || {});
3636
const [validationErrors, setValidationErrors] = useState([]);
37+
const [connectionActive, setConnectionActive] = useState(false);
3738

3839
const validateForm = () => {
3940
let errors = [];
@@ -105,6 +106,7 @@ function AddConnectionModal({ open, onCancelCb, onSaveCb, connection }) {
105106
enqueueSnackbar("Connection test successful", {
106107
variant: "success",
107108
});
109+
setConnectionActive(true);
108110
ws.close();
109111
onCancelCb();
110112
}
@@ -268,32 +270,37 @@ function AddConnectionModal({ open, onCancelCb, onSaveCb, connection }) {
268270
/>
269271
</DialogContent>
270272
<DialogActions>
271-
<Button
272-
onClick={testConnection({
273-
...localConnection,
274-
...{
275-
provider_slug: connectionType?.provider_slug,
276-
connection_type_slug: connectionType?.slug,
277-
},
278-
})}
279-
>
280-
Test Connection
281-
</Button>
282273
<Button onClick={handleCloseCb}>Cancel</Button>
283-
<Button
284-
onClick={() =>
285-
handleSaveCb({
274+
{!connectionActive && (
275+
<Button
276+
onClick={testConnection({
286277
...localConnection,
287278
...{
288279
provider_slug: connectionType?.provider_slug,
289280
connection_type_slug: connectionType?.slug,
290281
},
291-
})
292-
}
293-
variant="contained"
294-
>
295-
Save
296-
</Button>
282+
})}
283+
variant="contained"
284+
>
285+
Test Connection
286+
</Button>
287+
)}
288+
{connectionActive && (
289+
<Button
290+
onClick={() =>
291+
handleSaveCb({
292+
...localConnection,
293+
...{
294+
provider_slug: connectionType?.provider_slug,
295+
connection_type_slug: connectionType?.slug,
296+
},
297+
})
298+
}
299+
variant="contained"
300+
>
301+
Save
302+
</Button>
303+
)}
297304
</DialogActions>
298305
</Dialog>
299306
);

llmstack/connections/handlers/linkedin_login.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ async def activate(self, connection) -> Iterator[Union[Connection, dict]]:
5555
return
5656

5757
# Wait for login to complete and redirect to /feed/
58-
await page.wait_for_url('https://www.linkedin.com/feed/')
58+
await page.wait_for_url('https://www.linkedin.com/feed/', timeout=5000)
59+
60+
if page.url != 'https://www.linkedin.com/feed/':
61+
connection.status = ConnectionStatus.FAILED
62+
await browser.close()
63+
yield {'error': 'Login failed', 'connection': connection}
64+
return
5965

6066
# Get storage state
6167
storage_state = await context.storage_state()

0 commit comments

Comments
 (0)