MCPcopy
hub / github.com/refined-github/refined-github / addQuickButtons

Function addQuickButtons

source/features/actions-run-removal.tsx:12–35  ·  view source on GitHub ↗
(contextMenuIcon: HTMLElement)

Source from the content-addressed store, hash-verified

10import observe from '../helpers/selector-observer.js';
11
12function addQuickButtons(contextMenuIcon: HTMLElement): void {
13 const contextMenuDetails = closestElement('details', contextMenuIcon);
14
15 // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments -- Wrong
16 const menuItem = $optional<HTMLElement>([
17 'form[action$="/cancel"]',
18 'li:has(> button[data-show-dialog-id^="delete-workflow-run"])',
19 ], contextMenuDetails)?.cloneNode(true);
20
21 if (!menuItem) {
22 // No access to this repo
23 return;
24 }
25
26 const button = $('button', menuItem);
27 button.ariaLabel = button.textContent.trim();
28 button.replaceChildren(menuItem.tagName === 'FORM' ? <SquareCircleIcon /> : <TrashIcon />);
29 button.classList = 'timeline-comment-action color-fg-muted btn-link rgh-actions-run-removal p-1';
30 $('summary', contextMenuDetails).classList.add('p-1');
31 const rightControlsContainer = contextMenuDetails.parentElement!;
32 // Prepending so that the cloned dialog opens instead of the one inside the menu, as it is hidden when the menu is closed
33 rightControlsContainer.classList.add('d-flex', 'flex-column-reverse', 'mt-n2', 'mb-n2');
34 rightControlsContainer.prepend(menuItem);
35}
36
37function init(signal: AbortSignal): void {
38 observe('#partial-actions-workflow-runs .Box-row details .octicon-kebab-horizontal', addQuickButtons, {signal});

Callers

nothing calls this directly

Calls 2

cloneNodeMethod · 0.80
prependMethod · 0.80

Tested by

no test coverage detected