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

Function populateSourceSelect

public/js/fileActions.js:203–223  ·  view source on GitHub ↗
(selectEl, sources, activeId)

Source from the content-addressed store, hash-verified

201}
202
203function populateSourceSelect(selectEl, sources, activeId) {
204 if (!selectEl) return;
205 selectEl.innerHTML = '';
206 sources.forEach(src => {
207 if (!src || typeof src !== 'object') return;
208 const id = String(src.id || '');
209 if (!id) return;
210 const name = String(src.name || id);
211 const type = String(src.type || '');
212 const ro = src.readOnly ? ` \uD83D\uDD12 ${t('read_only')}` : '';
213 const label = type ? `${name} (${type})${ro}` : `${name}${ro}`;
214 const opt = document.createElement('option');
215 opt.value = id;
216 opt.textContent = label;
217 if (src.readOnly) opt.disabled = true;
218 selectEl.appendChild(opt);
219 });
220 if (!selectEl.options.length) return;
221 const hasActive = Array.from(selectEl.options).some(opt => opt.value === activeId && !opt.disabled);
222 selectEl.value = hasActive ? activeId : selectEl.options[0].value;
223}
224
225async function initCopyMoveSourceSelect(kind, preferredFolder = '', preferredSourceId = '') {
226 const rowId = kind === 'move' ? 'moveFilesSourceRow' : 'copyFilesSourceRow';

Callers 1

initCopyMoveSourceSelectFunction · 0.85

Calls 1

tFunction · 0.85

Tested by

no test coverage detected