Skip to content

Commit d66cfa8

Browse files
committed
Make project logic more permissive.
1 parent 7c9636e commit d66cfa8

File tree

2 files changed

+47
-15
lines changed

2 files changed

+47
-15
lines changed

src/lib/enhancers/github/GitHubEditEnhancer.tsx

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,59 @@ export class GitHubEditEnhancer implements CommentEnhancer<GitHubEditSpot> {
3131

3232
// Check for project draft edit first
3333
const isProjectDraftEdit = location.pathname.match(
34-
/^\/(?:orgs|users)\/[^/]+\/projects\/\d+\/views\/\d+/
34+
/^\/(?:orgs|users)\/[^/]+\/projects\/\d+(?:\/views\/\d+)?/
3535
)
3636
if (isProjectDraftEdit) {
3737
const params = new URLSearchParams(location.search)
3838
const itemId = params.get("itemId")
39-
// Exclude textareas within Shared-module__CommentBox (those are for adding new comments, not editing)
40-
const isInCommentBox = textarea.closest(
41-
'[class*="Shared-module__CommentBox"]'
42-
)
43-
if (itemId && textarea.closest("[role='dialog']") && !isInCommentBox) {
44-
const unique_key = `github.com:project-draft:${itemId}:edit-body`
45-
logger.debug(
46-
`${this.constructor.name} enhanced project draft body textarea`,
47-
unique_key
39+
const issueParam = params.get("issue")
40+
41+
// Handle draft editing (itemId parameter)
42+
if (itemId) {
43+
// Exclude textareas within Shared-module__CommentBox (those are for adding new comments, not editing)
44+
const isInCommentBox = textarea.closest(
45+
'[class*="Shared-module__CommentBox"]'
4846
)
49-
return {
50-
isIssue: true,
51-
type: GH_EDIT,
52-
unique_key,
47+
if (textarea.closest("[role='dialog']") && !isInCommentBox) {
48+
const unique_key = `github.com:project-draft:${itemId}:edit-body`
49+
logger.debug(
50+
`${this.constructor.name} enhanced project draft body textarea`,
51+
unique_key
52+
)
53+
return {
54+
isIssue: true,
55+
type: GH_EDIT,
56+
unique_key,
57+
}
58+
}
59+
}
60+
61+
// Handle existing issue comment editing (issue parameter)
62+
if (issueParam) {
63+
// Parse issue parameter: "owner|repo|number"
64+
const parts = issueParam.split("|")
65+
if (parts.length === 3) {
66+
const [owner, repo, numberStr] = parts
67+
const slug = `${owner}/${repo}`
68+
const number = parseInt(numberStr!, 10)
69+
70+
// Edit mode: empty placeholder
71+
// Add new comment mode: has placeholder "Add your comment here..." or similar
72+
if (!textarea.placeholder || textarea.placeholder.trim() === "") {
73+
const unique_key = `github.com:${slug}:${number}:edit-comment`
74+
logger.debug(
75+
`${this.constructor.name} enhanced project issue comment edit textarea`,
76+
unique_key
77+
)
78+
return {
79+
isIssue: true,
80+
type: GH_EDIT,
81+
unique_key,
82+
}
83+
}
5384
}
5485
}
86+
5587
return null
5688
}
5789

src/lib/enhancers/github/GitHubIssueAppendEnhancer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class GitHubIssueAppendEnhancer
4747

4848
// Check for project URLs with issue parameter first
4949
const isProjectView = location.pathname.match(
50-
/^\/(?:orgs|users)\/[^/]+\/projects\/\d+\/views\/\d+/
50+
/^\/(?:orgs|users)\/[^/]+\/projects\/\d+(?:\/views\/\d+)?/
5151
)
5252
if (isProjectView) {
5353
const params = new URLSearchParams(location.search)

0 commit comments

Comments
 (0)