Skip to content

Commit

Permalink
remove default table headers from relation tests 🐰
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-fintlabs committed Dec 11, 2024
1 parent ff7c289 commit 913871e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 93 deletions.
162 changes: 70 additions & 92 deletions app/routes/relasjonstest/RelationTestResultsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { BodyShort, Table, Tooltip } from '@navikt/ds-react';
import { Table, Tooltip } from '@navikt/ds-react';
import {
ArrowCirclepathIcon,
CheckmarkCircleIcon,
Expand Down Expand Up @@ -40,98 +40,76 @@ const RelationTestResultsTable = ({ logResults }: TestResultsTableProps) => {
};

return (
<>
{logResults ? (
<Table size="small">
<Table.Header>
<Table.Row>
<Table.HeaderCell scope="col">Status</Table.HeaderCell>
<Table.HeaderCell scope="col">Tid</Table.HeaderCell>
<Table.HeaderCell scope="col">Miljø</Table.HeaderCell>
<Table.HeaderCell scope="col">Ressurs</Table.HeaderCell>
<Table.HeaderCell scope="col">Gjenstående</Table.HeaderCell>
<Table.HeaderCell scope="col">Feil</Table.HeaderCell>
<Table.HeaderCell scope="col">Ok</Table.HeaderCell>
<Table.HeaderCell scope={'col'} />
</Table.Row>
</Table.Header>
<Table.Body>
{logResults
.sort(
(a, b) => parseDate(b.time).getTime() - parseDate(a.time).getTime()
)
.map((result, index) => (
<Table.Row key={index}>
<Table.DataCell>
{result.status === 'FAILED' && (
<Tooltip
content={
result.errorMessage || 'An error occurred'
}>
<XMarkOctagonIcon
title="FAILED"
fontSize="1.5rem"
className={'navds-error-message'}
/>
</Tooltip>
)}
{result.status === 'COMPLETED' && (
<CheckmarkCircleIcon
title="COMPLETED"
fontSize="1.5rem"
/>
)}
{[
'STARTED',
'FETCHING_RESOURCES',
'CREATING_ENTRY_REPORTS',
'PROCESSING_LINKS',
].includes(result.status) && (
<ArrowCirclepathIcon
title={result.status}
fontSize="1.5rem"
/>
)}
</Table.DataCell>
<Table.DataCell>{result.time}</Table.DataCell>
<Table.DataCell>{result.env}</Table.DataCell>
<Table.DataCell>{result.uri}</Table.DataCell>
<Table size="small">
<Table.Header>
<Table.Row>
<Table.HeaderCell scope="col">Status</Table.HeaderCell>
<Table.HeaderCell scope="col">Tid</Table.HeaderCell>
<Table.HeaderCell scope="col">Miljø</Table.HeaderCell>
<Table.HeaderCell scope="col">Ressurs</Table.HeaderCell>
<Table.HeaderCell scope="col">Gjenstående</Table.HeaderCell>
<Table.HeaderCell scope="col">Feil</Table.HeaderCell>
<Table.HeaderCell scope="col">Ok</Table.HeaderCell>
<Table.HeaderCell scope={'col'} />
</Table.Row>
</Table.Header>
<Table.Body>
{logResults
.sort((a, b) => parseDate(b.time).getTime() - parseDate(a.time).getTime())
.map((result, index) => (
<Table.Row key={index}>
<Table.DataCell>
{result.status === 'FAILED' && (
<Tooltip content={result.errorMessage || 'An error occurred'}>
<XMarkOctagonIcon
title="FAILED"
fontSize="1.5rem"
className={'navds-error-message'}
/>
</Tooltip>
)}
{result.status === 'COMPLETED' && (
<CheckmarkCircleIcon title="COMPLETED" fontSize="1.5rem" />
)}
{[
'STARTED',
'FETCHING_RESOURCES',
'CREATING_ENTRY_REPORTS',
'PROCESSING_LINKS',
].includes(result.status) && (
<ArrowCirclepathIcon title={result.status} fontSize="1.5rem" />
)}
</Table.DataCell>
<Table.DataCell>{result.time}</Table.DataCell>
<Table.DataCell>{result.env}</Table.DataCell>
<Table.DataCell>{result.uri}</Table.DataCell>

<Table.DataCell align={'center'}>
{result.totalRequests -
result.healthyRelations -
result.relationErrors}
</Table.DataCell>
<Table.DataCell align={'center'}>
{result.relationErrors}
</Table.DataCell>
<Table.DataCell align={'center'}>
{result.healthyRelations}
</Table.DataCell>
<Table.DataCell>
<button
onClick={() => handleDownload(result.id)}
style={{
background: 'none',
border: 'none',
cursor: 'pointer',
}}>
<DownloadIcon
title="Download Excel"
fontSize="1.5rem"
/>
</button>
</Table.DataCell>
</Table.Row>
))}
</Table.Body>
</Table>
) : (
<div>
<BodyShort>Please use the form to create a report</BodyShort>
</div>
)}
</>
<Table.DataCell align={'center'}>
{result.totalRequests -
result.healthyRelations -
result.relationErrors}
</Table.DataCell>
<Table.DataCell align={'center'}>
{result.relationErrors}
</Table.DataCell>
<Table.DataCell align={'center'}>
{result.healthyRelations}
</Table.DataCell>
<Table.DataCell>
<button
onClick={() => handleDownload(result.id)}
style={{
background: 'none',
border: 'none',
cursor: 'pointer',
}}>
<DownloadIcon title="Download Excel" fontSize="1.5rem" />
</button>
</Table.DataCell>
</Table.Row>
))}
</Table.Body>
</Table>
);
};

Expand Down
2 changes: 1 addition & 1 deletion app/routes/relasjonstest/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default function Index() {
/>
</Box>

{relationTests && (
{relationTests && relationTests.length > 0 && (
<>
<Box className="w-full" padding="6">
<HStack gap={'10'}>
Expand Down

0 comments on commit 913871e

Please sign in to comment.