Skip to content

Commit 578fa11

Browse files
authored
open-all-conversations - Support new issue view (#8508)
1 parent 0825ae5 commit 578fa11

4 files changed

Lines changed: 51 additions & 18 deletions

File tree

.github/workflows/labeler.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
(github.event_name == 'pull_request_target' && github.event.pull_request.merged == true)
1616
runs-on: ubuntu-latest
1717
permissions:
18+
contents: read
1819
pull-requests: write
1920
steps:
2021
- name: Check if PR has no labels

build/__snapshots__/features-meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@
526526
{
527527
"id": "open-all-conversations",
528528
"description": "Lets you open all visible issues/PRs at once.",
529-
"screenshot": "https://user-images.githubusercontent.com/46634000/110980658-5face000-8366-11eb-88f9-0cc94f75ce57.gif"
529+
"screenshot": "https://github.com/user-attachments/assets/0d890b01-d5ca-4247-8270-055dd6355606"
530530
},
531531
{
532532
"id": "open-all-notifications",

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ https://github.com/refined-github/refined-github/wiki/Contributing#metadata-guid
190190

191191
### Conversations
192192

193-
- [](# "open-all-conversations") [Lets you open all visible issues/PRs at once.](https://user-images.githubusercontent.com/46634000/110980658-5face000-8366-11eb-88f9-0cc94f75ce57.gif)
193+
- [](# "open-all-conversations") [Lets you open all visible issues/PRs at once.](https://github.com/user-attachments/assets/0d890b01-d5ca-4247-8270-055dd6355606)
194194
- [](# "sticky-conversation-list-toolbar") [Makes the issue/PR list’s filters toolbar sticky.](https://github-production-user-asset-6210df.s3.amazonaws.com/83146190/261164103-875b70f7-5adc-4bb2-b158-8d5231d47da2.gif)
195195
- [](# "conversation-authors") [Highlights issues/PRs opened by you or the current repo’s collaborators.](https://github-production-user-asset-6210df.s3.amazonaws.com/83146190/252804821-a412e05c-fb76-400b-85b5-5acbda538ab2.png)
196196
- [](# "align-issue-labels") [In issue/PR lists, aligns the labels to the left, below each title.](https://github-production-user-asset-6210df.s3.amazonaws.com/83146190/261160640-28ae4f12-0e95-4db5-a79c-e89ae523a4d0.png)

source/features/open-all-conversations.tsx

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,76 @@
11
import React from 'dom-chef';
2-
import {$$} from 'select-dom';
3-
import delegate, {type DelegateEvent} from 'delegate-it';
2+
import {$$} from 'select-dom/strict.js';
3+
import delegate from 'delegate-it';
44
import elementReady from 'element-ready';
55
import * as pageDetect from 'github-url-detection';
66

77
import features from '../feature-manager.js';
88
import openTabs from '../helpers/open-tabs.js';
99
import observe from '../helpers/selector-observer.js';
1010

11-
const issueListSelector = pageDetect.isGlobalIssueOrPRList()
12-
? '#js-issues-toolbar div'
13-
: 'div[aria-label="Issues"][role="group"]';
11+
function onButtonClick(): void {
12+
const links = $$([
13+
'a[data-testid="issue-pr-title-link"]',
14+
'a.h4.js-navigation-open', // TODO: Pre-React selector; Drop in 2026
15+
]);
1416

15-
function onButtonClick(event: DelegateEvent<MouseEvent, HTMLButtonElement>): void {
16-
const onlySelected = event.delegateTarget.closest('.table-list-triage')
17-
? ':has(:checked)'
18-
: '';
17+
if (links.length > 25) {
18+
console.warn('Selected too many links. Is the selector still correct?');
19+
}
1920

20-
const issueSelector = `${issueListSelector} .js-issue-row${onlySelected} a.js-navigation-open`;
21+
const selectedLinks = links.filter(link =>
22+
link.closest([
23+
'.js-issue-row.selected', // TODO: Pre-React selector; Drop in 2026
24+
'[aria-label^="Selected"]',
25+
]),
26+
);
27+
28+
const linksToOpen = selectedLinks.length > 0
29+
? selectedLinks
30+
: links;
2131

22-
const urls = $$(issueSelector as 'a').map(issue => issue.href);
32+
const urls = linksToOpen.map(link => link.href);
2333
void openTabs(urls);
2434
}
2535

36+
const multipleConversationsSelector = [
37+
'.js-issue-row + .js-issue-row', // TODO: Pre-React selector; Drop in 2026
38+
'[role="list"] > div:nth-child(2) > [class^="IssueRow"]',
39+
] as const;
40+
2641
async function hasMoreThanOneConversation(): Promise<boolean> {
27-
return Boolean(await elementReady('.js-issue-row + .js-issue-row', {waitForChildren: false}));
42+
return Boolean(await elementReady(multipleConversationsSelector.join(', '), {waitForChildren: false}));
2843
}
2944

3045
function add(anchor: HTMLElement): void {
46+
const isLegacy = anchor.closest('.table-list-header-toggle');
47+
const isSelected = anchor.closest([
48+
'.table-list-triage', // TODO: Pre-React selector; Drop in 2026
49+
'[aria-label="Bulk actions"]',
50+
]);
51+
const classes = isLegacy
52+
? 'btn-link px-2'
53+
: isSelected
54+
? 'btn'
55+
: 'btn btn-sm';
3156
anchor.prepend(
3257
<button
3358
type="button"
34-
className="btn-link rgh-open-all-conversations px-2"
59+
className={`rgh-open-all-conversations ${classes}`}
3560
>
36-
{anchor.closest('.table-list-triage') ? 'Open selected' : 'Open all'}
61+
{isSelected
62+
? 'Open selected'
63+
: 'Open all'}
3764
</button>,
3865
);
3966
}
4067

4168
async function init(signal: AbortSignal): Promise<void | false> {
42-
observe('.table-list-header-toggle:not(.states)', add, {signal});
69+
observe([
70+
'.table-list-header-toggle:not(.states)', // TODO: Pre-React selector; Drop in 2026
71+
'[aria-label="Bulk actions"] > :first-child',
72+
'[aria-label="Actions"] > :first-child',
73+
], add, {signal});
4374
delegate('button.rgh-open-all-conversations', 'click', onButtonClick, {signal});
4475
}
4576

@@ -66,7 +97,8 @@ void features.add(import.meta.url, {
6697
Test URLs:
6798
6899
- Global: https://github.com/issues
69-
- Repo: https://github.com/sindresorhus/refined-github/pulls
100+
- Issues: https://github.com/refined-github/refined-github/issues
101+
- PRs: https://github.com/refined-github/refined-github/pulls
70102
- Nothing to open: https://github.com/fregante/empty/pulls
71103
72104
*/

0 commit comments

Comments
 (0)