Skip to content

Commit 9de68b7

Browse files
committed
feat: support multiple key value entries
1 parent 487adcb commit 9de68b7

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,8 @@ A text item that consists of a key and a value. The value can optionally be link
946946
|-----------------|---------|-------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
947947
| `type` | String | - | No | Must be `"keyValue"`. |
948948
| `key` | String | - | No | The key text to display. |
949-
| `value` | String | - | No | The value text to display. |
949+
| `value` | String | Array | - | No | The value text to display. Can be an array of values. |
950+
| `values` | Array | - | Yes | Additional values to display after `value`. Each item is an object with `value`, optional `url` and `isRelativeUrl`. |
950951
| `url` | String | `undefined` | Yes | The URL that will be opened in a new browser tab when clicking on the value text. It can be set to an absolute URL or a relative URL in which case the base URL is `<PROTOCOL>://<HOST>/<MOUNT_PATH>/`. |
951952
| `isRelativeUrl` | Boolean | `false` | Yes | Set this to `true` when linking to another dashboard page, in which case the base URL for the relative URL will be `<PROTOCOL>://<HOST>/<MOUNT_PATH>/apps/<APP_NAME>/`. |
952953
| `style` | Object | - | Yes | The CSS style definition. |
@@ -980,6 +981,17 @@ Examples:
980981
"isRelativeUrl": true
981982
}
982983
```
984+
```json
985+
{
986+
"type": "keyValue",
987+
"key": "Purchase Value",
988+
"value": "123",
989+
"url": "browser/Purchase",
990+
"isRelativeUrl": true,
991+
"values": [{ "value": "456" }]
992+
}
993+
```
994+
983995

984996
To navigate to a specific object using a relative URL, the query parameters must be URL encoded:
985997

@@ -1207,4 +1219,4 @@ As of April 5, 2017, Parse, LLC has transferred this code to the parse-community
12071219

12081220
[license-svg]: https://img.shields.io/badge/license-BSD-lightgrey.svg
12091221
[license-link]: LICENSE
1210-
[open-collective-link]: https://opencollective.com/parse-server
1222+
[open-collective-link]: https://opencollective.com/parse-server

src/components/AggregationPanel/AggregationPanelComponents.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,31 @@ export const TextElement = ({ text, style }) => (
1212

1313
// Key-Value Element Component
1414
export const KeyValueElement = ({ item, appName, style, showNote }) => {
15-
const values = Array.isArray(item.values)
16-
? [{ value: item.value, url: item.url, isRelativeUrl: item.isRelativeUrl }, ...item.values]
17-
: [{ value: item.value, url: item.url, isRelativeUrl: item.isRelativeUrl }];
15+
let values = [];
16+
17+
if (Array.isArray(item.value)) {
18+
values = item.value.map((val, idx) => ({
19+
value: val,
20+
url: Array.isArray(item.url) ? item.url[idx] : item.url,
21+
isRelativeUrl: Array.isArray(item.isRelativeUrl) ? item.isRelativeUrl[idx] : item.isRelativeUrl,
22+
}));
23+
} else {
24+
values = [
25+
{
26+
value: item.value,
27+
url: Array.isArray(item.url) ? item.url[0] : item.url,
28+
isRelativeUrl: Array.isArray(item.isRelativeUrl) ? item.isRelativeUrl[0] : item.isRelativeUrl,
29+
},
30+
];
31+
}
32+
33+
if (Array.isArray(item.values)) {
34+
values = values.concat(item.values);
35+
}
1836

1937
const handleCopy = () => {
20-
copy(String(item.value));
38+
const copyValue = Array.isArray(item.value) ? item.value[0] : item.value;
39+
copy(String(copyValue));
2140
if (showNote) {
2241
showNote('Value copied to clipboard', false);
2342
}

0 commit comments

Comments
 (0)