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

Function contextMenuHandler

src/pages/fileBrowser/fileBrowser.js:915–1021  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

913 }
914
915 async function contextMenuHandler() {
916 if (appSettings.value.vibrateOnTap) {
917 navigator.vibrate(config.VIBRATION_TIME);
918 }
919 if ($el.getAttribute("open-doc") === "true") return;
920
921 const deleteText =
922 currentDir.url === "/" ? strings.remove : strings.delete;
923 const options = [
924 ["delete", deleteText, "delete"],
925 ["rename", strings.rename, "text_format"],
926 ];
927
928 if (/s?ftp/.test(storageType)) {
929 options.push(["edit", strings.edit, "edit"]);
930 }
931
932 if (helpers.isFile(type)) {
933 options.push(["info", strings.info, "info"]);
934 options.push(["open_with", strings["open with"], "open_in_browser"]);
935 }
936
937 if (currentDir.url !== "/" && url) {
938 options.push(["copyuri", strings["copy uri"], "copy"]);
939 }
940
941 const option = await select(strings["select"], options);
942 switch (option) {
943 case "delete": {
944 let deleteFunction = removeFile;
945 let message = strings["delete entry"].replace("{name}", name);
946 if (uuid) {
947 deleteFunction = removeStorage;
948 message = strings["remove entry"].replace("{name}", name);
949 }
950
951 const confirmation = await confirm(strings.warning, message);
952 if (!confirmation) break;
953 deleteFunction();
954 break;
955 }
956
957 case "rename": {
958 let newname = await prompt(strings.rename, name, "text", {
959 match: config.FILE_NAME_REGEX,
960 });
961
962 newname = helpers.fixFilename(newname);
963 if (!newname || newname === name) break;
964
965 if (uuid) renameStorage(newname);
966 else renameFile(newname);
967 break;
968 }
969
970 case "edit": {
971 const storage = await remoteStorage.edit(
972 storageList.find((storage) => storage.uuid === uuid),

Callers 1

handleClickFunction · 0.85

Calls 13

confirmFunction · 0.85
renameStorageFunction · 0.85
updateStorageFunction · 0.85
alertFunction · 0.85
getShareableUriFunction · 0.85
writeTextMethod · 0.80
renameFileFunction · 0.70
execMethod · 0.65
copyMethod · 0.65
fileActionMethod · 0.65
selectFunction · 0.50
promptFunction · 0.50

Tested by

no test coverage detected