Skip to content

Commit 0912732

Browse files
feat: Overhaul popup menu and provider management (#103)
This PR is primarily meant to fix a bug where github enterprise URLs would not actually work due to 'github' being the hardcoded provider on API requests. While I was in here though I took it as a chance to rewrite the popup menu to address some other issues.
1 parent 876783f commit 0912732

File tree

9 files changed

+398
-506
lines changed

9 files changed

+398
-506
lines changed

package-lock.json

Lines changed: 0 additions & 151 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"code-tag": "^1.1.0",
1919
"color-alpha": "^1.1.3",
2020
"dom-chef": "^5.1.0",
21-
"fetch-intercept": "^2.4.0",
2221
"lodash": "^4.17.21",
2322
"react": "^18.2.0",
2423
"react-dom": "^18.2.0",
@@ -39,7 +38,6 @@
3938
"autoprefixer": "^10.4.14",
4039
"copy-webpack-plugin": "^9.0.1",
4140
"css-loader": "^6.7.3",
42-
"daisyui": "^2.51.3",
4341
"postcss": "^8.4.21",
4442
"postcss-loader": "^7.0.2",
4543
"prettier": "^2.2.1",

src/background/main.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,19 @@ async function handleMessages(message: {
3232
payload: any;
3333
referrer?: string;
3434
}) {
35+
const codecov = new Codecov();
3536
return Sentry.startSpan({ name: message.type }, async () => {
3637
switch (message.type) {
3738
case MessageType.FETCH_COMMIT_REPORT:
38-
return Codecov.fetchCommitReport(message.payload, message.referrer!);
39+
return codecov.fetchCommitReport(message.payload, message.referrer!);
3940
case MessageType.FETCH_PR_COMPARISON:
40-
return Codecov.fetchPRComparison(message.payload, message.referrer!);
41+
return codecov.fetchPRComparison(message.payload, message.referrer!);
4142
case MessageType.FETCH_FLAGS_LIST:
42-
return Codecov.listFlags(message.payload, message.referrer!);
43+
return codecov.listFlags(message.payload, message.referrer!);
4344
case MessageType.FETCH_COMPONENTS_LIST:
44-
return Codecov.listComponents(message.payload, message.referrer!);
45+
return codecov.listComponents(message.payload, message.referrer!);
4546
case MessageType.CHECK_AUTH:
46-
return Codecov.checkAuth(message.payload);
47+
return codecov.checkAuth(message.payload);
4748
case MessageType.REGISTER_CONTENT_SCRIPTS:
4849
return registerContentScript(message.payload);
4950
case MessageType.UNREGISTER_CONTENT_SCRIPTS:

src/constants.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
export const useSelfHostedStorageKey = "use_self_hosted";
1+
export const codecovApiTokenStorageKey = "self_hosted_codecov_api_token"; // Keeping this key to not break existing installs.
22
export const selfHostedCodecovURLStorageKey = "self_hosted_codecov_url";
33
export const selfHostedGitHubURLStorageKey = "self_hosted_github_url";
4-
export const selfHostedCodecovApiToken = "self_hosted_codecov_api_token";
54
export const dynamicContentScriptRegistrationId = "dynamic-content-script";
5+
6+
export const codecovCloudApiUrl = "https://api.codecov.io";
7+
export const githubCloudUrl = "https://github.com";
8+
9+
export const providers = {
10+
github: "github",
11+
githubEnterprise: "github_enterprise",
12+
} as const;

src/content/github/common/fetchers.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77

88
export async function getFlags(metadata: FileMetadata): Promise<string[]> {
99
const payload = {
10-
service: "github",
1110
owner: metadata.owner,
1211
repo: metadata.repo,
1312
};
@@ -25,7 +24,6 @@ export async function getFlags(metadata: FileMetadata): Promise<string[]> {
2524

2625
export async function getComponents(metadata: FileMetadata): Promise<string[]> {
2726
const payload = {
28-
service: "github",
2927
owner: metadata.owner,
3028
repo: metadata.repo,
3129
};
@@ -52,7 +50,6 @@ export async function getCommitReport(
5250
}
5351

5452
const payload = {
55-
service: "github",
5653
owner: metadata.owner,
5754
repo: metadata.repo,
5855
path: metadata.path,
@@ -74,7 +71,6 @@ export async function getBranchReport(
7471
metadata: FileMetadata
7572
): Promise<FileCoverageReportResponse> {
7673
const payload = {
77-
service: "github",
7874
owner: metadata.owner,
7975
repo: metadata.repo,
8076
path: metadata.path,
@@ -92,7 +88,6 @@ export async function getBranchReport(
9288

9389
export async function getPRReport(url: any) {
9490
const payload = {
95-
service: "github",
9691
owner: url.owner,
9792
repo: url.repo,
9893
pullid: url.id,

0 commit comments

Comments
 (0)