diff --git a/source/github-issue-link-status.js b/source/github-issue-link-status.js index f3b2faa..5e47480 100644 --- a/source/github-issue-link-status.js +++ b/source/github-issue-link-status.js @@ -8,9 +8,15 @@ const issueUrlRegex = /^[/]([^/]+[/][^/]+)[/](issues|pull)[/](\d+)([/]|$)/; const stateColorMap = { open: 'text-green', closed: 'text-red', - merged: 'text-purple' + merged: 'text-purple', + draft: 'text-gray' }; +const stateDependentIcons = [ + 'closedissue', + 'mergedpullrequest' +]; + function anySelector(selector) { const prefix = document.head.style.MozOrient === '' ? 'moz' : 'webkit'; return selector.replace(/:any\(/g, `:-${prefix}-any(`); @@ -50,7 +56,8 @@ function buildGQL(links) { ${esc(id)}: issueOrPullRequest(number: ${id}) { __typename ... on PullRequest { - state + state, + isDraft } ... on Issue { state @@ -108,10 +115,14 @@ async function apply() { for (const {link, repo, id} of links) { try { const item = data[esc(repo)][esc(id)]; - const state = item.state.toLowerCase(); const type = item.__typename.toLowerCase(); + let state = item.state.toLowerCase(); + if (item.isDraft && state === 'open') { + state = 'draft'; + } + link.classList.add(stateColorMap[state]); - if (state !== 'open' && state + type !== 'closedpullrequest') { + if (stateDependentIcons.includes(state + type)) { link.querySelector('svg').outerHTML = icons[state + type]; } } catch {/* Probably a redirect */} diff --git a/webpack.config.js b/webpack.config.js index d173e42..0a47e95 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,6 +3,7 @@ const path = require('path'); const CopyWebpackPlugin = require('copy-webpack-plugin'); module.exports = { + devtool: 'source-map', entry: { 'github-issue-link-status': './source/github-issue-link-status', background: './source/background',