(event: DelegateEvent<MouseEvent, HTMLButtonElement>)
| 120 | } |
| 121 | |
| 122 | async 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 |
| 152 | function addLegacyMenuItem(editFile: HTMLAnchorElement): void { |
nothing calls this directly
no test coverage detected