Skip to content

Commit

Permalink
Improve handling of case without resources
Browse files Browse the repository at this point in the history
  • Loading branch information
alisman committed Jan 10, 2025
1 parent ac1c18e commit e82a8d0
Showing 1 changed file with 37 additions and 32 deletions.
69 changes: 37 additions & 32 deletions src/shared/components/resources/ResourceTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ const ResourceTable = observer(
},
}));

return (
return resourceTable.data.length === 0 ? (
<p>There are no resources for this sample.</p>
) : (
<table className="simple-table table table-striped table-border-top">
<thead>
<tr>
Expand All @@ -64,42 +66,45 @@ const ResourceTable = observer(
</tr>
</thead>
<tbody>

{ resourceTable.data.length === 0 ? (
{resourceTable.data.length === 0 ? (
<tr>
<td colSpan={3} style={{ textAlign: 'center' }}>
There are no results
</td>
</tr>
) : (resourceTable.data.map(resource => (
<tr>
{sampleId && <td>{sampleId}</td>}
<td>
<a onClick={() => openResource(resource)}>
{icon(resource)}
{resource.resourceDefinition.displayName ||
resource.url}
</a>
</td>
<td>
<a
href={resource.url}
style={{ fontSize: 10 }}
target={'_blank'}
>
<i
className={`fa fa-external-link fa-sm`}
style={{
marginRight: 5,
color: 'black',
}}
/>
Open in new window
</a>
</td>
<td>{resource.resourceDefinition.description}</td>
</tr>
))}
) : (
resourceTable.data.map(resource => (
<tr>
{sampleId && <td>{sampleId}</td>}
<td>
<a onClick={() => openResource(resource)}>
{icon(resource)}
{resource.resourceDefinition
.displayName || resource.url}
</a>
</td>
<td>
<a
href={resource.url}
style={{ fontSize: 10 }}
target={'_blank'}
>
<i
className={`fa fa-external-link fa-sm`}
style={{
marginRight: 5,
color: 'black',
}}
/>
Open in new window
</a>
</td>
<td>
{resource.resourceDefinition.description}
</td>
</tr>
))
)}
</tbody>
</table>
);
Expand Down

0 comments on commit e82a8d0

Please sign in to comment.