(token, owner, repo, title, body, labels = [])
| 971 | } |
| 972 | }) |
| 973 | function createIssue(token, owner, repo, title, body, labels = []) { |
| 974 | const url = `https://api.github.com/repos/${owner}/${repo}/issues` |
| 975 | const issueData = { |
| 976 | title: title, |
| 977 | body: body, |
| 978 | labels: labels |
| 979 | } |
| 980 | const xhr = new XMLHttpRequest() |
| 981 | xhr.open('POST', url, true) |
| 982 | xhr.setRequestHeader('Authorization', `token ${token}`) |
| 983 | xhr.setRequestHeader('Accept', 'application/vnd.github+json') |
| 984 | xhr.setRequestHeader('Content-Type', 'application/json') |
| 985 | xhr.onreadystatechange = function () { |
| 986 | if (xhr.readyState === 4) { |
| 987 | if (xhr.status >= 200 && xhr.status < 300) { |
| 988 | const response = JSON.parse(xhr.responseText) |
| 989 | showDialog(translate.github_success, response.html_url) |
| 990 | |
| 991 | } else { |
| 992 | alert(`${translate.github_failed}\n ${xhr.status}\n ${xhr.statusText}\n ${xhr.responseText}`) |
| 993 | console.error(`${translate.github_failed}`, xhr.status, xhr.statusText, xhr.responseText) |
| 994 | } |
| 995 | } |
| 996 | } |
| 997 | xhr.send(JSON.stringify(issueData)) |
| 998 | } |
| 999 | })() |
no test coverage detected