mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-20 15:10:43 +00:00
cmd/tsconnect: enable web links addon in the terminal
More user friendly, and as a side-effect we handle SSH check mode better, since the URL that's output is now clickable. Fixes #5247 Signed-off-by: Mihai Parparita <mihai@tailscale.com>
This commit is contained in:
committed by
Mihai Parparita
parent
62035d6485
commit
b302742137
@@ -92,6 +92,12 @@ class App extends Component<{}, AppState> {
|
||||
}
|
||||
|
||||
handleBrowseToURL = (url: string) => {
|
||||
if (this.state.ipnState === "Running") {
|
||||
// Ignore URL requests if we're already running -- it's most likely an
|
||||
// SSH check mode trigger and we already linkify the displayed URL
|
||||
// in the terminal.
|
||||
return
|
||||
}
|
||||
this.setState({ browseToURL: url })
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Terminal } from "xterm"
|
||||
import { FitAddon } from "xterm-addon-fit"
|
||||
import { WebLinksAddon } from "xterm-addon-web-links"
|
||||
|
||||
export type SSHSessionDef = {
|
||||
username: string
|
||||
@@ -14,12 +15,17 @@ export function runSSHSession(
|
||||
) {
|
||||
const term = new Terminal({
|
||||
cursorBlink: true,
|
||||
allowProposedApi: true,
|
||||
})
|
||||
|
||||
const fitAddon = new FitAddon()
|
||||
term.loadAddon(fitAddon)
|
||||
term.open(termContainerNode)
|
||||
fitAddon.fit()
|
||||
|
||||
const webLinksAddon = new WebLinksAddon()
|
||||
term.loadAddon(webLinksAddon)
|
||||
|
||||
let onDataHook: ((data: string) => void) | undefined
|
||||
term.onData((e) => {
|
||||
onDataHook?.(e)
|
||||
|
||||
Reference in New Issue
Block a user