MCPcopy
hub / github.com/github/awesome-copilot / openFileModal

Function openFileModal

website/src/scripts/modal.ts:901–1020  ·  view source on GitHub ↗
(
  filePath: string,
  type: string,
  updateUrl = true,
  trigger?: HTMLElement
)

Source from the content-addressed store, hash-verified

899 * @param trigger - The element that triggered the modal (for focus return)
900 */
901export async function openFileModal(
902 filePath: string,
903 type: string,
904 updateUrl = true,
905 trigger?: HTMLElement
906): Promise<void> {
907 const modal = document.getElementById("file-modal");
908 const title = document.getElementById("modal-title");
909 const installDropdown = document.getElementById("install-dropdown");
910 const installBtnMain = document.getElementById(
911 "install-btn-main"
912 ) as HTMLAnchorElement | null;
913 const installVscode = document.getElementById(
914 "install-vscode"
915 ) as HTMLAnchorElement | null;
916 const installInsiders = document.getElementById(
917 "install-insiders"
918 ) as HTMLAnchorElement | null;
919 const copyBtn = document.getElementById("copy-btn");
920 const installCommandBtn = document.getElementById("install-command-btn");
921 const downloadBtn = document.getElementById("download-btn");
922 const closeBtn = document.getElementById("close-modal");
923 if (!modal || !title) return;
924
925 modal.classList.remove("details-mode");
926
927 currentFilePath = filePath;
928 currentFileType = type;
929 currentViewMode = "raw";
930
931 // Track trigger element for focus return
932 triggerElement =
933 trigger || triggerElement || (document.activeElement as HTMLElement);
934
935 // Update URL for deep linking
936 if (updateUrl) {
937 updateHash(filePath);
938 }
939
940 if (!originalDocumentTitle) {
941 originalDocumentTitle = document.title;
942 }
943
944 // Show modal with loading state
945 const fallbackName = getFileName(filePath);
946 updateModalTitle(fallbackName, filePath);
947 modal.classList.remove("hidden");
948 modal.classList.add("visible");
949
950 // Set focus to close button for accessibility
951 setTimeout(() => {
952 closeBtn?.focus();
953 }, 0);
954
955 // Handle plugins differently - show as item list
956 if (type === "plugin") {
957 const modalContent = getModalContent();
958 if (!modalContent) return;

Callers 4

setupModalFunction · 0.85
handleHashChangeFunction · 0.85
renderLocalPluginModalFunction · 0.85
showRecipeContentFunction · 0.85

Calls 13

getVSCodeInstallUrlFunction · 0.90
fetchFileContentFunction · 0.90
updateHashFunction · 0.85
getFileNameFunction · 0.85
updateModalTitleFunction · 0.85
getModalContentFunction · 0.85
hideSkillFileSwitcherFunction · 0.85
openPluginModalFunction · 0.85
renderPlainTextFunction · 0.85
updateViewButtonsFunction · 0.85
resolveResourceTitleFunction · 0.85

Tested by

no test coverage detected