1
1
import React , { useState } from 'react'
2
2
import { CButton , CCallout , CCol , CForm , CRow , CSpinner , CTooltip } from '@coreui/react'
3
3
import { useSelector } from 'react-redux'
4
- import { Field , Form } from 'react-final-form'
5
- import { RFFCFormSwitch } from 'src/components/forms'
4
+ import { Field , Form , FormSpy } from 'react-final-form'
5
+ import { RFFCFormInput , RFFCFormSwitch } from 'src/components/forms'
6
6
import {
7
7
useGenericGetRequestQuery ,
8
8
useLazyGenericGetRequestQuery ,
@@ -14,7 +14,6 @@ import { CippContentCard, CippPage, CippPageList } from 'src/components/layout'
14
14
import { CellTip } from 'src/components/tables/CellGenericFormat'
15
15
import 'react-datepicker/dist/react-datepicker.css'
16
16
import { CippActionsOffcanvas , ModalService , TenantSelector } from 'src/components/utilities'
17
- import CippCodeOffCanvas from 'src/components/utilities/CippCodeOffcanvas'
18
17
import arrayMutators from 'final-form-arrays'
19
18
const alertsList = [
20
19
{ name : 'MFAAlertUsers' , label : 'Alert on users without any form of MFA' } ,
@@ -25,8 +24,20 @@ const alertsList = [
25
24
'Alert on tenants without a Conditional Access policy, while having Conditional Access licensing available.' ,
26
25
} ,
27
26
{ name : 'AdminPassword' , label : 'Alert on changed admin Passwords' } ,
28
- { name : 'QuotaUsed' , label : 'Alert on 90% mailbox quota used' } ,
29
- { name : 'SharePointQuota' , label : 'Alert on 90% SharePoint quota used' } ,
27
+ {
28
+ name : 'QuotaUsed' ,
29
+ label : 'Alert on % mailbox quota used' ,
30
+ requiresInput : true ,
31
+ inputLabel : 'Enter quota percentage' ,
32
+ inputName : 'QuotaUsedQuota' ,
33
+ } ,
34
+ {
35
+ name : 'SharePointQuota' ,
36
+ label : 'Alert on % SharePoint quota used' ,
37
+ requiresInput : true ,
38
+ inputLabel : 'Enter quota percentage' ,
39
+ inputName : 'SharePointQuotaQuota' ,
40
+ } ,
30
41
{ name : 'ExpiringLicenses' , label : 'Alert on licenses expiring in 30 days' } ,
31
42
{ name : 'SecDefaultsUpsell' , label : 'Alert on Security Defaults automatic enablement' } ,
32
43
{
@@ -121,7 +132,7 @@ const ListClassicAlerts = () => {
121
132
const [ genericPostRequest , postResults ] = useLazyGenericPostRequestQuery ( )
122
133
const onSubmit = ( values ) => {
123
134
Object . keys ( values ) . filter ( function ( x ) {
124
- if ( values [ x ] === null ) {
135
+ if ( values [ x ] === null || values [ x ] === 0 ) {
125
136
delete values [ x ]
126
137
}
127
138
return null
@@ -201,11 +212,24 @@ const ListClassicAlerts = () => {
201
212
< hr />
202
213
{ alertsList . map ( ( alert , index ) => (
203
214
< CCol key = { alert . name } md = "6" >
204
- < RFFCFormSwitch
205
- name = { alert . name }
206
- label = { alert . label }
207
- sublabel = { getLabel ( alert . name ) }
208
- />
215
+ < RFFCFormSwitch name = { alert . name } label = { alert . label } />
216
+ { alert . requiresInput && (
217
+ < FormSpy subscription = { { values : true } } >
218
+ { ( { values } ) => {
219
+ if ( values [ alert . name ] ) {
220
+ return (
221
+ < RFFCFormInput
222
+ name = { `${ alert . inputName } ` }
223
+ placeholder = { alert . inputLabel }
224
+ initialValue = { alert . defaultValue } // Set the initial value
225
+ type = "number"
226
+ />
227
+ )
228
+ }
229
+ return null
230
+ } }
231
+ </ FormSpy >
232
+ ) }
209
233
</ CCol >
210
234
) ) }
211
235
</ CRow >
0 commit comments