All files / features / container-registries ContainerRegistriesListPage.tsx

81.57% Statements 31/38
68.18% Branches 15/22
83.33% Functions 10/12
84.84% Lines 28/33

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65        137x     60x 60x 4x             346x   8x                       8x 8x 4x   346x 346x 166x   8x       346x         4x           60x     4x         60x      
import { Outlet } from 'react-router-dom'
import { Page, DataTable, Crud } from '@/layers/L2R'
import type { PageConfig, ListConfig, CrudConfig } from '@/layers/interfaces'
import { formatDateTime } from '@/shared/utils/format'
import { CONTAINER_REGISTRY_FIELD_SET, CONTAINER_REGISTRY_FIELD_TYPES } from './containerRegistriesCrudConfig'
 
export function ContainerRegistriesListPage() {
  const pageConfig: PageConfig = { title: 'Container Registries' }
 
  const listConfig: ListConfig = {
    entityPath: 'container-registries',
    prefix: 'registries',
    columns: [
      {
        field: 'name',
        label: 'Name',
        sortable: true,
        render: (row) => (
          <a href={`#/container-registries/${row.id}`}>{row.name as string}</a>
        ),
      },
      {
        field: 'url',
        label: 'URL',
        sortable: true,
      },
      {
        field: 'username',
        label: 'Username',
        render: (row) => {
          const val = row.username
          if (val === undefined || val === null || val === '') return '\u2014'
          return String(val)
        },
      },
      {
        field: 'created_at',
        label: 'Created',
        render: (row) => formatDateTime(row.created_at as string | null | undefined),
      },
    ],
    sort: { field: 'name', order: 'asc' },
    createTarget: '/container-registries/add',
    createLabel: '+ Add Registry',
    rowTarget: '/container-registries/:id',
  }
 
  const crudConfig: CrudConfig = {
    entityPath: 'container-registries',
    fieldSet: CONTAINER_REGISTRY_FIELD_SET,
    fieldTypes: CONTAINER_REGISTRY_FIELD_TYPES,
    successTarget: '/container-registries/:id',
    cancelTarget: '/container-registries',
    title: 'Add Container Registry',
  }
 
  return (
    <Page config={pageConfig}>
      <DataTable config={listConfig} />
      <Crud config={crudConfig} />
      <Outlet />
    </Page>
  )
}