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

Function populateFolderAccessSourceSelect

public/js/adminFolderAccess.js:46–67  ·  view source on GitHub ↗
(selectEl, sources, activeId)

Source from the content-addressed store, hash-verified

44}
45
46function populateFolderAccessSourceSelect(selectEl, sources, activeId) {
47 if (!selectEl) return;
48 selectEl.innerHTML = '';
49 sources.forEach(src => {
50 if (!src || typeof src !== 'object') return;
51 const id = String(src.id || '');
52 if (!id) return;
53 const name = String(src.name || id);
54 const type = String(src.type || '');
55 const disabled = src.enabled === false;
56 const ro = src.readOnly ? ` (${tf('read_only', 'Read-only')})` : '';
57 const dis = disabled ? ' (disabled)' : '';
58 const label = type ? `${name} (${type})${ro}${dis}` : `${name}${ro}${dis}`;
59 const opt = document.createElement('option');
60 opt.value = id;
61 opt.textContent = label;
62 selectEl.appendChild(opt);
63 });
64 if (!selectEl.options.length) return;
65 const hasActive = Array.from(selectEl.options).some(opt => opt.value === activeId);
66 selectEl.value = hasActive ? activeId : selectEl.options[0].value;
67}
68
69async function initFolderAccessSourceSelector(opts = {}) {
70 const rowId = opts.rowId || 'folderAccessSourceRow';

Callers 1

Calls 1

tfFunction · 0.70

Tested by

no test coverage detected