/**
 * The harness for the actual console and filters.
 */
import React, { Component } from "react";
import LogLevelFilters from "./LogLevelFilters";
import LogList from "./LogList";
import LoggerSearchBox from "../LoggerSearchBox";
import LoggerStore from "../../../../stores/LoggerStore";

interface IProps {}
interface IState {
	showSearchBox: boolean;
}
class RightPanel extends Component<IProps, IState> {
	constructor(props: IProps = {}) {
		super(props);
		this.state = {
			showSearchBox: LoggerStore.getShowSearchBox(),
		};
		this.setShowSearchBox = this.setShowSearchBox.bind(this);
	}

	componentDidMount() {
		LoggerStore.addListener("showSearchBoxChange", this.setShowSearchBox);
	}

	componentWillUnmount() {
		LoggerStore.removeListener("showSearchBoxChange", this.setShowSearchBox);
	}

	setShowSearchBox() {
		this.setState({
			showSearchBox: LoggerStore.getShowSearchBox(),
		});
	}

	render() {
		return (
			<div className="right-panel">
				<LogLevelFilters />
				<LogList />
				<LoggerSearchBox show={this.state.showSearchBox} />
			</div>
		);
	}
}

export default RightPanel;
