diff --git a/src/dotnet/APIView/ClientSPA/src/app/_components/code-panel/code-panel.component.html b/src/dotnet/APIView/ClientSPA/src/app/_components/code-panel/code-panel.component.html index 38e105273b4..e57d83e97a3 100644 --- a/src/dotnet/APIView/ClientSPA/src/app/_components/code-panel/code-panel.component.html +++ b/src/dotnet/APIView/ClientSPA/src/app/_components/code-panel/code-panel.component.html @@ -26,6 +26,7 @@ = new EventEmitter(); @Output() saveCommentActionEmitter : EventEmitter = new EventEmitter(); @Output() deleteCommentActionEmitter : EventEmitter = new EventEmitter(); @@ -62,34 +63,37 @@ export class CommentThreadComponent { items: [{ title: "csharp", label: ".NET", - state: { - repo: "azure-sdk-for-net", - language: "C#" - } + command: (event) => this.createGitHubIssue(event), }, { title: "java", label: "Java", + command: (event) => this.createGitHubIssue(event), }, { title: "python", label: "Python", + command: (event) => this.createGitHubIssue(event), }, { title: "c", label: "C", + command: (event) => this.createGitHubIssue(event), }, { title: "javascript", label: "JavaScript", + command: (event) => this.createGitHubIssue(event), }, { title: "go", label: "Go", + command: (event) => this.createGitHubIssue(event), }, { title: "cplusplus", label: "C++", + command: (event) => this.createGitHubIssue(event), }, ] }); @@ -137,9 +141,9 @@ export class CommentThreadComponent { this.allowAnyOneToResolve = !this.allowAnyOneToResolve; } - createGitHubIsuue(title : string) { + createGitHubIssue(event: MenuItemCommandEvent) { let repo = ""; - switch (title) { + switch (event.item?.title) { case "csharp": repo = "azure-sdk-for-net"; break; @@ -162,6 +166,24 @@ export class CommentThreadComponent { repo = "azure-sdk-for-cpp"; break; } + + const target = (event.originalEvent?.target as Element).closest("a") as Element; + const commentId = target.getAttribute("data-item-id"); + const commentData = this.codePanelRowData?.comments?.find(comment => comment.id === commentId)?.commentText.replace(/<[^>]*>/g, '').trim(); + + console.log(this.associatedCodeLine); + + const codeLineContent = this.associatedCodeLine + ? this.associatedCodeLine.rowOfTokens + .map(token => token.value) + .join('') + : ''; + + const nodeId: string = this.codePanelRowData?.nodeId ?? 'defaultNodeId'; + const apiViewUrl = `${window.location.href.split("#")[0]}&nId=${encodeURIComponent(nodeId)}`; + const issueBody = encodeURIComponent(`\`\`\`${event.item?.title}\n${codeLineContent}\n\`\`\`\n#\n${commentData}\n#\n[Created from ApiView comment](${apiViewUrl})`); + + window.open(`https://github.com/Azure/${repo}/issues/new?body=${issueBody}`, '_blank'); } showReplyEditor(event: Event) {