MCPcopy
hub / github.com/refined-github/refined-github / handleClick

Function handleClick

source/features/restore-file.tsx:122–149  ·  view source on GitHub ↗
(event: DelegateEvent<MouseEvent, HTMLButtonElement>)

Source from the content-addressed store, hash-verified

120}
121
122async function handleClick(event: DelegateEvent<MouseEvent, HTMLButtonElement>): Promise<void> {
123 const menuItem = event.delegateTarget;
124 const filenames = getFilenames(menuItem);
125
126 const commitTitle = prompt(
127 'Are you sure you want to discard these changes? Enter the commit title',
128 `Discard changes to ${filenames.original}`,
129 );
130
131 if (!commitTitle) {
132 return;
133 }
134
135 await showToast(async progress => discardChanges(progress, filenames.original, filenames.new, commitTitle), {
136 message: 'Loading info…',
137 doneMessage: 'Changes discarded',
138 });
139
140 // Hide file from view
141 if (menuItem.tagName === 'BUTTON') {
142 closestElement('.file', menuItem).remove();
143 return;
144 }
145
146 // New React view: remove the tracked file container and close the menu
147 focusedFileContainer!.remove();
148 closestElement('div[data-focus-trap="active"]', menuItem).remove();
149}
150
151// Legacy view handler
152function addLegacyMenuItem(editFile: HTMLAnchorElement): void {

Callers

nothing calls this directly

Calls 4

getFilenamesFunction · 0.85
showToastFunction · 0.85
discardChangesFunction · 0.85
removeMethod · 0.80

Tested by

no test coverage detected