-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from open-sauced/beta
main <- v1.0.0-beta.12
- Loading branch information
Showing
26 changed files
with
483 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
export const SUPABASE_LOCAL_STORAGE_KEY = "supabase.auth.token"; | ||
export const SUPABASE_AUTH_DOMAIN = "ibcwmlhcimymasokhgvn.supabase.co"; | ||
export const SUPABASE_COOKIE_NAME = "sb-access-token"; | ||
export const SUPABASE_LOGIN_URL = "https://ibcwmlhcimymasokhgvn.supabase.co/auth/v1/authorize?provider=github&redirect_to=https://hot.opensauced.pizza/"; | ||
export const SUPABASE_LOGOUT_URL = "https://ibcwmlhcimymasokhgvn.supabase.co/auth/v1/logout"; | ||
// OpenSauced constants | ||
export const SUPABASE_LOGIN_URL = "https://ibcwmlhcimymasokhgvn.supabase.co/auth/v1/authorize?provider=github&redirect_to=https://insights.opensauced.pizza/"; | ||
export const SUPABASE_AUTH_COOKIE_NAME = "supabase-auth-token"; | ||
export const OPEN_SAUCED_AUTH_TOKEN_KEY = "os-access-token"; | ||
export const OPEN_SAUCED_INSIGHTS_DOMAIN = "insights.opensauced.pizza"; | ||
|
||
// API endpoints | ||
export const OPEN_SAUCED_USERS_ENDPOINT = "https://api.opensauced.pizza/v1/users"; | ||
export const OPEN_SAUCED_REPOS_ENDPOINT = "https://api.opensauced.pizza/v1/repos"; | ||
export const OPEN_SAUCED_SESSION_ENDPOINT = "https://api.opensauced.pizza/v1/auth/session"; | ||
|
||
// GitHub constants/selectors | ||
export const GITHUB_PROFILE_MENU_SELECTOR = ".p-nickname.vcard-username.d-block"; | ||
export const GITHUB_PROFILE_EDIT_MENU_SELECTOR = "button.js-profile-editable-edit-button"; | ||
export const GITHUB_PR_AUTHOR_USERNAME_SELECTOR = "author Link--primary text-bold css-overflow-wrap-anywhere"; | ||
export const GITHUB_LOGGED_IN_USER_USERNAME_SELECTOR = "meta[name=\"user-login\"]"; | ||
export const GITHUB_PR_COMMENT_HEADER_SELECTOR = "timeline-comment-header clearfix d-flex"; | ||
export const GITHUB_REPO_ACTIONS_SELECTOR = ".pagehead-actions"; |
15 changes: 15 additions & 0 deletions
15
src/content-scripts/components/AddPRToHighlights/AddPRToHighlightsButton.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { createHtmlElement } from "../../../utils/createHtmlElement"; | ||
import openSaucedLogoIcon from "../../../assets/opensauced-icon.svg"; | ||
|
||
export const AddPRToHighlightsButton = () => { | ||
const addPRToHighlightsButton = createHtmlElement("a", { | ||
href: `https://insights.opensauced.pizza/feed?url=${encodeURIComponent(window.location.href)}`, | ||
target: "_blank", | ||
rel: "noopener noreferrer", | ||
innerHTML: `<span aria-label="Add PR to OpenSauced highlights." data-view-component="true" class="tooltipped tooltipped-n"> | ||
<img data-view-component="true" class="mr-1 mt-1" height="16px" width="16px" src=${chrome.runtime.getURL(openSaucedLogoIcon)}> | ||
</span>`, | ||
}); | ||
|
||
return addPRToHighlightsButton; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/content-scripts/components/RepoVoting/RepoUnvoteButton.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import "../../content-scripts.css"; | ||
import { createHtmlElement } from "../../../utils/createHtmlElement"; | ||
import { getAuthToken } from "../../../utils/checkAuthentication"; | ||
import { VoteRepoButton } from "./RepoVoteButton"; | ||
import { voteOrUnvoteRepo } from "../../../utils/fetchOpenSaucedApiData"; | ||
|
||
export const RepoUnvoteButton = (ownerName: string, repoName: string) => { | ||
const repoUnvoteButton = createHtmlElement("li", { | ||
className: | ||
"text-white text-center hover:shadow-button bg-gradient-to-r from-[#e67e22] to-[#d35400] btn btn-sm", | ||
innerHTML: ` | ||
<span>Unvote</span> | ||
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" class="align-middle"><g><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-.997-6l7.07-7.071-1.414-1.414-5.656 5.657-2.829-2.829-1.414 1.414L11.003 16z"></path></g></svg> | ||
`, | ||
}); | ||
|
||
repoUnvoteButton.addEventListener("click", async () => { | ||
repoUnvoteButton.innerHTML = ` | ||
<span>Loading...</span> | ||
`; | ||
const userToken = await getAuthToken(); | ||
|
||
const unvoted = await voteOrUnvoteRepo(userToken, ownerName, repoName, "DELETE"); | ||
|
||
if (unvoted) { | ||
const { VoteRepoButton } = await import("./RepoVoteButton"); | ||
repoUnvoteButton.replaceWith(VoteRepoButton(ownerName, repoName)); | ||
} else { | ||
console.log("Something went wrong"); | ||
} | ||
}); | ||
|
||
|
||
return repoUnvoteButton; | ||
}; |
33 changes: 33 additions & 0 deletions
33
src/content-scripts/components/RepoVoting/RepoVoteButton.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import "../../content-scripts.css"; | ||
import { createHtmlElement } from "../../../utils/createHtmlElement"; | ||
import { getAuthToken } from "../../../utils/checkAuthentication"; | ||
import { voteOrUnvoteRepo } from "../../../utils/fetchOpenSaucedApiData"; | ||
|
||
export const VoteRepoButton = (ownerName: string, repoName: string) => { | ||
const voteRepoButton = createHtmlElement("li", { | ||
className: | ||
"text-white text-center hover:shadow-button bg-gradient-to-r from-[#e67e22] to-[#d35400] btn btn-sm", | ||
innerHTML: ` | ||
<span>Upvote</span> | ||
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" class="align-middle"><g><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-.997-6l7.07-7.071-1.414-1.414-5.656 5.657-2.829-2.829-1.414 1.414L11.003 16z"></path></g></svg> | ||
`, | ||
}); | ||
|
||
voteRepoButton.addEventListener("click", async () => { | ||
voteRepoButton.innerHTML = ` | ||
<span>Loading...</span> | ||
`; | ||
const userToken = await getAuthToken(); | ||
|
||
const voted = await voteOrUnvoteRepo(userToken, ownerName, repoName, "PUT"); | ||
|
||
if (voted) { | ||
const { RepoUnvoteButton } = await import("./RepoUnvoteButton"); | ||
voteRepoButton.replaceWith(RepoUnvoteButton(ownerName, repoName)); | ||
} else { | ||
console.log("Something went wrong"); | ||
} | ||
}); | ||
|
||
return voteRepoButton; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { | ||
getGithubUsername, | ||
isGithubProfilePage, | ||
isGithubPullRequestPage, | ||
isGithubRepoPage, | ||
} from "../utils/urlMatchers"; | ||
import { isOpenSaucedUser } from "../utils/fetchOpenSaucedApiData"; | ||
import injectViewOnOpenSauced from "../utils/dom-utils/viewOnOpenSauced"; | ||
import injectInviteToOpenSauced from "../utils/dom-utils/inviteToOpenSauced"; | ||
import { prefersDarkMode } from "../utils/colorPreference"; | ||
import injectAddPRToHighlightsButton from "../utils/dom-utils/addPRToHighlights"; | ||
import injectRepoVotingButtons from "../utils/dom-utils/repoVotingButtons"; | ||
import domUpdateWatch from "../utils/dom-utils/domUpdateWatcher"; | ||
|
||
const processGithubPage = async () => { | ||
if (prefersDarkMode(document.cookie)) { | ||
document.documentElement.classList.add("dark"); | ||
} | ||
|
||
if (isGithubPullRequestPage(window.location.href)) { | ||
await injectAddPRToHighlightsButton(); | ||
} else if (isGithubProfilePage(window.location.href)) { | ||
const username = getGithubUsername(window.location.href); | ||
|
||
if (!username) { | ||
return; | ||
} | ||
if (await isOpenSaucedUser(username)) { | ||
injectViewOnOpenSauced(username); | ||
} else { | ||
injectInviteToOpenSauced(username); | ||
} | ||
} else if (isGithubRepoPage(window.location.href)) { | ||
const ownerName = getGithubUsername(window.location.href) ?? ""; | ||
const repoName = window.location.href.split("/").pop() ?? ""; | ||
|
||
await injectRepoVotingButtons(ownerName, repoName); | ||
} | ||
|
||
domUpdateWatch(processGithubPage, 25); | ||
}; | ||
|
||
void processGithubPage(); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.