Skip to content

Commit cc72125

Browse files
committed
feat: list usefull links only when there are some
1 parent 5ca8621 commit cc72125

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed

web/src/ui/pages/softwareDetails/PreviewTab.tsx

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ export const PreviewTab = (props: Props) => {
7070
const { t } = useTranslation();
7171
const { lang } = useLang();
7272

73+
const usefullLinks = identifiers.filter(identifier => {
74+
const identifierURLString = identifier?.url?.toString();
75+
return (
76+
!officialWebsiteUrl ||
77+
(officialWebsiteUrl &&
78+
identifierURLString &&
79+
!officialWebsiteUrl.startsWith(identifierURLString))
80+
);
81+
});
82+
7383
return (
7484
<>
7585
<section className={classes.tabContainer}>
@@ -319,44 +329,25 @@ export const PreviewTab = (props: Props) => {
319329
</div>
320330
)}
321331

322-
{uiConfig?.softwareDetails.links.enabled && (
332+
{uiConfig?.softwareDetails.links.enabled && usefullLinks.length > 0 && (
323333
<div className={classes.section}>
324334
<p className={cx(fr.cx("fr-text--bold"), classes.item)}>
325335
{t("previewTab.use full links")}
326336
</p>
327-
{identifiers && (
328-
<>
329-
{identifiers
330-
.filter(identifier => {
331-
const identifierURLString =
332-
identifier?.url?.toString();
333-
return (
334-
!officialWebsiteUrl ||
335-
(officialWebsiteUrl &&
336-
identifierURLString &&
337-
!officialWebsiteUrl.startsWith(
338-
identifierURLString
339-
))
340-
);
341-
})
342-
.map(identifier => {
343-
const url =
344-
identifier.url ?? identifier.subjectOf?.url;
345337

346-
return (
347-
<LogoURLButton
348-
key={url?.toString()}
349-
className={cx(
350-
fr.cx("fr-ml-4v", "fr-my-2v")
351-
)}
352-
priority="secondary"
353-
url={url}
354-
labelFromURL={true}
355-
/>
356-
);
357-
})}
358-
</>
359-
)}
338+
{usefullLinks.map(identifier => {
339+
const url = identifier.url ?? identifier.subjectOf?.url;
340+
341+
return (
342+
<LogoURLButton
343+
key={url?.toString()}
344+
className={cx(fr.cx("fr-ml-4v", "fr-my-2v"))}
345+
priority="secondary"
346+
url={url}
347+
labelFromURL={true}
348+
/>
349+
);
350+
})}
360351
</div>
361352
)}
362353
</section>

0 commit comments

Comments
 (0)