|
| 1 | +import React from 'react'; |
| 2 | +import RequestTypesChart from '../charts/request-type-chart.jsx'; |
| 3 | +import ResponseCodesChart from '../charts/response-code-chart.jsx'; |
| 4 | +import SpeedChart from '../charts/speed-chart.jsx'; |
| 5 | +import ProcessesChart from '../charts/processes-chart.jsx'; |
| 6 | +import TemperatureChart from '../charts/temperature-chart.jsx'; |
| 7 | +import LatencyChart from '../charts/latency-chart.jsx'; |
| 8 | +import MemoryChart from '../charts/memory-chart.jsx'; |
| 9 | + |
| 10 | +const Modal = (props) => { |
| 11 | + // Destructuring props to make linter happy |
| 12 | + const { |
| 13 | + modalChart, service, toggleModalDisplay, chartTitle, |
| 14 | + } = props; |
| 15 | + // Dictionary used to render proper data chart within Modal component upon rendering |
| 16 | + const dict = { |
| 17 | + request: <RequestTypesChart service={service} />, |
| 18 | + response: <ResponseCodesChart service={service} />, |
| 19 | + speed: <SpeedChart service={service} />, |
| 20 | + processes: <ProcessesChart service={service} />, |
| 21 | + latency: <LatencyChart service={service} />, |
| 22 | + temperature: <TemperatureChart service={service} />, |
| 23 | + memory: <MemoryChart service={service} />, |
| 24 | + }; |
| 25 | + |
| 26 | + // event.stopPropogation allows the user to interact with the chart as opposed to a click on the |
| 27 | + // chart bubbling out and closing the Modal. |
| 28 | + return ( |
| 29 | + <div id="modalWindow" onClick={() => toggleModalDisplay(!toggleModalDisplay)}> |
| 30 | + <div id="modalContent" onClick={(event) => event.stopPropagation()}> |
| 31 | + <h3 id="chartTitle">{`${service} - ${chartTitle}`}</h3> |
| 32 | + <button id="modalCloseButton" onClick={() => toggleModalDisplay(!toggleModalDisplay)}>×</button> |
| 33 | + {dict[modalChart]} |
| 34 | + </div> |
| 35 | + </div> |
| 36 | + ); |
| 37 | +}; |
| 38 | + |
| 39 | +export default Modal; |
0 commit comments