Skip to content

Commit 9e10c78

Browse files
Merge pull request #2178 from BNWEIN/dev
Added custom thresholds for SharePoint and Mailbox Quota alerts
2 parents 0477b25 + 9fd38bf commit 9e10c78

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

src/views/tenant/administration/ListAlertsQueue.jsx

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from 'react'
22
import { CButton, CCallout, CCol, CForm, CRow, CSpinner, CTooltip } from '@coreui/react'
33
import { useSelector } from 'react-redux'
4-
import { Field, Form } from 'react-final-form'
4+
import { Field, Form, FormSpy } from 'react-final-form'
55
import { RFFCFormSwitch } from 'src/components/forms'
66
import {
77
useGenericGetRequestQuery,
@@ -25,8 +25,18 @@ const alertsList = [
2525
'Alert on tenants without a Conditional Access policy, while having Conditional Access licensing available.',
2626
},
2727
{ 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' },
28+
{
29+
name: 'QuotaUsed',
30+
label: 'Alert on % mailbox quota used',
31+
requiresInput: true,
32+
inputLabel: 'Enter quota percentage',
33+
},
34+
{
35+
name: 'SharePointQuota',
36+
label: 'Alert on % SharePoint quota used',
37+
requiresInput: true,
38+
inputLabel: 'Enter quota percentage',
39+
},
3040
{ name: 'ExpiringLicenses', label: 'Alert on licenses expiring in 30 days' },
3141
{ name: 'SecDefaultsUpsell', label: 'Alert on Security Defaults automatic enablement' },
3242
{
@@ -121,7 +131,7 @@ const ListClassicAlerts = () => {
121131
const [genericPostRequest, postResults] = useLazyGenericPostRequestQuery()
122132
const onSubmit = (values) => {
123133
Object.keys(values).filter(function (x) {
124-
if (values[x] === null) {
134+
if (values[x] === null || values[x] === 0) {
125135
delete values[x]
126136
}
127137
return null
@@ -201,11 +211,27 @@ const ListClassicAlerts = () => {
201211
<hr />
202212
{alertsList.map((alert, index) => (
203213
<CCol key={alert.name} md="6">
204-
<RFFCFormSwitch
205-
name={alert.name}
206-
label={alert.label}
207-
sublabel={getLabel(alert.name)}
208-
/>
214+
<RFFCFormSwitch name={alert.name} label={alert.label} />
215+
{alert.requiresInput && (
216+
<FormSpy subscription={{ values: true }}>
217+
{({ values }) => {
218+
// Check if the switch for this alert is turned on before showing the input
219+
if (values[alert.name]) {
220+
return (
221+
<Field
222+
name={`${alert.name}Quota`} // Unique name for the input field
223+
component="input"
224+
type="number"
225+
placeholder={alert.inputLabel}
226+
initialValue={alert.defaultValue} // Set the initial value
227+
parse={(value) => Number(value)} // Ensure value is a number
228+
/>
229+
)
230+
}
231+
return null
232+
}}
233+
</FormSpy>
234+
)}
209235
</CCol>
210236
))}
211237
</CRow>

0 commit comments

Comments
 (0)