Skip to content

Commit e40306e

Browse files
committed
fix: try key avlue list
1 parent 33c5762 commit e40306e

2 files changed

Lines changed: 14 additions & 22 deletions

File tree

src/components/controls/SimpleKeyValueList.tsx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,7 @@ const SimpleKeyValueList = ({ object, indent = false }: Props) => {
99
return (
1010
<div className="json-list">
1111
{Object.entries(object).map(([key, val]) => {
12-
if (val == null) return null;
13-
14-
if (Array.isArray(val)) {
15-
return (
16-
<LabeledValue key={key} label={stacFormatter.label(key)} indent={indent}>
17-
{val.join(", ")}
18-
</LabeledValue>
19-
);
20-
}
21-
22-
if (typeof val === "object") {
23-
return (
24-
<LabeledValue key={key} label={stacFormatter.label(key)} indent={indent}>
25-
<SimpleKeyValueList object={val} indent />
26-
</LabeledValue>
27-
);
28-
}
12+
if (Array.isArray(val) || typeof val === "object") return null;
2913

3014
return (
3115
<LabeledValue key={key} label={stacFormatter.label(key)} indent={indent}>

src/utils/stac.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,15 +683,23 @@ export const renderItemColumn = (item, _, column) => {
683683
if (Array.isArray(fieldContent)) {
684684
fieldContent = fieldContent.join(", ");
685685
} else if (isObject(fieldContent)) {
686-
return (
687-
<Revealer>
688-
<SimpleKeyValueList object={fieldContent} />
689-
</Revealer>
690-
);
686+
return formatObject(fieldContent);
691687
}
692688
return stacFormatter.format(fieldContent, column.fieldName);
693689
}
694690
};
695691

692+
const formatValue = value => {
693+
if (Array.isArray(value)) return value.join(", ");
694+
if (isObject(value)) return formatObject(value);
695+
return String(value);
696+
};
697+
698+
const formatObject = obj => {
699+
return Object.entries(obj)
700+
.map(([k, v]) => `${stacFormatter.label(k)}: ${formatValue(v)}`)
701+
.join(", ");
702+
};
703+
696704
const boldStyle = { root: { fontWeight: "bold" } };
697705
const gap4 = { childrenGap: 4 };

0 commit comments

Comments
 (0)