wesleybliss
11/22/2017 - 2:31 AM

Fixes repo names when importing from BitBucket/etc., where the name contains invalid characters

Fixes repo names when importing from BitBucket/etc., where the name contains invalid characters

/**
 * Paste this in Chrome's console.
 * 
 * Given an import job where:
 *     - URL is my-project
 *     - Name is "My Project!!!"
 * The target import namespace will changed to the
 * URL slug ("my-project", int this case).
 */
clear(); (function() {

const q = sel => document.querySelector(sel)
const qa = sel => document.querySelectorAll(sel)

const table = q('table.import-jobs')
const pendingRows = table.querySelectorAll('tr:not(.success)')

for (let i in pendingRows) {
    
    try {
        
        const fromCol = pendingRows[i].querySelectorAll('td')[0]
        const toCol = pendingRows[i].querySelector('td.import-target')
        
        const source = fromCol.innerText.toString().split('/').pop()
        const target = toCol.querySelector('input#path')
        
        //console.log('FROM [' + source + '] ... TO [' + target.value + ']')
        
        target.value = source
        
    }
    catch (e) {
        
        //
        
    }
    
}

})()