MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / execOperation

Function execOperation

src/lib/openFolder.js:424–946  ·  view source on GitHub ↗

* @param {"dir"|"file"|"root"} type * @param {"copy"|"cut"|"delete"|"rename"|"paste"|"new file"|"new folder"|"cancel"|"open-folder"|"install-plugin"} action * @param {string} url target url * @param {HTMLElement} $target target element * @param {string} name Name of file or folder

(type, action, url, $target, name)

Source from the content-addressed store, hash-verified

422 * @param {string} name Name of file or folder
423 */
424function execOperation(type, action, url, $target, name) {
425 const { clipBoard, $node, remove, url: rootUrl } = openFolder.find(url);
426 const startLoading = () => $node.$title.classList.add("loading");
427 const stopLoading = () => $node.$title.classList.remove("loading");
428
429 switch (action) {
430 case "copy":
431 case "cut":
432 return clipBoardAction();
433
434 case "delete":
435 return deleteFile();
436
437 case "rename":
438 return renameFile();
439
440 case "paste":
441 return paste();
442
443 case "new file":
444 case "new folder":
445 return createNew();
446
447 case "cancel":
448 return cancelAction();
449
450 case "open-folder":
451 return open();
452
453 case "insert-file":
454 return insertFile();
455
456 case "close":
457 return remove();
458
459 case "install-plugin":
460 return installPlugin();
461
462 case "open-in-terminal":
463 return openInTerminal();
464
465 case "copy-relative-path":
466 return copyRelativePath();
467 }
468
469 async function installPlugin() {
470 try {
471 const manifest = JSON.parse(
472 await fsOperation(
473 Url.dirname(url) + ACODE_PLUGIN_MANIFEST_FILE,
474 ).readFile("utf8"),
475 );
476 const { default: installPlugin } = await import("lib/installPlugin");
477 await installPlugin(url, manifest.name);
478 toast(strings["success"], 3000);
479 } catch (error) {
480 helpers.error(error);
481 console.error(error);

Callers 1

handleContextmenuFunction · 0.85

Calls 12

clipBoardActionFunction · 0.85
createNewFunction · 0.85
cancelActionFunction · 0.85
insertFileFunction · 0.85
openInTerminalFunction · 0.85
copyRelativePathFunction · 0.85
deleteFileFunction · 0.70
renameFileFunction · 0.70
pasteFunction · 0.70
openFunction · 0.70
removeFunction · 0.70
installPluginFunction · 0.70

Tested by

no test coverage detected