Last active
June 16, 2019 08:27
-
-
Save hlindberg/28a9633d7963d3b90cb6d69ba846a3ad to your computer and use it in GitHub Desktop.
Script to run in browser dev-mode when on label edit page for a github repo
This file contains hidden or 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
[ | |
{ | |
'name': 'bug', | |
'color': 'd63230', | |
'desc': 'Does not work (according to specification)' | |
}, | |
{ | |
'name': 'improvement', | |
'color': '39a9db', | |
'desc': 'improvement - neither bug nor new feature' | |
}, | |
{ | |
'name': 'feature', | |
'color': '1c77c3', | |
'desc': 'new feature' | |
}, | |
{ | |
'name': 'maint', | |
'color': '40bcd8', | |
'desc': 'maintenance' | |
}, | |
{ | |
'name': 'wontfix', | |
'color': '000000', | |
'desc': 'will not be worked on' | |
}, | |
{ | |
'name': 'invalid', | |
'color': '000000', | |
'desc': 'faulty / incomplete' | |
}, | |
{ | |
'name': 'duplicate', | |
'color': '000000', | |
'desc': 'duplicate of ticket or PR' | |
}, | |
{ | |
'name': 'cannot reproduce', | |
'color': '000000', | |
'desc': 'the described issue cannot be reproduced' | |
}, | |
{ | |
'name': 'docs', | |
'color': 'cccccc', | |
'desc': 'only affects documentation or comments' | |
}, | |
{ | |
'name': 'task', | |
'color': 'ecf8f8', | |
'desc': 'will not result in merged code' | |
}, | |
{ | |
'name': 'ACCEPTED', | |
'color': 'efeceb', | |
'desc': 'triaged - accepted, not yet ready for engineering' | |
}, | |
{ | |
'name': 'BLOCKED', | |
'color': 'f39237', | |
'desc': 'waiting on decision / input from assignee' | |
}, | |
{ | |
'name': 'ENGINEERING', | |
'color': 'eee4e1', | |
'desc': 'ready for engineering' | |
}, | |
{ | |
'name': 'MERGING', | |
'color': 'e7d8c9', | |
'desc': 'in process of being merged' | |
}, | |
{ | |
'name': 'TESTING', | |
'color': 'e6beae', | |
'desc': 'in process of being tested' | |
}, | |
{ | |
'name': 'RESOLVED', | |
'color': 'b2967d', | |
'desc': 'issue verified to have been released' | |
} | |
].forEach(function(label) { | |
addLabel(label) | |
}) | |
function updateLabel (label) { | |
var flag = false; | |
[].slice.call(document.querySelectorAll('.labels-list-item')) | |
.forEach(function(element) { | |
if (element.querySelector('.label-link').textContent.trim() === label.name) { | |
flag = true | |
element.querySelector('.js-edit-label').click() | |
element.querySelector('.js-new-label-name-input').value = label.name | |
element.querySelector('.js-new-label-description-input').value = label.desc | |
element.querySelector('.js-new-label-color-input').value = '#' + label.color | |
element.querySelector('.js-edit-label-cancel ~ .btn-primary').click() | |
} | |
}) | |
return flag | |
} | |
function addNewLabel (label) { | |
document.querySelector('.js-new-label-name-input').value = label.name | |
document.querySelector('.js-new-label-description-input').value = label.desc | |
document.querySelector('.js-new-label-color-input').value = '#' + label.color | |
document.querySelector('.js-details-target ~ .btn-primary').disabled = false | |
document.querySelector('.js-details-target ~ .btn-primary').click() | |
} | |
function addLabel (label) { | |
if (!updateLabel(label)) addNewLabel(label) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment