diff --git a/components/policy-explorer/PolicyDetailSheet.tsx b/components/policy-explorer/PolicyDetailSheet.tsx
index 1b25831..a43414a 100644
--- a/components/policy-explorer/PolicyDetailSheet.tsx
+++ b/components/policy-explorer/PolicyDetailSheet.tsx
@@ -8,6 +8,7 @@ import {
SheetTitle,
} from '@/components/ui/sheet';
import type { PolicySettingSearchResult } from '@/lib/actions/policySettings';
+import { PolicyTypeBadge } from './PolicyTypeBadge';
import { formatDistanceToNow } from 'date-fns';
import { de } from 'date-fns/locale';
@@ -68,9 +69,7 @@ export function PolicyDetailSheet({
Policy Type
-
- {policy.policyType.replace(/([A-Z])/g, ' $1').trim()}
-
+
{/* Setting Name */}
diff --git a/components/policy-explorer/PolicyTable.tsx b/components/policy-explorer/PolicyTable.tsx
index 832626e..f542f75 100644
--- a/components/policy-explorer/PolicyTable.tsx
+++ b/components/policy-explorer/PolicyTable.tsx
@@ -9,9 +9,8 @@ import {
TableRow,
} from '@/components/ui/table';
import { Card, CardContent } from '@/components/ui/card';
-import { Badge } from '@/components/ui/badge';
import type { PolicySettingSearchResult } from '@/lib/actions/policySettings';
-import { getPolicyBadgeConfig } from '@/lib/utils/policyBadges';
+import { PolicyTypeBadge } from './PolicyTypeBadge';
import { formatDistanceToNow } from 'date-fns';
import { de } from 'date-fns/locale';
@@ -54,14 +53,7 @@ export function PolicyTable({ policies, onRowClick }: PolicyTableProps) {
{policy.policyName}
- {(() => {
- const badgeConfig = getPolicyBadgeConfig(policy.policyType);
- return (
-
- {badgeConfig.label}
-
- );
- })()}
+
{formatDistanceToNow(new Date(policy.lastSyncedAt), {
diff --git a/components/policy-explorer/PolicyTypeBadge.tsx b/components/policy-explorer/PolicyTypeBadge.tsx
new file mode 100644
index 0000000..f522145
--- /dev/null
+++ b/components/policy-explorer/PolicyTypeBadge.tsx
@@ -0,0 +1,20 @@
+import { Badge } from "@/components/ui/badge";
+import { getPolicyBadgeConfig } from "@/lib/utils/policyBadges";
+
+interface PolicyTypeBadgeProps {
+ type: string;
+}
+
+/**
+ * Badge component for displaying policy types with consistent styling
+ * Maps Intune policy types to user-friendly labels and colors
+ */
+export function PolicyTypeBadge({ type }: PolicyTypeBadgeProps) {
+ const { variant, label } = getPolicyBadgeConfig(type);
+
+ return (
+
+ {label}
+
+ );
+}
diff --git a/lib/utils/policyBadges.ts b/lib/utils/policyBadges.ts
index 324bdac..0f40aa6 100644
--- a/lib/utils/policyBadges.ts
+++ b/lib/utils/policyBadges.ts
@@ -1,6 +1,6 @@
/**
* Policy Type Badge Configuration
- * Maps Intune policy types to Shadcn Badge variants and colors
+ * Maps Intune policy types to Shadcn Badge variants and labels
*/
export type PolicyBadgeVariant = 'default' | 'secondary' | 'destructive' | 'outline';
@@ -10,11 +10,63 @@ interface PolicyBadgeConfig {
label: string;
}
+/**
+ * Definitive mapping of Intune policy types to badge configuration
+ */
+const POLICY_TYPE_MAP: Record = {
+ // Device Configuration (Legacy)
+ deviceConfiguration: {
+ variant: 'secondary',
+ label: 'Device Configuration'
+ },
+
+ // Settings Catalog (Modern Configuration)
+ configurationProfile: {
+ variant: 'default',
+ label: 'Settings Catalog'
+ },
+
+ // Compliance Policies
+ compliancePolicy: {
+ variant: 'default',
+ label: 'Compliance Policy'
+ },
+
+ // Endpoint Security
+ endpointSecurity: {
+ variant: 'destructive',
+ label: 'Endpoint Security'
+ },
+
+ // Windows Update
+ windowsUpdateForBusiness: {
+ variant: 'outline',
+ label: 'Windows Update'
+ },
+
+ // Enrollment Configuration
+ enrollmentConfiguration: {
+ variant: 'secondary',
+ label: 'Enrollment'
+ },
+
+ // App Configuration
+ appConfiguration: {
+ variant: 'outline',
+ label: 'App Configuration'
+ }
+};
+
/**
* Maps policy type to badge configuration
- * Based on Microsoft Intune policy categories
*/
export function getPolicyBadgeConfig(policyType: string): PolicyBadgeConfig {
+ // Direct lookup for exact matches
+ if (POLICY_TYPE_MAP[policyType]) {
+ return POLICY_TYPE_MAP[policyType];
+ }
+
+ // Fallback to heuristic matching for unknown types
const type = policyType.toLowerCase();
// Security & Protection
@@ -37,7 +89,7 @@ export function getPolicyBadgeConfig(policyType: string): PolicyBadgeConfig {
return { variant: 'outline', label: formatPolicyType(policyType) };
}
- // Default for unknown types
+ // Default for completely unknown types
return { variant: 'secondary', label: formatPolicyType(policyType) };
}