({
modalEl,
sourcesEnabled,
sourcesCfg,
isPro,
proSourcesApiOk,
sourcesAllowedTypes = CORE_SOURCE_TYPES,
sourcesProExtended = false
})
| 1296 | } |
| 1297 | |
| 1298 | function initSourcesSection({ |
| 1299 | modalEl, |
| 1300 | sourcesEnabled, |
| 1301 | sourcesCfg, |
| 1302 | isPro, |
| 1303 | proSourcesApiOk, |
| 1304 | sourcesAllowedTypes = CORE_SOURCE_TYPES, |
| 1305 | sourcesProExtended = false |
| 1306 | }) { |
| 1307 | const container = document.getElementById('sourcesContent'); |
| 1308 | if (!container || container.__initialized) return; |
| 1309 | container.__initialized = true; |
| 1310 | |
| 1311 | if (sourcesCfg && sourcesCfg.available === false) { |
| 1312 | container.innerHTML = `<div class="text-muted">${escapeHTML(tf('sources_unavailable', 'Sources are unavailable on this build.'))}</div>`; |
| 1313 | return; |
| 1314 | } |
| 1315 | |
| 1316 | const normalizedAllowedTypes = Array.isArray(sourcesAllowedTypes) |
| 1317 | ? sourcesAllowedTypes.map(v => String(v || '').trim().toLowerCase()).filter(Boolean) |
| 1318 | : []; |
| 1319 | const filteredAllowed = normalizedAllowedTypes.filter(type => ALL_SOURCE_TYPES.includes(type)); |
| 1320 | const effectiveAllowedTypes = filteredAllowed.length ? filteredAllowed : CORE_SOURCE_TYPES.slice(); |
| 1321 | const allowedTypeSet = new Set(effectiveAllowedTypes); |
| 1322 | const limitedAdaptersHint = (!sourcesProExtended && effectiveAllowedTypes.length < ALL_SOURCE_TYPES.length) |
| 1323 | ? tf( |
| 1324 | 'sources_core_types_hint', |
| 1325 | 'Core supports Local and WebDAV sources. Upgrade to FileRise Pro for S3, SFTP, FTP, SMB, Google Drive, Dropbox, and OneDrive.' |
| 1326 | ) |
| 1327 | : ''; |
| 1328 | |
| 1329 | container.innerHTML = ` |
| 1330 | <div class="sources-admin"> |
| 1331 | <div class="form-group" style="margin-bottom:8px;"> |
| 1332 | <div class="form-check fr-toggle"> |
| 1333 | <input type="checkbox" class="form-check-input fr-toggle-input" id="sourcesEnabledToggle" /> |
| 1334 | <label class="form-check-label" for="sourcesEnabledToggle"> |
| 1335 | ${tf('sources_enabled', 'Enable sources')} |
| 1336 | </label> |
| 1337 | </div> |
| 1338 | <small class="text-muted d-block mt-1"> |
| 1339 | ${tf('sources_help', 'Sources are separate roots; users only see sources they can access.')} |
| 1340 | </small> |
| 1341 | </div> |
| 1342 | |
| 1343 | <div class="sources-toolbar"> |
| 1344 | <button type="button" id="sourceAddBtn" class="btn btn-sm btn-primary"> |
| 1345 | ${tf('source_add', 'Add Source')} |
| 1346 | </button> |
| 1347 | <button type="button" id="sourceRefreshBtn" class="btn btn-sm btn-secondary"> |
| 1348 | ${tf('refresh', 'Refresh')} |
| 1349 | </button> |
| 1350 | </div> |
| 1351 | |
| 1352 | <div id="sourcesStatus" class="text-muted small" style="margin-bottom:6px;"></div> |
| 1353 | <div id="sourcesList" class="sources-list"></div> |
| 1354 | |
| 1355 | <hr class="admin-divider"> |
no test coverage detected