forked from p34709852/monkey
Improved the Events modal
This commit is contained in:
parent
68383f069b
commit
4d24d8432e
|
@ -104,6 +104,7 @@
|
|||
"react-tooltip-lite": "^1.9.1",
|
||||
"redux": "^4.0.0",
|
||||
"sass-loader": "^7.1.0",
|
||||
"sha3": "^2.0.0"
|
||||
"sha3": "^2.0.0",
|
||||
"pluralize": "latest"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,13 +32,8 @@ export default class EventsButton extends Component {
|
|||
}
|
||||
|
||||
createEventsAmountBadge() {
|
||||
let eventsAmountBadge;
|
||||
if (this.props.events.length > 9) {
|
||||
eventsAmountBadge = <Badge>9+</Badge>;
|
||||
} else {
|
||||
eventsAmountBadge = <Badge>{this.props.events.length}</Badge>;
|
||||
}
|
||||
return eventsAmountBadge;
|
||||
const eventsAmountBadgeContent = this.props.events.length > 9 ? "9+" : this.props.events.length;
|
||||
return <Badge>{eventsAmountBadgeContent}</Badge>;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import React, {Component} from "react";
|
||||
import {Modal} from "react-bootstrap";
|
||||
import {Badge, Modal} from "react-bootstrap";
|
||||
import EventsTimeline from "./EventsTimeline";
|
||||
import * as PropTypes from "prop-types";
|
||||
import ExportEventsButton from "./ExportEventsButton";
|
||||
import saveJsonToFile from "../../utils/SaveJsonToFile";
|
||||
import EventsModalButtons from "./EventsModalButtons";
|
||||
import Pluralize from 'pluralize'
|
||||
import {statusToLabelType} from "./StatusLabel";
|
||||
|
||||
export default class EventsModal extends Component {
|
||||
constructor(props) {
|
||||
|
@ -15,28 +17,31 @@ export default class EventsModal extends Component {
|
|||
<div>
|
||||
<Modal show={this.props.showEvents} onHide={() => this.props.hideCallback()}>
|
||||
<Modal.Body>
|
||||
<h2>
|
||||
<h3>
|
||||
<div className="text-center">Events</div>
|
||||
</h2>
|
||||
|
||||
</h3>
|
||||
<hr />
|
||||
<p>
|
||||
There {Pluralize('is', this.props.events.length)} {<div className={"label label-primary"}>{this.props.events.length}</div>} {Pluralize('event', this.props.events.length)} associated with this finding.
|
||||
</p>
|
||||
{this.props.events.length > 5 ? this.renderButtons() : null}
|
||||
<EventsTimeline events={this.props.events}/>
|
||||
|
||||
<div className="text-center">
|
||||
<button type="button" className="btn btn-success btn-lg" style={{margin: '5px'}}
|
||||
onClick={() => this.props.hideCallback()}>
|
||||
Close
|
||||
</button>
|
||||
<ExportEventsButton onClick={() => {
|
||||
const dataToSave = this.props.events;
|
||||
const filename = this.props.exportFilename;
|
||||
saveJsonToFile(dataToSave, filename);
|
||||
}}/>
|
||||
</div>
|
||||
{this.renderButtons()}
|
||||
</Modal.Body>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
renderButtons() {
|
||||
return <EventsModalButtons
|
||||
onClickClose={() => this.props.hideCallback()}
|
||||
onClickExport={() => {
|
||||
const dataToSave = this.props.events;
|
||||
const filename = this.props.exportFilename;
|
||||
saveJsonToFile(dataToSave, filename);
|
||||
}}/>;
|
||||
}
|
||||
}
|
||||
|
||||
EventsModal.propTypes = {
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import React, {Component} from "react";
|
||||
import ExportEventsButton from "./ExportEventsButton";
|
||||
import * as PropTypes from "prop-types";
|
||||
|
||||
export default class EventsModalButtons extends Component {
|
||||
render() {
|
||||
return <div className="text-center">
|
||||
<button type="button" className="btn btn-success btn-lg" style={{margin: '5px'}}
|
||||
onClick={this.props.onClickClose}>
|
||||
Close
|
||||
</button>
|
||||
<ExportEventsButton onClick={this.props.onClickExport}/>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
EventsModalButtons.propTypes = {
|
||||
onClickClose: PropTypes.func,
|
||||
onClickExport: PropTypes.func
|
||||
};
|
|
@ -14,7 +14,7 @@ export default class EventsTimeline extends Component {
|
|||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Timeline>
|
||||
<Timeline style={{fontSize: '100%'}}>
|
||||
{
|
||||
this.props.events.map((event, index) => {
|
||||
const event_time = new Date(event.timestamp['$date']).toString();
|
||||
|
@ -22,7 +22,6 @@ export default class EventsTimeline extends Component {
|
|||
key={index}
|
||||
createdAt={event_time}
|
||||
title={event.title}
|
||||
|
||||
icon={<img src={eventTypeToIcon[event.event_type]} alt="icon" style={{width: '24px'}} />}>
|
||||
{event.message}
|
||||
</TimelineEvent>)
|
||||
|
|
Loading…
Reference in New Issue