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

Add action-pr-link feature #6694

Merged
merged 11 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ Thanks for contributing! 🦋🙌
- [](# "quick-new-issue") [Adds a link to create issues from anywhere in a repository.](https://user-images.githubusercontent.com/1402241/218251057-b94b62dd-a944-4763-b78a-fc233f7c9fd3.png)
- [](# "small-user-avatars") [Shows a small avatar next to the username in conversation lists.](https://user-images.githubusercontent.com/44045911/230960291-721f42cc-e1ac-4fdc-83ea-2430b062f9ce.png)
- [](# "unreleased-commits") 🔥 [Tells you whether you're looking at the latest version of a repository, or if there are any unreleased commits.](https://user-images.githubusercontent.com/1402241/234576563-1a0ca255-4c0d-45ae-883d-2b1aa2d7f4c1.png)
- [](# "action-pr-link") 🔥 [Adds a link back to the PR that ran the workflow.](https://github.com/refined-github/refined-github/assets/50487467/076a0137-36a2-4fd0-a66e-735ef3b3a563)

<!-- Refer to style guide above. Keep this message between sections. -->

Expand Down
32 changes: 32 additions & 0 deletions source/features/action-pr-link.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as pageDetect from 'github-url-detection';

import features from '../feature-manager.js';
import observe from '../helpers/selector-observer.js';

async function add(prLink: HTMLAnchorElement): Promise<void> {
const prNumber = prLink.textContent!.slice(1);

const runLink = prLink.closest('.Box-row')!.querySelector('a.Link--primary')!;
const parameters = new URLSearchParams(runLink.search);
parameters.set('pr', prNumber);
runLink.search = String(parameters);
}

async function init(signal: AbortSignal): Promise<void> {
observe('div.Box-row[id^=check_suite_] a[data-hovercard-type="pull_request"]', add, {signal});
}

void features.add(import.meta.url, {
include: [
pageDetect.isRepositoryActions,
],
init,
});

/*

## Test URLs

https://github.com/refined-github/refined-github/actions

*/

Check notice on line 32 in source/features/action-pr-link.tsx

View workflow job for this annotation

GitHub Actions / TestURLs

1 change: 1 addition & 0 deletions source/refined-github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,5 @@ import './features/pr-base-commit.js';
import './features/unreleased-commits.js';
import './features/previous-version.js';
import './features/status-subscription.js';
import './features/action-pr-link.js';
import './features/rgh-dim-commits.js';