MCPcopy Index your code
hub / github.com/github/awesome-copilot / openHookDetailsModal

Function openHookDetailsModal

website/src/scripts/pages/hooks.ts:114–163  ·  view source on GitHub ↗
(hookId: string, trigger?: HTMLElement)

Source from the content-addressed store, hash-verified

112}
113
114function openHookDetailsModal(hookId: string, trigger?: HTMLElement): void {
115 const item = hookById.get(hookId);
116 if (!item) {
117 return;
118 }
119
120 const metaParts = item.hooks.map(
121 (hookName) => `<span class="resource-tag tag-hook">${escapeHtml(hookName)}</span>`
122 );
123
124 if (item.assets.length > 0) {
125 metaParts.push(
126 `<span class="resource-tag tag-assets">${item.assets.length} asset${
127 item.assets.length === 1 ? '' : 's'
128 }</span>`
129 );
130 }
131
132 if (item.lastUpdated) {
133 metaParts.push(
134 `<span class="last-updated">Updated ${escapeHtml(
135 formatRelativeTime(item.lastUpdated)
136 )}</span>`
137 );
138 }
139
140 const tagHtml = item.tags
141 .map((tagText) => `<span class="resource-tag tag-tag">${escapeHtml(tagText)}</span>`)
142 .join('');
143
144 const actionsHtml = `
145 <button id="hook-details-download" class="btn btn-primary" type="button" data-hook-id="${escapeHtml(
146 item.id
147 )}">Download</button>
148 <button class="btn btn-secondary" type="button" data-open-file-path="${escapeHtml(
149 item.readmeFile
150 )}" data-open-file-type="hook">Source</button>
151 `;
152
153 openCardDetailsModal({
154 title: item.title,
155 description: item.description || 'No description',
156 previewIcon: '🪝',
157 previewText: 'Hook events and download options',
158 metaHtml: metaParts.join(''),
159 tagsHtml: tagHtml,
160 actionsHtml,
161 trigger,
162 });
163}
164
165function setupResourceListHandlers(list: HTMLElement | null): void {
166 if (!list || resourceListHandlersReady) return;

Callers 1

Calls 3

escapeHtmlFunction · 0.90
formatRelativeTimeFunction · 0.90
openCardDetailsModalFunction · 0.90

Tested by

no test coverage detected