Skip to content

Commit c778a86

Browse files
chivorotkivsergeibbb
authored andcommitted
Shows different "globe" tooltips on GitHub and Jira issues in StartWork
(#3774, #3775)
1 parent 352262d commit c778a86

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

src/commands/quickCommand.buttons.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ export const MergeQuickInputButton: QuickInputButton = {
132132
tooltip: 'Merge...',
133133
};
134134

135+
export const OpenOnJiraQuickInputButton: QuickInputButton = {
136+
iconPath: new ThemeIcon('globe'),
137+
tooltip: 'Open on Jira',
138+
};
139+
135140
export const OpenOnGitHubQuickInputButton: QuickInputButton = {
136141
iconPath: new ThemeIcon('globe'),
137142
tooltip: 'Open on GitHub',

src/plus/startWork/startWork.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { md5 } from '@env/crypto';
22
import slug from 'slug';
3-
import type { QuickPick } from 'vscode';
3+
import type { QuickInputButton, QuickPick } from 'vscode';
44
import { Uri } from 'vscode';
55
import type {
66
AsyncStepResultGenerator,
@@ -18,7 +18,7 @@ import {
1818
QuickCommand,
1919
StepResultBreak,
2020
} from '../../commands/quickCommand';
21-
import { OpenOnGitHubQuickInputButton } from '../../commands/quickCommand.buttons';
21+
import { OpenOnGitHubQuickInputButton, OpenOnJiraQuickInputButton } from '../../commands/quickCommand.buttons';
2222
import { getSteps } from '../../commands/quickWizard.utils';
2323
import { proBadge } from '../../constants';
2424
import type { IntegrationId } from '../../constants.integrations';
@@ -414,7 +414,8 @@ export class StartWorkCommand extends QuickCommand<State> {
414414
opened: boolean,
415415
): StepResultGenerator<StartWorkItem | StartWorkTypeItem> {
416416
const buildIssueItem = (i: StartWorkItem) => {
417-
const buttons = i.item.issue.url ? [OpenOnGitHubQuickInputButton] : [];
417+
const onWebbButton = i.item.issue.url ? getOpenOnWebQuickInputButton(i.item.issue.provider.id) : undefined;
418+
const buttons = onWebbButton ? [onWebbButton] : [];
418419
const hoverContent = i.item.issue.body ? `${repeatSpaces(200)}\n\n${i.item.issue.body}` : '';
419420
return {
420421
label:
@@ -499,11 +500,18 @@ export class StartWorkCommand extends QuickCommand<State> {
499500
items: [],
500501
onDidActivate: updateItems,
501502
onDidClickItemButton: (_quickpick, button, { item }) => {
502-
if (button === OpenOnGitHubQuickInputButton && !isStartWorkTypeItem(item)) {
503-
this.open(item);
504-
return undefined;
503+
if (isStartWorkTypeItem(item)) {
504+
return false;
505+
}
506+
507+
switch (button) {
508+
case OpenOnGitHubQuickInputButton:
509+
case OpenOnJiraQuickInputButton:
510+
this.open(item);
511+
return undefined;
512+
default:
513+
return false;
505514
}
506-
return false;
507515
},
508516
onDidChangeValue: () => true,
509517
});
@@ -576,3 +584,14 @@ function repeatSpaces(count: number) {
576584
export function getStartWorkItemIdHash(item: StartWorkItem) {
577585
return md5(item.item.issue.id);
578586
}
587+
588+
function getOpenOnWebQuickInputButton(integrationId: string): QuickInputButton | undefined {
589+
switch (integrationId) {
590+
case HostingIntegrationId.GitHub:
591+
return OpenOnGitHubQuickInputButton;
592+
case IssueIntegrationId.Jira:
593+
return OpenOnJiraQuickInputButton;
594+
default:
595+
return undefined;
596+
}
597+
}

0 commit comments

Comments
 (0)