All checks were successful
Trigger Cloudarix Deploy / call-webhook (push) Successful in 1s
- Create PolicyTypeBadge component for consistent badge rendering - Add POLICY_TYPE_MAP with explicit labels for all 7 policy types: - configurationProfile → 'Settings Catalog' - deviceConfiguration → 'Device Configuration' - compliancePolicy → 'Compliance Policy' - endpointSecurity → 'Endpoint Security' - windowsUpdateForBusiness → 'Windows Update' - enrollmentConfiguration → 'Enrollment' - appConfiguration → 'App Configuration' - Update PolicyTable and PolicyDetailSheet to use new component - Maintain fallback heuristic matching for unknown types
109 lines
2.8 KiB
TypeScript
109 lines
2.8 KiB
TypeScript
/**
|
|
* Policy Type Badge Configuration
|
|
* Maps Intune policy types to Shadcn Badge variants and labels
|
|
*/
|
|
|
|
export type PolicyBadgeVariant = 'default' | 'secondary' | 'destructive' | 'outline';
|
|
|
|
interface PolicyBadgeConfig {
|
|
variant: PolicyBadgeVariant;
|
|
label: string;
|
|
}
|
|
|
|
/**
|
|
* Definitive mapping of Intune policy types to badge configuration
|
|
*/
|
|
const POLICY_TYPE_MAP: Record<string, PolicyBadgeConfig> = {
|
|
// 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
|
|
*/
|
|
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
|
|
if (type.includes('security') || type.includes('defender') || type.includes('threat')) {
|
|
return { variant: 'destructive', label: formatPolicyType(policyType) };
|
|
}
|
|
|
|
// Compliance & Conditional Access
|
|
if (type.includes('compliance') || type.includes('conditional')) {
|
|
return { variant: 'default', label: formatPolicyType(policyType) };
|
|
}
|
|
|
|
// Configuration Profiles
|
|
if (type.includes('configuration') || type.includes('profile') || type.includes('settings')) {
|
|
return { variant: 'secondary', label: formatPolicyType(policyType) };
|
|
}
|
|
|
|
// App Management
|
|
if (type.includes('app') || type.includes('application')) {
|
|
return { variant: 'outline', label: formatPolicyType(policyType) };
|
|
}
|
|
|
|
// Default for completely unknown types
|
|
return { variant: 'secondary', label: formatPolicyType(policyType) };
|
|
}
|
|
|
|
/**
|
|
* Formats policy type string for display
|
|
* Converts camelCase/PascalCase to readable format
|
|
*/
|
|
function formatPolicyType(policyType: string): string {
|
|
return policyType
|
|
.replace(/([A-Z])/g, ' $1') // Add space before capital letters
|
|
.trim()
|
|
.replace(/\s+/g, ' ') // Collapse multiple spaces
|
|
.split(' ')
|
|
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
.join(' ');
|
|
}
|