mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
62 lines
1.4 KiB
TypeScript
62 lines
1.4 KiB
TypeScript
import "./terminal-tab.scss";
|
|
|
|
import React from "react";
|
|
import { observer } from "mobx-react";
|
|
import { autobind, cssNames } from "../../utils";
|
|
import { DockTab, DockTabProps } from "./dock-tab";
|
|
import { Icon } from "../icon";
|
|
import { terminalStore } from "./terminal.store";
|
|
import { dockStore } from "./dock.store";
|
|
import { reaction } from "mobx";
|
|
import { SvgIcon } from "@material-ui/core";
|
|
import { Terminal } from "../../icons";
|
|
|
|
interface Props extends DockTabProps {
|
|
}
|
|
|
|
@observer
|
|
export class TerminalTab extends React.Component<Props> {
|
|
componentDidMount() {
|
|
reaction(() => this.isDisconnected === true, () => {
|
|
dockStore.closeTab(this.tabId);
|
|
});
|
|
}
|
|
|
|
get tabId() {
|
|
return this.props.value.id;
|
|
}
|
|
|
|
get isDisconnected() {
|
|
return terminalStore.isDisconnected(this.tabId);
|
|
}
|
|
|
|
@autobind()
|
|
reconnect() {
|
|
terminalStore.reconnect(this.tabId);
|
|
}
|
|
|
|
render() {
|
|
const tabIcon = <SvgIcon component={Terminal}/>;
|
|
const className = cssNames("TerminalTab", this.props.className, {
|
|
disconnected: this.isDisconnected,
|
|
});
|
|
|
|
return (
|
|
<DockTab
|
|
{...this.props}
|
|
className={className}
|
|
icon={tabIcon}
|
|
moreActions={this.isDisconnected && (
|
|
<Icon
|
|
small
|
|
material="refresh"
|
|
className="restart-icon"
|
|
tooltip="Restart session"
|
|
onClick={this.reconnect}
|
|
/>
|
|
)}
|
|
/>
|
|
);
|
|
}
|
|
}
|