diff options
Diffstat (limited to 'source/features/convert-pr-to-draft-improvements.tsx')
-rw-r--r-- | source/features/convert-pr-to-draft-improvements.tsx | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/source/features/convert-pr-to-draft-improvements.tsx b/source/features/convert-pr-to-draft-improvements.tsx index 22d3ca7c..2cef203c 100644 --- a/source/features/convert-pr-to-draft-improvements.tsx +++ b/source/features/convert-pr-to-draft-improvements.tsx @@ -12,6 +12,19 @@ function closeModal({delegateTarget: button}: delegate.Event<MouseEvent, HTMLBut button.disabled = true; } +function addConvertToDraftButton(alternativeActions: Element): void { + const existingButton = select('[data-url$="/convert_to_draft"]'); + // Needs to check the existence of both to guarantee the non-draft state + if (!existingButton || select.exists('[action$="/ready_for_review"]')) { + return; + } + + alternativeActions.classList.add('rgh-convert-pr-draft-position'); + const convertToDraft = existingButton.closest('details')!.cloneNode(true); + select('.Link--muted', convertToDraft)!.classList.remove('Link--muted'); + alternativeActions.prepend(convertToDraft); +} + function init(): Deinit[] { return [ // Immediately close lightbox after click instead of waiting for the ajaxed widget to refresh @@ -19,18 +32,7 @@ function init(): Deinit[] { // Copy button to mergeability box observe('.alt-merge-options:not(.rgh-convert-pr-draft-position)', { - add(alternativeActions) { - const existingButton = select('[data-url$="/convert_to_draft"]'); - // Needs to check the existence of both to guarantee the non-draft state - if (!existingButton || select.exists('[action$="/ready_for_review"]')) { - return; - } - - alternativeActions.classList.add('rgh-convert-pr-draft-position'); - const convertToDraft = existingButton.closest('details')!.cloneNode(true); - select('.Link--muted', convertToDraft)!.classList.remove('Link--muted'); - alternativeActions.prepend(convertToDraft); - }, + add: addConvertToDraftButton, }), ]; } |