diff --git a/popup/popup.js b/popup/popup.js index 67f24d2..a76523a 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -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"; diff --git a/scripts/highlighting.js b/scripts/highlighting.js index 89b4dfb..1942740 100644 --- a/scripts/highlighting.js +++ b/scripts/highlighting.js @@ -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]); } } } @@ -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}`; @@ -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'); @@ -167,7 +167,7 @@ async function FilesInPrBitbucket(response) { value2.style.backgroundColor = '#c5cc02'; } } - }) + }); } } ticking = false; @@ -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); @@ -253,13 +253,13 @@ const githubHunkHighlight = async (apiResponses) => { } } } - }) - }) + }); + }); } } } - }) -} + }); +}; /** * Highlights specific hunks (sections) of code in a Bitbucket pull request. @@ -329,9 +329,9 @@ const bitBucketHunkHighlight = (apiResponses) => { secondChild.style.borderLeft = 'solid 6px #f1f549'; } } - }) + }); - }) + }); } else { // for unified view @@ -347,7 +347,7 @@ const bitBucketHunkHighlight = (apiResponses) => { secondChild.style.borderLeft = 'solid 6px #f1f549'; } } - }) + }); } } }); @@ -357,4 +357,4 @@ const bitBucketHunkHighlight = (apiResponses) => { ticking = true; } }); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/scripts/orchestrator.js b/scripts/orchestrator.js index 6ba3e8d..8ad4046 100644 --- a/scripts/orchestrator.js +++ b/scripts/orchestrator.js @@ -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); @@ -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); @@ -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); @@ -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); } } @@ -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); } @@ -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); } @@ -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); } } } - }) + }); }; \ No newline at end of file