Skip to content

Commit b505fb1

Browse files
Merge pull request #513 from k-grube/react
Add ListAlerts modal
2 parents 01b4f81 + c096c80 commit b505fb1

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

src/views/security/reports/ListAlerts.js

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
77
import { CippPage } from '../../../components'
88
import PropTypes from 'prop-types'
99
import { faRedo } from '@fortawesome/free-solid-svg-icons'
10+
import cellGetProperty from '../../../components/cipp/cellGetProperty'
11+
import { useDispatch } from 'react-redux'
12+
import { showModal } from '../../../store/features/modal'
1013

1114
const columns = [
1215
{
@@ -35,11 +38,6 @@ const columns = [
3538
selector: (row) => row['Status'],
3639
sortable: true,
3740
},
38-
{
39-
name: 'RawResult',
40-
selector: (row) => row['RawResult'],
41-
sortable: true,
42-
},
4341
]
4442

4543
const AlertBox = ({ value, title, fetching }) => {
@@ -60,6 +58,7 @@ AlertBox.propTypes = {
6058
}
6159

6260
const ListAlerts = () => {
61+
const dispatch = useDispatch()
6362
const [execAlertsList, results] = useLazyExecAlertsListQuery()
6463
const { data: alerts = {}, isFetching, error } = results
6564
const {
@@ -76,6 +75,35 @@ const ListAlerts = () => {
7675
execAlertsList()
7776
}, [execAlertsList])
7877

78+
const handleShowModal = (value) =>
79+
dispatch(
80+
showModal({
81+
title: 'More Information',
82+
body: (
83+
<div>
84+
<pre>{JSON.stringify(value, null, 2)}</pre>
85+
</div>
86+
),
87+
visible: true,
88+
size: 'xl',
89+
}),
90+
)
91+
92+
columns.push({
93+
name: 'RawResult',
94+
selector: (row) => row['RawResult'],
95+
sortable: true,
96+
cell: (row, index, column, id) => {
97+
const value = cellGetProperty(row, index, column, id)
98+
99+
return (
100+
<CButton size="sm" onClick={() => handleShowModal(value)}>
101+
More
102+
</CButton>
103+
)
104+
},
105+
})
106+
79107
return (
80108
<CippPage tenantSelector={false} title="List Alerts">
81109
<CCardGroup>

0 commit comments

Comments
 (0)