Skip to content

Commit

Permalink
Merge pull request #80 from Alokit-Innovations/akg/bitbucket_bug_fix
Browse files Browse the repository at this point in the history
minor: linting changes
  • Loading branch information
tapishr authored Oct 18, 2023
2 parents ae89d13 + 00803af commit 92a463d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 39 deletions.
30 changes: 15 additions & 15 deletions popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@ chrome.storage.local.get(["websiteUrl"]).then(({ websiteUrl }) => {

// Retrieve the session token from the cookie and store user details in Chrome's local storage.
chrome.cookies.get({ url: websiteUrl, name: '__Secure-next-auth.session-token' })
.then((cookie) => {
const tokenval = cookie.value;
chrome.storage.local.set({
userId: user.id,
userName: user.name,
userImage: user.image,
token: tokenval,
}).then(() => {
console.debug(`[popup] userId has been set to ${user.id}`);
}).catch(err => {
console.error(`[popup] Local storage could not be set. userId: ${user.id}`, err);
.then((cookie) => {
const tokenval = cookie.value;
chrome.storage.local.set({
userId: user.id,
userName: user.name,
userImage: user.image,
token: tokenval,
}).then(() => {
console.debug(`[popup] userId has been set to ${user.id}`);
}).catch(err => {
console.error(`[popup] Local storage could not be set. userId: ${user.id}`, err);
});
})
.catch((err) => {
console.error("Unable to get Cookie value for session: ", err);
});
})
.catch((err) => {
console.error("Unable to get Cookie value for session: ", err);
});
} else {
// If no user session exists, display the login options.
document.querySelector("#login-div").style.display = "flex";
Expand Down
26 changes: 13 additions & 13 deletions scripts/highlighting.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function highlightRelevantPRs(highlightedPRIds) {
if (highlightedPRIds) {
for (const priorityLevel in highlightedPRIds) {
for (const prNumber in highlightedPRIds[priorityLevel]) {
addingCssElementToGithub(prNumber, keyToLabel[priorityLevel], highlightedPRIds[priorityLevel][prNumber])
addingCssElementToGithub(prNumber, keyToLabel[priorityLevel], highlightedPRIds[priorityLevel][prNumber]);
}
}
}
Expand Down Expand Up @@ -76,7 +76,7 @@ function addCssElementToBitbucket(highlightedPRIds) {
beforePsuedoElement.style.color = 'white';
beforePsuedoElement.style.padding = '2px';
beforePsuedoElement.style.paddingLeft = '5px';
beforePsuedoElement.style.paddingRight = '5px'
beforePsuedoElement.style.paddingRight = '5px';
beforePsuedoElement.style.borderRadius = '3px';
const parent = item.closest('tr');
parent.style.backgroundColor = `${backgroundColor}`;
Expand Down Expand Up @@ -148,7 +148,7 @@ async function FilesInPrBitbucket(response) {
if (currentScrollPosition - lastKnownScrollPosition > 100) {
if ("files" in response) {
const encryptedFileNames = new Set(response['files']);
const fileNav = Array.from(document.querySelectorAll("[aria-label^='Diff of file']"))
const fileNav = Array.from(document.querySelectorAll("[aria-label^='Diff of file']"));
lastKnownScrollPosition = currentScrollPosition;
fileNav.forEach(async (element) => {
const h3Element = element.querySelector('h3');
Expand All @@ -167,7 +167,7 @@ async function FilesInPrBitbucket(response) {
value2.style.backgroundColor = '#c5cc02';
}
}
})
});
}
}
ticking = false;
Expand Down Expand Up @@ -216,7 +216,7 @@ const githubHunkHighlight = async (apiResponses) => {
// for unified view
let flag = false;
value.forEach((item, index) => {
const deletedLines = item.querySelector('button[data-original-line]')
const deletedLines = item.querySelector('button[data-original-line]');
if (deletedLines !== null) {
const originalLine = deletedLines.getAttribute('data-original-line');
const signature = originalLine.charAt(0);
Expand Down Expand Up @@ -253,13 +253,13 @@ const githubHunkHighlight = async (apiResponses) => {
}
}
}
})
})
});
});
}
}
}
})
}
});
};

