import { sanitizeExternalUrl } from "@allurereport/core-api"; import { SvgIcon, Text, allureIcons } from "@allurereport/web-components"; import type { FunctionalComponent } from "preact"; import { useState } from "preact/hooks"; import type { ClassicTestResult } from "types"; import { MetadataButton } from "@/components/MetadataButton"; import { useI18n } from "@/stores/locale"; import * as styles from "./styles.scss"; interface TestResultLinkProps { name: string; url: string; type: string; } const linksIconMap: Record = { issue: allureIcons.lineDevBug2, link: allureIcons.lineGeneralLink1, tms: allureIcons.lineGeneralChecklist3, github: allureIcons.github, }; const TestResultLink: FunctionalComponent<{ link: TestResultLinkProps; }> = ({ link }) => { const { url, type } = link; const safeUrl = sanitizeExternalUrl(url); return (
{safeUrl ? ( {url} ) : ( {url} )}
); }; export type TestResultLinksProps = { links: ClassicTestResult["links"]; }; export const TestResultLinks: FunctionalComponent = ({ links }) => { const [isOpened, setIsOpen] = useState(true); const { t } = useI18n("ui"); const linkMap = links.map((link, index) => { return ; }); return (
{isOpened &&
{linkMap}
}
); };