Close terminal pipe, when closing the pod panel

Moving `deletePipe()` in `componentWillUnmount()` ensures the pipe is deleted when:
1. the terminal is closed
2. the terminal is closed when closing the pod panel

The pipe still does not get deleted when popping out the terminal.
This commit is contained in:
Roberto Bruggemann
2018-01-31 15:07:55 +00:00
parent 8c627b50bd
commit 520ca3a570
2 changed files with 9 additions and 6 deletions
+1 -4
View File
@@ -234,15 +234,12 @@ export function clickCloseDetails(nodeId) {
};
}
export function clickCloseTerminal(pipeId, closePipe) {
export function clickCloseTerminal(pipeId) {
return (dispatch, getState) => {
dispatch({
type: ActionTypes.CLICK_CLOSE_TERMINAL,
pipeId
});
if (closePipe) {
deletePipe(pipeId, dispatch);
}
updateRoute(getState);
};
}
+8 -2
View File
@@ -9,7 +9,7 @@ import Term from 'xterm';
import { clickCloseTerminal } from '../actions/app-actions';
import { getNeutralColor } from '../utils/color-utils';
import { setDocumentTitle } from '../utils/title-utils';
import { getPipeStatus, doResizeTty, getWebsocketUrl, basePath } from '../utils/web-api-utils';
import { getPipeStatus, deletePipe, doResizeTty, getWebsocketUrl, basePath } from '../utils/web-api-utils';
const log = debug('scope:terminal');
@@ -86,6 +86,7 @@ class Terminal extends React.Component {
this.state = {
connected: false,
detached: false,
rows: DEFAULT_ROWS,
cols: DEFAULT_COLS,
characterWidth: 0,
@@ -213,6 +214,10 @@ class Terminal extends React.Component {
this.term = null;
}
if (!this.state.detached) {
deletePipe(this.getPipeId());
}
if (this.socket) {
log('close socket');
this.socket.close();
@@ -235,13 +240,14 @@ class Terminal extends React.Component {
handleCloseClick(ev) {
ev.preventDefault();
this.props.dispatch(clickCloseTerminal(this.getPipeId(), true));
this.props.dispatch(clickCloseTerminal(this.getPipeId()));
}
handlePopoutTerminal(ev) {
ev.preventDefault();
const paramString = JSON.stringify(this.props);
this.props.dispatch(clickCloseTerminal(this.getPipeId()));
this.setState({detached: true});
const bcr = this.node.getBoundingClientRect();
const minWidth = (this.state.characterWidth * 80) + (8 * 2);