Compare commits

..

2 Commits

Author SHA1 Message Date
Sage Vaillancourt e3c8199598 1.0.24 - Highlight on mouseover instead of click.
Also, switch to a more dark-theme friendly highlight color.
2025-04-11 14:06:09 -04:00
Sage Vaillancourt 46bd17172a Search all projects user has access to for reviewer counts
Except GRAV and TEST.
2025-02-03 12:20:26 -05:00
5 changed files with 43 additions and 23 deletions

View File

@ -1,7 +1,7 @@
{
"name": "Sage's BitBucket Addon",
"description": "Ensure searches don't include forks (and other enhancements)",
"version": "1.0.22",
"version": "1.0.24",
"manifest_version": 2,
"browser_specific_settings": {
"gecko": {

View File

@ -1,4 +1,10 @@
if (location.toString().includes('/pull-requests?create')) {
const addOnly = async () => ['ADD']
const allProjects = async () => fetch('https://git.add123.com/rest/api/latest/projects')
.then(resp => resp.json())
.then(async ({ values }) => values.map(project => project.key).filter(key => !['GRAV', 'TEST'].includes(key)))
const names = [
"Tam Nguyen",
"David Daniel",
@ -15,28 +21,37 @@ if (location.toString().includes('/pull-requests?create')) {
const urlPrefix = 'https://git.add123.com/rest/api/latest'
fetch(`${urlPrefix}/projects/ADD/repos?limit=999`)
.then(resp => resp.json())
.then(async ({values: allRepos}) => {
const prListUrls = allRepos.map(repo => `${urlPrefix}/projects/ADD/repos/${repo.slug}/pull-requests`)
const allPullRequests = (await Promise.all(
prListUrls.map(async prListUrl => await fetch(prListUrl).then(resp => resp.json())))
).flatMap(({values}) => values)
const getPullRequestsForProject = async project => {
return await fetch(`${urlPrefix}/projects/${project}/repos?limit=999`)
.then(resp => resp.json())
.then(async (resp) => {
if (!resp) {
return []
}
const { values: allRepos } = resp
const prListUrls = allRepos.map(repo => `${urlPrefix}/projects/${project}/repos/${repo.slug}/pull-requests`)
return (await Promise.all(
prListUrls.map(async prListUrl => await fetch(prListUrl).then(resp => resp.json())))
).flatMap(({values}) => values)})
}
const reviewerCounts = Object.fromEntries(names.map(name => [name, 0]))
allPullRequests.forEach(({reviewers}) => {
reviewers?.map(r => r.user.displayName)
.filter(displayName => !["Chris Gamache", "Tom Keels"].includes(displayName))
.forEach(displayName => {
reviewerCounts[displayName] ??= 0
reviewerCounts[displayName] += 1
})
})
const sortedCounts = Object.entries(reviewerCounts)
.map(([name, count]) => ({ name, count }))
.toSorted((a, b) => a.count - b.count)
allProjects().then(async allProjects => {
const allPullRequests = (await Promise.all(allProjects.map(async project => await getPullRequestsForProject(project)))).flatMap(a => a)
const reviewerCounts = Object.fromEntries(names.map(name => [name, 0]))
allPullRequests.forEach(({reviewers}) => {
reviewers?.map(r => r.user.displayName)
.filter(displayName => names.includes(displayName))
//.filter(displayName => !["Chris Gamache", "Tom Keels", "Todd Sherrin", "Kelly Gunter", "Mark Garrett"].includes(displayName))
.forEach(displayName => {
reviewerCounts[displayName] ??= 0
reviewerCounts[displayName] += 1
})
})
const sortedCounts = Object.entries(reviewerCounts)
.map(([name, count]) => ({name, count}))
.toSorted((a, b) => a.count - b.count)
const tryDisplay = () => setTimeout(() => {
if (document.getElementById('reviewer-counts')) {
if (!sortedCounts.length || document.getElementById('reviewer-counts')) {
return
}
const formBodyMain = document.querySelector('.create-pull-request-form .form-body .form-body-main')
@ -56,6 +71,10 @@ if (location.toString().includes('/pull-requests?create')) {
reviewerCountsNode.appendChild(listItem)
})
const projectHeadsUp = document.createElement('div')
projectHeadsUp.innerText = 'Note: this list does not take into account any projects that you do not have access to. E.g. STA'
reviewerCountsNode.appendChild(projectHeadsUp)
const label = countsParent.querySelector('.form-label')
label.innerText = 'Now reviewing'
const message = countsParent.querySelector('.form-field-content')

Binary file not shown.

Binary file not shown.

View File

@ -65,7 +65,8 @@ const addVariableClickers = skipExpandos => {
getVarElements()
.forEach(e => {
e.onclick = () => selectVar(e.innerText)
e.onmouseover = () => selectVar(e.innerText)
e.onmouseleave = () => selectVar('zzzzz')
e.ondblclick = () => {
let searchBox = getSearchBox()
@ -86,7 +87,7 @@ addFix(() => {
const styleSheet = document.createElement('style')
styleSheet.innerText = `
.${selectedClass} {
background: rgb(255, 253, 170) !important;
background: rgba(255, 253, 170, 0.1) !important;
border-radius: 3px;
padding: 2px !important;
margin: -2px !important;