diff options
author | 2020-07-03 00:29:52 +0200 | |
---|---|---|
committer | 2020-07-03 00:29:52 +0200 | |
commit | daf633137ec08e6f5647a6f8bb0b02d5dce58ef9 (patch) | |
tree | a4263d323bd4b963a7e6168800a0126f3f6b9c2d /source/features/conversation-links-on-repo-lists.tsx | |
parent | 19e2a375c34c0dc18462a2b8a9bb4ff6bb9c6590 (diff) | |
download | refined-github-daf633137ec08e6f5647a6f8bb0b02d5dce58ef9.tar.gz refined-github-daf633137ec08e6f5647a6f8bb0b02d5dce58ef9.tar.zst refined-github-daf633137ec08e6f5647a6f8bb0b02d5dce58ef9.zip |
Rename `discussion` → `conversation` (#3308)
Diffstat (limited to 'source/features/conversation-links-on-repo-lists.tsx')
-rw-r--r-- | source/features/conversation-links-on-repo-lists.tsx | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/source/features/conversation-links-on-repo-lists.tsx b/source/features/conversation-links-on-repo-lists.tsx new file mode 100644 index 00000000..5a02b4f5 --- /dev/null +++ b/source/features/conversation-links-on-repo-lists.tsx @@ -0,0 +1,60 @@ +import React from 'dom-chef'; +import select from 'select-dom'; +import IssueIcon from 'octicon/issue-opened.svg'; +import * as pageDetect from 'github-url-detection'; +import PullRequestIcon from 'octicon/git-pull-request.svg'; + +import features from '.'; +import observeElement from '../helpers/simplified-element-observer'; + +function init(): void { + const repositories = select.all<HTMLAnchorElement>([ + '[itemprop="name codeRepository"]:not(.rgh-discussion-links)', // `isUserProfileRepoTab` + '[data-hydro-click*=\'"model_name":"Repository"\']' // `isGlobalSearchResults` + ]); + + for (const repositoryLink of repositories) { + repositoryLink.classList.add('rgh-discussion-links'); + + const repository = repositoryLink.closest('li')!; + + // Remove the "X issues need help" link + select('[href*="issues?q=label%3A%22help+wanted"]', repository)?.remove(); + + // Place before the "Updated on" element + select('relative-time', repository)!.previousSibling!.before( + <a + className="muted-link mr-3" + href={repositoryLink.href + '/issues?q=is%3Aissue+is%3Aopen'} + > + <IssueIcon/> + </a>, + <a + className="muted-link mr-3" + href={repositoryLink.href + '/pulls?q=is%3Apr+is%3Aopen'} + > + <PullRequestIcon/> + </a> + ); + } +} + +void features.add({ + id: __filebasename, + description: 'Adds a link to the issues and pulls on the user profile repository tab and global search.', + screenshot: 'https://user-images.githubusercontent.com/16872793/78712349-82c54900-78e6-11ea-8328-3c2d39a78862.png' +}, { + include: [ + pageDetect.isUserProfileRepoTab, + pageDetect.isGlobalSearchResults + ], + init +}, { + include: [ + pageDetect.isUserProfileRepoTab + ], + init: () => { + observeElement('#user-repositories-list', init); + return false; + } +}); |