+
+
State
+
+
+ {
+ setViewRawData(checked ? 'raw' : 'render');
+ }}
+ >
+
+
+
{stateData !== undefined && (
- {stateData !== undefined && (
-
- )}
+
{error && (
<>
Error
>
)}
- {resultData && (
+ {resultData && Object.keys(resultData).length > 0 && (
<>
-
Result
-
+
Result
+
+ >
+ )}
+ {inputs && Object.keys(inputs).length > 0 && (
+ <>
+
Input
+
+ >
+ )}
+
+ );
+};
+
+export const StateView = (props: {
+ stateData: DataType | undefined;
+ viewRawData: 'render' | 'raw';
+}) => {
+ const { stateData, viewRawData } = props;
+ return (
+ <>
+ {stateData !== undefined && viewRawData === 'render' &&
}
+ {stateData !== undefined && viewRawData === 'raw' && (
+
+ )}
+ >
+ );
+};
+
+export const ResultView = (props: {
+ resultData: DataType | undefined;
+ viewRawData: 'render' | 'raw';
+}) => {
+ const { resultData, viewRawData } = props;
+ return (
+ <>
+ {resultData && viewRawData === 'render' && (
+ <>
+
>
)}
- {Object.keys(inputs || {}).length > 0 && (
+ {resultData && viewRawData === 'raw' && (
<>
-
Inputs
-
+
>
)}
+ >
+ );
+};
+
+export const InputsView = (props: { inputs: object }) => {
+ const { inputs } = props;
+ return
;
+};
+
+type DataType = Record
;
+
+interface FormRendererProps {
+ data: Record;
+}
+
+const Header = (props: {
+ name: string;
+ isExpanded: boolean;
+ setExpanded: (expanded: boolean) => void;
+}) => {
+ const MinimizeMaximizeIcon = props.isExpanded ? ChevronUpIcon : ChevronDownIcon;
+
+ return (
+
+
{props.name}
+ {
+ props.setExpanded(!props.isExpanded);
+ }}
+ />
);
};
+const RenderedField = (props: {
+ value: string | number | boolean | object;
+ keyName: string;
+ level: number;
+}) => {
+ const [isExpanded, setExpanded] = useState(true);
+ // TODO: have max level depth.
+ const { value, keyName: key, level } = props;
+ const bodyClassNames =
+ 'border-gray-100 border-l-[8px] pl-1 hover:bg-gray-100 text-sm text-gray-700';
+ if (key.startsWith('__')) {
+ return null;
+ }
+ return (
+ <>
+
+ {isExpanded &&
+ (typeof value === 'string' ? (
+
+ ) : Array.isArray(value) ? (
+
+
+ {value.map((v, i) => {
+ return (
+
+
+
+ );
+ })}
+
+
+ ) : typeof value === 'object' ? (
+
+
+ {value === null ? (
+
NULL
+ ) : (
+ Object.entries(value).map(([k, v]) => {
+ return (
+
+
+
+ );
+ })
+ )}
+
+
+ ) : value === null ? (
+
+ ) : (
+
+ ))}
+ >
+ );
+};
+
+// This component is used to render the form data in a structured way
+const FormRenderer: React.FC = ({ data }) => {
+ if (data !== null) {
+ return (
+ <>
+ {Object.entries(data).map(([key, value]) => {
+ return ;
+ })}
+ >
+ );
+ }
+ return null;
+};
+
+export default FormRenderer;
diff --git a/telemetry/ui/src/components/routes/app/StateMachine.tsx b/telemetry/ui/src/components/routes/app/StateMachine.tsx
index b2b6901e..25745c23 100644
--- a/telemetry/ui/src/components/routes/app/StateMachine.tsx
+++ b/telemetry/ui/src/components/routes/app/StateMachine.tsx
@@ -31,7 +31,7 @@ export const AppStateView = (props: {
return (
<>
-
+
{currentTab === 'graph' && (