Skip to content

Commit

Permalink
Merge pull request #2159 from Agenta-AI/AGE-1177/delete-trace-functio…
Browse files Browse the repository at this point in the history
…nality-does-not-work

(frontend)[Age 1177]: Delete trace functionality does not work
  • Loading branch information
mmabrouk authored Oct 31, 2024
2 parents 4aa05ed + c5b3a17 commit 378afa3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
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}`)
}

0 comments on commit 378afa3

Please sign in to comment.