Skip to content

Commit

Permalink
Merge pull request #172 from gatewayapps/enhancement/143-batch-cloning
Browse files Browse the repository at this point in the history
Enhancement/143 batch cloning
  • Loading branch information
johnmurphy01 authored May 6, 2021
2 parents 1a840d6 + 1931947 commit ba3d69f
Show file tree
Hide file tree
Showing 24 changed files with 15,001 additions and 9,467 deletions.
2 changes: 1 addition & 1 deletion .prettier-ignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
handlebars.runtime-v4.0.10.js
handlebars.runtime.min-v4.7.7.js
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"cSpell.words": [
"Nevermind",
"Repos",
"kamino",
"linkstring"
]
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Kamino now supports a quick clone feature. The last repository you cloned to wil

For those who have a large number of repositories, Kamino has now introduced a search feature. This can be used to filter the list of repositories quickly. Thanks to [@CamSoper](https://github.com/CamSoper) for the request!

## Batch Cloning(EXPERIMENTAL!!!)

For those who require the ability to clone multiple issues all at once to a repository, there is now a Batch Clone button on the issue list page. This will display a popup that asks where the issue(s) should be cloned and which issue(s) should be cloned. Again, this is a new feature(as of May 2021) and Kamino wasn't meant to do batch cloning, so use at your own risk but I appreciate any and all feedback.

### How does it work?

Kamino leverages the GitHub API to gather information about the issue you are on. Kamino is a chrome extension utilizing content scripts to create a button on specific web pages, specifically GitHub issue pages.
Expand Down
31 changes: 20 additions & 11 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,32 @@ var token = ''
// repo list
var repoList = []

var intervalIds = []

$(window).on('unload', () => {
intervalIds.forEach(clearInterval)
return
})

// don't try to re initialize the extension if there's a token in memory
if (token === '') {
// load jquery via JS
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.min.js', () => {
setInterval(() => {
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js', () => {
intervalIds.push(setInterval(() => {
initializeExtension()
}, 1000)
}, 1000))
})
}

function initializeExtension() {
// if there's already a button on the screen, exit
if ($('.kaminoButton').length > 0) {
if ($('.kaminoButton').length > 0 || $('.batchButton').length > 0) {
intervalIds.forEach(clearInterval)
return
}

intervalIds.forEach(clearInterval)

// the button
const newBtn = $(Handlebars.templates.button().replace(/(\r\n|\n|\r)/gm, ''))

Expand All @@ -39,7 +49,8 @@ function initializeExtension() {
urlObj.url.indexOf(`${urlObj.organization}/${urlObj.currentRepo}/compare/`) < 0 &&
urlObj.url.indexOf(`${urlObj.organization}/${urlObj.currentRepo}/pull/`) < 0 &&
urlObj.url.indexOf(`${urlObj.organization}/${urlObj.currentRepo}/issues/new`) < 0 &&
$('.kaminoButton').length === 0
$('.kaminoButton').length === 0 &&
$('.batchButton').length === 0
) {
// look for any applied issue filters
saveAppliedFilters(urlObj)
Expand Down Expand Up @@ -95,7 +106,7 @@ function initializeExtension() {
$('.noClone').click(() => {
closeModal()
})
}
}
}

function saveAppliedFilters(urlObj) {
Expand Down Expand Up @@ -151,9 +162,7 @@ function saveAppliedFilters(urlObj) {
{
filters: item.filters,
},
() => {
console.log('filters saved')
}
() => {}
)
}
}
Expand Down Expand Up @@ -184,6 +193,7 @@ function getRepos(url) {
return null
}
} else {
compileRepositoryList(repos.data)
return null
}
})
Expand All @@ -206,7 +216,7 @@ function loadRepos() {

// if there's no personal access token, disable the button
if (token === '') {
console.log('disabling button because there is no Personal Access Token for authentication with Github')
console.warn('disabling button because there is no Personal Access Token for authentication with Github')
$('.kaminoButton').prop('disabled', true)
$('.quickClone').prop('disabled', true)
}
Expand Down Expand Up @@ -242,7 +252,6 @@ function compileRepositoryList(list, searchTerm) {

// filter out most used by search term
if (searchTerm && searchTerm !== '') {
console.log('filtering most used: ', searchTerm)
mostUsed = item.mostUsed.filter((item, index) => {
return item.indexOf(searchTerm) > -1
})
Expand Down
5 changes: 2 additions & 3 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// used when Github uses push state.
chrome.webNavigation.onHistoryStateUpdated.addListener((details) => {
chrome.tabs.executeScript(null, { file: "jquery/jquery-3.2.0.min.js", runAt: 'document_end' }, (j) => {
chrome.tabs.executeScript(null, { file: "handlebars.runtime-v4.0.10.js", runAt: 'document_end' }, (h) => {
chrome.tabs.executeScript(null, { file: "jquery/jquery-3.6.0.min.js", runAt: 'document_end' }, (j) => {
chrome.tabs.executeScript(null, { file: "handlebars.runtime.min-v4.7.7.js", runAt: 'document_end' }, (h) => {
chrome.tabs.executeScript(null, { file: "template.js", runAt: 'document_end' }, (h) => {
chrome.tabs.executeScript(null, { file: "app.js", runAt: 'document_end' }, (a) => {
chrome.tabs.insertCSS(null, { file: "css/style.css", runAt: 'document_end' })
Expand Down Expand Up @@ -55,7 +55,6 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
})
}
else {
console.log('no navigation')
if (item.createTab) {
// if user setting is not set, open open cloned issue in new tab and set focus to that tab
setTimeout(() => { chrome.tabs.create({ url: `https://github.com/${request.repo}/issues/${request.issueNumber}`, selected: true }) }, 1000)
Expand Down
Loading

0 comments on commit ba3d69f

Please sign in to comment.