()
| 367 | } |
| 368 | |
| 369 | const deleteTool = async () => { |
| 370 | const confirmPayload = { |
| 371 | title: `Delete Tool`, |
| 372 | description: `Delete tool ${toolName}?`, |
| 373 | confirmButtonName: 'Delete', |
| 374 | cancelButtonName: 'Cancel' |
| 375 | } |
| 376 | const isConfirmed = await confirm(confirmPayload) |
| 377 | |
| 378 | if (isConfirmed) { |
| 379 | try { |
| 380 | const delResp = await toolsApi.deleteTool(toolId) |
| 381 | if (delResp.data) { |
| 382 | enqueueSnackbar({ |
| 383 | message: 'Tool deleted', |
| 384 | options: { |
| 385 | key: new Date().getTime() + Math.random(), |
| 386 | variant: 'success', |
| 387 | action: (key) => ( |
| 388 | <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}> |
| 389 | <IconX /> |
| 390 | </Button> |
| 391 | ) |
| 392 | } |
| 393 | }) |
| 394 | onConfirm() |
| 395 | } |
| 396 | } catch (error) { |
| 397 | enqueueSnackbar({ |
| 398 | message: `Failed to delete Tool: ${ |
| 399 | typeof error.response.data === 'object' ? error.response.data.message : error.response.data |
| 400 | }`, |
| 401 | options: { |
| 402 | key: new Date().getTime() + Math.random(), |
| 403 | variant: 'error', |
| 404 | persist: true, |
| 405 | action: (key) => ( |
| 406 | <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}> |
| 407 | <IconX /> |
| 408 | </Button> |
| 409 | ) |
| 410 | } |
| 411 | }) |
| 412 | onCancel() |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | const handlePastedJSON = (formattedData) => { |
| 418 | setToolSchema(formattedData) |
no test coverage detected