Skip to content

Commit a988f11

Browse files
committed
Rename GithubAddComment entities to GithubAddPRComment.
1 parent c1665e5 commit a988f11

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

browser-extension/src/lib/enhancers/github/githubAddComment.ts renamed to browser-extension/src/lib/enhancers/github/githubPRAddComment.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@ import OverType, { type OverTypeInstance } from '../../../overtype/overtype'
22
import type { CommentEnhancer, CommentSpot } from '../../enhancer'
33
import { logger } from '../../logger'
44
import { githubHighlighter } from './githubHighlighter'
5-
import { GITHUB_SPOT_TYPES } from './githubSpotTypes'
5+
import { GITHUB_SPOT_TYPES, type GitHubSpotType } from './githubSpotTypes'
66

7-
type GitHubSpotType = (typeof GITHUB_SPOT_TYPES)[number]
8-
9-
interface GitHubAddCommentSpot extends CommentSpot {
7+
interface GitHubPRAddCommentSpot extends CommentSpot {
108
type: GitHubSpotType // Override to narrow from string to specific union
119
domain: string
1210
slug: string // owner/repo
1311
number: number // issue/PR number, undefined for new issues and PRs
1412
}
1513

16-
export class GitHubAddCommentEnhancer implements CommentEnhancer<GitHubAddCommentSpot> {
14+
export class GitHubPRAddCommentEnhancer implements CommentEnhancer<GitHubPRAddCommentSpot> {
1715
forSpotTypes(): string[] {
1816
return [...GITHUB_SPOT_TYPES]
1917
}
2018

21-
tryToEnhance(_textarea: HTMLTextAreaElement): GitHubAddCommentSpot | null {
19+
tryToEnhance(_textarea: HTMLTextAreaElement): GitHubPRAddCommentSpot | null {
2220
// Only handle github.com domains TODO: identify GitHub Enterprise somehow
2321
if (window.location.hostname !== 'github.com') {
2422
return null
@@ -47,7 +45,7 @@ export class GitHubAddCommentEnhancer implements CommentEnhancer<GitHubAddCommen
4745
OverType.setCodeHighlighter(githubHighlighter)
4846
}
4947

50-
enhance(textArea: HTMLTextAreaElement, _spot: GitHubAddCommentSpot): OverTypeInstance {
48+
enhance(textArea: HTMLTextAreaElement, _spot: GitHubPRAddCommentSpot): OverTypeInstance {
5149
const overtypeContainer = this.modifyDOM(textArea)
5250
return new OverType(overtypeContainer, {
5351
autoResize: true,
@@ -70,16 +68,16 @@ export class GitHubAddCommentEnhancer implements CommentEnhancer<GitHubAddCommen
7068
return overtypeContainer.parentElement!.closest('div')!
7169
}
7270

73-
tableTitle(spot: GitHubAddCommentSpot): string {
71+
tableTitle(spot: GitHubPRAddCommentSpot): string {
7472
const { slug, number } = spot
7573
return `${slug} PR #${number}`
7674
}
7775

78-
tableIcon(_: GitHubAddCommentSpot): string {
76+
tableIcon(_: GitHubPRAddCommentSpot): string {
7977
return '🔄' // PR icon TODO: icon urls in /public
8078
}
8179

82-
buildUrl(spot: GitHubAddCommentSpot): string {
80+
buildUrl(spot: GitHubPRAddCommentSpot): string {
8381
return `https://${spot.domain}/${spot.slug}/pull/${spot.number}`
8482
}
8583
}

browser-extension/src/lib/enhancers/github/githubSpotTypes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ export const GITHUB_SPOT_TYPES = [
99
'GH_PR_CODE_COMMENT',
1010
*/
1111
] as const
12+
13+
export type GitHubSpotType = (typeof GITHUB_SPOT_TYPES)[number]

browser-extension/src/lib/registries.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { OverTypeInstance } from '../overtype/overtype'
22
import type { CommentEnhancer, CommentSpot } from './enhancer'
3-
import { GitHubAddCommentEnhancer } from './enhancers/github/githubAddComment'
3+
import { GitHubPRAddCommentEnhancer } from './enhancers/github/githubPRAddComment'
44

55
export interface EnhancedTextarea<T extends CommentSpot = CommentSpot> {
66
textarea: HTMLTextAreaElement
@@ -15,7 +15,7 @@ export class EnhancerRegistry {
1515

1616
constructor() {
1717
// Register all available handlers
18-
this.register(new GitHubAddCommentEnhancer())
18+
this.register(new GitHubPRAddCommentEnhancer())
1919
}
2020

2121
private register<T extends CommentSpot>(handler: CommentEnhancer<T>): void {

0 commit comments

Comments
 (0)