@@ -67,32 +67,37 @@ function ensurePR<TIssue extends Issue, TIssueModel extends IssueModel<TIssue>>(
6767
6868export async function openDescription (
6969 telemetry : ITelemetry ,
70- pullRequestModel : IssueModel ,
70+ issueModel : IssueModel ,
7171 descriptionNode : DescriptionNode | undefined ,
7272 folderManager : FolderRepositoryManager ,
7373 revealNode : boolean ,
7474 preserveFocus : boolean = true ,
7575 notificationProvider ?: NotificationProvider
7676) {
77- const pullRequest = ensurePR ( folderManager , pullRequestModel ) ;
77+ const issue = ensurePR ( folderManager , issueModel ) ;
7878 if ( revealNode ) {
7979 descriptionNode ?. reveal ( descriptionNode , { select : true , focus : true } ) ;
8080 }
8181 // Create and show a new webview
82- if ( pullRequest instanceof PullRequestModel ) {
83- await PullRequestOverviewPanel . createOrShow ( telemetry , folderManager . context . extensionUri , folderManager , pullRequest , undefined , preserveFocus ) ;
82+ if ( issue instanceof PullRequestModel ) {
83+ await PullRequestOverviewPanel . createOrShow ( telemetry , folderManager . context . extensionUri , folderManager , issue , undefined , preserveFocus ) ;
84+ /* __GDPR__
85+ "pr.openDescription" : {}
86+ */
87+ telemetry . sendTelemetryEvent ( 'pr.openDescription' ) ;
8488 } else {
85- await IssueOverviewPanel . createOrShow ( telemetry , folderManager . context . extensionUri , folderManager , pullRequest ) ;
89+ await IssueOverviewPanel . createOrShow ( telemetry , folderManager . context . extensionUri , folderManager , issue ) ;
90+ /* __GDPR__
91+ "issue.openDescription" : {}
92+ */
93+ telemetry . sendTelemetryEvent ( 'issue.openDescription' ) ;
8694 }
8795
88- if ( notificationProvider ?. hasNotification ( pullRequest ) ) {
89- notificationProvider . markPrNotificationsAsRead ( pullRequest ) ;
96+ if ( notificationProvider ?. hasNotification ( issue ) ) {
97+ notificationProvider . markPrNotificationsAsRead ( issue ) ;
9098 }
9199
92- /* __GDPR__
93- "pr.openDescription" : {}
94- */
95- telemetry . sendTelemetryEvent ( 'pr.openDescription' ) ;
100+
96101}
97102
98103async function chooseItem < T > (
@@ -115,7 +120,7 @@ async function chooseItem<T>(
115120 return ( await vscode . window . showQuickPick ( items , options ) ) ?. itemValue ;
116121}
117122
118- export async function openPullRequestOnGitHub ( e : PRNode | DescriptionNode | PullRequestModel | NotificationTreeItem , telemetry : ITelemetry ) {
123+ export async function openPullRequestOnGitHub ( e : PRNode | DescriptionNode | IssueModel | NotificationTreeItem , telemetry : ITelemetry ) {
119124 if ( e instanceof PRNode || e instanceof DescriptionNode ) {
120125 vscode . commands . executeCommand ( 'vscode.open' , vscode . Uri . parse ( e . pullRequestModel . html_url ) ) ;
121126 } else if ( isNotificationTreeItem ( e ) ) {
@@ -805,50 +810,61 @@ export function registerCommands(
805810 } ) ,
806811 ) ;
807812
808- context . subscriptions . push (
809- vscode . commands . registerCommand (
810- 'pr.openDescription' ,
811- async ( argument : DescriptionNode | IssueModel | undefined ) => {
812- let pullRequestModel : IssueModel | undefined ;
813- if ( ! argument ) {
814- const activePullRequests : PullRequestModel [ ] = reposManager . folderManagers
815- . map ( manager => manager . activePullRequest ! )
816- . filter ( activePR => ! ! activePR ) ;
817- if ( activePullRequests . length >= 1 ) {
818- pullRequestModel = await chooseItem < PullRequestModel > (
819- activePullRequests ,
820- itemValue => itemValue . title ,
821- ) ;
822- }
823- } else {
824- pullRequestModel = argument instanceof DescriptionNode ? argument . pullRequestModel : argument ;
825- }
813+ async function openDescriptionCommand ( argument : DescriptionNode | IssueModel | undefined ) {
814+ let issueModel : IssueModel | undefined ;
815+ if ( ! argument ) {
816+ const activePullRequests : PullRequestModel [ ] = reposManager . folderManagers
817+ . map ( manager => manager . activePullRequest ! )
818+ . filter ( activePR => ! ! activePR ) ;
819+ if ( activePullRequests . length >= 1 ) {
820+ issueModel = await chooseItem < PullRequestModel > (
821+ activePullRequests ,
822+ itemValue => itemValue . title ,
823+ ) ;
824+ }
825+ } else {
826+ issueModel = argument instanceof DescriptionNode ? argument . pullRequestModel : argument ;
827+ }
826828
827- if ( ! pullRequestModel ) {
828- Logger . appendLine ( 'No pull request found.' , logId ) ;
829- return ;
830- }
829+ if ( ! issueModel ) {
830+ Logger . appendLine ( 'No pull request found.' , logId ) ;
831+ return ;
832+ }
831833
832- const folderManager = reposManager . getManagerForIssueModel ( pullRequestModel ) ;
833- if ( ! folderManager ) {
834- return ;
835- }
834+ const folderManager = reposManager . getManagerForIssueModel ( issueModel ) ;
835+ if ( ! folderManager ) {
836+ return ;
837+ }
836838
837- let descriptionNode : DescriptionNode | undefined ;
838- if ( argument instanceof DescriptionNode ) {
839- descriptionNode = argument ;
840- } else {
841- const reviewManager = ReviewManager . getReviewManagerForFolderManager ( reviewsManager . reviewManagers , folderManager ) ;
842- if ( ! reviewManager ) {
843- return ;
844- }
839+ let descriptionNode : DescriptionNode | undefined ;
840+ if ( argument instanceof DescriptionNode ) {
841+ descriptionNode = argument ;
842+ } else {
843+ const reviewManager = ReviewManager . getReviewManagerForFolderManager ( reviewsManager . reviewManagers , folderManager ) ;
844+ if ( ! reviewManager ) {
845+ return ;
846+ }
845847
846- descriptionNode = reviewManager . changesInPrDataProvider . getDescriptionNode ( folderManager ) ;
847- }
848+ descriptionNode = reviewManager . changesInPrDataProvider . getDescriptionNode ( folderManager ) ;
849+ }
848850
849- await openDescription ( telemetry , pullRequestModel , descriptionNode , folderManager , ! ( argument instanceof DescriptionNode ) , ! ( argument instanceof RepositoryChangesNode ) , tree . notificationProvider ) ;
850- } ,
851- ) ,
851+ const revealDescription = ! ( argument instanceof DescriptionNode ) && ( ! ( argument instanceof IssueModel ) || ( argument instanceof PullRequestModel ) ) ;
852+
853+ await openDescription ( telemetry , issueModel , descriptionNode , folderManager , revealDescription , ! ( argument instanceof RepositoryChangesNode ) , tree . notificationProvider ) ;
854+ }
855+
856+ context . subscriptions . push (
857+ vscode . commands . registerCommand (
858+ 'pr.openDescription' ,
859+ openDescriptionCommand
860+ )
861+ ) ;
862+
863+ context . subscriptions . push (
864+ vscode . commands . registerCommand (
865+ 'issue.openDescription' ,
866+ openDescriptionCommand
867+ )
852868 ) ;
853869
854870 context . subscriptions . push (
@@ -1460,6 +1476,7 @@ ${contents}
14601476 vscode . env . openExternal ( getPullsUrl ( githubRepo ) ) ;
14611477 }
14621478 } ) ) ;
1479+
14631480 context . subscriptions . push (
14641481 vscode . commands . registerCommand ( 'issues.openIssuesWebsite' , async ( ) => {
14651482 const githubRepo = await chooseRepoToOpen ( ) ;
0 commit comments