mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Terminal tab auto-close fixes (#314)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
105021509c
commit
b8fd4040a1
@ -16,7 +16,7 @@ interface Props extends DockTabProps {
|
|||||||
@observer
|
@observer
|
||||||
export class TerminalTab extends React.Component<Props> {
|
export class TerminalTab extends React.Component<Props> {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
reaction(() => this.isDisconnected, () => {
|
reaction(() => this.isDisconnected === true, () => {
|
||||||
dockStore.closeTab(this.tabId)
|
dockStore.closeTab(this.tabId)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ export class ShellSession extends EventEmitter {
|
|||||||
protected kubectlBinDir: string;
|
protected kubectlBinDir: string;
|
||||||
protected helmBinDir: string;
|
protected helmBinDir: string;
|
||||||
protected preferences: ClusterPreferences;
|
protected preferences: ClusterPreferences;
|
||||||
|
protected running = false;
|
||||||
|
|
||||||
constructor(socket: WebSocket, pathToKubeconfig: string, cluster: Cluster) {
|
constructor(socket: WebSocket, pathToKubeconfig: string, cluster: Cluster) {
|
||||||
super()
|
super()
|
||||||
@ -42,6 +43,7 @@ export class ShellSession extends EventEmitter {
|
|||||||
name: "xterm-256color",
|
name: "xterm-256color",
|
||||||
rows: 30,
|
rows: 30,
|
||||||
});
|
});
|
||||||
|
this.running = true;
|
||||||
|
|
||||||
this.pipeStdout()
|
this.pipeStdout()
|
||||||
this.pipeStdin()
|
this.pipeStdin()
|
||||||
@ -137,6 +139,8 @@ export class ShellSession extends EventEmitter {
|
|||||||
protected pipeStdin() {
|
protected pipeStdin() {
|
||||||
// write websocket messages to shellProcess
|
// write websocket messages to shellProcess
|
||||||
this.websocket.on("message", function(data: string) {
|
this.websocket.on("message", function(data: string) {
|
||||||
|
if (!this.running) { return }
|
||||||
|
|
||||||
const message = Buffer.from(data.slice(1, data.length), "base64").toString()
|
const message = Buffer.from(data.slice(1, data.length), "base64").toString()
|
||||||
switch (data[0]) {
|
switch (data[0]) {
|
||||||
case "0":
|
case "0":
|
||||||
@ -160,8 +164,16 @@ export class ShellSession extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected closeWebsocketOnProcessExit() {
|
protected closeWebsocketOnProcessExit() {
|
||||||
this.shellProcess.on("exit", (_code) => {
|
this.shellProcess.on("exit", (code) => {
|
||||||
this.exit()
|
this.running = false
|
||||||
|
let timeout = 0
|
||||||
|
if (code > 0) {
|
||||||
|
this.sendResponse("Terminal will auto-close in 15 seconds ...")
|
||||||
|
timeout = 15*1000
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
this.exit()
|
||||||
|
}, timeout)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user