Skip to content

Commit

Permalink
Merge pull request #2087 from weaveworks/1982-control-indicator
Browse files Browse the repository at this point in the history
Add control status icon to Terminal header
  • Loading branch information
jpellizzari authored Dec 20, 2016
2 parents 293c87f + 2b83ebd commit 32bb7c3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
8 changes: 5 additions & 3 deletions client/app/scripts/actions/app-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ export function doControl(nodeId, control) {
return (dispatch) => {
dispatch({
type: ActionTypes.DO_CONTROL,
nodeId
nodeId,
control
});
doControlRequest(nodeId, control, dispatch);
};
Expand Down Expand Up @@ -591,7 +592,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()
Expand All @@ -611,7 +612,8 @@ export function receiveControlPipe(pipeId, nodeId, rawTty, resizeTtyControl) {
nodeId,
pipeId,
rawTty,
resizeTtyControl
resizeTtyControl,
control
});

updateRoute(getState);
Expand Down
19 changes: 17 additions & 2 deletions client/app/scripts/components/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ class Terminal extends React.Component {
title="Close" className="terminal-header-tools-item-icon fa fa-close"
onClick={this.handleCloseClick} />
</div>
{this.getControlStatusIcon()}
<span className="terminal-header-title">{this.getTitle()}</span>
</div>
);
Expand Down Expand Up @@ -386,12 +387,26 @@ class Terminal extends React.Component {
</div>
);
}
getControlStatusIcon() {
const icon = this.props.controlStatus && this.props.controlStatus.get('control').icon;
return (
<span
style={{marginRight: '8px', width: '14px'}}
className={classNames('fa', {[icon]: icon})}
/>
);
}
}

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);
1 change: 1 addition & 0 deletions client/app/scripts/reducers/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ export function rootReducer(state = initialState, action) {
nodeId: action.nodeId,
raw: action.rawTty,
resizeTtyControl: action.resizeTtyControl,
control: action.control
}));
}

Expand Down
4 changes: 3 additions & 1 deletion client/app/scripts/utils/web-api-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 32bb7c3

Please sign in to comment.