message: Restore `convert-release-to-draft` feature
diff: @@ -7,11 +7,10 @@ import delegate, {DelegateEvent} from 'delegate-it';
  import features from '.';
  import * as api from '../github-helpers/api';
  import LoadingIcon from '../github-helpers/icon-loading';
  +import attachElement from '../helpers/attach-element';
  +import {getRepo} from '../github-helpers';
  -const editReleaseButtonSelector = [
  - '.BtnGroup a[href*="releases/edit"]', // Before "Releases UI refresh" #4902
  - '.Box-btn-octicon[aria-label="Edit"]',
  -].join(',');
  +const getReleaseEditLinkSelector = (): string => `a[href^="/${getRepo()!.nameWithOwner}/releases/edit"]`;
  async function convertToDraft({delegateTarget: draftButton}: DelegateEvent): Promise<void> {
  try {
  @@ -26,7 +25,7 @@ async function convertToDraft({delegateTarget: draftButton}: DelegateEvent): Pro
  },
  });
  - select(editReleaseButtonSelector)!.click(); // Visit "Edit release" page
  + select(getReleaseEditLinkSelector())!.click(); // Visit "Edit release" page
  } catch (error) {
  draftButton.textContent = 'Error. Check console or retry';
  features.log.error(import.meta.url, error);
  @@ -36,27 +35,25 @@ async function convertToDraft({delegateTarget: draftButton}: DelegateEvent): Pro
  async function init(signal: AbortSignal): Promise<void | false> {
  await api.expectToken();
  - const editButton = await elementReady(editReleaseButtonSelector);
  + const editButton = await elementReady(getReleaseEditLinkSelector());
  if (!editButton || select.exists('.label-draft')) {
  return false;
  }
  - const convertToDraftButton = (
  + // Fix spacing but avoid the two buttons sticking together
  + editButton.classList.replace('ml-1', 'ml-0');
  +
  + attachElement({
  + anchor: editButton,
  + before: () => (
  <button
  type="button"
  className={'btn rgh-convert-draft ' + (pageDetect.isEnterprise() ? 'BtnGroup-item' : 'btn-sm ml-3')}
  >
  Convert to draft
  </button>
  - );
  -
  - if (pageDetect.isEnterprise()) { // Before "Releases UI refresh" #4902
  - editButton.after(convertToDraftButton);
  - } else {
  - editButton.before(convertToDraftButton);
  - // Fix spacing but avoid the two buttons sticking together
  - editButton.classList.replace('ml-1', 'ml-0');
  - }
  + ),
  + });
  delegate(document, '.rgh-convert-draft', 'click', convertToDraft, {signal});
  }
  @@ -66,6 +63,6 @@ void features.add(import.meta.url, {
  pageDetect.isSingleTag,
  ],
  awaitDomReady: false,
  - deduplicate: 'has-rgh-inner',
  + deduplicate: '.rgh-convert-draft',
  init,
  });
  