Secrets.utils.tsx 1.4 KB

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