Skip to content

Commit

Permalink
Add DetailDrawer support.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinkambic committed May 23, 2018
1 parent c288084 commit 522a6b9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,26 @@ import {
EuiFlexGroup
} from '@elastic/eui';

function clickableStatementName(name) {
function clickableStatementName(name, onVertexSelected) {
return (
<EuiFlexItem
grow={false}
>
<EuiButtonEmpty
color="text"
size="xs"
onClick={onVertexSelected}
>
<span className="cv-ifStatement__title">{name}</span>
</EuiButtonEmpty>
</EuiFlexItem>
);
}

function ifStatement(statement) {
function ifStatement(statement, onVertexSelected) {
const { condition } = statement;
return [
clickableStatementName('if'),
clickableStatementName('if', onVertexSelected),
(
<EuiFlexItem grow={false}>
<EuiCodeBlock
Expand Down Expand Up @@ -78,12 +79,17 @@ export class CollapsibleStatement extends React.PureComponent {
getStatementBody() {
const {
isIf,
statement
statement,
onShowVertexDetails
} = this.props;

const { vertex } = statement;

const showVertexDetailsClicked = () => { onShowVertexDetails(vertex); };

return isIf ?
ifStatement(statement)
: clickableStatementName('else');
ifStatement(statement, showVertexDetailsClicked)
: clickableStatementName('else', showVertexDetailsClicked);
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,23 @@ export class ConfigViewer extends React.Component {
iconType="logstashInput"
headingText="Inputs"
elements={inputs}
onShowVertexDetails={this.onShowVertexDetails}
detailVertex={this.state.detailDrawer.vertex}
/>
<Queue queue={queue} />
<StatementSection
iconType="logstashFilter"
headingText="Filters"
elements={filters}
onShowVertexDetails={this.onShowVertexDetails}
detailVertex={this.state.detailDrawer.vertex}
/>
<StatementSection
iconType="logstashOutput"
headingText="Outputs"
elements={outputs}
onShowVertexDetails={this.onShowVertexDetails}
detailVertex={this.state.detailDrawer.vertex}
/>
{ this.renderDetailDrawer() }
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ import {
// }
// };

function pluginStatement(statement) {
function pluginStatement(statement, onShowVertexDetails) {
const {
hasExplicitId,
id,
name,
vertex,
} = statement;
return (
<div className="cv-statement">
Expand All @@ -116,6 +117,7 @@ function pluginStatement(statement) {
flush="left"
size="xs"
className="cv-statement__name"
onClick={() => { onShowVertexDetails(vertex); }}
>
<span>{name}</span>
</EuiButtonEmpty>
Expand Down Expand Up @@ -148,14 +150,16 @@ export class Statement extends React.PureComponent
collapse,
element,
expand,
isCollapsed
isCollapsed,
onShowVertexDetails
} = this.props;
const { id } = element;

const isIf = element instanceof IfElement;

console.log(onShowVertexDetails);
return statement instanceof PluginStatement
? pluginStatement(statement)
? pluginStatement(statement, onShowVertexDetails)
:
(
<CollapsibleStatement
Expand All @@ -165,6 +169,7 @@ export class Statement extends React.PureComponent
isIf={isIf}
isCollapsed={isCollapsed}
id={id}
onShowVertexDetails={onShowVertexDetails}
/>
);
}
Expand All @@ -176,6 +181,7 @@ export class Statement extends React.PureComponent
statement
} = this.props.element;

console.log(this.props);
const spacers = this.getNestingSpacers(depth);

const statementComponent = this.getStatement(statement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ import { Statement } from './statement';
// );
// }

export function StatementSection({ iconType, headingText, elements }) {
export function StatementSection({ iconType, headingText, elements, onShowVertexDetails }) {
return (
<div className="cv-statementList">
<StatementListHeading
iconType={iconType}
title={headingText}
/>
<StatementList elements={elements} />
<StatementList
elements={elements}
onShowVertexDetails={onShowVertexDetails}
/>
</div>
);
}
Expand Down Expand Up @@ -138,6 +141,7 @@ class StatementList extends React.PureComponent {

getStatement(element) {
const { id, parentId } = element;
const { onShowVertexDetails } = this.props;

return this.state.collapsedIds.has(parentId) || this.state.collapsedChildIds.has(parentId) ?
null
Expand All @@ -149,6 +153,7 @@ class StatementList extends React.PureComponent {
collapse={this.collapse}
expand={this.expand}
isCollapsed={this.elementIsCollapsed(id)}
onShowVertexDetails={onShowVertexDetails}
/>
);
}
Expand Down

0 comments on commit 522a6b9

Please sign in to comment.