Skip to content

Commit 6c2495b

Browse files
waleedlatif1claude
andcommitted
refactor(audit-logs): derive resource type filter from AuditResourceType
Instead of maintaining a separate hardcoded list, the filter dropdown now derives its options directly from the AuditResourceType const object. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e0ab844 commit 6c2495b

1 file changed

Lines changed: 18 additions & 27 deletions

File tree

apps/sim/ee/audit-logs/components/audit-logs.tsx

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,31 @@ import { Badge, Button, Combobox, type ComboboxOption, Skeleton } from '@/compon
77
import { Input } from '@/components/ui'
88
import { cn } from '@/lib/core/utils/cn'
99
import { formatDateTime } from '@/lib/core/utils/formatting'
10+
import { AuditResourceType } from '@/lib/audit/log'
1011
import type { EnterpriseAuditLogEntry } from '@/app/api/v1/audit-logs/format'
1112
import { type AuditLogFilters, useAuditLogs } from '@/ee/audit-logs/hooks/audit-logs'
1213

1314
const logger = createLogger('AuditLogs')
1415

16+
const ACRONYMS = new Set(['API', 'BYOK', 'MCP', 'OAuth'])
17+
18+
function formatResourceLabel(key: string): string {
19+
const words = key.split('_')
20+
return words
21+
.map((w) => {
22+
const upper = w.toUpperCase()
23+
if (ACRONYMS.has(upper)) return upper
24+
return w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()
25+
})
26+
.join(' ')
27+
.replace('OAUTH', 'OAuth')
28+
}
29+
1530
const RESOURCE_TYPE_OPTIONS: ComboboxOption[] = [
1631
{ label: 'All Types', value: '' },
17-
{ label: 'API Key', value: 'api_key' },
18-
{ label: 'Billing', value: 'billing' },
19-
{ label: 'BYOK Key', value: 'byok_key' },
20-
{ label: 'Chat', value: 'chat' },
21-
{ label: 'Connector', value: 'connector' },
22-
{ label: 'Credential', value: 'credential' },
23-
{ label: 'Credential Set', value: 'credential_set' },
24-
{ label: 'Custom Tool', value: 'custom_tool' },
25-
{ label: 'Document', value: 'document' },
26-
{ label: 'Environment', value: 'environment' },
27-
{ label: 'File', value: 'file' },
28-
{ label: 'Folder', value: 'folder' },
29-
{ label: 'Form', value: 'form' },
30-
{ label: 'Knowledge Base', value: 'knowledge_base' },
31-
{ label: 'MCP Server', value: 'mcp_server' },
32-
{ label: 'Notification', value: 'notification' },
33-
{ label: 'OAuth', value: 'oauth' },
34-
{ label: 'Organization', value: 'organization' },
35-
{ label: 'Password', value: 'password' },
36-
{ label: 'Permission Group', value: 'permission_group' },
37-
{ label: 'Schedule', value: 'schedule' },
38-
{ label: 'Skill', value: 'skill' },
39-
{ label: 'Table', value: 'table' },
40-
{ label: 'Template', value: 'template' },
41-
{ label: 'Webhook', value: 'webhook' },
42-
{ label: 'Workflow', value: 'workflow' },
43-
{ label: 'Workspace', value: 'workspace' },
32+
...(Object.entries(AuditResourceType) as [string, string][])
33+
.map(([key, value]) => ({ label: formatResourceLabel(key), value }))
34+
.sort((a, b) => a.label.localeCompare(b.label)),
4435
]
4536

4637
const DATE_RANGE_OPTIONS: ComboboxOption[] = [

0 commit comments

Comments
 (0)