@@ -21,22 +21,22 @@ function initializeExtension() {
2121 }
2222
2323 // the button
24- const newBtn = $ ( Handlebars . templates . button ( ) . replace ( / ( \r \n | \n | \r ) / gm, "" ) )
24+ const newBtn = $ ( Handlebars . templates . button ( ) . replace ( / ( \r \n | \n | \r ) / gm, "" ) )
2525
2626 // the modal
27- const context = { confirmText : 'Are you sure you want to clone this issue to another repository? Choose whether to clone and close or clone and keep the original issue open.' }
28- const popup = $ ( Handlebars . templates . modal ( context ) . replace ( / ( \r \n | \n | \r ) / gm, "" ) )
27+ const context = { confirmText : 'Are you sure you want to clone this issue to another repository? Choose whether to clone and close or clone and keep the original issue open.' }
28+ const popup = $ ( Handlebars . templates . modal ( context ) . replace ( / ( \r \n | \n | \r ) / gm, "" ) )
2929
3030 // get url
3131 const urlObj = populateUrlMetadata ( )
3232
3333 // if the page is not a pull request page(view or create)
3434 // and the page is not a new issue page
3535 // and there is no Kamino button in the DOM, proceed
36- if ( urlObj . url . indexOf ( urlObj . organization + '/' + urlObj . currentRepo + ' /compare/' ) < 0 &&
37- urlObj . url . indexOf ( urlObj . organization + '/' + urlObj . currentRepo + ' /pull/' ) < 0 &&
38- urlObj . url . indexOf ( urlObj . organization + '/' + urlObj . currentRepo + ' /issues/new' ) < 0 &&
39- $ ( '.kaminoButton' ) . length === 0 ) {
36+ if ( urlObj . url . indexOf ( ` ${ urlObj . organization } / ${ urlObj . currentRepo } /compare/` ) < 0 &&
37+ urlObj . url . indexOf ( ` ${ urlObj . organization } / ${ urlObj . currentRepo } /pull/` ) < 0 &&
38+ urlObj . url . indexOf ( ` ${ urlObj . organization } / ${ urlObj . currentRepo } /issues/new` ) < 0 &&
39+ $ ( '.kaminoButton' ) . length === 0 ) {
4040
4141 // look for any applied issue filters
4242 saveAppliedFilters ( urlObj )
@@ -166,7 +166,7 @@ function getRepos(url) {
166166
167167 compileRepositoryList ( repos . data )
168168
169- if ( nextLink ) {
169+ if ( nextLink ) {
170170 return getRepos ( nextLink )
171171 } else {
172172 return null
@@ -180,16 +180,16 @@ function getRepos(url) {
180180function loadRepos ( ) {
181181 // wire up search value change events
182182 var lastValue = '' ;
183- $ ( ".repoSearch" ) . on ( 'change keyup paste mouseup' , function ( ) {
184- if ( $ ( this ) . val ( ) != lastValue ) {
185- lastValue = $ ( this ) . val ( )
186- searchRepositories ( lastValue )
187- }
183+ $ ( ".repoSearch" ) . on ( 'change keyup paste mouseup' , function ( ) {
184+ if ( $ ( this ) . val ( ) != lastValue ) {
185+ lastValue = $ ( this ) . val ( )
186+ searchRepositories ( lastValue )
187+ }
188188 } )
189189
190190 // create a way to go to options without using the extension context menu
191191 $ ( ".kamino-heading" ) . click ( ( ) => {
192- chrome . runtime . sendMessage ( { action :'goToOptions' } , ( response ) => {
192+ chrome . runtime . sendMessage ( { action : 'goToOptions' } , ( response ) => {
193193 } )
194194 } )
195195
@@ -221,23 +221,23 @@ function compileRepositoryList(list, searchTerm) {
221221 // check for a populated list
222222 if ( item . mostUsed && item . mostUsed . length > 0 ) {
223223 $ ( '.quickClone' ) . attr ( 'data-repo' , item . mostUsed [ 0 ] ) ;
224- $ ( '.quickClone' ) . text ( ' Clone to ' + item . mostUsed [ 0 ] . substring ( item . mostUsed [ 0 ] . indexOf ( '/' ) + 1 ) )
224+ $ ( '.quickClone' ) . text ( ` Clone to ${ item . mostUsed [ 0 ] . substring ( item . mostUsed [ 0 ] . indexOf ( '/' ) + 1 ) } ` )
225225
226226 // show used separator header
227227 $ ( '.dropdown-header-used' ) . addClass ( 'active' )
228228
229229 var mostUsed = item . mostUsed
230230
231231 // filter out most used by search term
232- if ( searchTerm && searchTerm !== '' ) {
232+ if ( searchTerm && searchTerm !== '' ) {
233233 console . log ( 'filtering most used: ' , searchTerm )
234234 mostUsed = item . mostUsed . filter ( ( item , index ) => {
235235 return item . indexOf ( searchTerm ) > - 1
236236 } )
237237 }
238238
239239 // hide header if there are no last used items
240- if ( ! mostUsed || mostUsed . length === 0 ) {
240+ if ( ! mostUsed || mostUsed . length === 0 ) {
241241 $ ( '.dropdown-header-used' ) . removeClass ( 'active' )
242242 }
243243
@@ -259,7 +259,7 @@ function compileRepositoryList(list, searchTerm) {
259259 }
260260
261261 // show or hide rest header based on number of items
262- if ( ! list || list . length === 0 ) {
262+ if ( ! list || list . length === 0 ) {
263263 $ ( '.dropdown-header-rest' ) . removeClass ( 'active' )
264264 } else {
265265 $ ( '.dropdown-header-rest' ) . addClass ( 'active' )
@@ -289,11 +289,11 @@ function searchRepositories(searchTerm) {
289289function getGithubIssue ( repo , closeOriginal ) {
290290 const urlObj = populateUrlMetadata ( )
291291
292- ajaxRequest ( 'GET' , '' , ' https://api.github.com/repos/' + urlObj . organization + '/' + urlObj . currentRepo + ' /issues/' + urlObj . issueNumber ) . then ( ( issue ) => {
292+ ajaxRequest ( 'GET' , '' , ` https://api.github.com/repos/${ urlObj . organization } / ${ urlObj . currentRepo } /issues/${ urlObj . issueNumber } ` ) . then ( ( issue ) => {
293293 // build new issue
294294 const newIssue = {
295295 title : issue . data . title ,
296- body : ' From ' + urlObj . currentRepo + ' created by [' + issue . data . user . login + '](' + issue . data . user . html_url + ') : ' + urlObj . organization + '/' + urlObj . currentRepo + '#' + urlObj . issueNumber + " \n\n" + issue . data . body ,
296+ body : ` From ${ urlObj . currentRepo } created by [${ issue . data . user . login } ]( ${ issue . data . user . html_url } ): ${ urlObj . organization } / ${ urlObj . currentRepo } # ${ urlObj . issueNumber } \n\n${ issue . data . body } ` ,
297297 labels : issue . data . labels
298298 }
299299
@@ -303,7 +303,7 @@ function getGithubIssue(repo, closeOriginal) {
303303
304304// create the cloned GitHub issue
305305function createGithubIssue ( newIssue , repo , oldIssue , closeOriginal ) {
306- ajaxRequest ( 'POST' , newIssue , ' https://api.github.com/repos/' + repo + ' /issues' ) . then ( ( response ) => {
306+ ajaxRequest ( 'POST' , newIssue , ` https://api.github.com/repos/${ repo } /issues` ) . then ( ( response ) => {
307307 // add a comment to the closed issue
308308 commentOnIssue ( repo , oldIssue , response . data , closeOriginal )
309309 } )
@@ -316,18 +316,18 @@ function closeGithubIssue(oldIssue) {
316316
317317 const urlObj = populateUrlMetadata ( )
318318
319- ajaxRequest ( 'PATCH' , issueToClose , ' https://api.github.com/repos/' + urlObj . organization + '/' + urlObj . currentRepo + ' /issues/' + urlObj . issueNumber ) . then ( ( done ) => {
319+ ajaxRequest ( 'PATCH' , issueToClose , ` https://api.github.com/repos/${ urlObj . organization } / ${ urlObj . currentRepo } /issues/${ urlObj . issueNumber } ` ) . then ( ( done ) => {
320320 } )
321321}
322322
323323function commentOnIssue ( repo , oldIssue , newIssue , closeOriginal ) {
324324 const urlObj = populateUrlMetadata ( )
325- const newIssueLink = '[' + repo + ']' + '(' + newIssue . html_url + ')'
325+ const newIssueLink = `[ ${ repo } ]( ${ newIssue . html_url } )`
326326 const comment = {
327- body : closeOriginal ? ' Kamino closed and cloned this issue to ' + newIssueLink : ' Kamino cloned this issue to ' + newIssueLink
327+ body : closeOriginal ? ` Kamino closed and cloned this issue to ${ newIssueLink } ` : ` Kamino cloned this issue to ${ newIssueLink } `
328328 }
329329
330- ajaxRequest ( 'POST' , comment , ' https://api.github.com/repos/' + urlObj . organization + '/' + urlObj . currentRepo + ' /issues/' + urlObj . issueNumber + ' /comments' ) . then ( ( response ) => {
330+ ajaxRequest ( 'POST' , comment , ` https://api.github.com/repos/${ urlObj . organization } / ${ urlObj . currentRepo } /issues/${ urlObj . issueNumber } /comments` ) . then ( ( response ) => {
331331
332332 if ( closeOriginal ) {
333333 // if success, close the existing issue and open new in a new tab
@@ -352,7 +352,7 @@ function ajaxRequest(type, data, url) {
352352 $ . ajax ( {
353353 type : type ,
354354 beforeSend : ( request ) => {
355- request . setRequestHeader ( 'Authorization' , ' token ' + token )
355+ request . setRequestHeader ( 'Authorization' , ` token ${ token } ` )
356356 request . setRequestHeader ( 'Content-Type' , 'application/json' )
357357 } ,
358358 data : JSON . stringify ( data ) ,
@@ -373,15 +373,15 @@ function addRepoToList(repoFullName, repo, section) {
373373 const periodReplace = repo . replace ( / \. / g, '_' )
374374
375375 // determine where the item needs to go
376- if ( section === 'used' ) {
377- if ( $ ( '#' + periodReplace ) . length === 0 ) {
378- $ ( '.dropdown-header-rest' ) . before ( ' <li data-toggle="modal" id="' + periodReplace + ' " data-target="#kaminoModal"><a class="repoItem" href="#">' + repoFullName + ' </a></li>' )
376+ if ( section === 'used' ) {
377+ if ( $ ( `# ${ periodReplace } ` ) . length === 0 ) {
378+ $ ( '.dropdown-header-rest' ) . before ( ` <li data-toggle="modal" id="${ periodReplace } " data-target="#kaminoModal"><a class="repoItem" href="#">${ repoFullName } </a></li>` )
379379 }
380380 } else {
381- $ ( '.repoDropdown' ) . append ( ' <li data-toggle="modal" id="' + periodReplace + ' " data-target="#kaminoModal"><a class="repoItem" href="#">' + repoFullName + ' </a></li>' )
381+ $ ( '.repoDropdown' ) . append ( ` <li data-toggle="modal" id="${ periodReplace } " data-target="#kaminoModal"><a class="repoItem" href="#">${ repoFullName } </a></li>` )
382382 }
383383
384- $ ( '#' + periodReplace ) . bind ( 'click' , ( ) => { itemClick ( repoFullName ) } )
384+ $ ( `# ${ periodReplace } ` ) . bind ( 'click' , ( ) => { itemClick ( repoFullName ) } )
385385}
386386
387387function populateUrlMetadata ( ) {
@@ -456,7 +456,7 @@ function itemClick(repo) {
456456
457457 $ ( '.cloneAndClose' ) . attr ( 'data-repo' , repo )
458458 $ ( '.cloneAndKeepOpen' ) . attr ( 'data-repo' , repo )
459- $ ( '.confirmText' ) . text ( ' Are you sure you want to clone this issue to ' + repo + ' ? Choose whether to clone and close or clone and keep the original issue open.' )
459+ $ ( '.confirmText' ) . text ( ` Are you sure you want to clone this issue to ${ repo } ? Choose whether to clone and close or clone and keep the original issue open.` )
460460 openModal ( )
461461}
462462
0 commit comments