mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-04 10:41:14 +00:00
- 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.
30 lines
1.1 KiB
JavaScript
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>
|
|
);
|
|
}
|