Skip to content

Commit 6389fc6

Browse files
authored
feat: Add info panel keyValue item parameter isRelativeUrl to link to dashboard pages (#2646)
1 parent 243e92c commit 6389fc6

File tree

4 files changed

+44
-10
lines changed

4 files changed

+44
-10
lines changed

README.md

+39-7
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Parse Dashboard is a standalone dashboard for managing your [Parse Server](https
7171
- [Video Item](#video-item)
7272
- [Audio Item](#audio-item)
7373
- [Button Item](#button-item)
74+
- [Panel Item](#panel-item)
7475
- [Browse as User](#browse-as-user)
7576
- [Change Pointer Key](#change-pointer-key)
7677
- [Limitations](#limitations)
@@ -929,12 +930,13 @@ Example:
929930

930931
A text item that consists of a key and a value. The value can optionally be linked to a URL.
931932

932-
| Parameter | Value | Optional | Description |
933-
|-----------|--------|----------|-----------------------------------------------------------------------------------|
934-
| `type` | String | No | Must be `"keyValue"`. |
935-
| `key` | String | No | The key text to display. |
936-
| `value` | String | No | The value text to display. |
937-
| `url` | String | Yes | The URL that will be opened in a new browser tab when clicking on the value text. |
933+
| Parameter | Value | Default | Optional | Description |
934+
|-----------------|---------|-------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
935+
| `type` | String | - | No | Must be `"keyValue"`. |
936+
| `key` | String | - | No | The key text to display. |
937+
| `value` | String | - | No | The value text to display. |
938+
| `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>/`. |
939+
| `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>/`. |
938940

939941
Examples:
940942

@@ -951,7 +953,17 @@ Examples:
951953
"type": "keyValue",
952954
"key": "Last purchase ID",
953955
"value": "123",
954-
"url": "https://example.com/purchaseDetails?purchaseId=012345"
956+
"url": "https://example.com/purchaseDetails?purchaseId=123"
957+
}
958+
```
959+
960+
```json
961+
{
962+
"type": "keyValue",
963+
"key": "Last purchase ID",
964+
"value": "123",
965+
"url": "browser/_User",
966+
"isRelativeUrl": true
955967
}
956968
```
957969

@@ -1082,6 +1094,26 @@ Example:
10821094
}
10831095
```
10841096

1097+
#### Panel Item
1098+
1099+
A sub-panel whose data is loaded on-demand by expanding the item.
1100+
1101+
| Parameter | Value | Optional | Description |
1102+
|---------------------|--------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------|
1103+
| `type` | String | No | Must be `"infoPanel"`. |
1104+
| `title` | String | No | The title to display in the expandable headline. |
1105+
| `cloudCodeFunction` | String | No | The Cloud Code Function to call which receives the selected object in the data browser and returns the response to be displayed in the sub-panel. |
1106+
1107+
Example:
1108+
1109+
```json
1110+
{
1111+
"type": "panel",
1112+
"text": "Purchase History",
1113+
"cloudCodeFunction": "getUserPurchaseHistory"
1114+
}
1115+
```
1116+
10851117
## Browse as User
10861118

10871119
▶️ *Core > Browser > Browse*

src/components/AggregationPanel/AggregationPanel.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const AggregationPanel = ({
2121
showNote,
2222
setSelectedObjectId,
2323
selectedObjectId,
24+
appName,
2425
depth = 0,
2526
cloudCodeFunction = null,
2627
panelTitle = null,
@@ -89,7 +90,7 @@ const AggregationPanel = ({
8990
case 'text':
9091
return <TextElement key={idx} text={item.text} />;
9192
case 'keyValue':
92-
return <KeyValueElement key={idx} item={item} />;
93+
return <KeyValueElement key={idx} item={item} appName={appName} />;
9394
case 'table':
9495
return <TableElement key={idx} columns={item.columns} rows={item.rows} />;
9596
case 'image':

src/components/AggregationPanel/AggregationPanelComponents.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ export const TextElement = ({ text }) => (
99
);
1010

1111
// Key-Value Element Component
12-
export const KeyValueElement = ({ item }) => (
12+
export const KeyValueElement = ({ item, appName }) => (
1313
<div className={styles.keyValue}>
1414
{item.key}:
15-
{item.url ? <a href={item.url} target="_blank">{item.value}</a> : <span>{item.value}</span>}
15+
{item.url ? <a href={item.isRelativeUrl ? `apps/${appName}/${item.url}` : item.url} target="_blank">{item.value}</a> : <span>{item.value}</span>}
1616
</div>
1717
);
1818

src/dashboard/Data/Browser/DataBrowser.react.js

+1
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ export default class DataBrowser extends React.Component {
609609
setErrorAggregatedData={this.props.setErrorAggregatedData}
610610
setSelectedObjectId={this.setSelectedObjectId}
611611
selectedObjectId={this.state.selectedObjectId}
612+
appName = {this.props.appName}
612613
/>
613614
</div>
614615
</ResizableBox>

0 commit comments

Comments
 (0)