/**
* Highlights specific hunks (sections) of code in a Bitbucket pull request.
Expand Down Expand Up @@ -329,9 +329,9 @@ const bitBucketHunkHighlight = (apiResponses) => {
secondChild.style.borderLeft = 'solid 6px #f1f549';
}
}
})
});

})
});

} else {
// for unified view
Expand All @@ -347,7 +347,7 @@ const bitBucketHunkHighlight = (apiResponses) => {
secondChild.style.borderLeft = 'solid 6px #f1f549';
}
}
})
});
}
}
});
Expand All @@ -357,4 +357,4 @@ const bitBucketHunkHighlight = (apiResponses) => {
ticking = true;
}
});
}
};
22 changes: 11 additions & 11 deletions scripts/orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const orchestrator = (tabUrl, websiteUrl, userId) => {
"repo_name": repoName,
"user_id": userId,
"is_github": true
}
};
const url = `${backendUrl}/relevance/pr`;
const highlightedPRIds = await apiCall(url, body);
highlightRelevantPRs(highlightedPRIds);
Expand All @@ -53,7 +53,7 @@ const orchestrator = (tabUrl, websiteUrl, userId) => {
"user_id": userId,
"pr_number": prNumber,
"is_github": true
}
};
const url = `${backendUrl}/relevance/pr/files`;
const response = await apiCall(url, body);
showImpFileInPr(response);
Expand All @@ -64,7 +64,7 @@ const orchestrator = (tabUrl, websiteUrl, userId) => {
"user_id": userId,
"pr_number": prNumber,
"repo_provider": "github"
}
};
const hunk_info_url = `${backendUrl}/relevance/hunkinfo`;
const hunk_info_response = await apiCall(hunk_info_url, hunk_info_body);
githubHunkHighlight(hunk_info_response);
Expand All @@ -76,7 +76,7 @@ const orchestrator = (tabUrl, websiteUrl, userId) => {
(urlObj[3] == 'orgs' && urlObj[4] && urlObj[5] === 'repositories')) {
// for woking on this url https://github.com/Alokit-Innovations or https://github.com/orgs/Alokit-Innovations/repositories?type=all type
const orgName = (urlObj[3] === "orgs") ? urlObj[4] : urlObj[3];
const trackedRepos = await getTrackedRepos(orgName, userId, 'github')
const trackedRepos = await getTrackedRepos(orgName, userId, 'github');
updateTrackedReposInOrgGitHub(trackedRepos, websiteUrl);
}
}
Expand All @@ -85,7 +85,7 @@ const orchestrator = (tabUrl, websiteUrl, userId) => {
// for showing tracked repo of a organization
if (urlObj[4] === 'workspace' && urlObj[5] === 'repositories') {
const workspaceSlug = urlObj[3];
const trackedRepos = await getTrackedRepos(workspaceSlug, userId, 'bitbucket')
const trackedRepos = await getTrackedRepos(workspaceSlug, userId, 'bitbucket');
updateTrackedReposInBitbucketOrg(trackedRepos, websiteUrl);
}

Expand All @@ -99,9 +99,9 @@ const orchestrator = (tabUrl, websiteUrl, userId) => {
"repo_name": repoName,
"user_id": userId,
"repo_provider": "bitbucket"
}
};
const url = `${websiteUrl}/api/extension/relevant`;
const query_params = {type: "review"};
const query_params = { type: "review" };
const highlightedPRIds = await apiCallOnprem(url, body, query_params);
addCssElementToBitbucket(highlightedPRIds);
}
Expand All @@ -115,17 +115,17 @@ const orchestrator = (tabUrl, websiteUrl, userId) => {
"pr_number": prNumber,
"repo_provider": 'bitbucket',
"is_github": false
}
};
const url = `${websiteUrl}/api/extension/relevant`;
let query_params = {type: "file"};
let query_params = { type: "file" };
const response = await apiCallOnprem(url, body, query_params);
FilesInPrBitbucket(response);
// for hunk level high light of each file
query_params = {type: "hunk"};
query_params = { type: "hunk" };
const hunkResponse = await apiCallOnprem(url, body, query_params);
bitBucketHunkHighlight(hunkResponse);
}
}
}
})
});
};

0 comments on commit 92a463d

Please sign in to comment.