refactor: Improve CopilotActionPropViewer component

This commit is contained in:
Simon Larsen 2024-09-03 16:15:50 +01:00
parent 9be38d55c6
commit 6a10bdff56
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
2 changed files with 30 additions and 13 deletions

View File

@ -20,7 +20,6 @@ export interface ComponentProps {
const CopilotActionPropViewer: FunctionComponent<ComponentProps> = (
props: ComponentProps,
): ReactElement => {
if (!props.actionProps) {
return <>-</>;
}
@ -31,8 +30,6 @@ const CopilotActionPropViewer: FunctionComponent<ComponentProps> = (
const actionPropType: CopilotActionPropType =
CopilotActionPropUtil.getCopilotActionPropByActionType(props.actionType);
if (actionPropType === CopilotActionPropType.Directory) {
return (
<div>
@ -58,11 +55,14 @@ const CopilotActionPropViewer: FunctionComponent<ComponentProps> = (
<div>
<p className="text-gray-900">Exception</p>
<p>
{(props.actionProps as ExceptionActionProp).fingerprint && <TelemetryExceptionElement
message={(props.actionProps as ExceptionActionProp).message}
fingerprint={(props.actionProps as ExceptionActionProp).fingerprint}
/>}
{(props.actionProps as ExceptionActionProp).fingerprint && (
<TelemetryExceptionElement
message={(props.actionProps as ExceptionActionProp).message}
fingerprint={
(props.actionProps as ExceptionActionProp).fingerprint
}
/>
)}
{!(props.actionProps as ExceptionActionProp).fingerprint && <p>-</p>}
</p>
@ -76,17 +76,18 @@ const CopilotActionPropViewer: FunctionComponent<ComponentProps> = (
<p className="text-gray-900">Trace ID</p>
<p>
{!(props.actionProps as SpanActionProp).traceId && <p>-</p>}
{(props.actionProps as SpanActionProp).traceId && <TraceElement
traceId={(props.actionProps as SpanActionProp).traceId}
/>}
{(props.actionProps as SpanActionProp).traceId && (
<TraceElement
traceId={(props.actionProps as SpanActionProp).traceId}
/>
)}
</p>
</div>
);
}
if (actionPropType === CopilotActionPropType.Function) {
if(!(props.actionProps as FunctionActionProp).functionName) {
if (!(props.actionProps as FunctionActionProp).functionName) {
return <>-</>;
}

View File

@ -19,6 +19,7 @@ import SimpleLogViewer from "Common/UI/Components/SimpleLogViewer/SimpleLogViewe
import { ButtonStyleType } from "Common/UI/Components/Button/Button";
import IconProp from "Common/Types/Icon/IconProp";
import ServiceCatalogElement from "../../ServiceCatalog/ServiceElement";
import CopilotActionPropViewer from "./CopilotActionPropViewer";
export interface ComponentProps {
query: Query<CopilotAction>;
@ -53,6 +54,21 @@ const CopilotActionTable: FunctionComponent<ComponentProps> = (
title: "Action Type",
type: FieldType.Text,
},
{
field: {
copilotActionProp: true,
},
title: "More Details",
type: FieldType.Element,
getElement: (item: CopilotAction): ReactElement => {
return (
<CopilotActionPropViewer
actionProps={item.copilotActionProp!}
actionType={item.copilotActionType!}
/>
);
},
},
{
field: {
serviceCatalog: {