import React, { Component, PropTypes } from 'react'; import radium from 'radium'; import Button from '../../buttons/Button'; import { availability, columnsToRender, displayTypeForDataType, numAdditionalColumns, shouldShowAllColumns, } from './helpers'; import { osqueryTables } from '../../../utilities/osquery_tables'; import SecondarySidePanelContainer from '../SecondarySidePanelContainer'; const classBlock = 'query-side-panel'; class QuerySidePanel extends Component { static propTypes = { onOsqueryTableSelect: PropTypes.func, onTextEditorInputChange: PropTypes.func, selectedOsqueryTable: PropTypes.object, }; componentWillMount () { const { selectedOsqueryTable } = this.props; const showAllColumns = shouldShowAllColumns(selectedOsqueryTable); this.setState({ showAllColumns }); } componentWillReceiveProps (nextProps) { const { selectedOsqueryTable } = nextProps; if (this.props.selectedOsqueryTable !== selectedOsqueryTable) { const showAllColumns = shouldShowAllColumns(selectedOsqueryTable); this.setState({ showAllColumns }); } return false; } onSelectTable = ({ target }) => { const { onOsqueryTableSelect } = this.props; const { value: tableName } = target; onOsqueryTableSelect(tableName); return false; } onShowAllColumns = () => { this.setState({ showAllColumns: true }); } onSuggestedQueryClick = (query) => { return (evt) => { evt.preventDefault(); const { onTextEditorInputChange } = this.props; return onTextEditorInputChange(query); }; }; renderColumns = () => { const { selectedOsqueryTable } = this.props; const { showAllColumns } = this.state; const columns = columnsToRender(selectedOsqueryTable, showAllColumns); return columns.map(column => { return (
Choose a Table
{renderTableSelect()}{description}
OS Availability
{availability(platform)}
Columns
{renderColumns()} {renderMoreColumns()}Joins
Suggested Queries
{renderSuggestedQueries()}