From 2b83ebd74ce8bec6a31fd9a1811648ea16732afa Mon Sep 17 00:00:00 2001 From: jpellizzari Date: Mon, 14 Nov 2016 16:37:01 +0000 Subject: [PATCH] Added control status icon to Terminal header --- client/app/scripts/actions/app-actions.js | 8 +++++--- client/app/scripts/components/terminal.js | 19 +++++++++++++++++-- client/app/scripts/reducers/root.js | 1 + client/app/scripts/utils/web-api-utils.js | 4 +++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/client/app/scripts/actions/app-actions.js b/client/app/scripts/actions/app-actions.js index d248c33873..3de8ebf771 100644 --- a/client/app/scripts/actions/app-actions.js +++ b/client/app/scripts/actions/app-actions.js @@ -366,7 +366,8 @@ export function doControl(nodeId, control) { return (dispatch) => { dispatch({ type: ActionTypes.DO_CONTROL, - nodeId + nodeId, + control }); doControlRequest(nodeId, control, dispatch); }; @@ -590,7 +591,7 @@ export function receiveControlPipeFromParams(pipeId, rawTty, resizeTtyControl) { }; } -export function receiveControlPipe(pipeId, nodeId, rawTty, resizeTtyControl) { +export function receiveControlPipe(pipeId, nodeId, rawTty, resizeTtyControl, control) { return (dispatch, getState) => { const state = getState(); if (state.get('nodeDetails').last() @@ -610,7 +611,8 @@ export function receiveControlPipe(pipeId, nodeId, rawTty, resizeTtyControl) { nodeId, pipeId, rawTty, - resizeTtyControl + resizeTtyControl, + control }); updateRoute(getState); diff --git a/client/app/scripts/components/terminal.js b/client/app/scripts/components/terminal.js index af2ce51da2..3243342872 100644 --- a/client/app/scripts/components/terminal.js +++ b/client/app/scripts/components/terminal.js @@ -316,6 +316,7 @@ class Terminal extends React.Component { + {this.getControlStatusIcon()} {this.getTitle()} ); @@ -382,12 +383,26 @@ class Terminal extends React.Component { ); } + getControlStatusIcon() { + const icon = this.props.controlStatus && this.props.controlStatus.get('control').icon; + return ( + + ); + } } +function mapStateToProps(state, ownProps) { + const controlStatus = state.get('controlPipes').find((pipe) => + pipe.get('nodeId') === ownProps.pipe.get('nodeId') + ); + return { controlStatus }; +} Terminal.defaultProps = { connect: true }; - -export default connect()(Terminal); +export default connect(mapStateToProps)(Terminal); diff --git a/client/app/scripts/reducers/root.js b/client/app/scripts/reducers/root.js index 28a3fb36fa..722a354157 100644 --- a/client/app/scripts/reducers/root.js +++ b/client/app/scripts/reducers/root.js @@ -469,6 +469,7 @@ export function rootReducer(state = initialState, action) { nodeId: action.nodeId, raw: action.rawTty, resizeTtyControl: action.resizeTtyControl, + control: action.control })); } diff --git a/client/app/scripts/utils/web-api-utils.js b/client/app/scripts/utils/web-api-utils.js index 76bdad3775..3f1899c33d 100644 --- a/client/app/scripts/utils/web-api-utils.js +++ b/client/app/scripts/utils/web-api-utils.js @@ -238,7 +238,9 @@ export function doControlRequest(nodeId, control, dispatch) { res.pipe, nodeId, res.raw_tty, - resizeTtyControl)); + resizeTtyControl, + control + )); } if (res.removedNode) { dispatch(receiveControlNodeRemoved(nodeId));