Skip to content

Commit ca6d3d9

Browse files
author
Whitney Shake
committed
PR change requests complete
1 parent e64066c commit ca6d3d9

3 files changed

Lines changed: 23 additions & 12 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<ng-container *ngIf="item.type === CodePanelRowDatatype.CommentThread">
2626
<app-comment-thread
2727
[codePanelRowData]="item"
28-
[associatedCodeLine]="codePanelData!.nodeMetaData[item.nodeIdHashed]!.codeLines[item.associatedRowPositionInGroup]!"
28+
[associatedCodeLine]="getAssociatedCodeLine(item)"
2929
(cancelCommentActionEmitter)="handleCancelCommentActionEmitter($event)"
3030
(saveCommentActionEmitter)="handleSaveCommentActionEmitter($event)"
3131
(deleteCommentActionEmitter)="handleDeleteCommentActionEmitter($event)"

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ export class CodePanelComponent implements OnChanges{
136136
return "";
137137
}
138138

139+
getAssociatedCodeLine(item: CodePanelRowData): CodePanelRowData | undefined {
140+
if (this.codePanelData?.nodeMetaData && this.codePanelData.nodeMetaData[item.nodeIdHashed]) {
141+
return this.codePanelData.nodeMetaData[item.nodeIdHashed].codeLines[item.associatedRowPositionInGroup] || undefined;
142+
}
143+
return undefined;
144+
}
145+
139146
toggleNodeComments(target: Element) {
140147
const nodeIdHashed = target.closest('.code-line')!.getAttribute('data-node-id');
141148
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: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,15 @@ export class CommentThreadComponent {
9797
},
9898
]
9999
});
100-
101100
this.setCommentResolutionState();
102101
}
103102

104103
ngOnChanges(changes: SimpleChanges) {
105104
if (changes['codePanelRowData']) {
106105
this.setCommentResolutionState();
107106
}
107+
if (changes['associatedCodeLine']) {
108+
}
108109
}
109110

110111
setCommentResolutionState() {
@@ -170,17 +171,20 @@ export class CommentThreadComponent {
170171
const target = (event.originalEvent?.target as Element).closest("a") as Element;
171172
const commentId = target.getAttribute("data-item-id");
172173
const commentData = this.codePanelRowData?.comments?.find(comment => comment.id === commentId)?.commentText.replace(/<[^>]*>/g, '').trim();
173-
174+
174175
const codeLineContent = this.associatedCodeLine
175-
? this.associatedCodeLine.rowOfTokens
176-
.filter(token => token.kind !== 'nonBreakingSpace')
177-
.map(token => token.value)
178-
.join('')
179-
: '';
180-
181-
const apiViewUrl = `${window.location.href.split("#")[0]}%23${encodeURIComponent(encodeURIComponent(event.item?.title!))}`;
182-
const issueBody = encodeURIComponent(`\`\`\`${event.item?.title}\n${codeLineContent}\n\`\`\`\n#\n${commentData}\n#\n[Created from ApiView comment]\n(${apiViewUrl})`);
183-
176+
? this.associatedCodeLine.rowOfTokens
177+
.filter(token => token.kind !== 'nonBreakingSpace')
178+
.map(token => token.value)
179+
.join(' ')
180+
.replace(/\s+/g, ' ')
181+
.trim()
182+
: '';
183+
184+
const nodeId: string = this.codePanelRowData?.nodeId ?? 'defaultNodeId';
185+
const apiViewUrl = `${window.location.href.split("#")[0]}&nId=${encodeURIComponent(nodeId)}`;
186+
const issueBody = encodeURIComponent(`\`\`\`${event.item?.title}\n${codeLineContent}\n\`\`\`\n#\n${commentData}\n#\n[Created from ApiView comment](${apiViewUrl})`);
187+
184188
window.open(`https://github.com/Azure/${repo}/issues/new?body=${issueBody}`, '_blank');
185189
}
186190

0 commit comments

Comments
 (0)