Created
April 3, 2018 14:27
-
-
Save hswolff/fe0575267ead42a8dbdf7cbb41ace117 to your computer and use it in GitHub Desktop.
Little Script to Rank to Top issues in a Jira Epic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function rankNonDoneIssuesToTopInEpic(dryRun = true) { | |
console.warn(`Dry Run: ${dryRun ? 'ENABLED' : 'DISABLED'}`); | |
const issuesInEpic = Array.from(document.querySelectorAll('.nav.status')) | |
.filter(el => !['Resolved', 'Closed'].includes(el.textContent.trim())) | |
// Go from bottom up so the order remains the same | |
.reverse(); | |
const sleep = (time = 1000) => | |
new Promise(resolve => setTimeout(resolve, time)); | |
for (const el of issuesInEpic) { | |
const rowEl = el.parentElement; | |
const data = { | |
ticketNumber: rowEl.getAttribute('data-issuekey'), | |
summary: rowEl.querySelector('.ghx-summary').textContent.trim(), | |
}; | |
const message = `${data.ticketNumber}: ${data.summary}`; | |
console.group(message); | |
console.log('Updating'); | |
// Open gear menu | |
rowEl.querySelector('.nav.issue_actions a').click(); | |
console.log('Opening gear menu'); | |
await sleep(); | |
// Get Rank to Top element | |
const rankToTopEl = Array.from( | |
document.querySelectorAll('.ajs-layer.active .aui-last a') | |
).find(el => el.textContent.trim() === 'Rank to Top'); | |
if (rankToTopEl) { | |
console.log('Clicking Rank to Top'); | |
if (!dryRun) { | |
rankToTopEl.click(); | |
} | |
await sleep(); | |
} | |
console.groupEnd(message); | |
} | |
console.log('Done!'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment