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

Function configureVisibility

public/js/fileMenu.js:46–72  ·  view source on GitHub ↗
({ any, one, many, anyZip, canEdit, allowLink, allowShare, allowZip, allowExtractZip })

Source from the content-addressed store, hash-verified

44
45// Show/hide items based on selection state
46function configureVisibility({ any, one, many, anyZip, canEdit, allowLink, allowShare, allowZip, allowExtractZip }) {
47 const m = qMenu(); if (!m) return;
48
49 const show = (sel, on) => sel.forEach(el => el.hidden = !on);
50
51 show(m.querySelectorAll('[data-when="always"]'), true);
52 show(m.querySelectorAll('[data-when="any"]'), any);
53 show(m.querySelectorAll('[data-when="one"]'), one);
54 show(m.querySelectorAll('[data-when="many"]'), many);
55 show(m.querySelectorAll('[data-when="zip"]'), anyZip);
56 show(m.querySelectorAll('[data-when="can-edit"]'), canEdit);
57
58 // Capability gates (e.g. encrypted folders disable share/zip actions)
59 try {
60 const link = m.querySelector('.mi[data-action="link_file"]');
61 if (link) link.hidden = link.hidden || !allowLink;
62 const share = m.querySelector('.mi[data-action="share_file"]');
63 if (share) share.hidden = share.hidden || !allowShare;
64 const dlZip = m.querySelector('.mi[data-action="download_zip"]');
65 if (dlZip) dlZip.hidden = dlZip.hidden || !allowZip;
66 const exZip = m.querySelector('.mi[data-action="extract_zip"]');
67 if (exZip) exZip.hidden = exZip.hidden || !allowExtractZip;
68 } catch (e) { /* ignore */ }
69
70 // Hide separators at edges or duplicates
71 cleanupSeparators(m);
72}
73
74function cleanupSeparators(menu) {
75 const kids = Array.from(menu.children);

Callers 1

Calls 3

qMenuFunction · 0.85
cleanupSeparatorsFunction · 0.85
showFunction · 0.70

Tested by

no test coverage detected