import React, { Component } from "react"; import { Row, Col, ListView, Icon } from "patternfly-react"; import { Link } from "react-router-dom"; import PlaybookArgs from "./PlaybookArgs"; export default class Playbook extends Component { constructor(props) { super(props); this.state = { expanded: false, selection: null }; } _toggleExpanded = selection => { this.setState(prevState => { if (selection === prevState.selection) { return { expanded: !prevState.expanded }; } else { return { expanded: true, selection }; } }); }; render() { const { playbook } = this.props; const { expanded, selection } = this.state; const LeftIcon = playbook.completed ? ( ) : ( ); return ( } leftContent={LeftIcon} additionalInfo={[ this._toggleExpanded("args")} > Arguments , this._toggleExpanded("hosts")} > {playbook.hosts.length} Hosts , this._toggleExpanded("files")} > {playbook.files.length} Files ]} actions={ {Math.round(playbook.duration)} sec } heading={ playbook.name ? playbook.name : playbook.file.path.split("/").slice(-1)[0] } stacked={false} compoundExpand compoundExpanded={expanded} onCloseCompoundExpand={() => this.setState({ expanded: false })} > {selection === "args" ? ( ) : ( selection )} ); } }