* Open plugin modal with item list
( filePath: string, title: HTMLElement, modalContent: HTMLElement, installDropdown: HTMLElement | null, copyBtn: HTMLElement | null, downloadBtn: HTMLElement | null )
| 1102 | * Open plugin modal with item list |
| 1103 | */ |
| 1104 | async function openPluginModal( |
| 1105 | filePath: string, |
| 1106 | title: HTMLElement, |
| 1107 | modalContent: HTMLElement, |
| 1108 | installDropdown: HTMLElement | null, |
| 1109 | copyBtn: HTMLElement | null, |
| 1110 | downloadBtn: HTMLElement | null |
| 1111 | ): Promise<void> { |
| 1112 | // Hide install dropdown and copy/download for plugins |
| 1113 | if (installDropdown) installDropdown.style.display = "none"; |
| 1114 | if (copyBtn) copyBtn.style.display = "none"; |
| 1115 | if (downloadBtn) downloadBtn.style.display = "none"; |
| 1116 | |
| 1117 | // Replace <pre> with a <div> so plugin content isn't styled as preformatted text |
| 1118 | const modalBody = modalContent.parentElement; |
| 1119 | if (modalBody) { |
| 1120 | const div = document.createElement("div"); |
| 1121 | div.id = "modal-content"; |
| 1122 | div.innerHTML = '<div class="collection-loading">Loading plugin...</div>'; |
| 1123 | modalBody.replaceChild(div, modalContent); |
| 1124 | modalContent = div; |
| 1125 | } else { |
| 1126 | modalContent.innerHTML = |
| 1127 | '<div class="collection-loading">Loading plugin...</div>'; |
| 1128 | } |
| 1129 | |
| 1130 | // Load plugins data if not cached |
| 1131 | if (!pluginsCache) { |
| 1132 | pluginsCache = await fetchData<PluginsData>("plugins.json"); |
| 1133 | } |
| 1134 | |
| 1135 | if (!pluginsCache) { |
| 1136 | modalContent.innerHTML = |
| 1137 | '<div class="collection-error">Failed to load plugin data.</div>'; |
| 1138 | return; |
| 1139 | } |
| 1140 | |
| 1141 | // Find the plugin |
| 1142 | const plugin = pluginsCache.items.find((c) => c.path === filePath); |
| 1143 | if (!plugin) { |
| 1144 | modalContent.innerHTML = |
| 1145 | '<div class="collection-error">Plugin not found.</div>'; |
| 1146 | return; |
| 1147 | } |
| 1148 | |
| 1149 | // Update title |
| 1150 | title.textContent = plugin.name; |
| 1151 | document.title = `${plugin.name} | Awesome GitHub Copilot`; |
| 1152 | |
| 1153 | // Render external plugin view (metadata + links) or local plugin view (items list) |
| 1154 | if (plugin.external) { |
| 1155 | renderExternalPluginModal(plugin, modalContent); |
| 1156 | } else { |
| 1157 | renderLocalPluginModal(plugin, modalContent); |
| 1158 | } |
| 1159 | } |
| 1160 | |
| 1161 | /** |
no test coverage detected