From 9fabd18b5c38d1a6276c60c567867d6e0592bffe Mon Sep 17 00:00:00 2001 From: John Murphy Date: Tue, 2 Apr 2019 12:30:21 -0500 Subject: [PATCH 1/3] clone comments option --- app.js | 37 +++++++++++++++++++++++++++++++++++-- options.html | 6 +++++- options.js | 10 +++++++--- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index cac1e0a..579eab8 100644 --- a/app.js +++ b/app.js @@ -303,9 +303,42 @@ function getGithubIssue(repo, closeOriginal) { // create the cloned GitHub issue function createGithubIssue(newIssue, repo, oldIssue, closeOriginal) { + const urlObj = populateUrlMetadata() + ajaxRequest('POST', newIssue, `https://api.github.com/repos/${repo}/issues`).then((response) => { - // add a comment to the closed issue - commentOnIssue(repo, oldIssue, response.data, closeOriginal) + // clone comments from old issue to new issue + cloneOldIssueComments(response.data.number, repo, `https://api.github.com/repos/${urlObj.organization}/${urlObj.currentRepo}/issues/${urlObj.issueNumber}/comments?per_page=100`).then((res) => { + // add a comment to the closed issue + commentOnIssue(repo, oldIssue, response.data, closeOriginal) + }) + }) +} + +function cloneOldIssueComments(newIssue, repo, url) { + return ajaxRequest('GET', '', url).then((comments) => { + chrome.storage.sync.get({ + cloneComments: false + }, (item) => { + if (!item.cloneComments) { + return Promise.resolve(null) + } + + if (!comments || !comments.data || comments.data.length === 0) { + return Promise.resolve(null) + } + + const promises = [] + comments.data.forEach((comment) => { + const c = { + body: comment.body + } + promises.push(ajaxRequest('POST', c, `https://api.github.com/repos/${repo}/issues/${newIssue}/comments`)) + }) + + Promise.all(promises).then((res) => { + return Promise.resolve({}) + }) + }) }) } diff --git a/options.html b/options.html index abf192b..e54febc 100644 --- a/options.html +++ b/options.html @@ -46,6 +46,10 @@

General Settings

+ +
+ +

@@ -64,4 +68,4 @@

General Settings

- \ No newline at end of file + diff --git a/options.js b/options.js index 1fc2709..641635a 100644 --- a/options.js +++ b/options.js @@ -3,11 +3,13 @@ function save_options() { var token = document.getElementById('github-pat').value; var goToList = document.getElementById('go-to-issue-list').checked; var createTab = document.getElementById('create-tab').checked; + var cloneComments = document.getElementById('clone-comments').checked; chrome.storage.sync.set({ githubToken: token, goToList: goToList, - createTab: createTab + createTab: createTab, + cloneComments: cloneComments }, function() { // Update status to let user know options were saved. var status = document.getElementById('status'); @@ -27,11 +29,13 @@ function restore_options() { chrome.storage.sync.get({ githubToken: '', goToList: false, - createTab: true + createTab: true, + cloneComments: false }, function(items) { document.getElementById('github-pat').value = items.githubToken; document.getElementById('go-to-issue-list').checked = items.goToList; document.getElementById('create-tab').checked = items.createTab; + document.getElementById('clone-comments').checked = items.cloneComments; }); } @@ -39,4 +43,4 @@ document.addEventListener('DOMContentLoaded', restore_options); document.getElementById('saveButton').addEventListener('click', save_options); document.getElementById('paypal-button').addEventListener('click', - paypal_donate); \ No newline at end of file + paypal_donate); From 824007a43264598b35500130eb437dd50b652b52 Mon Sep 17 00:00:00 2001 From: John Murphy Date: Tue, 2 Apr 2019 12:42:21 -0500 Subject: [PATCH 2/3] updated readme/terminology --- README.md | 7 +++++-- options.html | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8847086..32757a5 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,17 @@ Once you have your PAT, enter it on the Options screen for Kamino and click `Sav # Features +## Settings +- `Go to original repo's issue list after cloning` will navigate to the issue list for the repo from which the cloning was done +- `Create tab for cloned issue` will open a new tab and navigate to the newly cloned issue +- `Copy comments when cloning issue` will copy all comments when the issue is cloned + ## Normal operations Clicking this button will display a dropdown list of repos. Selecting a repo will ask you to perform one of the following actions: - `Clone and Close` will clone the issue and automatically close the original issue - `Just Clone` will clone the issue and keep the original issue open. This is useful if you've got shared code bases across repos and the issue is similar or the same across repos. - `Nevermind` will close the modal and no action will be performed -There are user settings for opening the new issue in a tab as well as navigating back to the original issue's repository issues list and these things will happen after Kamino has cloned the issue. Check the `Options` screen where your Personal Access Token was entered and saved. - ## Last used Kamino will remember the last 5 repositories you cloned to so that it will be easy for you to find. If you are someone that is a member of a lot of repos, this should be very handy! diff --git a/options.html b/options.html index e54febc..38e0c02 100644 --- a/options.html +++ b/options.html @@ -40,7 +40,7 @@

General Settings

- +
From a2d4abd2382b042a0034c8bb27f21848bc7ff65d Mon Sep 17 00:00:00 2001 From: John Murphy Date: Tue, 2 Apr 2019 12:42:58 -0500 Subject: [PATCH 3/3] version 2.10.0 --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 3c262a7..7002e40 100644 --- a/manifest.json +++ b/manifest.json @@ -35,7 +35,7 @@ "webNavigation", "*://github.com/*" ], - "version": "2.9.2", + "version": "2.10.0", "web_accessible_resources":[ "icons/*.png", "bootstrap/js/bootstrap.min.js", @@ -48,4 +48,4 @@ "options.js", "background.js" ] -} \ No newline at end of file +}