mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
fix(ui): linkify only ticket id
This commit is contained in:
committed by
Łukasz Mierzwa
parent
f7bf357950
commit
e51f4d6940
@@ -110,13 +110,15 @@ describe("<SilenceComment />", () => {
|
||||
it("Renders a JIRA link if present", () => {
|
||||
silence.ticketURL = "http://localhost/1234";
|
||||
silence.ticketID = "1234";
|
||||
silence.comment = "Ticket id 1234 and also 1234";
|
||||
const tree = MountedSilenceComment(true);
|
||||
expect(tree.find("a[href='http://localhost/1234']")).toHaveLength(1);
|
||||
expect(tree.find("a[href='http://localhost/1234']")).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("Renders a JIRA link if present and comment is expanded", () => {
|
||||
silence.ticketURL = "http://localhost/1234";
|
||||
silence.ticketID = "1234";
|
||||
silence.comment = "Ticket id 1234";
|
||||
const tree = MountedSilenceComment(false);
|
||||
expect(tree.find("a[href='http://localhost/1234']")).toHaveLength(1);
|
||||
});
|
||||
|
||||
@@ -27,22 +27,20 @@ const SilenceComment: FC<{
|
||||
collapseToggle,
|
||||
alertStore,
|
||||
}) => {
|
||||
const comment = silence.ticketURL ? (
|
||||
<a
|
||||
href={silence.ticketURL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={
|
||||
collapsed
|
||||
? "components-managed-silence-comment mw-100 text-truncate d-block"
|
||||
: "components-managed-silence-comment"
|
||||
}
|
||||
>
|
||||
<FontAwesomeIcon className="me-2" icon={faExternalLinkAlt} />
|
||||
{silence.comment}
|
||||
</a>
|
||||
) : (
|
||||
silence.comment
|
||||
const comment = silence.comment.split(" ").map((w, i) =>
|
||||
silence.ticketURL && w === silence.ticketID ? (
|
||||
<a
|
||||
key={i}
|
||||
href={silence.ticketURL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<FontAwesomeIcon className="me-2" icon={faExternalLinkAlt} />
|
||||
{silence.ticketID}
|
||||
</a>
|
||||
) : (
|
||||
" " + w
|
||||
)
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -60,7 +58,7 @@ const SilenceComment: FC<{
|
||||
collapsed ? "text-truncate overflow-hidden" : ""
|
||||
}`}
|
||||
>
|
||||
{comment}
|
||||
{comment.map((w) => w)}
|
||||
</div>
|
||||
<div className="components-managed-silence-cite mt-1">
|
||||
<span className="text-muted me-2 font-italic">
|
||||
|
||||
Reference in New Issue
Block a user