Skip to content

Commit dacdb09

Browse files
committed
Adds a QuickInputButton that lets user to open an issue on web
(#3621, #3698)
1 parent afd6c7c commit dacdb09

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/plus/startWork/startWork.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
QuickCommand,
1818
StepResultBreak,
1919
} from '../../commands/quickCommand';
20+
import { OpenOnGitHubQuickInputButton } from '../../commands/quickCommand.buttons';
2021
import { getSteps } from '../../commands/quickWizard.utils';
2122
import { proBadge } from '../../constants';
2223
import type { IntegrationId } from '../../constants.integrations';
@@ -33,6 +34,7 @@ import { getScopedCounter } from '../../system/counter';
3334
import { fromNow } from '../../system/date';
3435
import { some } from '../../system/iterable';
3536
import { configuration } from '../../system/vscode/configuration';
37+
import { openUrl } from '../../system/vscode/utils';
3638

3739
export type StartWorkItem = {
3840
item: SearchedIssue;
@@ -324,6 +326,7 @@ export class StartWorkCommand extends QuickCommand<State> {
324326
context: Context,
325327
): StepResultGenerator<StartWorkItem | StartWorkAction> {
326328
const buildIssueItem = (i: StartWorkItem) => {
329+
const buttons = i.item.issue.url ? [OpenOnGitHubQuickInputButton] : [];
327330
return {
328331
label:
329332
i.item.issue.title.length > 60 ? `${i.item.issue.title.substring(0, 60)}...` : i.item.issue.title,
@@ -335,6 +338,7 @@ export class StartWorkCommand extends QuickCommand<State> {
335338
iconPath: i.item.issue.author?.avatarUrl != null ? Uri.parse(i.item.issue.author.avatarUrl) : undefined,
336339
item: i,
337340
picked: i.item.issue.id === state.item?.item?.issue.id,
341+
buttons: buttons,
338342
};
339343
};
340344

@@ -378,6 +382,13 @@ export class StartWorkCommand extends QuickCommand<State> {
378382
matchOnDescription: true,
379383
matchOnDetail: true,
380384
items: items,
385+
onDidClickItemButton: (_quickpick, button, { item }) => {
386+
if (button === OpenOnGitHubQuickInputButton && typeof item !== 'string') {
387+
this.open(item);
388+
return true;
389+
}
390+
return false;
391+
},
381392
});
382393

383394
const selection: StepSelection<typeof step> = yield step;
@@ -395,6 +406,11 @@ export class StartWorkCommand extends QuickCommand<State> {
395406
}
396407
}
397408

409+
private open(item: StartWorkItem): void {
410+
if (item.item.issue.url == null) return;
411+
void openUrl(item.item.issue.url);
412+
}
413+
398414
private async getConnectedIntegrations(): Promise<Map<IntegrationId, boolean>> {
399415
const connected = new Map<IntegrationId, boolean>();
400416
await Promise.allSettled(

0 commit comments

Comments
 (0)