Skip to content

Commit

Permalink
feat: Overhaul popup menu and provider management (#103)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
spalmurray-codecov authored Dec 16, 2024
1 parent 876783f commit 0912732
Show file tree
Hide file tree
Showing 9 changed files with 398 additions and 506 deletions.
151 changes: 0 additions & 151 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"code-tag": "^1.1.0",
"color-alpha": "^1.1.3",
"dom-chef": "^5.1.0",
"fetch-intercept": "^2.4.0",
"lodash": "^4.17.21",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -39,7 +38,6 @@
"autoprefixer": "^10.4.14",
"copy-webpack-plugin": "^9.0.1",
"css-loader": "^6.7.3",
"daisyui": "^2.51.3",
"postcss": "^8.4.21",
"postcss-loader": "^7.0.2",
"prettier": "^2.2.1",
Expand Down
11 changes: 6 additions & 5 deletions src/background/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ async function handleMessages(message: {
payload: any;
referrer?: string;
}) {
const codecov = new Codecov();
return Sentry.startSpan({ name: message.type }, async () => {
switch (message.type) {
case MessageType.FETCH_COMMIT_REPORT:
return Codecov.fetchCommitReport(message.payload, message.referrer!);
return codecov.fetchCommitReport(message.payload, message.referrer!);
case MessageType.FETCH_PR_COMPARISON:
return Codecov.fetchPRComparison(message.payload, message.referrer!);
return codecov.fetchPRComparison(message.payload, message.referrer!);
case MessageType.FETCH_FLAGS_LIST:
return Codecov.listFlags(message.payload, message.referrer!);
return codecov.listFlags(message.payload, message.referrer!);
case MessageType.FETCH_COMPONENTS_LIST:
return Codecov.listComponents(message.payload, message.referrer!);
return codecov.listComponents(message.payload, message.referrer!);
case MessageType.CHECK_AUTH:
return Codecov.checkAuth(message.payload);
return codecov.checkAuth(message.payload);
case MessageType.REGISTER_CONTENT_SCRIPTS:
return registerContentScript(message.payload);
case MessageType.UNREGISTER_CONTENT_SCRIPTS:
Expand Down
11 changes: 9 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
export const useSelfHostedStorageKey = "use_self_hosted";
export const codecovApiTokenStorageKey = "self_hosted_codecov_api_token"; // Keeping this key to not break existing installs.
export const selfHostedCodecovURLStorageKey = "self_hosted_codecov_url";
export const selfHostedGitHubURLStorageKey = "self_hosted_github_url";
export const selfHostedCodecovApiToken = "self_hosted_codecov_api_token";
export const dynamicContentScriptRegistrationId = "dynamic-content-script";

export const codecovCloudApiUrl = "https://api.codecov.io";
export const githubCloudUrl = "https://github.com";

export const providers = {
github: "github",
githubEnterprise: "github_enterprise",
} as const;
5 changes: 0 additions & 5 deletions src/content/github/common/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {

export async function getFlags(metadata: FileMetadata): Promise<string[]> {
const payload = {
service: "github",
owner: metadata.owner,
repo: metadata.repo,
};
Expand All @@ -25,7 +24,6 @@ export async function getFlags(metadata: FileMetadata): Promise<string[]> {

export async function getComponents(metadata: FileMetadata): Promise<string[]> {
const payload = {
service: "github",
owner: metadata.owner,
repo: metadata.repo,
};
Expand All @@ -52,7 +50,6 @@ export async function getCommitReport(
}

const payload = {
service: "github",
owner: metadata.owner,
repo: metadata.repo,
path: metadata.path,
Expand All @@ -74,7 +71,6 @@ export async function getBranchReport(
metadata: FileMetadata
): Promise<FileCoverageReportResponse> {
const payload = {
service: "github",
owner: metadata.owner,
repo: metadata.repo,
path: metadata.path,
Expand All @@ -92,7 +88,6 @@ export async function getBranchReport(

export async function getPRReport(url: any) {
const payload = {
service: "github",
owner: url.owner,
repo: url.repo,
pullid: url.id,
Expand Down
Loading

0 comments on commit 0912732

Please sign in to comment.