|
1 | 1 | // ==UserScript==
|
2 | 2 |
|
3 | 3 | // @name AzDO Pull Request Improvements
|
4 |
| -// @version 2.22.1 |
| 4 | +// @version 2.23.0 |
5 | 5 | // @author Alejandro Barreto (National Instruments)
|
6 | 6 | // @description Adds sorting and categorization to the PR dashboard. Also adds minor improvements to the PR diff experience, such as a base update selector and per-file checkboxes.
|
7 | 7 | // @license MIT
|
|
51 | 51 | addCheckboxesToFiles();
|
52 | 52 | addBaseUpdateSelector();
|
53 | 53 | makePullRequestDiffEasierToScroll();
|
| 54 | + applyStickyPullRequestComments(); |
| 55 | + addAccessKeysToPullRequestTabs(); |
54 | 56 | } else if (/\/(_pulls|pullrequests)/i.test(window.location.pathname)) {
|
55 | 57 | sortPullRequestDashboard();
|
56 | 58 | }
|
| 59 | + |
| 60 | + applyNicerScrollbars(); |
| 61 | + } |
| 62 | + |
| 63 | + function applyStickyPullRequestComments() { |
| 64 | + // Comments that start with this string become sticky. Only the first comment of the thread counts. |
| 65 | + const lowerCasePrefix = 'note:'; |
| 66 | + |
| 67 | + addStyleOnce('sticky-comments', /* css */ ` |
| 68 | + .vc-discussion-thread-box .vc-discussion-thread-comment:first-of-type .vc-discussion-thread-renderparent[content^="${lowerCasePrefix}" i] { |
| 69 | + border: 2px solid var(--palette-black-alpha-20); |
| 70 | + aborder: 2px solid rgb(var(--palette-primary-tint-30)); |
| 71 | + border-radius: 5px; |
| 72 | + margin: 7px 0px; |
| 73 | + padding: 10px 15px; |
| 74 | + }`); |
| 75 | + |
| 76 | + // Expand threads that have the sticky prefix. |
| 77 | + $('.discussion-thread-host button.ms-Button.expand-button').once('opened-once').each(function () { |
| 78 | + // jQuery doesn't support case-insensitive string compares, so we need to drop into JS to find the prefix in the button's label. |
| 79 | + if (this.getAttribute('aria-label').toLowerCase().includes(`: "${lowerCasePrefix}`)) { |
| 80 | + this.click(); |
| 81 | + } |
| 82 | + }); |
| 83 | + } |
| 84 | + |
| 85 | + function addAccessKeysToPullRequestTabs() { |
| 86 | + // Give all the tabs an access key equal to their numeric position on screen. |
| 87 | + $('ul.vc-pullrequest-tabs a').once('add-accesskeys').each(function () { |
| 88 | + $(this).attr('accesskey', $(this).attr('aria-posinset')); |
| 89 | + }); |
| 90 | + } |
| 91 | + |
| 92 | + function applyNicerScrollbars() { |
| 93 | + addStyleOnce('nicer-scrollbars', /* css */ ` |
| 94 | + ::-webkit-scrollbar { |
| 95 | + width: 15px; |
| 96 | + height: 15px; |
| 97 | + } |
| 98 | + ::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { |
| 99 | + background: rgb(var(--palette-neutral-4)); |
| 100 | + } |
| 101 | + ::-webkit-scrollbar-thumb { |
| 102 | + background: rgb(var(--palette-neutral-20)); |
| 103 | + }`); |
57 | 104 | }
|
58 | 105 |
|
59 | 106 | function makePullRequestDiffEasierToScroll() {
|
|
0 commit comments