Commit 26c5039e authored by Élodie Thiéblin's avatar Élodie Thiéblin
Browse files

feat(ChipsUri): display blue links for clickable values,grey otherwise

parent 4b714dc6e77b
Pipeline #94407 passed with stages
in 6 minutes and 7 seconds
......@@ -3,12 +3,16 @@ import { Box, Avatar, Chip, List, ListItem } from '@mui/material';
import { getBestLabel, Label, UriAndLabels, generateUrlType } from './utils';
export function isURI(str: string) {
return str.startsWith('http') || str.startsWith('urn');
}
export const TextOrLink: React.FC<{ str: string; generateUrl: generateUrlType; labels?: Label[] }> = ({
str,
generateUrl,
labels = [],
}) => {
if (str.startsWith('http') || str.startsWith('urn')) {
if (isURI(str)) {
return <URIComponent uri={str} labels={labels} generateUrl={generateUrl} />;
} else {
return <>{str}</>;
......@@ -85,17 +89,23 @@ export const ChipsUris: React.FC<{
<>
{' '}
{relationName}
<Box sx={{ maxHeight: '300px', overflowY: 'scroll', overflowX: 'hidden' }}>
{urisAndLabels.map(({ uri, labels }) => (
<a key={uri} href={generateUrl(uri)}>
<Chip
size="small"
clickable={true}
avatar={<Avatar>{icon}</Avatar>}
label={labels[0]?.value ?? uri}
/>
</a>
))}
<Box sx={{ maxHeight: '300px', overflowY: 'auto', overflowX: 'hidden' }}>
{urisAndLabels.map(({ uri, labels }) =>
isURI(uri) ? (
<a key={uri} href={generateUrl(uri)}>
<Chip
size="small"
clickable={true}
icon={icon}
label={labels[0]?.value ?? uri}
color="primary"
variant="outlined"
/>
</a>
) : (
<Chip size="small" clickable={false} icon={icon} label={labels[0]?.value ?? uri} key={uri} />
)
)}
</Box>
</>
) : (
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment