| 11 | const unplannedCheckbox = 'input[name="state_reason"][value="not_planned"]'; |
| 12 | |
| 13 | function update(dropdown: HTMLElement): void { |
| 14 | const form = closestElement('form', dropdown); |
| 15 | const radio = $(unplannedCheckbox, dropdown); |
| 16 | const mainButton = $('[name="comment_and_close"]', form); |
| 17 | const icon = $('.octicon-skip', dropdown); |
| 18 | |
| 19 | const checkbox = radio.cloneNode(); |
| 20 | checkbox.hidden = true; |
| 21 | checkbox.type = 'checkbox'; |
| 22 | |
| 23 | mainButton.classList.add('tooltipped', 'tooltipped-nw'); |
| 24 | mainButton.setAttribute('aria-label', 'Done, closed, fixed, resolved'); |
| 25 | |
| 26 | const unplannedButton = mainButton.cloneNode(); |
| 27 | unplannedButton.append(icon); |
| 28 | unplannedButton.id = id; |
| 29 | unplannedButton.classList.add('btn', 'tooltipped', 'tooltipped-nw', 'mr-0'); |
| 30 | // Prevent content from being changed #7024 |
| 31 | unplannedButton.classList.remove('js-comment-and-button'); |
| 32 | unplannedButton.setAttribute('aria-label', 'Close as not planned.\nWon’t fix, can’t repro, duplicate, stale'); |
| 33 | |
| 34 | dropdown.replaceWith(unplannedButton); |
| 35 | form.append(checkbox); |
| 36 | } |
| 37 | |
| 38 | function updateCheckbox({delegateTarget: button}: DelegateEvent<MouseEvent, HTMLInputElement>): void { |
| 39 | $(unplannedCheckbox, button.form!).checked = button.id === id; |