(filePath: string)
| 367 | } |
| 368 | |
| 369 | async function configureSkillFileSwitcher(filePath: string): Promise<void> { |
| 370 | const switcher = document.getElementById("modal-file-switcher"); |
| 371 | const fileButtonLabel = document.getElementById("modal-file-button-label"); |
| 372 | const menu = document.getElementById("modal-file-menu"); |
| 373 | |
| 374 | if (!switcher || !fileButtonLabel || !menu) return; |
| 375 | |
| 376 | const skillItem = await getSkillItemByFilePath(filePath); |
| 377 | if (currentFilePath !== filePath) return; |
| 378 | |
| 379 | if (!skillItem || skillItem.files.length <= 1) { |
| 380 | switcher.classList.add("hidden"); |
| 381 | fileButtonLabel.textContent = ""; |
| 382 | menu.innerHTML = ""; |
| 383 | return; |
| 384 | } |
| 385 | |
| 386 | fileButtonLabel.textContent = getFileName(filePath); |
| 387 | menu.innerHTML = skillItem.files |
| 388 | .map( |
| 389 | (file) => |
| 390 | `<button type="button" class="modal-file-menu-item${ |
| 391 | file.path === filePath ? " active" : "" |
| 392 | }" data-path="${escapeHtml( |
| 393 | file.path |
| 394 | )}" role="menuitemradio" aria-checked="${ |
| 395 | file.path === filePath ? "true" : "false" |
| 396 | }">${escapeHtml(file.name)}</button>` |
| 397 | ) |
| 398 | .join(""); |
| 399 | switcher.classList.remove("hidden"); |
| 400 | } |
| 401 | |
| 402 | function hideSkillFileSwitcher(): void { |
| 403 | const switcher = document.getElementById("modal-file-switcher"); |
no test coverage detected