Skip to content

Instantly share code, notes, and snippets.

@nilsreichardt
Last active February 27, 2021 15:27
Show Gist options
  • Save nilsreichardt/fe7a6130cffd9f782ef405d909c14c7c to your computer and use it in GitHub Desktop.
Save nilsreichardt/fe7a6130cffd9f782ef405d909c14c7c to your computer and use it in GitHub Desktop.
A template for importing a list of common client labels.
[
{
"name": "accessibility",
"description": "Accessibility, e.g. VoiceOver or TalkBack. (aka a11y)",
"color": "38d8c8"
},
{
"name": "crash",
"description": "App crashes and is unusable in a significant way.",
"color": "900000"
},
{
"name": "bug",
"description": "Something is not working correctly.",
"color": "900000"
},
{
"name": "documentation",
"description": "Related to improving documentation and the wiki.",
"color": "6addf7"
},
{
"name": "feature request",
"description": "A new feature suggestion.",
"color": "84b6eb"
},
{
"name": "improvement",
"description": "Improvement upon an existing feature.",
"color": "84b6eb"
},
{
"name": "security",
"description": "Questions, concerns, or suggestions for improving the security of the app.",
"color": "1d76db"
},
{
"name": "platform-web",
"description": "Web applications specifically.",
"color": "003470"
},
{
"name": "platform-android",
"description": "Android applications specifically.",
"color": "003470"
},
{
"name": "platform-ios",
"description": "iOS applications specifically.",
"color": "003470"
},
{
"name": "platform-macos",
"description": "macOS applications specifically.",
"color": "003470"
},
{
"name": "platform-linux",
"description": "Linux applications specifically.",
"color": "003470"
},
{
"name": "platform-windows",
"description": "Windows applications specifically.",
"color": "003470"
},
{
"name": "platform-fuchsia",
"description": "Fuchsia applications specifically.",
"color": "003470"
},
{
"name": "platform-chromebook",
"description": "Chromebook applications specifically.",
"color": "003470"
},
{
"name": "P0",
"description": "Priority 0 should be fixed immediately, like security issues, crashes",
"color": "900000"
},
{
"name": "P1",
"description": "Priority 1",
"color": "900000"
},
{
"name": "P2",
"description": "Priority 2",
"color": "900000"
},
{
"name": "P3",
"description": "Priority 3",
"color": "900000"
},
{
"name": "P4",
"description": "Priority 4",
"color": "900000"
},
{
"name": "P5",
"description": "Priority 5",
"color": "900000"
},
{
"name": "P6",
"description": "Priority P6",
"color": "900000"
},
{
"name": "d: light mode",
"description": "",
"color": "8D008D"
},
{
"name": "d: dark mode",
"description": "",
"color": "8D008D"
},
{
"name": "d: ui",
"description": "",
"color": "8D008D"
},
{
"name": "d: ux",
"description": "",
"color": "8D008D"
},
{
"name": "d: desktop",
"description": "Related to the desktop experience",
"color": "8D008D"
},
{
"name": "d: tablet",
"description": "Related to the tablet experience",
"color": "8D008D"
},
{
"name": "d: mobile",
"description": "Related to the mobile experience",
"color": "8D008D"
},
{
"name": "d: animation",
"description": "",
"color": "8D008D"
},
{
"name": "performance",
"description": "",
"color": "A2D939"
},
{
"name": "test:unit",
"description": "Unit Tests",
"color": "FBCA04"
},
{
"name": "test:integration",
"description": "Integration Tests",
"color": "FBCA04"
},
{
"name": "test:e2e",
"description": "E2E Tests",
"color": "FBCA04"
},
{
"name": "navigation",
"description": "Tickets which are related to the navigation",
"color": ""
}
]
/**
* Copied from https://gist.github.com/douglascayers/d47e525dbd1e7149bafa65939f350baf (@douglascayers)
*/
function createLabel( 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 updateLabel( label ) {
let updatedLabel = false;
[].slice.call( document.querySelectorAll( '.js-labels-list-item' ) ).forEach( element => {
if ( element.querySelector( '.js-label-link' ).textContent.trim() === label.name ) {
updatedLabel = 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 updatedLabel;
}
function createOrUpdate( label ) {
if ( !updateLabel( label ) ) {
createLabel( label );
}
}
[
// YOUR LABELS JSON HERE
].forEach( label => createOrUpdate( label ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment