Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Feb 28, 2024
2 parents a02aa52 + 9e10c78 commit c313de9
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 35 deletions.
7 changes: 6 additions & 1 deletion src/components/forms/RFFComponents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,12 @@ export const RFFSelectSearch = ({
{label}
{refreshFunction && (
<CTooltip content="Refresh" placement="right">
<CButton onClick={refreshFunction} variant="ghost" className="ms-1" size="sm">
<CButton
onClick={refreshFunction}
variant="ghost"
className="ms-1 py-0 border-0"
size="sm"
>
<FontAwesomeIcon icon="sync" />
</CButton>
</CTooltip>
Expand Down
48 changes: 23 additions & 25 deletions src/views/tenant/administration/GraphExplorer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const GraphExplorer = () => {
const [alertVisible, setAlertVisible] = useState()
const [random, setRandom] = useState('')
const [random2, setRandom2] = useState('')
const [random3, setRandom3] = useState('')
const [ocVisible, setOCVisible] = useState(false)
const [searchNow, setSearchNow] = useState(false)
const [visibleA, setVisibleA] = useState(true)
Expand All @@ -59,21 +58,21 @@ const GraphExplorer = () => {
} = useGenericGetRequestQuery({ path: '/api/ListGraphExplorerPresets', params: { random2 } })
const QueryColumns = { set: false, data: [] }

function endpointChange(value) {
execPropRequest({
path: '/api/ListGraphRequest',
params: {
Endpoint: value,
ListProperties: true,
TenantFilter: tenant.defaultDomainName,
IgnoreErrors: true,
random: (Math.random() + 1).toString(36).substring(7),
},
})
}
const debounceEndpointChange = useMemo(() => {
function endpointChange(value) {
execPropRequest({
path: '/api/ListGraphRequest',
params: {
Endpoint: value,
ListProperties: true,
TenantFilter: tenant.defaultDomainName,
IgnoreErrors: true,
random: (Math.random() + 1).toString(36).substring(7),
},
})
}
return debounce(endpointChange, 1000)
}, [endpointChange])
}, [])

if (graphrequest.isSuccess) {
if (graphrequest.data?.Results?.length > 0) {
Expand Down Expand Up @@ -483,6 +482,7 @@ const GraphExplorer = () => {
)
}}
</FormSpy>
<hr />
<RFFCFormSwitch name="$count" label="Use $count" />
<WhenFieldChanges field="reportTemplate" set="$count" />
<RFFCFormSwitch name="NoPagination" label="Disable Pagination" />
Expand All @@ -504,13 +504,6 @@ const GraphExplorer = () => {
/>
<WhenFieldChanges field="reportTemplate" set="endpoint" />
<WhenFieldChanges field="endpoint" set="endpoint" />
<RFFCFormInput
type="text"
name="$filter"
label="Filter"
placeholder="Enter the filter string for the Graph query"
/>
<WhenFieldChanges field="reportTemplate" set="$filter" />
<div className="mb-3">
<RFFSelectSearch
name="$select"
Expand All @@ -529,12 +522,16 @@ const GraphExplorer = () => {
: []
}
allowCreate={true}
refreshFunction={() =>
setRandom3((Math.random() + 1).toString(36).substring(7))
}
isLoading={availableProperties.isFetching}
/>
</div>
<RFFCFormInput
type="text"
name="$filter"
label="Filter"
placeholder="Enter the filter string for the Graph query"
/>
<WhenFieldChanges field="reportTemplate" set="$filter" />
<WhenFieldChanges field="reportTemplate" set="$select" />
<RFFCFormInput
type="text"
Expand Down Expand Up @@ -572,7 +569,7 @@ const GraphExplorer = () => {
<hr />
<CippPage title="Report Results" tenantSelector={false}>
{!searchNow && <span>Execute a search to get started.</span>}
{graphrequest.isFetching && (
{graphrequest.isFetching && !QueryColumns.set && (
<div className="my-2">
<CSpinner className="me-2" /> Loading Data
</div>
Expand All @@ -593,6 +590,7 @@ const GraphExplorer = () => {
columns={QueryColumns.data}
data={graphrequest?.data?.Results}
isFetching={graphrequest.isFetching}
refreshFunction={() => setRandom((Math.random() + 1).toString(36).substring(7))}
/>
</>
</CCardBody>
Expand Down
44 changes: 35 additions & 9 deletions src/views/tenant/administration/ListAlertsQueue.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react'
import { CButton, CCallout, CCol, CForm, CRow, CSpinner, CTooltip } from '@coreui/react'
import { useSelector } from 'react-redux'
import { Field, Form } from 'react-final-form'
import { Field, Form, FormSpy } from 'react-final-form'
import { RFFCFormSwitch } from 'src/components/forms'
import {
useGenericGetRequestQuery,
Expand All @@ -25,8 +25,18 @@ const alertsList = [
'Alert on tenants without a Conditional Access policy, while having Conditional Access licensing available.',
},
{ name: 'AdminPassword', label: 'Alert on changed admin Passwords' },
{ name: 'QuotaUsed', label: 'Alert on 90% mailbox quota used' },
{ name: 'SharePointQuota', label: 'Alert on 90% SharePoint quota used' },
{
name: 'QuotaUsed',
label: 'Alert on % mailbox quota used',
requiresInput: true,
inputLabel: 'Enter quota percentage',
},
{
name: 'SharePointQuota',
label: 'Alert on % SharePoint quota used',
requiresInput: true,
inputLabel: 'Enter quota percentage',
},
{ name: 'ExpiringLicenses', label: 'Alert on licenses expiring in 30 days' },
{ name: 'SecDefaultsUpsell', label: 'Alert on Security Defaults automatic enablement' },
{
Expand Down Expand Up @@ -121,7 +131,7 @@ const ListClassicAlerts = () => {
const [genericPostRequest, postResults] = useLazyGenericPostRequestQuery()
const onSubmit = (values) => {
Object.keys(values).filter(function (x) {
if (values[x] === null) {
if (values[x] === null || values[x] === 0) {
delete values[x]
}
return null
Expand Down Expand Up @@ -201,11 +211,27 @@ const ListClassicAlerts = () => {
<hr />
{alertsList.map((alert, index) => (
<CCol key={alert.name} md="6">
<RFFCFormSwitch
name={alert.name}
label={alert.label}
sublabel={getLabel(alert.name)}
/>
<RFFCFormSwitch name={alert.name} label={alert.label} />
{alert.requiresInput && (
<FormSpy subscription={{ values: true }}>
{({ values }) => {
// Check if the switch for this alert is turned on before showing the input
if (values[alert.name]) {
return (
<Field
name={`${alert.name}Quota`} // Unique name for the input field
component="input"
type="number"
placeholder={alert.inputLabel}
initialValue={alert.defaultValue} // Set the initial value
parse={(value) => Number(value)} // Ensure value is a number
/>
)
}
return null
}}
</FormSpy>
)}
</CCol>
))}
</CRow>
Expand Down

0 comments on commit c313de9

Please sign in to comment.