()
| 237 | } |
| 238 | |
| 239 | const exportTool = async () => { |
| 240 | try { |
| 241 | const toolResp = await toolsApi.getSpecificTool(toolId) |
| 242 | if (toolResp.data) { |
| 243 | const toolData = toolResp.data |
| 244 | delete toolData.id |
| 245 | delete toolData.createdDate |
| 246 | delete toolData.updatedDate |
| 247 | let dataStr = JSON.stringify(toolData, null, 2) |
| 248 | //let dataUri = 'data:application/json;charset=utf-8,' + encodeURIComponent(dataStr) |
| 249 | const blob = new Blob([dataStr], { type: 'application/json' }) |
| 250 | const dataUri = URL.createObjectURL(blob) |
| 251 | |
| 252 | let exportFileDefaultName = `${toolName}-CustomTool.json` |
| 253 | |
| 254 | let linkElement = document.createElement('a') |
| 255 | linkElement.setAttribute('href', dataUri) |
| 256 | linkElement.setAttribute('download', exportFileDefaultName) |
| 257 | linkElement.click() |
| 258 | } |
| 259 | } catch (error) { |
| 260 | enqueueSnackbar({ |
| 261 | message: `Failed to export Tool: ${ |
| 262 | typeof error.response.data === 'object' ? error.response.data.message : error.response.data |
| 263 | }`, |
| 264 | options: { |
| 265 | key: new Date().getTime() + Math.random(), |
| 266 | variant: 'error', |
| 267 | persist: true, |
| 268 | action: (key) => ( |
| 269 | <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}> |
| 270 | <IconX /> |
| 271 | </Button> |
| 272 | ) |
| 273 | } |
| 274 | }) |
| 275 | onCancel() |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | const addNewTool = async () => { |
| 280 | try { |
no test coverage detected