@@ -17,6 +17,7 @@ import { UserProfile } from 'src/app/_models/userProfile';
1717} )
1818export 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 } ) ;
@@ -137,9 +141,9 @@ export class CommentThreadComponent {
137141 this . allowAnyOneToResolve = ! this . allowAnyOneToResolve ;
138142 }
139143
140- createGitHubIsuue ( title : string ) {
144+ createGitHubIssue ( event : MenuItemCommandEvent ) {
141145 let repo = "" ;
142- switch ( title ) {
146+ switch ( event . item ?. title ) {
143147 case "csharp" :
144148 repo = "azure-sdk-for-net" ;
145149 break ;
@@ -162,6 +166,24 @@ export class CommentThreadComponent {
162166 repo = "azure-sdk-for-cpp" ;
163167 break ;
164168 }
169+
170+ const target = ( event . originalEvent ?. target as Element ) . closest ( "a" ) as Element ;
171+ const commentId = target . getAttribute ( "data-item-id" ) ;
172+ const commentData = this . codePanelRowData ?. comments ?. find ( comment => comment . id === commentId ) ?. commentText . replace ( / < [ ^ > ] * > / g, '' ) . trim ( ) ;
173+
174+ console . log ( this . associatedCodeLine ) ;
175+
176+ const codeLineContent = this . associatedCodeLine
177+ ? this . associatedCodeLine . rowOfTokens
178+ . map ( token => token . value )
179+ . join ( '' )
180+ : '' ;
181+
182+ const nodeId : string = this . codePanelRowData ?. nodeId ?? 'defaultNodeId' ;
183+ const apiViewUrl = `${ window . location . href . split ( "#" ) [ 0 ] } &nId=${ encodeURIComponent ( nodeId ) } ` ;
184+ const issueBody = encodeURIComponent ( `\`\`\`${ event . item ?. title } \n${ codeLineContent } \n\`\`\`\n#\n${ commentData } \n#\n[Created from ApiView comment](${ apiViewUrl } )` ) ;
185+
186+ window . open ( `https://github.com/Azure/${ repo } /issues/new?body=${ issueBody } ` , '_blank' ) ;
165187 }
166188
167189 showReplyEditor ( event : Event ) {
0 commit comments