Last active
January 30, 2023 19:42
-
-
Save lucas-manuel/3ebe841841b3502b1e51e76a891a3dbe to your computer and use it in GitHub Desktop.
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
[ | |
{ | |
"name": "Priority: Critical", | |
"description": null, | |
"color": "b60205" | |
}, | |
{ | |
"name": "Priority: High", | |
"description": null, | |
"color": "d93f0b" | |
}, | |
{ | |
"name": "Priority: Low", | |
"description": null, | |
"color": "94f230" | |
}, | |
{ | |
"name": "Priority: Medium", | |
"description": null, | |
"color": "fbca04" | |
}, | |
{ | |
"name": "Status: Active Discussion", | |
"description": null, | |
"color": "f9d0c4" | |
}, | |
{ | |
"name": "Status: Approved", | |
"description": null, | |
"color": "0e8a16" | |
}, | |
{ | |
"name": "Status: Blocked", | |
"description": null, | |
"color": "e3ed78" | |
}, | |
{ | |
"name": "Status: Merge Conflicts", | |
"description": null, | |
"color": "d93f0b" | |
}, | |
{ | |
"name": "Status: On Hold", | |
"description": null, | |
"color": "e99695" | |
}, | |
{ | |
"name": "Status: Prototype", | |
"description": null, | |
"color": "c5def5" | |
}, | |
{ | |
"name": "Status: Ready for Merge", | |
"description": null, | |
"color": "08a5c5" | |
}, | |
{ | |
"name": "Status: Ready for Review", | |
"description": null, | |
"color": "0e8a16" | |
}, | |
{ | |
"name": "Status: Revisions Needed", | |
"description": null, | |
"color": "fef2c0" | |
}, | |
{ | |
"name": "Status: Work In Progress", | |
"description": null, | |
"color": "1d76db" | |
} | |
].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.description | |
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.description | |
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