Secrets.utils.tsx44 lines · main
| 1 | import type { Column } from 'react-data-grid' |
| 2 | import { cn } from 'ui' |
| 3 | |
| 4 | import { SecretRow } from './SecretRow' |
| 5 | import { SecretTableColumn } from './Secrets.types' |
| 6 | import type { VaultSecret } from '@/types' |
| 7 | |
| 8 | export const SECRET_TABLE_COLUMNS: SecretTableColumn[] = [ |
| 9 | { id: 'secret', name: 'Secret', minWidth: 300, width: 360 }, |
| 10 | { id: 'id', name: 'ID', minWidth: 220, width: 260 }, |
| 11 | { id: 'secret_value', name: 'Value', minWidth: 320, width: 420 }, |
| 12 | { id: 'updated_at', name: 'Last updated', minWidth: 180 }, |
| 13 | { id: 'actions', name: '', minWidth: 75, width: 75 }, |
| 14 | ] |
| 15 | |
| 16 | export const formatSecretColumns = (): Column<VaultSecret>[] => { |
| 17 | return SECRET_TABLE_COLUMNS.map((col) => { |
| 18 | const result: Column<VaultSecret> = { |
| 19 | key: col.id, |
| 20 | name: col.name, |
| 21 | minWidth: col.minWidth ?? 100, |
| 22 | maxWidth: col.maxWidth, |
| 23 | width: col.width, |
| 24 | resizable: false, |
| 25 | sortable: false, |
| 26 | draggable: false, |
| 27 | headerCellClass: undefined, |
| 28 | renderHeaderCell: () => { |
| 29 | return ( |
| 30 | <div |
| 31 | className={cn( |
| 32 | 'flex items-center justify-between font-normal text-xs w-full', |
| 33 | col.id === 'secret' && 'ml-8' |
| 34 | )} |
| 35 | > |
| 36 | <p className="text-foreground!">{col.name}</p> |
| 37 | </div> |
| 38 | ) |
| 39 | }, |
| 40 | renderCell: ({ row }) => <SecretRow row={row} col={col} />, |
| 41 | } |
| 42 | return result |
| 43 | }) |
| 44 | } |