Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(frontend)[Age 1177]: Delete trace functionality does not work #2159

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,20 +1,43 @@
import {useObservabilityData} from "@/contexts/observability.context"
import {deleteTrace} from "@/services/observability/core"
import {DeleteOutlined} from "@ant-design/icons"
import {Modal} from "antd"
import React from "react"
import React, {useState} from "react"

type DeleteTraceModalProps = {
setSelectedTraceId: (val: string) => void
activeTraceNodeId: string
} & React.ComponentProps<typeof Modal>

const DeleteTraceModal = ({setSelectedTraceId, ...props}: DeleteTraceModalProps) => {
const DeleteTraceModal = ({
setSelectedTraceId,
activeTraceNodeId,
...props
}: DeleteTraceModalProps) => {
const {fetchTraces} = useObservabilityData()
const [isLoading, setIsLoading] = useState(false)

const handleDelete = async () => {
try {
setIsLoading(true)
await deleteTrace(activeTraceNodeId)
fetchTraces()
setSelectedTraceId("")
} catch (error) {
console.error(error)
} finally {
setIsLoading(false)
}
}
return (
<Modal
centered
destroyOnClose
width={380}
title={"Are you sure you want to delete?"}
okButtonProps={{icon: <DeleteOutlined />, danger: true}}
okButtonProps={{icon: <DeleteOutlined />, danger: true, loading: isLoading}}
okText={"Delete"}
onOk={handleDelete}
{...props}
>
This action is not reversible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const TraceHeader = ({
<DeleteTraceModal
open={isDeleteModalOpen}
onCancel={() => setIsDeleteModalOpen(false)}
onOk={() => setSelectedTraceId("")}
activeTraceNodeId={activeTrace.node.id}
setSelectedTraceId={setSelectedTraceId}
/>
</>
Expand Down
4 changes: 4 additions & 0 deletions agenta-web/src/services/observability/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ export const fetchAllTraces = async ({appId, queries}: {appId: string; queries?:
)
return response.data
}

export const deleteTrace = async (nodeId: string) => {
return axios.delete(`${getAgentaApiUrl()}/api/observability/v1/traces?node_id=${nodeId}`)
}