Skip to content

Commit

Permalink
Merge pull request #74 from open-sauced/beta
Browse files Browse the repository at this point in the history
main <- v1.0.0-beta.12
  • Loading branch information
bdougie authored May 13, 2023
2 parents bbdac81 + 946f2bb commit 685d3de
Show file tree
Hide file tree
Showing 26 changed files with 483 additions and 183 deletions.
8 changes: 0 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ module.exports = {
rules: {
// eslint:recommended
"arrow-body-style": ["error", "as-needed"],
"capitalized-comments": [
"error",
"never",
{
ignorePattern: "pragma|ignored",
ignoreInlineComments: true,
},
],
curly: ["error", "all"],
"dot-notation": "error",
eqeqeq: ["error", "always"],
Expand Down
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,55 @@

> All notable changes to this project will be documented in this file
## [1.0.0-beta.12](https://github.com/open-sauced/browser-extensions/compare/v1.0.0-beta.11...v1.0.0-beta.12) (2023-05-13)


### 🐛 Bug Fixes

* circular-deps in vote buttons ([675496c](https://github.com/open-sauced/browser-extensions/commit/675496cc3b3cbbb214c0ea77e49a059bc5ba6d7c))

## [1.0.0-beta.11](https://github.com/open-sauced/browser-extensions/compare/v1.0.0-beta.10...v1.0.0-beta.11) (2023-05-13)


### 🐛 Bug Fixes

* incorrect request for voting ([#72](https://github.com/open-sauced/browser-extensions/issues/72)) ([7a35014](https://github.com/open-sauced/browser-extensions/commit/7a35014448fbf836702251176f54e4983f638bef))

## [1.0.0-beta.10](https://github.com/open-sauced/browser-extensions/compare/v1.0.0-beta.9...v1.0.0-beta.10) (2023-05-12)


### 🍕 Features

* vote repos ([#70](https://github.com/open-sauced/browser-extensions/issues/70)) ([ff2c8f4](https://github.com/open-sauced/browser-extensions/commit/ff2c8f4198cd09fa8f591498298e6eddbc982c49))

## [1.0.0-beta.9](https://github.com/open-sauced/browser-extensions/compare/v1.0.0-beta.8...v1.0.0-beta.9) (2023-05-05)


### 🐛 Bug Fixes

* render emojis in user bio ([#68](https://github.com/open-sauced/browser-extensions/issues/68)) ([d0158a5](https://github.com/open-sauced/browser-extensions/commit/d0158a55fd49960d1f8d07af87d7621871965679))

## [1.0.0-beta.8](https://github.com/open-sauced/browser-extensions/compare/v1.0.0-beta.7...v1.0.0-beta.8) (2023-05-04)


### 🍕 Features

* add to highlights button ([#64](https://github.com/open-sauced/browser-extensions/issues/64)) ([e2120a1](https://github.com/open-sauced/browser-extensions/commit/e2120a13d64fee2ab0867e5f17d647f64796467a))

## [1.0.0-beta.7](https://github.com/open-sauced/browser-extensions/compare/v1.0.0-beta.6...v1.0.0-beta.7) (2023-05-02)


### 🧑‍💻 Code Refactoring

* improved-auth-strategy ([#56](https://github.com/open-sauced/browser-extensions/issues/56)) ([d8b27c3](https://github.com/open-sauced/browser-extensions/commit/d8b27c3e8a4259a4f40086feaf5e229a95fb59e9))

## [1.0.0-beta.6](https://github.com/open-sauced/browser-extensions/compare/v1.0.0-beta.5...v1.0.0-beta.6) (2023-05-01)


### 🐛 Bug Fixes

* unrecognized-manifest-key ([#55](https://github.com/open-sauced/browser-extensions/issues/55)) ([d622500](https://github.com/open-sauced/browser-extensions/commit/d6225003fd3bcf5b16ab7c5113c6e559e5a50849))

## [1.0.0-beta.5](https://github.com/open-sauced/browser-extensions/compare/v1.0.0-beta.4...v1.0.0-beta.5) (2023-04-29)


Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
</a>
</p>

## Documentation

The documentation for the project can be found [here](https://docs.opensauced.pizza/chrome-extension/introduction-to-the-chrome-extension/).

## Running the project locally

To run the project, you'll need the following software binaries installed on your development machines:
Expand All @@ -36,7 +40,7 @@ To run a local instance of the project:
npm run dev
```

## Installing the extension on a Chromium based browser:
## Installing the local build on a Chromium based browser:
After running the above commands,
1. Navigate to `chrome://extensions`.
2. Enable the `Developer Mode`.
Expand Down
12 changes: 4 additions & 8 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
"action": { "default_popup": "index.html" },
"content_scripts": [
{
"js": ["src/content-scripts/profileScreen.ts"],
"matches": ["https://github.com/*"]
},
{
"js": ["src/content-scripts/hotOSHomePage.ts"],
"matches": ["https://hot.opensauced.pizza/*"],
"run_at": "document_end"
"js": ["src/content-scripts/github.ts"],
"matches": ["https://github.com/*"],
"run": "document_end"
}
],
"background": {
Expand All @@ -25,5 +21,5 @@
"128": "src/assets/os-icons/os-icon-128.png"
},
"host_permissions": ["<all_urls>"],
"permissions": ["storage","webRequest", "tabs", "cookies"]
"permissions": ["storage", "tabs", "cookies"]
}
24 changes: 22 additions & 2 deletions npm-shrinkwrap.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "opensauced-browser-extension",
"private": true,
"version": "1.0.0-beta.5",
"version": "1.0.0-beta.12",
"files": [
"dist"
],
Expand All @@ -14,6 +14,8 @@
},
"dependencies": {
"@types/chrome": "^0.0.231",
"@types/node-emoji": "^1.8.2",
"node-emoji": "^1.11.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-icons": "^4.8.0"
Expand Down
18 changes: 13 additions & 5 deletions src/constants.ts
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";
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;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import twitterSocialIcon from "../../../assets/twitter-icon.svg";
import linkedInSocailIcon from "../../../assets/linkedin-icon.svg";

interface Socials {
emailAddress?: string;
twitterUsername?: string;
linkedInUsername?: string;
emailAddress?: string | null;
twitterUsername?: string | null;
linkedInUsername?: string | null;
}

export const InviteToOpenSaucedModal = (
Expand Down
35 changes: 35 additions & 0 deletions src/content-scripts/components/RepoVoting/RepoUnvoteButton.ts
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 src/content-scripts/components/RepoVoting/RepoVoteButton.ts
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;
};
43 changes: 43 additions & 0 deletions src/content-scripts/github.ts
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();
32 changes: 0 additions & 32 deletions src/content-scripts/hotOSHomePage.ts

This file was deleted.

Loading

0 comments on commit 685d3de

Please sign in to comment.