diff options
author | 2022-06-06 23:59:52 +0800 | |
---|---|---|
committer | 2022-06-06 17:59:52 +0200 | |
commit | 50c6fafc9692daa97daf894b5af5d4acb0caf7d8 (patch) | |
tree | cb541117f6d97b1af1a1ea00c92a947e338c98e2 /source/features/convert-pr-to-draft-improvements.tsx | |
parent | fb994afa17888a0ce9029febdc9d7ae4ae94c8e4 (diff) | |
download | refined-github-50c6fafc9692daa97daf894b5af5d4acb0caf7d8.tar.gz refined-github-50c6fafc9692daa97daf894b5af5d4acb0caf7d8.tar.zst refined-github-50c6fafc9692daa97daf894b5af5d4acb0caf7d8.zip |
Lint (#5654)
Co-authored-by: cheap-glitch <cheap.glitch@gmail.com>
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, }), ]; } |