Skip to content

Commit

Permalink
Merge pull request #72 from j0be/2.2.17
Browse files Browse the repository at this point in the history
fix hosts issue => 2.2.17
  • Loading branch information
dragouf authored Nov 5, 2020
2 parents 1db1cb0 + b4b145a commit c1a1f7b
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 30 deletions.
16 changes: 10 additions & 6 deletions extension/chrome/src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const reloadTemplate = function() {
extensionStorage.loadTemplateUrl()
.then(extensionStorage.loadTemplateFromUrl)
.then(template => {
return extensionStorage.saveTemplate(template.join('\n'));
return template && extensionStorage.saveTemplate(template.join('\n'));
})
.then(() => console.info('Template updated'))
.catch(error => {
Expand Down Expand Up @@ -175,7 +175,7 @@ function retrieveActivities() {
Promise.all([reviewersPromised, authorPromised]).then(function([reviewersResult, authorResult]) {
if (reviewersResult.errors) { throw reviewersResult.errors }
if (authorResult.errors) { throw authorResult.errors }
const allPR = reviewersResult.concat(authorResult)
const allPR = reviewersResult.values.concat(authorResult.values);
let activities;
const requests = [];
// loop through PRs and request activities
Expand Down Expand Up @@ -247,11 +247,15 @@ function pingAllExistingTabs() {


// Click on extension icon
chrome.browserAction.onClicked.addListener(function() {
chrome.browserAction.onClicked.addListener(handleExtensionClick);

function handleExtensionClick() {
chrome.storage.local.get(['currentStashBaseUrl'], function(items) {
chrome.tabs.create({'url': `${items.currentStashBaseUrl}/`});
if (items.currentStashBaseUrl) {
chrome.tabs.create({'url': `${items.currentStashBaseUrl}/`});
}
});
});
}

setInterval(realoadAll, REVIEWERS_LIST_REFRESH);
realoadAll();
Expand Down Expand Up @@ -287,7 +291,7 @@ function handleUserDefinedHosts() {
chrome.storage.sync.get('user_defined_hosts', userhosts => {
let uhosts = userhosts.user_defined_hosts || [];
if (uhosts.length > 0) {
//
//
for (let host of uhosts) {
if (!(host in listsOfUserDefinedHostsRegexp)) {
listsOfUserDefinedHostsRegexp[host] = formatHosts(host)
Expand Down
42 changes: 22 additions & 20 deletions extension/chrome/src/js/userhosts.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
document.getElementById('save_user_hosts').addEventListener('click', (event) => {

let hostsButton = document.getElementById('user_defined_hosts'),
hosts = hostsButton.value.
replace(/,/g, ' ').
replace(/;/g, ' ').
replace(/\r/g, ' ').
replace(/\t/g, ' ').
replace(/\n/g, ' ').
split(' ');

let fhosts = [];
let hostsTextarea = document.getElementById('user_defined_hosts');
let hosts = hostsTextarea.value.
replace(/[,;\r\n\t]+/g, ' ').
trim().
split(' ').
filter(Boolean);

for(let host of hosts){
if (host != "") {
fhosts.push(host)
}
}
hosts = fhosts
if (hosts.length > 0) {
chrome.storage.sync.get('user_defined_hosts', oldhosts => {
chrome.storage.sync.set({'user_defined_hosts': (oldhosts.user_defined_hosts || []).concat(hosts)})
chrome.extension.getBackgroundPage().handleUserDefinedHosts()
let uniqueHosts = [...new Set(hosts)];
chrome.storage.sync.set({'user_defined_hosts': uniqueHosts});
populateTextArea();
chrome.extension.getBackgroundPage().handleUserDefinedHosts();
});
hostsButton.value = ''
}
})
});

populateTextArea();
chrome.extension.getBackgroundPage().handleExtensionClick();

function populateTextArea() {
let hostsTextarea = document.getElementById('user_defined_hosts');
chrome.storage.sync.get('user_defined_hosts', oldhost => {
hostsTextarea.value = [...new Set(oldhost.user_defined_hosts)].join("\r\n");
});
}

2 changes: 1 addition & 1 deletion extension/chrome/src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Bitbucket Server Extension",
"description": "Allow to add group of reviewers for pull request in bitbucket server + other features",
"version": "2.2.16",
"version": "2.2.17",
"permissions": [
"storage",
"alarms",
Expand Down
4 changes: 2 additions & 2 deletions extension/chrome/src/userhosts.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="author" content="MESOLIDO">

<title>Self Hosted Bitbucket Servers</title>

</head>

<body>
Expand All @@ -15,7 +15,7 @@ <h1>Adding more bitbucket servers</h1>
<p>By default, this extension is only enabled on <a href="https://bitbucket.org">bitbucket.org</a> and <a href="https://atlassian.com">atlassian.com</a>. But you can add more hosts (i.e. self-hosted bitbucket servers) where to enable it. Make sure that the hosts you type follow <a href="https://developer.chrome.com/extensions/match_patterns"> the URLs match patterns for extensions</a></p>
<div class="form-group">
<label for="user_defined_hosts"> </label>
<textarea class="form-control" rows="5" cols="50" id="user_defined_hosts" placeholder="*://*.bitbucket.org/**://*.atlassian.com/*"></textarea>
<textarea class="form-control" rows="5" cols="50" id="user_defined_hosts" placeholder="*://*.bitbucket.org/*&#10;*://*.atlassian.com/*"></textarea>
<button id="save_user_hosts" class="btn btn-default">Save</button>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions history
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2.2.17
===================
- Allow tab to be opened on click if currentStashBaseUrl already exists

2.2.15
===================
- legacy support
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.16
2.2.17

0 comments on commit c1a1f7b

Please sign in to comment.