Skip to content

Commit a8f110e

Browse files
authored
feat: Add additional values in info panel key-value element (#2904)
1 parent 4564a25 commit a8f110e

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,7 @@ A text item that consists of a key and a value. The value can optionally be link
949949
| `value` | String | - | No | The value text to display. |
950950
| `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>/`. |
951951
| `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>/`. |
952+
| `values` | Array | - | Yes | Additional values to display after `value`. Each item is an object with `value`, optional `url` and `isRelativeUrl`. |
952953
| `style` | Object | - | Yes | The CSS style definition. |
953954

954955
Examples:
@@ -981,6 +982,17 @@ Examples:
981982
}
982983
```
983984

985+
```json
986+
{
987+
"type": "keyValue",
988+
"key": "Purchase Value",
989+
"value": "123",
990+
"url": "browser/Purchase",
991+
"isRelativeUrl": true,
992+
"values": [{ "value": "456" }]
993+
}
994+
```
995+
984996
To navigate to a specific object using a relative URL, the query parameters must be URL encoded:
985997

986998
```js
@@ -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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,46 @@ import Icon from 'components/Icon/Icon.react';
44
import styles from './AggregationPanel.scss';
55

66
// Text Element Component
7-
export const TextElement = ({ text, style}) => (
7+
export const TextElement = ({ text, style }) => (
88
<div className="text-element" style={style}>
99
<p>{text}</p>
1010
</div>
1111
);
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 }];
18+
1519
const handleCopy = () => {
1620
copy(String(item.value));
1721
if (showNote) {
1822
showNote('Value copied to clipboard', false);
1923
}
2024
};
2125

26+
const renderValue = ({ value, url, isRelativeUrl }) => {
27+
if (url) {
28+
return (
29+
<a href={isRelativeUrl ? `apps/${appName}/${url}` : url} target="_blank" rel="noreferrer">
30+
{value}
31+
</a>
32+
);
33+
}
34+
35+
return <span>{value}</span>;
36+
};
37+
2238
return (
2339
<div className={styles.keyValue} style={style}>
2440
{item.key}:
25-
{item.url ? (
26-
<a href={item.isRelativeUrl ? `apps/${appName}/${item.url}` : item.url} target="_blank" rel="noreferrer">
27-
{item.value}
28-
</a>
29-
) : (
30-
<span>{item.value}</span>
31-
)}
41+
{values.map((val, idx) => (
42+
<React.Fragment key={idx}>
43+
{idx > 0 && ' '}
44+
{renderValue(val)}
45+
</React.Fragment>
46+
))}
3247
<span className={styles.copyIcon} onClick={handleCopy}>
3348
<Icon name="clone-icon" width={12} height={12} fill="currentColor" />
3449
</span>

0 commit comments

Comments
 (0)