Skip to content

Commit fa87554

Browse files
committed
fix: Roles display
Instead if rendering HTML into the page, we render a string listing out the roles
1 parent 53f3365 commit fa87554

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/pages/ItemDetail/AssetList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { StacAsset } from "stac-ts";
44
import StacFields from "@radiantearth/stac-fields";
55
import { PropertyGroup } from "../../types";
66
import PropertyList from "./PropertyList";
7+
import Roles from "./Roles";
78

89
type AssetProps = {
910
assetKey: string;
@@ -29,7 +30,7 @@ function Asset({ asset, assetKey }: AssetProps) {
2930
<Box borderBottom="1px dashed" borderColor="gray.300" pb="4">
3031
<Text as="h3" mb="1">{ title || assetKey }</Text>
3132
{ description && <Text my="0">{ description }</Text>}
32-
<Text my="0" fontSize="sm">{ formattedProperties.type.formatted } | { formattedProperties.roles.formatted }</Text>
33+
<Text my="0" fontSize="sm">{ formattedProperties.type.formatted } | <Roles roles={formattedProperties.roles} /></Text>
3334
<Box mt="2" mb="4">
3435
{ alternate ? (
3536
Object.entries(alternate)

src/pages/ItemDetail/Roles.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
type RolesProps = {
2+
roles: {
3+
spec: {
4+
label: "Purpose",
5+
mapping: {
6+
data: "Data"
7+
graphic: "Illustration"
8+
metadata: "Metadata"
9+
overview: "Overview"
10+
thumbnail: "Preview"
11+
visual: "Visualization"
12+
[key: string]: string
13+
}
14+
},
15+
value: string[];
16+
}
17+
};
18+
19+
function Roles({ roles }: RolesProps) {
20+
const { value, spec } = roles;
21+
const { mapping } = spec;
22+
return (
23+
<>
24+
{value.map((val) => mapping[val] || val).join(", ")}
25+
</>
26+
);
27+
}
28+
29+
export default Roles;

0 commit comments

Comments
 (0)