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 isClosedIssue; tighten related checks #201

Merged
merged 7 commits into from
Nov 6, 2024
Merged
Changes from 2 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
31 changes: 25 additions & 6 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,28 +286,47 @@ TEST: addTests('isQuickPR', [
'https://github.com/sindresorhus/refined-github/compare/test-branch?quick_pull=1',
]);

const prStateSelector = [
const stateSelector = [
'.State',
'[class^="StateLabel"]',
fregante marked this conversation as resolved.
Show resolved Hide resolved
].join(',');

export const isDraftPR = (): boolean => $(prStateSelector)!.textContent!.trim() === 'Draft';
export const isDraftPR = (): boolean => isPR() && $(stateSelector)!.textContent!.trim() === 'Draft';
export const isOpenPR = (): boolean => {
const status = $(prStateSelector)!.textContent!.trim();
if (isPR()) {
kovsu marked this conversation as resolved.
Show resolved Hide resolved
return false;
}

const status = $(stateSelector)!.textContent!.trim();
return status === 'Open' || status === 'Draft';
};

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

const status = $(stateSelector)!.textContent!.trim();
return status === 'Merged';
kovsu marked this conversation as resolved.
Show resolved Hide resolved
};

export const isClosedPR = (): boolean => {
const status = $(prStateSelector)!.textContent!.trim();
if (isPR()) {
return false;
}

const status = $(stateSelector)!.textContent!.trim();
return status === 'Closed' || status === 'Merged';
};

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

const status = $(stateSelector)!.textContent!.trim();
return status === 'Closed';
fregante marked this conversation as resolved.
Show resolved Hide resolved
};

export const isReleases = (url: URL | HTMLAnchorElement | Location = location): boolean => getRepo(url)?.path === 'releases';
TEST: addTests('isReleases', [
Expand Down
Loading