Skip to content

Commit

Permalink
Merge pull request #286 from codewithjazzy/feature-refactor-fix-281
Browse files Browse the repository at this point in the history
  • Loading branch information
nickytonline authored Nov 13, 2023
2 parents bc44a66 + 3087cdf commit 2d61626
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ export const OPEN_SAUCED_EMOJIS_ENDPOINT = `${OPEN_SAUCED_API_ENDPOINT}/emojis`;

// Content-scripts 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_COMMENT_HEADER_SELECTOR = "timeline-comment-header clearfix d-flex";
export const GITHUB_REVIEW_SUGGESTION_SELECTOR = "js-suggestion-button-placeholder";
export const GITHUB_PROFILE_EDIT_MENU_CLASS = "button.js-profile-editable-edit-button";
export const GITHUB_PR_COMMENT_HEADER_CLASS = "timeline-comment-header clearfix d-flex";
export const GITHUB_REVIEW_SUGGESTION_CLASS = "js-suggestion-button-placeholder";
export const GITHUB_REPO_ACTIONS_SELECTOR = ".pagehead-actions";
export const GITHUB_PR_COMMENT_TEXT_AREA_SELECTOR = "pull_request[body]";
export const GITHUB_PR_SUGGESTION_TEXT_AREA_SELECTOR = "[name='comment[body]']";
export const GITHUB_PR_BASE_BRANCH_SELECTOR = "css-truncate css-truncate-target";
export const GITHUB_PR_COMMENT_TEXT_AREA_CLASS = "pull_request[body]";
export const GITHUB_PR_SUGGESTION_TEXT_AREA_Attribute = "[name='comment[body]']";
export const GITHUB_PR_BASE_BRANCH_CLASS = "css-truncate css-truncate-target";
export const LINKEDIN_PROJECT_FORM_SELECTOR = ".artdeco-text-input--input";

// External Links
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GITHUB_PR_SUGGESTION_TEXT_AREA_SELECTOR } from "../../../constants";
import { GITHUB_PR_SUGGESTION_TEXT_AREA_Attribute } from "../../../constants";
import { insertTextAtCursor } from "../../../utils/ai-utils/cursorPositionInsert";
import {
DescriptionConfig,
Expand Down Expand Up @@ -130,7 +130,7 @@ const handleSubmit = async (
return console.error("No description was generated!");
}
const textArea = commentNode.querySelector(
GITHUB_PR_SUGGESTION_TEXT_AREA_SELECTOR,
GITHUB_PR_SUGGESTION_TEXT_AREA_Attribute,
)!;

insertTextAtCursor(textArea as HTMLTextAreaElement, suggestionStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import openSaucedLogoIcon from "../../../assets/opensauced-icon.svg";
import { getPullRequestAPIURL } from "../../../utils/urlMatchers";
import { getDescriptionContext, isOutOfContextBounds } from "../../../utils/fetchGithubAPIData";
import { generateDescription } from "../../../utils/ai-utils/openai";
import { GITHUB_PR_COMMENT_TEXT_AREA_SELECTOR } from "../../../constants";
import { GITHUB_PR_COMMENT_TEXT_AREA_CLASS } from "../../../constants";
import { insertTextAtCursor } from "../../../utils/ai-utils/cursorPositionInsert";
import { getAIDescriptionConfig } from "../../../utils/ai-utils/descriptionconfig";
import { getAuthToken, isLoggedIn, optLogIn } from "../../../utils/checkAuthentication";
Expand Down Expand Up @@ -50,7 +50,7 @@ const handleSubmit = async () => {
logo.classList.toggle("animate-spin");
button.classList.toggle("pointer-events-none");

const textArea = document.getElementsByName(GITHUB_PR_COMMENT_TEXT_AREA_SELECTOR)[0] as HTMLTextAreaElement;
const textArea = document.getElementsByName(GITHUB_PR_COMMENT_TEXT_AREA_CLASS)[0] as HTMLTextAreaElement;

insertTextAtCursor(textArea, descriptionStream);
} catch (error: unknown) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/dom-utils/addPRToHighlights.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AddPRToHighlightsButton } from "../../content-scripts/components/AddPRToHighlights/AddPRToHighlightsButton";
import { GITHUB_PR_COMMENT_HEADER_SELECTOR } from "../../constants";
import { GITHUB_PR_COMMENT_HEADER_CLASS } from "../../constants";
import { isLoggedIn } from "../checkAuthentication";
import { isPublicRepository } from "../fetchGithubAPIData";

Expand All @@ -9,7 +9,7 @@ const injectAddPRToHighlightsButton = async () => {
}

const commentFormatRow = document.getElementsByClassName(
GITHUB_PR_COMMENT_HEADER_SELECTOR,
GITHUB_PR_COMMENT_HEADER_CLASS,
)[0];
const addPRToHighlightsButton = AddPRToHighlightsButton();

Expand Down
4 changes: 2 additions & 2 deletions src/utils/dom-utils/changeSuggestorButton.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AICodeReviewButton } from "../../content-scripts/components/AICodeReview/AICodeReviewButton";
import { GITHUB_REVIEW_SUGGESTION_SELECTOR } from "../../constants";
import { GITHUB_REVIEW_SUGGESTION_CLASS } from "../../constants";
import { isPublicRepository } from "../fetchGithubAPIData";
import { SettingsConfig } from "../../popup/pages/settings";

Expand All @@ -22,7 +22,7 @@ const injectChangeSuggestorButton = async (commentNode: HTMLElement) => {
}
}

const suggestChangesIcon = commentNode.getElementsByClassName(GITHUB_REVIEW_SUGGESTION_SELECTOR)[0];
const suggestChangesIcon = commentNode.getElementsByClassName(GITHUB_REVIEW_SUGGESTION_CLASS)[0];
const changeSuggestorButton = AICodeReviewButton(commentNode);

if (suggestChangesIcon.querySelector("#os-ai-change-gen")) {
Expand Down

0 comments on commit 2d61626

Please sign in to comment.