mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
refactor: Update CopilotActionProps and ExceptionActionProp interfaces
This commit is contained in:
parent
507b214cc1
commit
4b986346ae
@ -1,3 +1,4 @@
|
||||
export default interface ExceptionActionProp {
|
||||
exceptionFingerprint: string;
|
||||
fingerprint: string;
|
||||
message: string;
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
export default interface FileActionProp {
|
||||
filePath: string;
|
||||
startLineNumber: number;
|
||||
endLineNumber: number;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import FileActionProp from "./FileActionProp";
|
||||
import ExceptionActionProp from "./ExceptionActionProp";
|
||||
import SpanActionProp from "./SpanActionProp";
|
||||
import FunctionActionProp from "./FunctionActionProp";
|
||||
import CopilotActionType from "../CopilotActionType";
|
||||
|
||||
type CopilotActionProp =
|
||||
| DirectoryActionProp
|
||||
@ -11,4 +12,85 @@ type CopilotActionProp =
|
||||
| SpanActionProp
|
||||
| FunctionActionProp;
|
||||
|
||||
export enum CopilotActionPropType {
|
||||
Directory = "Directory",
|
||||
File = "File",
|
||||
Exception = "Exception",
|
||||
Span = "Span",
|
||||
Metric = "Metric",
|
||||
Function = "Function",
|
||||
}
|
||||
|
||||
export class CopilotActionPropUtil {
|
||||
public static getCopilotActionPropByActionType(actionType: CopilotActionType): CopilotActionPropType {
|
||||
|
||||
if(actionType === CopilotActionType.FIX_EXCEPTIONS){
|
||||
return CopilotActionPropType.Exception;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.FIX_PERFORMANCE_ISSUES){
|
||||
return CopilotActionPropType.Span;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.FIX_BUGS){
|
||||
return CopilotActionPropType.Function;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.IMPROVE_LOGS){
|
||||
return CopilotActionPropType.File;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.IMPROVE_SPANS){
|
||||
return CopilotActionPropType.Function;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.IMPROVE_METRICS){
|
||||
return CopilotActionPropType.Function;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.ADD_LOGS){
|
||||
return CopilotActionPropType.File;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.ADD_SPANS){
|
||||
return CopilotActionPropType.Function;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.ADD_METRICS){
|
||||
return CopilotActionPropType.Function;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.REFACTOR_CODE){
|
||||
return CopilotActionPropType.Function;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.WRITE_UNIT_TESTS){
|
||||
return CopilotActionPropType.Function;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.IMPROVE_UNIT_TESTS){
|
||||
return CopilotActionPropType.Function;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.IMPROVE_COMMENTS){
|
||||
return CopilotActionPropType.File;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.ADD_COMMENTS){
|
||||
return CopilotActionPropType.File;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.ADD_README){
|
||||
return CopilotActionPropType.Directory;
|
||||
}
|
||||
|
||||
if(actionType === CopilotActionType.IMRPOVE_README){
|
||||
return CopilotActionPropType.File;
|
||||
}
|
||||
|
||||
return CopilotActionPropType.File;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export default CopilotActionProp;
|
||||
|
@ -1,13 +1,27 @@
|
||||
enum CopilotActionType {
|
||||
|
||||
IMPROVE_COMMENTS = "Improve Comments",
|
||||
ADD_COMMENTS = "Add Comments",
|
||||
|
||||
IMRPOVE_README = "Improve Readme",
|
||||
ADD_README = "Add Readme",
|
||||
|
||||
FIX_GRAMMAR_AND_SPELLING = "Fix Grammar and Spelling",
|
||||
IMPROVE_VARIABLE_NAMES = "Improve Variable Names",
|
||||
REFACTOR_CODE = "Refactor Code",
|
||||
|
||||
WRITE_UNIT_TESTS = "Write Unit Tests",
|
||||
IMPROVE_UNIT_TESTS = "Improve Unit Tests",
|
||||
|
||||
IMPROVE_LOGS = "Improve Logs",
|
||||
ADD_LOGS = "Add Logs",
|
||||
|
||||
IMPROVE_SPANS = "Improve Spans",
|
||||
ADD_SPANS = "Add Spans",
|
||||
|
||||
IMPROVE_METRICS = "Improve Metrics",
|
||||
ADD_METRICS = "Add Metrics",
|
||||
|
||||
FIX_EXCEPTIONS = "Fix Exceptions",
|
||||
FIX_PERFORMANCE_ISSUES = "Fix Performance Issues",
|
||||
FIX_BUGS = "Fix Bugs",
|
||||
@ -40,22 +54,40 @@ export class CopilotActionTypeUtil {
|
||||
},
|
||||
|
||||
// Improve debugging.
|
||||
|
||||
// add logs, metircs and spans.
|
||||
|
||||
{
|
||||
type: CopilotActionType.ADD_LOGS,
|
||||
description: "Add OpenTelemetry logs in your codebase",
|
||||
defaultPriority: 2,
|
||||
},
|
||||
{
|
||||
type: CopilotActionType.ADD_SPANS,
|
||||
description: "Add OpenTelemetry spans in your codebase",
|
||||
defaultPriority: 2,
|
||||
},
|
||||
{
|
||||
type: CopilotActionType.ADD_METRICS,
|
||||
description: "Add OpenTelemetry metrics in your codebase",
|
||||
defaultPriority: 2,
|
||||
},
|
||||
{
|
||||
type: CopilotActionType.IMPROVE_LOGS,
|
||||
description:
|
||||
"Add and Improve OpenTelemetry logs in your codebase where required to make debugging easier.",
|
||||
"Improve OpenTelemetry logs in your codebase where required to make debugging easier.",
|
||||
defaultPriority: 2,
|
||||
},
|
||||
{
|
||||
type: CopilotActionType.IMPROVE_SPANS,
|
||||
description:
|
||||
"Add and Improve OpenTelemetry spans in your codebase where required to make debugging easier.",
|
||||
"Improve OpenTelemetry spans in your codebase where required to make debugging easier.",
|
||||
defaultPriority: 2,
|
||||
},
|
||||
{
|
||||
type: CopilotActionType.IMPROVE_METRICS,
|
||||
description:
|
||||
"Add and Improve OpenTelemetry metrics in your codebase where required to make debugging easier.",
|
||||
"Improve OpenTelemetry metrics in your codebase where required to make debugging easier.",
|
||||
defaultPriority: 2,
|
||||
},
|
||||
|
||||
@ -67,14 +99,31 @@ export class CopilotActionTypeUtil {
|
||||
},
|
||||
{
|
||||
type: CopilotActionType.WRITE_UNIT_TESTS,
|
||||
description: "Write unit tests",
|
||||
description: "Add unit tests",
|
||||
defaultPriority: 3,
|
||||
},
|
||||
{
|
||||
type: CopilotActionType.IMPROVE_UNIT_TESTS,
|
||||
description: "Improve unit tests",
|
||||
defaultPriority: 3,
|
||||
},
|
||||
|
||||
// add comments.
|
||||
{
|
||||
type: CopilotActionType.IMPROVE_COMMENTS,
|
||||
description: "Add or improve comments in your codebase",
|
||||
description: "Improve comments in your codebase",
|
||||
defaultPriority: 4,
|
||||
},
|
||||
{
|
||||
type: CopilotActionType.ADD_COMMENTS,
|
||||
description: "Add comments in your codebase",
|
||||
defaultPriority: 4,
|
||||
},
|
||||
|
||||
// Add or improve README file.
|
||||
{
|
||||
type: CopilotActionType.ADD_README,
|
||||
description: "Add a README file",
|
||||
defaultPriority: 4,
|
||||
},
|
||||
{
|
||||
|
@ -0,0 +1,93 @@
|
||||
import React, { FunctionComponent, ReactElement } from "react";
|
||||
import CopilotActionType from "Common/Types/Copilot/CopilotActionType";
|
||||
import CopilotActionProp, { CopilotActionPropType, CopilotActionPropUtil } from "Common/Types/Copilot/CopilotActionProps/Index";
|
||||
import DirectoryActionProp from "Common/Types/Copilot/CopilotActionProps/DirectoryActionProp";
|
||||
import FileActionProp from "Common/Types/Copilot/CopilotActionProps/FileActionProp";
|
||||
import SpanActionProp from "Common/Types/Copilot/CopilotActionProps/SpanActionProp";
|
||||
import TraceElement from "../../Traces/TraceElement";
|
||||
import TelemetryExceptionElement from "../../Exceptions/ExceptionElement";
|
||||
import ExceptionActionProp from "Common/Types/Copilot/CopilotActionProps/ExceptionActionProp";
|
||||
import FunctionActionProp from "Common/Types/Copilot/CopilotActionProps/FunctionActionProp";
|
||||
|
||||
export interface ComponentProps {
|
||||
actionType: CopilotActionType;
|
||||
actionProps: CopilotActionProp;
|
||||
}
|
||||
|
||||
const LabelElement: FunctionComponent<ComponentProps> = (
|
||||
props: ComponentProps,
|
||||
): ReactElement => {
|
||||
|
||||
const actionPropType: CopilotActionPropType = CopilotActionPropUtil.getCopilotActionPropByActionType(props.actionType);
|
||||
|
||||
if (actionPropType === CopilotActionPropType.Directory) {
|
||||
return <div>
|
||||
<p className="text-gray-900">
|
||||
Directory Path
|
||||
</p>
|
||||
<p>
|
||||
{(props.actionProps as DirectoryActionProp).directoryPath}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
if (actionPropType === CopilotActionPropType.File) {
|
||||
return <div>
|
||||
<p className="text-gray-900">
|
||||
File Path
|
||||
</p>
|
||||
<p>
|
||||
{(props.actionProps as FileActionProp).filePath}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
// exception
|
||||
|
||||
if (actionPropType === CopilotActionPropType.Exception) {
|
||||
return <div>
|
||||
<p className="text-gray-900">
|
||||
Exception
|
||||
</p>
|
||||
<p>
|
||||
<TelemetryExceptionElement message={(props.actionProps as ExceptionActionProp).message} fingerprint={
|
||||
(props.actionProps as ExceptionActionProp).fingerprint
|
||||
} />
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
if (actionPropType === CopilotActionPropType.Span) {
|
||||
return <div>
|
||||
<p className="text-gray-900">
|
||||
Trace ID
|
||||
</p>
|
||||
<p>
|
||||
<TraceElement traceId={(props.actionProps as SpanActionProp).traceId} />
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
if (actionPropType === CopilotActionPropType.Function) {
|
||||
return <div>
|
||||
<p className="text-gray-900">
|
||||
Details
|
||||
</p>
|
||||
<p>
|
||||
<p>
|
||||
{(props.actionProps as FunctionActionProp).functionName} function
|
||||
</p>
|
||||
<p>
|
||||
{(props.actionProps as FunctionActionProp).className && ` in ${(props.actionProps as FunctionActionProp).className} Class`}
|
||||
</p>
|
||||
<p>
|
||||
{(props.actionProps as FunctionActionProp).filePath && ` in ${(props.actionProps as FunctionActionProp).filePath} File`}
|
||||
</p>
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
return <>-</>;
|
||||
};
|
||||
|
||||
export default LabelElement;
|
@ -18,6 +18,7 @@ import Modal, { ModalWidth } from "Common/UI/Components/Modal/Modal";
|
||||
import SimpleLogViewer from "Common/UI/Components/SimpleLogViewer/SimpleLogViewer";
|
||||
import { ButtonStyleType } from "Common/UI/Components/Button/Button";
|
||||
import IconProp from "Common/Types/Icon/IconProp";
|
||||
import ServiceCatalogElement from "../../ServiceCatalog/ServiceElement";
|
||||
|
||||
export interface ComponentProps {
|
||||
query: Query<CopilotAction>;
|
||||
@ -52,6 +53,25 @@ const CopilotActionTable: FunctionComponent<ComponentProps> = (
|
||||
title: "Action Type",
|
||||
type: FieldType.Text,
|
||||
},
|
||||
{
|
||||
field: {
|
||||
serviceCatalog: {
|
||||
name: true,
|
||||
serviceColor: true
|
||||
},
|
||||
},
|
||||
title: "Service",
|
||||
type: FieldType.Element,
|
||||
getElement: (item: CopilotAction): ReactElement => {
|
||||
if (!item.serviceCatalog) {
|
||||
return <p>-</p>;
|
||||
}
|
||||
|
||||
return (
|
||||
<ServiceCatalogElement serviceCatalog={item.serviceCatalog} />
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: {
|
||||
createdAt: true,
|
||||
|
@ -1,19 +1,36 @@
|
||||
import Route from "Common/Types/API/Route";
|
||||
import IconProp from "Common/Types/Icon/IconProp";
|
||||
import Icon from "Common/UI/Components/Icon/Icon";
|
||||
import Link from "Common/UI/Components/Link/Link";
|
||||
import Tooltip from "Common/UI/Components/Tooltip/Tooltip";
|
||||
import { GetReactElementFunction } from "Common/UI/Types/FunctionTypes";
|
||||
import React, { FunctionComponent, ReactElement } from "react";
|
||||
import RouteMap, { RouteUtil } from "../../Utils/RouteMap";
|
||||
import PageMap from "../../Utils/PageMap";
|
||||
|
||||
export interface ComponentProps {
|
||||
message: string;
|
||||
isResolved: boolean;
|
||||
isArchived: boolean;
|
||||
isResolved?: boolean | undefined;
|
||||
isArchived?: boolean | undefined;
|
||||
fingerprint?: string | undefined;
|
||||
}
|
||||
|
||||
const TelemetryExceptionElement: FunctionComponent<ComponentProps> = (
|
||||
props: ComponentProps,
|
||||
): ReactElement => {
|
||||
|
||||
let viewRoute: Route = RouteUtil.populateRouteParams(
|
||||
RouteMap[PageMap.TELEMETRY_EXCEPTIONS_ROOT]!,
|
||||
);
|
||||
|
||||
const getResolvedIcon: GetReactElementFunction = (): ReactElement => {
|
||||
|
||||
|
||||
|
||||
if (props.isResolved === undefined) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
if (!props.isResolved) {
|
||||
return <></>;
|
||||
}
|
||||
@ -32,6 +49,11 @@ const TelemetryExceptionElement: FunctionComponent<ComponentProps> = (
|
||||
};
|
||||
|
||||
const getUnresolvedIcon: GetReactElementFunction = (): ReactElement => {
|
||||
|
||||
if (props.isResolved === undefined) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
if (!props.isResolved && !props.isArchived) {
|
||||
return (
|
||||
<Tooltip text="Unresolved Exception">
|
||||
@ -46,6 +68,11 @@ const TelemetryExceptionElement: FunctionComponent<ComponentProps> = (
|
||||
};
|
||||
|
||||
const getArchivedIcon: GetReactElementFunction = (): ReactElement => {
|
||||
|
||||
if (props.isArchived === undefined) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
if (!props.isArchived) {
|
||||
return <></>;
|
||||
}
|
||||
@ -64,7 +91,12 @@ const TelemetryExceptionElement: FunctionComponent<ComponentProps> = (
|
||||
{getResolvedIcon()}
|
||||
{getUnresolvedIcon()}
|
||||
{getArchivedIcon()}
|
||||
<div className="mt-0.5 ml-2 font-mono">{props.message || "-"}</div>
|
||||
{!props.fingerprint && <div className="mt-0.5 ml-2 font-mono">{props.message || "-"}</div>}
|
||||
{props.fingerprint && (
|
||||
<Link to={new Route(viewRoute.toString()).addRoute(props.fingerprint)}>
|
||||
<div className="mt-0.5 ml-2 font-mono">{props.message || props.fingerprint || "-"}</div>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user