forked from chibat/chrome-extension-typescript-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
#54: move settings to options page #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
7024e48
#54: Move Settings to Options
HansKre 26454b6
#54: Refactor and modularize
HansKre dd7a675
#54: Remove SettingsTab
HansKre 1ab354a
#54: Move files from popup to pages
HansKre 5ddc609
#54: Create FeatureTogglesTab.module.scss
HansKre 0ef7e4b
#54: Refactor Tab-names
HansKre 2039d48
#54: Organize features by page
HansKre 3507db2
#54: Create Export/Import tab
HansKre 98a00dd
#54: Remove title from import/export tab
HansKre ed8d514
#54: Add CLAUDE.md
HansKre 553a386
#54: Remove isValidTab
HansKre 0e8fbcd
#54: Automatically scroll FeatureInput into view when toggled
HansKre 58480ff
#54: Move Autofilter to Feature Toggles
HansKre d3144b3
#54: Disable FeatureInput, instead hiding it
HansKre 690952a
#54: Rename template description to description template
HansKre ba3f80c
#54: Remove jira integration feature toggle
HansKre dce650b
#54: Distinguish between totalLinesPr and totalLinesPrs features
HansKre 18d85ed
#54: Update CLAUDE.md
HansKre dfae0b0
#54: Fix JiraTab
HansKre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,135 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Common Development Commands | ||
|
|
||
| ```bash | ||
| # Development | ||
| npm run watch # Watch mode for development | ||
| npm run build # Production build | ||
| npm run build:pack # Build and create dist.zip package | ||
| npm run release # Build and package for release | ||
|
|
||
| # Testing and Quality | ||
| npm test # Run Jest tests | ||
| npm run lint # Run ESLint | ||
| npm run lint:fix # Fix linting issues automatically | ||
| npm run prettier # Format code with Prettier | ||
|
|
||
| # Utility | ||
| npm run clean # Clean dist directory | ||
| npm run prepare # Setup husky hooks | ||
|
|
||
| # Chrome Extension Development | ||
| # Load the 'dist' directory in Chrome's extension developer mode after building | ||
| ``` | ||
|
|
||
| ## Project Architecture | ||
|
|
||
| This is a Chrome extension (Manifest v3) that enhances GitHub and GitHub Enterprise UI with productivity features. | ||
|
|
||
| ### Core Structure | ||
|
|
||
| - **Content Scripts**: Three separate content scripts inject functionality into different GitHub pages: | ||
| - `content_pr_page.tsx` - Individual PR pages | ||
| - `content_prs_page.tsx` - PRs listing page | ||
| - `content_compare_page.tsx` - Compare/diff pages | ||
|
|
||
| - **Background Service Worker**: `background.ts` handles JIRA API requests due to CORS restrictions | ||
|
|
||
| - **Extension Pages**: | ||
| - `popup.tsx` - Extension popup interface | ||
| - `options.tsx` - Options/settings page with tabbed interface | ||
|
|
||
| ### Key Components | ||
|
|
||
| - **Settings Management**: Uses Chrome storage API with Yup schema validation (`src/services/getSettings.ts`) | ||
| - **Multi-Instance Support**: Supports multiple GitHub instances (Enterprise + GitHub.com) via instance configuration | ||
| - **Feature Toggles**: All features are individually toggleable via settings | ||
| - **JIRA Integration**: Fetches issue data through background script to bypass CORS | ||
|
|
||
| ### Settings Architecture | ||
|
|
||
| Settings are validated using Yup schemas and organized into: | ||
|
|
||
| - **`instances[]`** - GitHub instance configurations | ||
| - `pat` - Personal Access Token (must start with `ghp_`, minimum 30 characters) | ||
| - `org` - GitHub organization name | ||
| - `repo` - Repository name | ||
| - `ghBaseUrl` - GitHub API base URL (defaults to `https://api.github.com`) | ||
| - `randomReviewers` - Comma-separated list of reviewer usernames | ||
|
|
||
| - **`features{}`** - Boolean toggles for extension features: | ||
| - `baseBranchLabels` - Show base branch labels on PRs | ||
| - `changedFiles` - Display changed files count | ||
| - `totalLinesPrs` - Show total lines changed on PR list page | ||
| - `totalLinesPr` - Show total lines changed on individual PR page | ||
| - `reOrderPrs` - Reorder PRs by custom logic | ||
| - `addUpdateBranchButton` - Add update branch button | ||
| - `autoFilter` - Enable automatic PR filtering | ||
| - `prTitleFromJira` - Auto-populate PR title from JIRA ticket | ||
| - `descriptionTemplate` - Use custom PR description template | ||
| - `randomReviewer` - Enable random reviewer assignment | ||
|
|
||
| - **`jira{}`** - JIRA integration settings (optional) | ||
| - `pat` - JIRA Personal Access Token (minimum 30 characters) | ||
| - `baseUrl` - JIRA instance base URL | ||
| - `issueKeyRegex` - Regex pattern for JIRA issue keys (e.g., "TEST-\\d+") | ||
|
|
||
| - **`autoFilter`** - Custom PR filtering query string (optional) | ||
| - **`descriptionTemplate`** - Custom PR description template text (optional) | ||
|
|
||
| ### Options Page Structure | ||
|
|
||
| The Options page uses a tabbed interface with the following tabs: | ||
|
|
||
| - **Feature Toggles** - Individual toggles for all extension features | ||
| - **GH Instances** - GitHub instance configuration (PAT, org, repo, base URL) | ||
| - **Jira** - JIRA integration settings | ||
| - **Import/Export** - Settings backup and restore functionality | ||
|
|
||
| Each tab is implemented as a separate component in `src/pages/Tabs/` with dedicated styling and logic. | ||
|
|
||
| ### Build System | ||
|
|
||
| - **Webpack**: Multi-entry build with code splitting (vendor chunk for all except background) | ||
| - **SASS Modules**: CSS modules with local scope and hash-based class names | ||
| - **TypeScript**: Full TypeScript with strict validation | ||
| - **Entry Points**: Separate bundles for popup, options, content scripts, and background | ||
|
|
||
| ### Chrome Extension Permissions | ||
|
|
||
| - `storage` - Chrome storage for settings | ||
| - `host_permissions: ["<all_urls>"]` - Access to all GitHub instances | ||
| - Content scripts inject into `https://*/*` patterns | ||
|
|
||
| ### Development Workflow | ||
|
|
||
| 1. Run `npm run watch` for development | ||
| 2. Load `dist` directory in Chrome extension developer mode | ||
| 3. Changes auto-reload with webpack watch mode | ||
| 4. Use `npm run clean` to clear dist before production builds | ||
| 5. Run `npm test` to execute Jest unit tests | ||
| 6. Use `npm run lint:fix` to automatically fix linting issues | ||
| 7. Format code with `npm run prettier` before committing | ||
|
|
||
| ## Coding Guidelines | ||
|
|
||
| - **Type Definitions**: Always use `type` instead of `interface` | ||
| - **React Component Props**: Always name component props type as `Props` and never export it | ||
| - **Exports**: Never use default exports - always use named exports | ||
| - **Component Structure**: Follow existing component folder structure with index.ts barrel exports | ||
| - **Type Safety**: Never use `any` type - use proper typing with `unknown` for uncertain types | ||
| - **Type Casting**: When type casting is necessary, always include safety checks before casting | ||
|
|
||
| ## Important Implementation Notes | ||
|
|
||
| - Settings validation uses Yup schemas with strict type checking | ||
| - GitHub API integration uses Octokit with user-provided PATs | ||
| - JIRA API calls must go through background script due to CORS | ||
| - Features are conditionally loaded based on current page URL and user settings | ||
| - CSS modules prevent style conflicts with GitHub's native styles | ||
| - Pre-commit hooks with husky and lint-staged ensure code quality | ||
| - All settings are persisted to Chrome's local storage API | ||
| - The extension supports hot reloading during development via webpack watch mode |
This file contains hidden or 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
7 changes: 4 additions & 3 deletions
7
src/popup/Typography/Paragraph.tsx → src/components/Paragraph/Paragraph.tsx
This file contains hidden or 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
File renamed without changes.
This file contains hidden or 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,9 @@ | ||
| @import "../../shared-component-styles.scss"; | ||
|
|
||
| .sectionTitle { | ||
| color: $fontColor; | ||
| font-size: 20px; | ||
| font-weight: bold; | ||
| margin-bottom: 24px; | ||
| margin-top: 24px; | ||
| } |
This file contains hidden or 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 { Text } from "@primer/react"; | ||
| import React, { ReactNode } from "react"; | ||
| import styles from "./SectionTitle.module.scss"; | ||
|
|
||
| type Props = { | ||
| children: ReactNode; | ||
| }; | ||
|
|
||
| export const SectionTitle: React.FC<Props> = ({ children }) => { | ||
| return ( | ||
| <Text as="h2" className={styles.sectionTitle}> | ||
| {children} | ||
| </Text> | ||
| ); | ||
| }; |
This file contains hidden or 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 @@ | ||
| export { SectionTitle } from "./SectionTitle"; |
This file contains hidden or 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,4 @@ | ||
| .subtitle { | ||
| font-size: 14px; | ||
| font-style: italic; | ||
| } |
This file contains hidden or 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 { Text } from "@primer/react"; | ||
| import React, { ReactNode } from "react"; | ||
| import styles from "./Subtitle.module.scss"; | ||
|
|
||
| type Props = { | ||
| children: ReactNode; | ||
| }; | ||
|
|
||
| export const Subtitle: React.FC<Props> = ({ children }) => { | ||
| return ( | ||
| <Text as="p" className={styles.subtitle}> | ||
| {children} | ||
| </Text> | ||
| ); | ||
| }; |
This file contains hidden or 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 @@ | ||
| export { Subtitle } from "./Subtitle"; |
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
| export * from "./tabs"; |
This file contains hidden or 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,8 @@ | ||
| export const TABS = [ | ||
| "Feature Toggles", | ||
| "GH Instances", | ||
| "Jira", | ||
| "Import/Export", | ||
| ] as const; | ||
|
|
||
| export type Tab = (typeof TABS)[number]; |
12 changes: 6 additions & 6 deletions
12
src/content/addTemplateDescription.ts → src/content/addDescriptionTemplate.ts
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.