Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new PR view in isMergedPR and isClosedPR #200

Merged
merged 5 commits into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,27 @@ TEST: addTests('isQuickPR', [
'https://github.com/sindresorhus/refined-github/compare/test-branch?quick_pull=1',
]);

export const isDraftPR = (): boolean => exists('#partial-discussion-header .octicon-git-pull-request-draft');
export const isOpenPR = (): boolean => exists('#partial-discussion-header :is(.octicon-git-pull-request, .octicon-git-pull-request-draft)');
export const isMergedPR = (): boolean => exists('#partial-discussion-header .octicon-git-merge');
export const isClosedPR = (): boolean => exists('#partial-discussion-header :is(.octicon-git-pull-request-closed, .octicon-git-merge)');
const prStateSelector = [
'.State',
'[class^="StateLabel"]',
].join(',');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
].join(',');
];

If it doesn't work, just update select-dom

Copy link
Member Author

@kovsu kovsu Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it works.

image image image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm referring to dropping .join()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it doesn't support string[].

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah because we're not using select-dom


export const isDraftPR = (): boolean => $(prStateSelector)!.textContent!.trim() === 'Draft';
export const isOpenPR = (): boolean => {
const status = $(prStateSelector)!.textContent!.trim();
return status === 'Open' || status === 'Draft';
};

export const isMergedPR = (): boolean => {
const status = $(prStateSelector)!.textContent!.trim();
return status === 'Merged';
};

export const isClosedPR = (): boolean => {
const status = $(prStateSelector)!.textContent!.trim();
return status === 'Closed' || status === 'Merged';
};

export const isClosedIssue = (): boolean => exists('#partial-discussion-header :is(.octicon-issue-closed, .octicon-skip)');

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

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


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

/** @deprecated Use `canUserAdminRepo` */
Expand Down
Loading