From 58fe296c374d69276c75682500bca28d8d83ffbf Mon Sep 17 00:00:00 2001 From: Fregante Date: Sun, 26 Apr 2020 17:31:33 +0200 Subject: [PATCH 1/5] Maybe add draft support #31 --- source/github-issue-link-status.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/github-issue-link-status.js b/source/github-issue-link-status.js index f3b2faa..c033067 100644 --- a/source/github-issue-link-status.js +++ b/source/github-issue-link-status.js @@ -8,7 +8,8 @@ const issueUrlRegex = /^[/]([^/]+[/][^/]+)[/](issues|pull)[/](\d+)([/]|$)/; const stateColorMap = { open: 'text-green', closed: 'text-red', - merged: 'text-purple' + merged: 'text-purple', + draft: 'text-gray' }; function anySelector(selector) { @@ -51,6 +52,7 @@ function buildGQL(links) { __typename ... on PullRequest { state + isDraft } ... on Issue { state @@ -108,7 +110,7 @@ async function apply() { for (const {link, repo, id} of links) { try { const item = data[esc(repo)][esc(id)]; - const state = item.state.toLowerCase(); + const state = item.isDraft ? 'draft' : item.state.toLowerCase(); const type = item.__typename.toLowerCase(); link.classList.add(stateColorMap[state]); if (state !== 'open' && state + type !== 'closedpullrequest') { From 08af42b17b23d8f3f1e47360952e457d597f7739 Mon Sep 17 00:00:00 2001 From: Federico Brigante Date: Sun, 26 Apr 2020 17:41:44 +0200 Subject: [PATCH 2/5] Fix watch build --- webpack.config.js | 1 + 1 file changed, 1 insertion(+) 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', From 8a44e83bdd312fe8dc6b913045edd23313d23e43 Mon Sep 17 00:00:00 2001 From: Federico Brigante Date: Sun, 26 Apr 2020 17:42:12 +0200 Subject: [PATCH 3/5] Fix GQL broken due to GQL minification --- source/github-issue-link-status.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/github-issue-link-status.js b/source/github-issue-link-status.js index c033067..4a2f064 100644 --- a/source/github-issue-link-status.js +++ b/source/github-issue-link-status.js @@ -51,7 +51,7 @@ function buildGQL(links) { ${esc(id)}: issueOrPullRequest(number: ${id}) { __typename ... on PullRequest { - state + state, isDraft } ... on Issue { From 5a063229f2b760624a8ea57cb067b0e4d0e4e740 Mon Sep 17 00:00:00 2001 From: Federico Brigante Date: Sun, 26 Apr 2020 17:42:21 +0200 Subject: [PATCH 4/5] Fix icon --- source/github-issue-link-status.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/github-issue-link-status.js b/source/github-issue-link-status.js index 4a2f064..541de08 100644 --- a/source/github-issue-link-status.js +++ b/source/github-issue-link-status.js @@ -12,6 +12,11 @@ const stateColorMap = { 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(`); @@ -113,7 +118,7 @@ async function apply() { const state = item.isDraft ? 'draft' : item.state.toLowerCase(); const type = item.__typename.toLowerCase(); 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 */} From 68723b4187a918589766d9467b40fbd11a2a7cfb Mon Sep 17 00:00:00 2001 From: Federico Brigante Date: Sun, 26 Apr 2020 17:59:54 +0200 Subject: [PATCH 5/5] Leave closed PRs as gray --- source/github-issue-link-status.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/github-issue-link-status.js b/source/github-issue-link-status.js index 541de08..5e47480 100644 --- a/source/github-issue-link-status.js +++ b/source/github-issue-link-status.js @@ -14,7 +14,7 @@ const stateColorMap = { const stateDependentIcons = [ 'closedissue', - 'mergedpullrequest', + 'mergedpullrequest' ]; function anySelector(selector) { @@ -115,8 +115,12 @@ async function apply() { for (const {link, repo, id} of links) { try { const item = data[esc(repo)][esc(id)]; - const state = item.isDraft ? 'draft' : 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 (stateDependentIcons.includes(state + type)) { link.querySelector('svg').outerHTML = icons[state + type];