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

Function setupActionHandlers

website/src/scripts/utils.ts:651–686  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

649 * Setup global action handlers for download and share buttons
650 */
651export function setupActionHandlers(): void {
652 if (actionHandlersReady) return;
653 actionHandlersReady = true;
654
655 document.addEventListener(
656 "click",
657 async (e) => {
658 const target = (e.target as HTMLElement).closest(
659 ".action-download, .action-share"
660 ) as HTMLElement | null;
661 if (!target) return;
662
663 e.preventDefault();
664 e.stopPropagation();
665
666 const path = target.dataset.path;
667 if (!path) return;
668
669 if (target.classList.contains("action-download")) {
670 const success = await downloadFile(path);
671 showToast(
672 success ? "Download started!" : "Download failed",
673 success ? "success" : "error"
674 );
675 return;
676 }
677
678 const success = await shareFile(path);
679 showToast(
680 success ? "Link copied!" : "Failed to copy link",
681 success ? "success" : "error"
682 );
683 },
684 true
685 );
686}
687
688let dropdownHandlersReady = false;
689let actionHandlersReady = false;

Callers 3

initInstructionsPageFunction · 0.90
initAgentsPageFunction · 0.90
initWorkflowsPageFunction · 0.90

Calls 4

downloadFileFunction · 0.85
showToastFunction · 0.85
shareFileFunction · 0.85
addEventListenerMethod · 0.80

Tested by

no test coverage detected