diff --git a/telemetry/ui/src/components/routes/app/DataView.tsx b/telemetry/ui/src/components/routes/app/DataView.tsx index 3ca43c99..dee2afb6 100644 --- a/telemetry/ui/src/components/routes/app/DataView.tsx +++ b/telemetry/ui/src/components/routes/app/DataView.tsx @@ -1,3 +1,4 @@ +import React from 'react'; import { Step } from '../../../api'; import JsonView from '@uiw/react-json-view'; import { Button } from '../../common/button'; @@ -22,6 +23,7 @@ export const DataView = (props: { currentStep: Step | undefined; priorStep: Step const resultData = stepToExamine?.step_end_log?.result; const inputs = stepToExamine?.step_start_log?.inputs; const error = props.currentStep?.step_end_log?.exception; + const [viewRawData, setViewRawData] = useState<'raw' | 'render'>('render'); return (
@@ -29,13 +31,29 @@ export const DataView = (props: { currentStep: Step | undefined; priorStep: Step

State

{stateData !== undefined && ( - { - setWhichState('after'); - }} - /> + <> + { + setViewRawData('raw'); + }} + /> + { + setViewRawData('render'); + }} + /> + { + setWhichState('after'); + }} + /> + )} { @@ -50,7 +68,11 @@ export const DataView = (props: { currentStep: Step | undefined; priorStep: Step
- {stateData !== undefined && ( + {stateData !== undefined && viewRawData === 'render' && ( + // + + )} + {stateData !== undefined && viewRawData === 'raw' && ( )} {error && ( @@ -74,3 +96,36 @@ export const DataView = (props: { currentStep: Step | undefined; priorStep: Step ); }; + +interface FormRendererProps { + data: Record; +} +const FormRenderer: React.FC = ({ data }) => { + const renderField = (value: string | number | boolean | object, key: string) => { + if (typeof value === 'string') { + return ( +
+ +
+
{value}
+
+ ); + } else { + return ( +
+ +
+ {value.toString()} +
+ ); + } + }; + + const renderFields = () => { + return Object.entries(data).map(([key, value]) => renderField(value, key)); + }; + + return
{renderFields()}
; +}; + +export default FormRenderer;