Skip to content

Commit 15c9171

Browse files
committed
Make a change to GitHubEditEnhancer so that it detects edited comments on project pages. TODO: figure out appending comments to issues on project pages
1 parent fd5c38d commit 15c9171

File tree

3 files changed

+86
-11
lines changed

3 files changed

+86
-11
lines changed

src/lib/enhancers/github/GitHubEditEnhancer.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,28 @@ export class GitHubEditEnhancer implements CommentEnhancer<GitHubEditSpot> {
2929
return null
3030
}
3131

32+
// Check for project draft edit first
33+
const isProjectDraftEdit = location.pathname.match(
34+
/^\/(?:orgs|users)\/[^/]+\/projects\/\d+\/views\/\d+/
35+
)
36+
if (isProjectDraftEdit) {
37+
const params = new URLSearchParams(location.search)
38+
const itemId = params.get("itemId")
39+
if (itemId && textarea.closest("[role='dialog']")) {
40+
const unique_key = `github.com:project-draft:${itemId}:edit-body`
41+
logger.debug(
42+
`${this.constructor.name} enhanced project draft body textarea`,
43+
unique_key
44+
)
45+
return {
46+
isIssue: true,
47+
type: GH_EDIT,
48+
unique_key,
49+
}
50+
}
51+
return null
52+
}
53+
3254
// Parse GitHub URL structure: /owner/repo/issues/123 or /owner/repo/pull/456
3355
const match = location.pathname.match(
3456
/^\/([^/]+)\/([^/]+)\/(?:issues|pull)\/(\d+)/

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,30 +224,46 @@ exports[`github detection > gh_project_draft:should detect correct spots 1`] = `
224224
exports[`github detection > gh_project_draft_edit:should detect correct spots 1`] = `
225225
[
226226
{
227-
"for": "id=:r5a: name=null className=prc-Textarea-TextArea-13q4j",
228-
"spot": "NO_SPOT",
227+
"for": "id=:r5a: name=null className=prc-Textarea-TextArea-13q4j overtype-input",
228+
"spot": {
229+
"isIssue": true,
230+
"type": "GH_EDIT",
231+
"unique_key": "github.com:project-draft:129503329:edit-body",
232+
},
229233
},
230234
]
231235
`;
232236

233237
exports[`github detection > gh_project_issue:should detect correct spots 1`] = `
234238
[
235239
{
236-
"for": "id=:rbs: name=null className=prc-Textarea-TextArea-13q4j",
237-
"spot": "NO_SPOT",
240+
"for": "id=:rbs: name=null className=prc-Textarea-TextArea-13q4j overtype-input",
241+
"spot": {
242+
"isIssue": true,
243+
"type": "GH_EDIT",
244+
"unique_key": "github.com:project-draft:129503239:edit-body",
245+
},
238246
},
239247
]
240248
`;
241249

242250
exports[`github detection > gh_project_issue_edit:should detect correct spots 1`] = `
243251
[
244252
{
245-
"for": "id=:rdh: name=null className=prc-Textarea-TextArea-13q4j",
246-
"spot": "NO_SPOT",
253+
"for": "id=:rdh: name=null className=prc-Textarea-TextArea-13q4j overtype-input",
254+
"spot": {
255+
"isIssue": true,
256+
"type": "GH_EDIT",
257+
"unique_key": "github.com:project-draft:129503239:edit-body",
258+
},
247259
},
248260
{
249-
"for": "id=:rbs: name=null className=prc-Textarea-TextArea-13q4j",
250-
"spot": "NO_SPOT",
261+
"for": "id=:rbs: name=null className=prc-Textarea-TextArea-13q4j overtype-input",
262+
"spot": {
263+
"isIssue": true,
264+
"type": "GH_EDIT",
265+
"unique_key": "github.com:project-draft:129503239:edit-body",
266+
},
251267
},
252268
]
253269
`;

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

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,45 @@ exports[`github ui > gh_project:should render correct UI elements 1`] = `[]`;
274274

275275
exports[`github ui > gh_project_draft:should render correct UI elements 1`] = `[]`;
276276

277-
exports[`github ui > gh_project_draft_edit:should render correct UI elements 1`] = `[]`;
277+
exports[`github ui > gh_project_draft_edit:should render correct UI elements 1`] = `
278+
[
279+
{
280+
"for": "id=:r5a: name=null className=prc-Textarea-TextArea-13q4j overtype-input",
281+
"title": "N/A",
282+
"upperDecoration": <span>
283+
N/A
284+
</span>,
285+
},
286+
]
287+
`;
278288

279-
exports[`github ui > gh_project_issue:should render correct UI elements 1`] = `[]`;
289+
exports[`github ui > gh_project_issue:should render correct UI elements 1`] = `
290+
[
291+
{
292+
"for": "id=:rbs: name=null className=prc-Textarea-TextArea-13q4j overtype-input",
293+
"title": "N/A",
294+
"upperDecoration": <span>
295+
N/A
296+
</span>,
297+
},
298+
]
299+
`;
280300

281-
exports[`github ui > gh_project_issue_edit:should render correct UI elements 1`] = `[]`;
301+
exports[`github ui > gh_project_issue_edit:should render correct UI elements 1`] = `
302+
[
303+
{
304+
"for": "id=:rdh: name=null className=prc-Textarea-TextArea-13q4j overtype-input",
305+
"title": "N/A",
306+
"upperDecoration": <span>
307+
N/A
308+
</span>,
309+
},
310+
{
311+
"for": "id=:rbs: name=null className=prc-Textarea-TextArea-13q4j overtype-input",
312+
"title": "N/A",
313+
"upperDecoration": <span>
314+
N/A
315+
</span>,
316+
},
317+
]
318+
`;

0 commit comments

Comments
 (0)