Skip to content

Commit 263f073

Browse files
Sticky comments, PR tab keyboard shortcuts, and nicer scrollbars (#11)
- Make comments that start with "note" always appear on load, and highlight them with a border - Add keyboard shortcuts to the PR tabs (in Chrome, it'd be Alt+1, Alt+2, etc) - Make all scrollbars match the AzDO color theme - Updated README
1 parent 019aad2 commit 263f073

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ After (scrollbar is always visible):
6666

6767
![Scrollbars always visible.](static/after-pr-diff-scroll-improvements.png)
6868

69+
You can now use keyboard shortcuts to quickly switch between PR tabs (e.g. Overview, Files, etc). In Chrome, it'd be `Alt+1`, `Alt+2`, etc. In FireFox, it is `Alt+Shift+Num`. [See this table for details on your browser.](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey)
70+
71+
![PR tab keyboard shortcuts in Chrome.](static/pr-tab-accesskeys.png)
72+
73+
Finally, PR comments that start with `note:` (case insensitive) will appear expanded on page load, even if they are closed. They are also highlighted with a light border:
74+
75+
![Sticky comments are highlighted.](static/sticky-comment-highlighting.png)
76+
6977
### Better owners review
7078

7179
> These features are currently specific to National Instruments.
@@ -86,6 +94,10 @@ Hopefully all this makes it very easy to scan for the stuff you care about.
8694

8795
Note: If there is no owner info, or if you are not listed, nothing is highlighted and the button does not appear. It also only works with newer PRs (created or updated since approx. July 2019).
8896

97+
### Overall
98+
99+
Scrollbars site-wide now match the current Azure DevOps color theme.
100+
89101
## Documentation
90102

91103
- [Support and troubleshooting](SUPPORT.md)

src/azdo-pr-dashboard.user.js

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22

33
// @name AzDO Pull Request Improvements
4-
// @version 2.22.1
4+
// @version 2.23.0
55
// @author Alejandro Barreto (National Instruments)
66
// @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.
77
// @license MIT
@@ -51,9 +51,56 @@
5151
addCheckboxesToFiles();
5252
addBaseUpdateSelector();
5353
makePullRequestDiffEasierToScroll();
54+
applyStickyPullRequestComments();
55+
addAccessKeysToPullRequestTabs();
5456
} else if (/\/(_pulls|pullrequests)/i.test(window.location.pathname)) {
5557
sortPullRequestDashboard();
5658
}
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+
}`);
57104
}
58105

59106
function makePullRequestDiffEasierToScroll() {

static/pr-tab-accesskeys.png

20.7 KB
Loading
10.7 KB
Loading

0 commit comments

Comments
 (0)