MCPcopy
hub / github.com/FlowiseAI/Flowise / exportTool

Function exportTool

packages/ui/src/views/tools/ToolDialog.jsx:239–277  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 {

Callers 1

ToolDialogFunction · 0.85

Calls 5

enqueueSnackbarFunction · 0.90
closeSnackbarFunction · 0.90
onCancelFunction · 0.85
stringifyMethod · 0.80
getTimeMethod · 0.45

Tested by

no test coverage detected