Skip to content

Commit d275e61

Browse files
Whitney Shakechidozieononiwu
authored andcommitted
Create GitHub Issue feature complete
Create GitHub Issue feature rebased and ready for review Corrected typo refactored to use component communication instead of service removed unneccessary var Refactored passing of data Removed comment Reverted to prior commit and re-incorporated new logic
1 parent fb1b7a2 commit d275e61

3 files changed

Lines changed: 42 additions & 9 deletions

File tree

src/dotnet/APIView/ClientSPA/src/app/_components/code-panel/code-panel.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<ng-container *ngIf="item.type === CodePanelRowDatatype.CommentThread">
2626
<app-comment-thread
2727
[codePanelRowData]="item"
28+
[associatedCodeLine]="getAssociatedCodeLine(item)"
2829
(cancelCommentActionEmitter)="handleCancelCommentActionEmitter($event)"
2930
(saveCommentActionEmitter)="handleSaveCommentActionEmitter($event)"
3031
(deleteCommentActionEmitter)="handleDeleteCommentActionEmitter($event)"

src/dotnet/APIView/ClientSPA/src/app/_components/code-panel/code-panel.component.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ export class CodePanelComponent implements OnChanges{
5656
this.codePanelRowSource = undefined;
5757
}
5858
}
59-
59+
6060
if (changes['scrollToNodeIdHashed'] && changes['scrollToNodeIdHashed'].currentValue) {
6161
this.scrollToNode(this.scrollToNodeIdHashed!);
6262
}
63-
63+
6464
if (changes['loadFailed'] && changes['loadFailed'].currentValue) {
6565
this.isLoading = false;
6666
}
6767
}
6868

69-
onCodePanelItemClick(event: Event) {
69+
onCodePanelItemClick(event: Event) {
7070
const target = event.target as Element;
7171
if (target.classList.contains('nav-token')) {
7272
const navigationId = target.getAttribute('data-navigate-to-id');
@@ -137,6 +137,13 @@ export class CodePanelComponent implements OnChanges{
137137
return "";
138138
}
139139

140+
getAssociatedCodeLine(item: CodePanelRowData): CodePanelRowData | undefined {
141+
if (this.codePanelData?.nodeMetaData && this.codePanelData.nodeMetaData[item.nodeIdHashed]) {
142+
return this.codePanelData.nodeMetaData[item.nodeIdHashed].codeLines[item.associatedRowPositionInGroup] || undefined;
143+
}
144+
return undefined;
145+
}
146+
140147
toggleNodeComments(target: Element) {
141148
const nodeIdHashed = target.closest('.code-line')!.getAttribute('data-node-id');
142149
const rowPositionInGroup = parseInt(target.closest('.code-line')!.getAttribute('data-row-position-in-group')!, 10);

src/dotnet/APIView/ClientSPA/src/app/_components/shared/comment-thread/comment-thread.component.ts

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { UserProfile } from 'src/app/_models/userProfile';
1717
})
1818
export class CommentThreadComponent {
1919
@Input() codePanelRowData: CodePanelRowData | undefined = undefined;
20+
@Input() associatedCodeLine: CodePanelRowData | undefined;
2021
@Output() cancelCommentActionEmitter : EventEmitter<any> = new EventEmitter<any>();
2122
@Output() saveCommentActionEmitter : EventEmitter<any> = new EventEmitter<any>();
2223
@Output() deleteCommentActionEmitter : EventEmitter<any> = new EventEmitter<any>();
@@ -62,34 +63,37 @@ export class CommentThreadComponent {
6263
items: [{
6364
title: "csharp",
6465
label: ".NET",
65-
state: {
66-
repo: "azure-sdk-for-net",
67-
language: "C#"
68-
}
66+
command: (event) => this.createGitHubIssue(event),
6967
},
7068
{
7169
title: "java",
7270
label: "Java",
71+
command: (event) => this.createGitHubIssue(event),
7372
},
7473
{
7574
title: "python",
7675
label: "Python",
76+
command: (event) => this.createGitHubIssue(event),
7777
},
7878
{
7979
title: "c",
8080
label: "C",
81+
command: (event) => this.createGitHubIssue(event),
8182
},
8283
{
8384
title: "javascript",
8485
label: "JavaScript",
86+
command: (event) => this.createGitHubIssue(event),
8587
},
8688
{
8789
title: "go",
8890
label: "Go",
91+
command: (event) => this.createGitHubIssue(event),
8992
},
9093
{
9194
title: "cplusplus",
9295
label: "C++",
96+
command: (event) => this.createGitHubIssue(event),
9397
},
9498
]
9599
});
@@ -101,6 +105,8 @@ export class CommentThreadComponent {
101105
if (changes['codePanelRowData']) {
102106
this.setCommentResolutionState();
103107
}
108+
if (changes['associatedCodeLine']) {
109+
}
104110
}
105111

106112
setCommentResolutionState() {
@@ -137,9 +143,9 @@ export class CommentThreadComponent {
137143
this.allowAnyOneToResolve = !this.allowAnyOneToResolve;
138144
}
139145

140-
createGitHubIsuue(title : string) {
146+
createGitHubIssue(event: MenuItemCommandEvent) {
141147
let repo = "";
142-
switch (title) {
148+
switch (event.item?.title) {
143149
case "csharp":
144150
repo = "azure-sdk-for-net";
145151
break;
@@ -162,6 +168,25 @@ export class CommentThreadComponent {
162168
repo = "azure-sdk-for-cpp";
163169
break;
164170
}
171+
172+
const target = (event.originalEvent?.target as Element).closest("a") as Element;
173+
const commentId = target.getAttribute("data-item-id");
174+
const commentData = this.codePanelRowData?.comments?.find(comment => comment.id === commentId)?.commentText.replace(/<[^>]*>/g, '').trim();
175+
176+
const codeLineContent = this.associatedCodeLine
177+
? this.associatedCodeLine.rowOfTokens
178+
.filter(token => token.kind !== 'nonBreakingSpace')
179+
.map(token => token.value)
180+
.join(' ')
181+
.replace(/\s+/g, ' ')
182+
.trim()
183+
: '';
184+
185+
const nodeId: string = this.codePanelRowData?.nodeId ?? 'defaultNodeId';
186+
const apiViewUrl = `${window.location.href.split("#")[0]}&nId=${encodeURIComponent(nodeId)}`;
187+
const issueBody = encodeURIComponent(`\`\`\`${event.item?.title}\n${codeLineContent}\n\`\`\`\n#\n${commentData}\n#\n[Created from ApiView comment](${apiViewUrl})`);
188+
189+
window.open(`https://github.com/Azure/${repo}/issues/new?body=${issueBody}`, '_blank');
165190
}
166191

167192
showReplyEditor(event: Event) {

0 commit comments

Comments
 (0)