(menuButon: HTMLButtonElement, {signal}: SignalAsOptions)
| 28 | const editMenuItemSelector = 'li[data-component="ActionList.Item"]:has(.octicon-pencil)'; |
| 29 | |
| 30 | async function addQuickEditButton(menuButon: HTMLButtonElement, {signal}: SignalAsOptions): Promise<void> { |
| 31 | if (await isConversationIneditable(signal)) { |
| 32 | features.unload(import.meta.url); |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | const editButton = tooltipped('Edit comment', |
| 37 | <button |
| 38 | type="button" |
| 39 | className="Button Button--iconOnly Button--invisible Button--small" |
| 40 | onClick={async () => withMenuOpen(menuButon, menu => { |
| 41 | $(editMenuItemSelector, menu).click(); |
| 42 | })} |
| 43 | > |
| 44 | <PencilIcon /> |
| 45 | </button>, |
| 46 | ); |
| 47 | menuButon.before(editButton); |
| 48 | |
| 49 | // Remove our edit button when entering editing mode in case React doesn't, preventing duplicate buttons where only one works |
| 50 | await onElementRemoval(menuButon, signal); |
| 51 | editButton.remove(); |
| 52 | } |
| 53 | |
| 54 | async function addQuickEditButtonLegacy(commentDropdown: HTMLDetailsElement, {signal}: SignalAsOptions): Promise<void> { |
| 55 | if (await isConversationIneditable(signal)) { |
nothing calls this directly
no test coverage detected