Skip to content

Commit eab2b35

Browse files
committed
Make linked issues clickable links to open in browser
Adds the issue url to the GraphQL query and through the IssueReference type, then wraps the issue label in an <a href> in the sidebar. VS Code's webview intercepts the click and opens the URL via openExternal, matching the behavior of AuthorLink in the same view.
1 parent d171a17 commit eab2b35

6 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/github/graphql.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ export interface PullRequest extends Issue {
773773
id: number,
774774
title: string,
775775
number: number,
776-
state: 'CLOSED' | 'OPEN'
776+
state: 'CLOSED' | 'OPEN',
777+
url: string,
777778
}[];
778779
};
779780
}

src/github/interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ export interface IssueReference {
228228
number: number;
229229
title: string;
230230
state: GithubItemStateEnum;
231+
url: string;
231232
}
232233

233234
export interface PullRequest extends Issue {

src/github/queries.gql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ fragment PullRequestFragment on PullRequest {
230230
number
231231
title
232232
state
233+
url
233234
}
234235
}
235236
merged

src/github/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,8 +1070,8 @@ function parseSuggestedReviewers(
10701070
}
10711071

10721072
function parseClosingIssuesReferences(
1073-
closingIssuesReferences: Array<{ id: number, number: number, title: string, state: string }> | undefined
1074-
): Array<{ id: number, number: number, title: string, state: GithubItemStateEnum }> {
1073+
closingIssuesReferences: Array<{ id: number, number: number, title: string, state: string, url: string }> | undefined
1074+
): Array<{ id: number, number: number, title: string, state: GithubItemStateEnum, url: string }> {
10751075
if (!closingIssuesReferences) {
10761076
return [];
10771077
}
@@ -1081,6 +1081,7 @@ function parseClosingIssuesReferences(
10811081
number: issue.number,
10821082
title: issue.title,
10831083
state: issue.state === 'OPEN' ? GithubItemStateEnum.Open : GithubItemStateEnum.Closed,
1084+
url: issue.url,
10841085
}));
10851086
}
10861087

src/github/views.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface IssueReference {
3232
number: number;
3333
title: string;
3434
state: GithubItemStateEnum;
35+
url: string;
3536
}
3637

3738
export interface DisplayLabel extends ILabel {

webviews/components/sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ function IssueItem({ issue }: { issue: IssueReference }) {
598598
return (
599599
<div className="avatar-with-author">
600600
{issue.state === GithubItemStateEnum.Open ? issueIcon : issueClosedIcon}
601-
<span>#{issue.number} {issue.title}</span>
601+
<a href={issue.url} title={issue.url}>#{issue.number} {issue.title}</a>
602602
</div>
603603
);
604604
}

0 commit comments

Comments
 (0)