MCPcopy Create free account
hub / github.com/error311/FileRise / folderManagerContextMenuHandler

Function folderManagerContextMenuHandler

public/js/folderManager.js:3392–3448  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

3390});
3391
3392async function folderManagerContextMenuHandler(e) {
3393 const target = e.target.closest('.folder-option, .breadcrumb-link');
3394 if (!target) return;
3395 e.preventDefault();
3396 e.stopPropagation();
3397
3398 // Defensive: some browsers can blank unrelated inline SVGs when a context menu opens.
3399 // Kick a best-effort repair immediately (before any async awaits) and let the menu helper
3400 // schedule additional passes after paint.
3401 try {
3402 queueMicrotask(() => { try { repairBlankFolderIcons({ force: true }); } catch (e) {} });
3403 } catch (e) { /* ignore */ }
3404
3405 // Toggle-only for locked nodes (no menu)
3406 if (target.classList && target.classList.contains('locked')) {
3407 const folder = target.getAttribute('data-folder') || '';
3408 const ul = getULForFolder(folder);
3409 if (ul) {
3410 const willExpand = !ul.classList.contains('expanded');
3411 ul.classList.toggle('expanded', willExpand);
3412 ul.classList.toggle('collapsed', !willExpand);
3413 const li = target.closest('li[role="treeitem"]');
3414 if (li) li.setAttribute('aria-expanded', String(willExpand));
3415 const st = loadFolderTreeState(); st[folder] = willExpand ? 'block' : 'none'; saveFolderTreeState(st);
3416 if (willExpand) ensureChildrenLoaded(folder, ul);
3417 }
3418 return;
3419 }
3420
3421 const folder = target.getAttribute('data-folder');
3422 if (!folder) return;
3423
3424 const x = e.clientX;
3425 const y = e.clientY;
3426
3427 if (folder === 'recycle_bin') {
3428 const menuItems = [
3429 {
3430 label: t('empty_recycle_bin') || 'Empty Recycle Bin',
3431 icon: 'delete_forever',
3432 action: () => {
3433 if (typeof window.confirmEmptyRecycleBin === 'function') {
3434 window.confirmEmptyRecycleBin();
3435 return;
3436 }
3437 const btn = document.getElementById('deleteAllBtn');
3438 if (btn) { btn.click(); return; }
3439 showToast(t('recycle_bin_empty_unavailable'), 'warning');
3440 }
3441 }
3442 ];
3443 showFolderManagerContextMenu(x, y, menuItems);
3444 return;
3445 }
3446
3447 await openFolderActionsMenu(folder, target, x, y);
3448}
3449

Callers 1

Calls 9

repairBlankFolderIconsFunction · 0.85
getULForFolderFunction · 0.85
loadFolderTreeStateFunction · 0.85
saveFolderTreeStateFunction · 0.85
ensureChildrenLoadedFunction · 0.85
tFunction · 0.85
openFolderActionsMenuFunction · 0.85
showToastFunction · 0.70

Tested by

no test coverage detected