Skip to content

Commit 47c2bc8

Browse files
koonpengmxgrey
andauthored
Add help text (#115)
Signed-off-by: Teo Koon Peng <[email protected]> Signed-off-by: Michael X. Grey <[email protected]> Co-authored-by: Grey <[email protected]>
1 parent 07617c9 commit 47c2bc8

File tree

8 files changed

+398
-28
lines changed

8 files changed

+398
-28
lines changed

diagram-editor/frontend/api.preprocessed.schema.json

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,22 @@
114114
}
115115
]
116116
},
117+
"ConfigExample": {
118+
"properties": {
119+
"config": {
120+
"description": "The value of the config"
121+
},
122+
"description": {
123+
"description": "A description of what this config is for",
124+
"type": "string"
125+
}
126+
},
127+
"required": [
128+
"description",
129+
"config"
130+
],
131+
"type": "object"
132+
},
117133
"DebugSessionMessage": {
118134
"oneOf": [
119135
{
@@ -780,6 +796,18 @@
780796
"description": "If the user does not specify a default display text, the node ID will\n be used here.",
781797
"type": "string"
782798
},
799+
"description": {
800+
"type": [
801+
"string",
802+
"null"
803+
]
804+
},
805+
"example_configs": {
806+
"items": {
807+
"$ref": "#/$defs/ConfigExample"
808+
},
809+
"type": "array"
810+
},
783811
"request": {
784812
"type": "string"
785813
},
@@ -798,7 +826,8 @@
798826
"request",
799827
"response",
800828
"streams",
801-
"config_schema"
829+
"config_schema",
830+
"example_configs"
802831
],
803832
"type": "object"
804833
},
@@ -1027,14 +1056,27 @@
10271056
"default_display_text": {
10281057
"type": "string"
10291058
},
1059+
"description": {
1060+
"type": [
1061+
"string",
1062+
"null"
1063+
]
1064+
},
1065+
"example_configs": {
1066+
"items": {
1067+
"$ref": "#/$defs/ConfigExample"
1068+
},
1069+
"type": "array"
1070+
},
10301071
"metadata": {
10311072
"$ref": "#/$defs/SectionMetadata"
10321073
}
10331074
},
10341075
"required": [
10351076
"default_display_text",
10361077
"metadata",
1037-
"config_schema"
1078+
"config_schema",
1079+
"example_configs"
10381080
],
10391081
"type": "object"
10401082
},

diagram-editor/frontend/forms/node-form.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
import { Autocomplete, TextField } from '@mui/material';
1+
import {
2+
Autocomplete,
3+
Box,
4+
ListItem,
5+
Stack,
6+
TextField,
7+
Tooltip,
8+
} from '@mui/material';
29
import { useMemo, useState } from 'react';
10+
import { MaterialSymbol } from '../nodes';
311
import { useRegistry } from '../registry-provider';
412
import BaseEditOperationForm, {
513
type BaseEditOperationFormProps,
@@ -60,6 +68,25 @@ function NodeForm(props: NodeFormProps) {
6068
renderInput={(params) => (
6169
<TextField {...params} required label="Builder" />
6270
)}
71+
renderOption={({ key, ...otherProps }, value) => {
72+
const nodeMetadata = registry.nodes[value];
73+
return (
74+
<ListItem key={key} {...otherProps}>
75+
<Stack
76+
direction="row"
77+
justifyContent="space-between"
78+
width="100%"
79+
>
80+
<span>{value}</span>
81+
{nodeMetadata?.description && (
82+
<Tooltip title={nodeMetadata.description}>
83+
<MaterialSymbol symbol="info" />
84+
</Tooltip>
85+
)}
86+
</Stack>
87+
</ListItem>
88+
);
89+
}}
6390
/>
6491
<TextField
6592
multiline

diagram-editor/frontend/nodes/icons.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ export interface MaterialSymbolProps extends BoxProps {
99

1010
export function MaterialSymbol({
1111
symbol,
12+
className,
1213
...otherProps
1314
}: MaterialSymbolProps): React.JSX.Element {
1415
return (
15-
<Box component="span" className="material-symbols-outlined" {...otherProps}>
16+
<Box
17+
component="span"
18+
className={`material-symbols-outlined ${className}`}
19+
{...otherProps}
20+
>
1621
{symbol}
1722
</Box>
1823
);

diagram-editor/frontend/types/api.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,23 @@ export interface BufferSettings {
352352
retention: RetentionPolicy;
353353
[k: string]: unknown;
354354
}
355+
/**
356+
* This interface was referenced by `DiagramEditorApi`'s JSON-Schema
357+
* via the `definition` "ConfigExample".
358+
*/
359+
export interface ConfigExample {
360+
/**
361+
* The value of the config
362+
*/
363+
config: {
364+
[k: string]: unknown;
365+
};
366+
/**
367+
* A description of what this config is for
368+
*/
369+
description: string;
370+
[k: string]: unknown;
371+
}
355372
/**
356373
* This interface was referenced by `DiagramEditorApi`'s JSON-Schema
357374
* via the `definition` "Diagram".
@@ -1111,6 +1128,8 @@ export interface NodeRegistration {
11111128
* be used here.
11121129
*/
11131130
default_display_text: string;
1131+
description?: string | null;
1132+
example_configs: ConfigExample[];
11141133
request: string;
11151134
response: string;
11161135
streams: {
@@ -1125,6 +1144,8 @@ export interface NodeRegistration {
11251144
export interface SectionRegistration {
11261145
config_schema: Schema;
11271146
default_display_text: string;
1147+
description?: string | null;
1148+
example_configs: ConfigExample[];
11281149
metadata: SectionMetadata;
11291150
[k: string]: unknown;
11301151
}

examples/diagram/calculator/diagrams/split_and_join.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
"type": "node",
99
"builder": "mul",
1010
"next": "a00aa305-9763-4602-b638-6cb190e6c452",
11-
"config": 10
11+
"config": 100,
12+
"display_text": "x100"
1213
},
1314
"fee7f385-2a74-4a87-b8a7-87b8bd03fdf8": {
1415
"type": "node",
1516
"builder": "add",
1617
"next": {
1718
"builtin": "terminate"
18-
}
19+
},
20+
"display_text": "sum"
1921
},
2022
"31fb7423-5300-447a-b259-49c5c79654e7": {
2123
"type": "join",
@@ -29,7 +31,8 @@
2931
"type": "node",
3032
"builder": "mul",
3133
"next": "305f46be-cf0d-42ac-bd28-26d63746abc3",
32-
"config": 100
34+
"config": 10,
35+
"display_text": "x10"
3336
},
3437
"74764679-1f94-49f3-8080-259e57f78be9": {
3538
"type": "split",

0 commit comments

Comments
 (0)