-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathTagsDisplay.tsx
More file actions
62 lines (59 loc) · 1.62 KB
/
TagsDisplay.tsx
File metadata and controls
62 lines (59 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React from "react";
import {
EuiDescriptionList,
EuiDescriptionListDescription,
EuiDescriptionListTitle,
} from "@elastic/eui";
import EuiCustomLink from "./EuiCustomLink";
interface TagsDisplayProps {
createLink?: (key: string, value: string) => string;
tags: Record<string, string>;
owner?: string;
description?: string;
}
const TagsDisplay = ({
tags,
createLink,
owner,
description,
}: TagsDisplayProps) => {
return (
<EuiDescriptionList textStyle="reverse">
{owner ? (
<React.Fragment key={"owner"}>
<EuiDescriptionListTitle>owner</EuiDescriptionListTitle>
<EuiDescriptionListDescription>{owner}</EuiDescriptionListDescription>
</React.Fragment>
) : (
""
)}
{description ? (
<React.Fragment key={"description"}>
<EuiDescriptionListTitle>description</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
{description}
</EuiDescriptionListDescription>
</React.Fragment>
) : (
""
)}
{Object.entries(tags).map(([key, value]) => {
return (
<React.Fragment key={key}>
<EuiDescriptionListTitle>{key}</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
{createLink ? (
<EuiCustomLink to={createLink(key, value)}>
{value}
</EuiCustomLink>
) : (
value
)}
</EuiDescriptionListDescription>
</React.Fragment>
);
})}
</EuiDescriptionList>
);
};
export default TagsDisplay;