Skip to content

Commit f5415ce

Browse files
committed
Update GitHubIssueCreateEnhancer to handle the project case.
1 parent 0056c73 commit f5415ce

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

src/lib/enhancers/github/GitHubIssueCreateEnhancer.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,35 @@ export class GitHubIssueCreateEnhancer
3737
return null
3838
}
3939

40+
// Check for project board URLs first
41+
const isProjectView = location.pathname.match(
42+
/^\/(?:orgs|users)\/[^/]+\/projects\/\d+(?:\/views\/\d+)?/
43+
)
44+
if (isProjectView) {
45+
// Check if we're in a "Create new issue" dialog
46+
const dialog = textarea.closest('[role="dialog"]')
47+
if (dialog) {
48+
const dialogHeading = dialog.querySelector("h1")?.textContent
49+
const slugMatch = dialogHeading?.match(/Create new issue in (.+)/)
50+
if (slugMatch) {
51+
const slug = slugMatch[1]!
52+
const unique_key = `github.com:${slug}:new`
53+
const titleInput = document.querySelector(
54+
'input[placeholder="Title"]'
55+
) as HTMLInputElement
56+
const title = titleInput?.value || ""
57+
return {
58+
domain: location.host,
59+
slug,
60+
title,
61+
type: GH_ISSUE_CREATE,
62+
unique_key,
63+
}
64+
}
65+
}
66+
return null
67+
}
68+
4069
// Parse GitHub URL structure: /owner/repo/issues/123 or /owner/repo/pull/456
4170
logger.debug(`${this.constructor.name} examing url`, location.pathname)
4271

tests/lib/enhancers/__snapshots__/gh-detection.test.ts.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,18 @@ exports[`github detection > gh_project_issue_edit:should detect correct spots 1`
273273
},
274274
]
275275
`;
276+
277+
exports[`github detection > gh_project_issue_new:should detect correct spots 1`] = `
278+
[
279+
{
280+
"for": "id=:r4t: name=null className=prc-Textarea-TextArea-13q4j overtype-input",
281+
"spot": {
282+
"domain": "github.com",
283+
"slug": "diffplug/gitcasso",
284+
"title": "Draft project title",
285+
"type": "GH_ISSUE_CREATE",
286+
"unique_key": "github.com:diffplug/gitcasso:new",
287+
},
288+
},
289+
]
290+
`;

tests/lib/enhancers/__snapshots__/gh-ui.test.ts.snap

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,30 @@ exports[`github ui > gh_project_issue_edit:should render correct UI elements 1`]
348348
},
349349
]
350350
`;
351+
352+
exports[`github ui > gh_project_issue_new:should render correct UI elements 1`] = `
353+
[
354+
{
355+
"for": "id=:r4t: name=null className=prc-Textarea-TextArea-13q4j overtype-input",
356+
"title": "Draft project title",
357+
"upperDecoration": <React.Fragment>
358+
<span
359+
className="flex h-4 w-4 flex-shrink-0 items-center justify-center"
360+
>
361+
<IssueOpenedIcon
362+
size={16}
363+
/>
364+
</span>
365+
<span>
366+
&lt;draft&gt;
367+
368+
<LinkOutOfPopup
369+
href="https://github.com/diffplug/gitcasso"
370+
>
371+
diffplug/gitcasso
372+
</LinkOutOfPopup>
373+
</span>
374+
</React.Fragment>,
375+
},
376+
]
377+
`;

0 commit comments

Comments
 (0)