Skip to content

Commit c80fd64

Browse files
authored
Support new PR view in isMergedPR and isClosedPR (#200)
1 parent 79147db commit c80fd64

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

index.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,27 @@ TEST: addTests('isQuickPR', [
286286
'https://github.com/sindresorhus/refined-github/compare/test-branch?quick_pull=1',
287287
]);
288288

289-
export const isDraftPR = (): boolean => exists('#partial-discussion-header .octicon-git-pull-request-draft');
290-
export const isOpenPR = (): boolean => exists('#partial-discussion-header :is(.octicon-git-pull-request, .octicon-git-pull-request-draft)');
291-
export const isMergedPR = (): boolean => exists('#partial-discussion-header .octicon-git-merge');
292-
export const isClosedPR = (): boolean => exists('#partial-discussion-header :is(.octicon-git-pull-request-closed, .octicon-git-merge)');
289+
const prStateSelector = [
290+
'.State',
291+
'[class^="StateLabel"]',
292+
].join(',');
293+
294+
export const isDraftPR = (): boolean => $(prStateSelector)!.textContent!.trim() === 'Draft';
295+
export const isOpenPR = (): boolean => {
296+
const status = $(prStateSelector)!.textContent!.trim();
297+
return status === 'Open' || status === 'Draft';
298+
};
299+
300+
export const isMergedPR = (): boolean => {
301+
const status = $(prStateSelector)!.textContent!.trim();
302+
return status === 'Merged';
303+
};
304+
305+
export const isClosedPR = (): boolean => {
306+
const status = $(prStateSelector)!.textContent!.trim();
307+
return status === 'Closed' || status === 'Merged';
308+
};
309+
293310
export const isClosedIssue = (): boolean => exists('#partial-discussion-header :is(.octicon-issue-closed, .octicon-skip)');
294311

295312
export const isReleases = (url: URL | HTMLAnchorElement | Location = location): boolean => getRepo(url)?.path === 'releases';
@@ -740,7 +757,6 @@ TEST: addTests('isRepositoryActions', [
740757

741758
export const isUserTheOrganizationOwner = (): boolean => isOrganizationProfile() && exists('[aria-label="Organization"] [data-tab-item="org-header-settings-tab"]');
742759

743-
744760
export const canUserAdminRepo = (): boolean => isRepo() && exists('.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]');
745761

746762
/** @deprecated Use `canUserAdminRepo` */

0 commit comments

Comments
 (0)