/** * PolicyTableColumns * * Column definitions for the Policy Explorer V2 data table. * Uses TanStack Table column definition API. * * Columns: * - settingName: The setting key/identifier * - settingValue: The setting value (truncated with tooltip) * - policyName: Name of the policy containing this setting * - policyType: Type badge (deviceConfiguration, compliancePolicy, etc.) * - lastSyncedAt: Timestamp of last sync from Intune * - graphPolicyId: Microsoft Graph Policy ID (truncated) */ import type { ColumnDef } from '@tanstack/react-table'; import type { PolicySettingRow } from '@/lib/types/policy-table'; import { Badge } from '@/components/ui/badge'; import { formatDistanceToNow } from 'date-fns'; import { ArrowUpDown, ArrowUp, ArrowDown } from 'lucide-react'; import { Button } from '@/components/ui/button'; export const policyTableColumns: ColumnDef[] = [ { id: 'select', header: ({ table }) => (
{ if (input) { input.indeterminate = table.getIsSomePageRowsSelected() && !table.getIsAllPageRowsSelected(); } }} onChange={table.getToggleAllPageRowsSelectedHandler()} aria-label="Select all rows on this page" className="h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary" />
), cell: ({ row }) => (
), enableSorting: false, enableResizing: false, }, { accessorKey: 'settingName', header: ({ column }) => { const isSorted = column.getIsSorted(); return ( ); }, cell: ({ row }) => { const settingName = row.getValue('settingName') as string; return (
{settingName}
); }, enableSorting: true, enableResizing: true, }, { accessorKey: 'settingValue', header: 'Setting Value', cell: ({ row }) => { const settingValue = row.getValue('settingValue') as string; const truncated = settingValue.length > 100 ? settingValue.slice(0, 100) + '...' : settingValue; return (
{truncated}
); }, enableSorting: false, enableResizing: true, }, { accessorKey: 'policyName', header: ({ column }) => { const isSorted = column.getIsSorted(); return ( ); }, cell: ({ row }) => { const policyName = row.getValue('policyName') as string; return (
{policyName}
); }, enableSorting: true, enableResizing: true, }, { accessorKey: 'policyType', header: ({ column }) => { const isSorted = column.getIsSorted(); return ( ); }, cell: ({ row }) => { const policyType = row.getValue('policyType') as string; return ( {policyType} ); }, enableSorting: true, enableResizing: true, }, { accessorKey: 'lastSyncedAt', header: ({ column }) => { const isSorted = column.getIsSorted(); return ( ); }, cell: ({ row }) => { const lastSyncedAt = row.getValue('lastSyncedAt') as Date; const formattedDate = formatDistanceToNow(new Date(lastSyncedAt), { addSuffix: true }); return (
{formattedDate}
); }, enableSorting: true, enableResizing: true, }, { accessorKey: 'graphPolicyId', header: 'Graph Policy ID', cell: ({ row }) => { const graphPolicyId = row.getValue('graphPolicyId') as string; const truncated = graphPolicyId.length > 40 ? graphPolicyId.slice(0, 40) + '...' : graphPolicyId; return (
{truncated}
); }, enableSorting: false, enableResizing: true, }, ];