Files
weave-scope/client/app/scripts/components/embedded-terminal.js
Simon Howe 8c4f025fa4 Ensure we create a new terminal instance for each new pipe.
- Prevents new session from continuing in the same terminal as an old
  one.
- This is implemented using react's key behaviour at the moment: When
  the key changes, react unmounts and remounts the component and all
  term.js stuff inside of it. Could probably do this more explicitly.
2016-04-18 14:23:09 +01:00

30 lines
1.1 KiB
JavaScript

import React from 'react';
import { getNodeColor, getNodeColorDark } from '../utils/color-utils';
import Terminal from './terminal';
import { DETAILS_PANEL_WIDTH, DETAILS_PANEL_MARGINS,
DETAILS_PANEL_OFFSET } from '../constants/styles';
export default function EmeddedTerminal({pipe, details}) {
const nodeId = pipe.get('nodeId');
const node = details.get(nodeId);
const d = node && node.details;
const titleBarColor = d && getNodeColorDark(d.rank, d.label);
const statusBarColor = d && getNodeColor(d.rank, d.label);
const title = d && d.label;
const style = {
right: DETAILS_PANEL_MARGINS.right + DETAILS_PANEL_WIDTH + 10 +
(details.size * DETAILS_PANEL_OFFSET)
};
// React unmount/remounts when key changes, this is important for cleaning up
// the term.js and creating a new one for the new pipe.
return (
<div className="terminal-embedded" style={style}>
<Terminal key={pipe.get('id')} pipe={pipe} titleBarColor={titleBarColor}
statusBarColor={statusBarColor} containerMargin={style.right} title={title} />
</div>
);
}