Skip to content

Commit 937b1cc

Browse files
committed
Adds a QuickInputButton that lets user to open an issue on web
(#3621)
1 parent 9659c19 commit 937b1cc

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/plus/startWork/startWork.ts

Lines changed: 16 additions & 2 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;
@@ -329,7 +331,7 @@ export class StartWorkCommand extends QuickCommand<State> {
329331
context: Context,
330332
): StepResultGenerator<StartWorkItem | StartWorkAction> {
331333
const buildIssueItem = (i: StartWorkItem) => {
332-
const buttons = [StartWorkQuickInputButton];
334+
const buttons = [...(i.item.issue.url ? [OpenOnGitHubQuickInputButton] : []), StartWorkQuickInputButton];
333335
return {
334336
label:
335337
i.item.issue.title.length > 60 ? `${i.item.issue.title.substring(0, 60)}...` : i.item.issue.title,
@@ -386,10 +388,17 @@ export class StartWorkCommand extends QuickCommand<State> {
386388
matchOnDetail: true,
387389
items: items,
388390
onDidClickItemButton: (_quickpick, button, { item }) => {
389-
if (button === StartWorkQuickInputButton && typeof item !== 'string') {
391+
if (typeof item === 'string') {
392+
return false;
393+
}
394+
if (button === StartWorkQuickInputButton) {
390395
this.startWork(state, item);
391396
return true;
392397
}
398+
if (button === OpenOnGitHubQuickInputButton) {
399+
this.open(item);
400+
return true;
401+
}
393402
return false;
394403
},
395404
});
@@ -409,6 +418,11 @@ export class StartWorkCommand extends QuickCommand<State> {
409418
}
410419
}
411420

421+
private open(item: StartWorkItem): void {
422+
if (item.item.issue.url == null) return;
423+
void openUrl(item.item.issue.url);
424+
}
425+
412426
private async getConnectedIntegrations(): Promise<Map<IntegrationId, boolean>> {
413427
const connected = new Map<IntegrationId, boolean>();
414428
await Promise.allSettled(

0 commit comments

Comments
 (0)