Skip to content

Commit d961d17

Browse files
Added Compliance Policies
1 parent df8e011 commit d961d17

File tree

5 files changed

+171
-3
lines changed

5 files changed

+171
-3
lines changed

src/_nav.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,11 @@ const _nav = [
484484
name: 'Configuration Policies',
485485
to: '/endpoint/MEM/list-policies',
486486
},
487+
{
488+
component: CNavItem,
489+
name: 'Compliance Policies',
490+
to: '/endpoint/MEM/list-compliance-policies',
491+
},
487492
{
488493
component: CNavItem,
489494
name: 'Protection Policies',

src/routes.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ const AutopilotListStatusPages = React.lazy(() =>
130130
import('src/views/endpoint/autopilot/AutopilotListStatusPages'),
131131
)
132132
const IntuneListPolicies = React.lazy(() => import('src/views/endpoint/intune/MEMListPolicies'))
133+
const IntuneListCompliance = React.lazy(() => import('src/views/endpoint/intune/MEMListCompliance'))
134+
133135
const IntuneListAppProtection = React.lazy(() =>
134136
import('src/views/endpoint/intune/MEMListAppProtection'),
135137
)
@@ -490,6 +492,11 @@ const routes = [
490492
name: 'List Intune Policies',
491493
component: IntuneListPolicies,
492494
},
495+
{
496+
path: '/endpoint/MEM/list-compliance-policies',
497+
name: 'List Intune Compliance Policies',
498+
component: IntuneListCompliance,
499+
},
493500
{
494501
path: '/endpoint/MEM/list-appprotection-policies',
495502
name: 'List App Protection Policies',

src/views/endpoint/intune/MEMAddPolicy.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ const AddPolicy = () => {
171171
{ label: 'Settings Catalog', value: 'Catalog' },
172172
{ label: 'Custom Configuration', value: 'Device' },
173173
{ label: 'App Protection or Configuration Policy', value: 'AppProtection' },
174+
{ label: 'Compliance Policy', value: 'deviceCompliancePolicies' },
174175
]}
175176
/>
176177
</CCol>
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
import React, { useState } from 'react'
2+
import { useSelector } from 'react-redux'
3+
import { CButton } from '@coreui/react'
4+
import {
5+
faBook,
6+
faEdit,
7+
faEllipsisV,
8+
faGlobeEurope,
9+
faPager,
10+
faTrashAlt,
11+
faUser,
12+
} from '@fortawesome/free-solid-svg-icons'
13+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
14+
import { CippPageList } from 'src/components/layout'
15+
import { Link } from 'react-router-dom'
16+
import { CippActionsOffcanvas, CippCodeBlock } from 'src/components/utilities'
17+
import { TitleButton } from 'src/components/buttons'
18+
import { cellBooleanFormatter, cellDateFormatter } from 'src/components/tables'
19+
20+
const Actions = (row, rowIndex, formatExtraData) => {
21+
const [ocVisible, setOCVisible] = useState(false)
22+
console.log(row)
23+
const tenant = useSelector((state) => state.app.currentTenant)
24+
return (
25+
<>
26+
<CButton size="sm" color="link" onClick={() => setOCVisible(true)}>
27+
<FontAwesomeIcon icon={faEllipsisV} />
28+
</CButton>
29+
<CippActionsOffcanvas
30+
title="Policy Information"
31+
extendedInfo={[
32+
{ label: 'Created on', value: `${row.createdDateTime}` },
33+
{ label: 'Display Name', value: `${row.displayName}` },
34+
{ label: 'Last Modified', value: `${row.lastModifiedDateTime}` },
35+
{ label: 'Type', value: `${row.PolicyTypeName}` },
36+
]}
37+
actions={[
38+
{
39+
label: 'Create template based on policy (beta)',
40+
color: 'info',
41+
modal: true,
42+
icon: <FontAwesomeIcon icon={faBook} className="me-2" />,
43+
modalUrl: `/api/AddIntuneTemplate?TenantFilter=${tenant.defaultDomainName}&ID=${row.id}&URLName=deviceCompliancePolicies`,
44+
modalMessage: 'Are you sure you want to create a template based on this policy?',
45+
},
46+
{
47+
icon: <FontAwesomeIcon icon={faUser} />,
48+
label: ' Assign to All Users',
49+
color: 'info',
50+
modal: true,
51+
modalUrl: `/api/ExecAssignPolicy?AssignTo=allLicensedUsers&TenantFilter=${tenant.defaultDomainName}&ID=${row.id}&type=deviceCompliancePolicies`,
52+
modalMessage: `Are you sure you want to assign ${row.displayName} to all users?`,
53+
},
54+
{
55+
icon: <FontAwesomeIcon icon={faPager} />,
56+
label: ' Assign to All Devices',
57+
color: 'info',
58+
modal: true,
59+
modalUrl: `/api/ExecAssignPolicy?AssignTo=AllDevices&TenantFilter=${tenant.defaultDomainName}&ID=${row.id}&type=deviceCompliancePolicies`,
60+
modalMessage: `Are you sure you want to assign ${row.displayName} to all devices?`,
61+
},
62+
{
63+
icon: <FontAwesomeIcon icon={faGlobeEurope} />,
64+
label: ' Assign Globally (All Users / All Devices)',
65+
color: 'info',
66+
modal: true,
67+
modalUrl: `/api/ExecAssignPolicy?AssignTo=AllDevicesAndUsers&TenantFilter=${tenant.defaultDomainName}&ID=${row.id}&type=deviceCompliancePolicies`,
68+
modalMessage: `Are you sure you want to assign ${row.displayName} to all users and devices?`,
69+
},
70+
{
71+
label: 'Delete Policy',
72+
color: 'danger',
73+
modal: true,
74+
icon: <FontAwesomeIcon icon={faTrashAlt} className="me-2" />,
75+
modalUrl: `/api/RemovePolicy?TenantFilter=${tenant.defaultDomainName}&ID=${row.id}&URLName=${row.URLName}`,
76+
modalMessage: 'Are you sure you want to delete this policy?',
77+
},
78+
]}
79+
placement="end"
80+
visible={ocVisible}
81+
id={row.id}
82+
hideFunction={() => setOCVisible(false)}
83+
/>
84+
</>
85+
)
86+
}
87+
88+
const columns = [
89+
{
90+
selector: (row) => row['displayName'],
91+
name: 'Name',
92+
sortable: true,
93+
exportSelector: 'displayName',
94+
},
95+
{
96+
selector: (row) => row['description'],
97+
name: 'Description',
98+
sortable: true,
99+
exportSelector: 'description',
100+
},
101+
{
102+
selector: (row) => row['lastModifiedDateTime'],
103+
name: 'Last Modified',
104+
exportSelector: 'lastModifiedDateTime',
105+
cell: cellDateFormatter({ format: 'relative' }),
106+
},
107+
{
108+
name: 'Actions',
109+
cell: Actions,
110+
maxWidth: '80px',
111+
},
112+
]
113+
114+
const ComplianceList = () => {
115+
const tenant = useSelector((state) => state.app.currentTenant)
116+
117+
// eslint-disable-next-line react/prop-types
118+
const ExpandedComponent = ({ data }) => (
119+
// eslint-disable-next-line react/prop-types
120+
<CippCodeBlock code={JSON.stringify(data, null, 2)} language="json" />
121+
)
122+
123+
return (
124+
<CippPageList
125+
title="Intune Compliance Policies"
126+
titleButton={
127+
<>
128+
<TitleButton
129+
href={`/endpoint/MEM/add-policy?customerId=${tenant?.customerId}&tableFilter=${tenant?.defaultDomainName}`}
130+
title="Deploy MEM Policy"
131+
/>
132+
</>
133+
}
134+
tenantSelector={true}
135+
datatable={{
136+
path: '/api/ListGraphRequest',
137+
params: {
138+
TenantFilter: tenant?.defaultDomainName,
139+
Endpoint: 'deviceManagement/deviceCompliancePolicies',
140+
$orderby: 'displayName',
141+
$count: true,
142+
},
143+
columns,
144+
reportName: `${tenant?.defaultDomainName}-MEMPolicies-List`,
145+
tableProps: {
146+
expandableRows: true,
147+
expandableRowsComponent: ExpandedComponent,
148+
expandOnRowClicked: true,
149+
},
150+
}}
151+
/>
152+
)
153+
}
154+
155+
export default ComplianceList

src/views/endpoint/intune/MEMListPolicies.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,23 @@ const Actions = (row, rowIndex, formatExtraData) => {
4747
label: ' Assign to All Users',
4848
color: 'info',
4949
modal: true,
50-
modalUrl: `/api/ExecAssignPolicy?AssignTo=allLicensedUsers&TenantFilter=${tenant.defaultDomainName}&ID=${row.id}`,
50+
modalUrl: `/api/ExecAssignPolicy?AssignTo=allLicensedUsers&TenantFilter=${tenant.defaultDomainName}&ID=${row.id}&type=${row.URLName}`,
5151
modalMessage: `Are you sure you want to assign ${row.displayName} to all users?`,
5252
},
5353
{
5454
icon: <FontAwesomeIcon icon={faPager} />,
5555
label: ' Assign to All Devices',
5656
color: 'info',
5757
modal: true,
58-
modalUrl: `/api/ExecAssignPolicy?AssignTo=AllDevices&TenantFilter=${tenant.defaultDomainName}&ID=${row.id}`,
58+
modalUrl: `/api/ExecAssignPolicy?AssignTo=AllDevices&TenantFilter=${tenant.defaultDomainName}&ID=${row.id}&type=${row.URLName}`,
5959
modalMessage: `Are you sure you want to assign ${row.displayName} to all devices?`,
6060
},
6161
{
6262
icon: <FontAwesomeIcon icon={faGlobeEurope} />,
6363
label: ' Assign Globally (All Users / All Devices)',
6464
color: 'info',
6565
modal: true,
66-
modalUrl: `/api/ExecAssignPolicy?AssignTo=AllDevicesAndUsers&TenantFilter=${tenant.defaultDomainName}&ID=${row.id}`,
66+
modalUrl: `/api/ExecAssignPolicy?AssignTo=AllDevicesAndUsers&TenantFilter=${tenant.defaultDomainName}&ID=${row.id}&type=${row.URLName}`,
6767
modalMessage: `Are you sure you want to assign ${row.displayName} to all users and devices?`,
6868
},
6969
{

0 commit comments

Comments
 (0)