Skip to content

Commit 7a3fe75

Browse files
Show MDM Policy on app and Fix MDM policy status issue on portal (#1740)
* fix(app): show MDM policy for mac User * fix(app): fix status issue of mdm policy * fix(portal): fix status issue of mdm policy --------- Co-authored-by: chasprowebdev <chasgarciaprowebdev@gmail.com>
1 parent 1f981a7 commit 7a3fe75

4 files changed

Lines changed: 71 additions & 25 deletions

File tree

apps/app/src/app/(app)/[orgId]/people/devices/components/HostDetails.tsx

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,22 @@ import { Button } from '@comp/ui/button';
22
import { Card, CardContent, CardHeader, CardTitle } from '@comp/ui/card';
33
import { cn } from '@comp/ui/cn';
44
import { ArrowLeft, CheckCircle2, XCircle } from 'lucide-react';
5+
import { useMemo } from 'react';
56
import type { Host } from '../types';
67

78
export const HostDetails = ({ host, onClose }: { host: Host; onClose: () => void }) => {
9+
const isMacOS = useMemo(() => {
10+
return host.cpu_type && (host.cpu_type.includes('arm64') || host.cpu_type.includes('intel'));
11+
}, [host]);
12+
13+
const mdmEnabledStatus = useMemo(() => {
14+
return {
15+
id: 'mdm',
16+
response: host?.mdm.connected_to_fleet ? 'pass' : 'fail',
17+
name: 'MDM Enabled',
18+
};
19+
}, [host]);
20+
821
return (
922
<div className="space-y-4">
1023
<Button variant="outline" className="w-min" onClick={onClose}>
@@ -17,28 +30,52 @@ export const HostDetails = ({ host, onClose }: { host: Host; onClose: () => void
1730
</CardHeader>
1831
<CardContent className="space-y-3">
1932
{host.policies.length > 0 ? (
20-
host.policies.map((policy) => (
21-
<div
22-
key={policy.id}
23-
className={cn(
24-
'hover:bg-muted/50 flex items-center justify-between rounded-md border border-l-4 p-3 shadow-sm transition-colors',
25-
policy.response === 'pass' ? 'border-l-primary' : 'border-l-red-500',
26-
)}
27-
>
28-
<p className="font-medium">{policy.name}</p>
29-
{policy.response === 'pass' ? (
30-
<div className="flex items-center gap-1 text-primary">
31-
<CheckCircle2 size={16} />
32-
<span>Pass</span>
33-
</div>
34-
) : (
35-
<div className="flex items-center gap-1 text-red-600">
36-
<XCircle size={16} />
37-
<span>Fail</span>
38-
</div>
39-
)}
40-
</div>
41-
))
33+
<>
34+
{host.policies.map((policy) => (
35+
<div
36+
key={policy.id}
37+
className={cn(
38+
'hover:bg-muted/50 flex items-center justify-between rounded-md border border-l-4 p-3 shadow-sm transition-colors',
39+
policy.response === 'pass' ? 'border-l-primary' : 'border-l-red-500',
40+
)}
41+
>
42+
<p className="font-medium">{policy.name}</p>
43+
{policy.response === 'pass' ? (
44+
<div className="flex items-center gap-1 text-primary">
45+
<CheckCircle2 size={16} />
46+
<span>Pass</span>
47+
</div>
48+
) : (
49+
<div className="flex items-center gap-1 text-red-600">
50+
<XCircle size={16} />
51+
<span>Fail</span>
52+
</div>
53+
)}
54+
</div>
55+
))}
56+
{isMacOS && (
57+
<div
58+
key={mdmEnabledStatus.id}
59+
className={cn(
60+
'hover:bg-muted/50 flex items-center justify-between rounded-md border border-l-4 p-3 shadow-sm transition-colors',
61+
mdmEnabledStatus.response === 'pass' ? 'border-l-primary' : 'border-l-red-500',
62+
)}
63+
>
64+
<p className="font-medium">{mdmEnabledStatus.name}</p>
65+
{mdmEnabledStatus.response === 'pass' ? (
66+
<div className="flex items-center gap-1 text-primary">
67+
<CheckCircle2 size={16} />
68+
<span>Pass</span>
69+
</div>
70+
) : (
71+
<div className="flex items-center gap-1 text-red-600">
72+
<XCircle size={16} />
73+
<span>Fail</span>
74+
</div>
75+
)}
76+
</div>
77+
)}
78+
</>
4279
) : (
4380
<p className="text-muted-foreground">No policies found for this device.</p>
4481
)}

apps/app/src/app/(app)/[orgId]/people/devices/types/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export interface Host {
6666
gigs_total_disk_space: number;
6767
disk_encryption_enabled: boolean;
6868
issues: object;
69-
mdm: object;
69+
mdm: MDM;
7070
refetch_critical_queries_until: string | null;
7171
last_restarted_at: string;
7272
policies: FleetPolicy[];
@@ -80,3 +80,12 @@ export interface Host {
8080
display_text: string;
8181
display_name: string;
8282
}
83+
84+
export type MDM = {
85+
connected_to_fleet: boolean;
86+
dep_profile_error: boolean;
87+
encryption_key_available: boolean;
88+
enrollment_status: string;
89+
name?: string;
90+
server_url?: string;
91+
};

apps/portal/src/app/(app)/(home)/[orgId]/components/tasks/DeviceAgentAccordionItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function DeviceAgentAccordionItem({
3636
const mdmEnabledStatus = useMemo(() => {
3737
return {
3838
id: 'mdm',
39-
response: host?.mdm.enrollment_status === 'On' ? 'pass' : 'fail',
39+
response: host?.mdm.connected_to_fleet ? 'pass' : 'fail',
4040
name: 'MDM Enabled',
4141
};
4242
}, [host]);

apps/portal/src/app/(app)/(home)/[orgId]/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export type MDM = {
8585
connected_to_fleet: boolean;
8686
dep_profile_error: boolean;
8787
encryption_key_available: boolean;
88-
enrollment_status: "Off" | "On";
88+
enrollment_status: string;
8989
name?: string;
9090
server_url?: string;
9191
};

0 commit comments

Comments
 (0)