Skip to content

Commit b310900

Browse files
authored
Shows GitLab issues (#3787)
(#3779, #3787)
1 parent e675db6 commit b310900

File tree

5 files changed

+43
-8
lines changed

5 files changed

+43
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
99
### Added
1010

1111
- Adds the ability to get autolinks for branches via the branch name — closes [#3547](https://github.com/gitkraken/vscode-gitlens/issues/3547)
12+
- Adds GitLab issues to the issues list in the _Start Work_ command when GitLab is connected — closes [#3779](https://github.com/gitkraken/vscode-gitlens/issues/3779)
1213

1314
## [16.0.4] - 2024-11-25
1415

src/plus/integrations/providers/gitlab.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import type {
2323
import { HostingIntegration } from '../integration';
2424
import { fromGitLabMergeRequestProvidersApi } from './gitlab/models';
2525
import type { ProviderPullRequest } from './models';
26-
import { ProviderPullRequestReviewState, providersMetadata } from './models';
26+
import { ProviderPullRequestReviewState, providersMetadata, toSearchedIssue } from './models';
2727
import type { ProvidersApi } from './providersApi';
2828

2929
const metadata = providersMetadata[HostingIntegrationId.GitLab];
@@ -243,11 +243,33 @@ abstract class GitLabIntegrationBase<
243243
return results;
244244
}
245245

246-
protected override searchProviderMyIssues(
247-
_session: AuthenticationSession,
248-
_repos?: GitLabRepositoryDescriptor[],
246+
protected override async searchProviderMyIssues(
247+
{ accessToken }: AuthenticationSession,
248+
repos?: GitLabRepositoryDescriptor[],
249249
): Promise<SearchedIssue[] | undefined> {
250-
return Promise.resolve(undefined);
250+
const api = await this.container.gitlab;
251+
const providerApi = await this.getProvidersApi();
252+
253+
if (!api || !repos) {
254+
return undefined;
255+
}
256+
257+
const repoIdsResult = await Promise.allSettled(
258+
repos.map(
259+
(r: GitLabRepositoryDescriptor): Promise<string | undefined> =>
260+
api.getProjectId(this, accessToken, r.owner, r.name, this.apiBaseUrl, undefined),
261+
) ?? [],
262+
);
263+
const repoInput = repoIdsResult
264+
.map(result => (result.status === 'fulfilled' ? result.value : undefined))
265+
.filter((r): r is string => r != null);
266+
const apiResult = await providerApi.getIssuesForRepos(this.id, repoInput, {
267+
accessToken: accessToken,
268+
});
269+
270+
return apiResult.values
271+
.map(issue => toSearchedIssue(issue, this))
272+
.filter((result): result is SearchedIssue => result != null);
251273
}
252274

253275
protected override async mergeProviderPullRequest(

src/plus/integrations/providers/gitlab/gitlab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ $search: String!
707707
}
708708
}
709709

710-
private getProjectId(
710+
getProjectId(
711711
provider: Provider,
712712
token: string,
713713
group: string,

src/plus/integrations/providers/models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ export function toSearchedIssue(
532532
labels: issue.labels.map(label => ({ color: label.color ?? undefined, name: label.name })),
533533
commentsCount: issue.commentCount ?? undefined,
534534
thumbsUpCount: issue.upvoteCount ?? undefined,
535+
body: issue.description ?? undefined,
535536
},
536537
};
537538
}

src/plus/startWork/startWork.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ import {
1818
QuickCommand,
1919
StepResultBreak,
2020
} from '../../commands/quickCommand';
21-
import { OpenOnGitHubQuickInputButton, OpenOnJiraQuickInputButton } from '../../commands/quickCommand.buttons';
21+
import {
22+
OpenOnGitHubQuickInputButton,
23+
OpenOnGitLabQuickInputButton,
24+
OpenOnJiraQuickInputButton,
25+
} from '../../commands/quickCommand.buttons';
2226
import { getSteps } from '../../commands/quickWizard.utils';
2327
import { proBadge } from '../../constants';
2428
import type { IntegrationId } from '../../constants.integrations';
@@ -68,7 +72,11 @@ export interface StartWorkCommandArgs {
6872
type?: StartWorkType;
6973
}
7074

71-
export const supportedStartWorkIntegrations = [HostingIntegrationId.GitHub, IssueIntegrationId.Jira];
75+
export const supportedStartWorkIntegrations = [
76+
HostingIntegrationId.GitHub,
77+
HostingIntegrationId.GitLab,
78+
IssueIntegrationId.Jira,
79+
];
7280
export type SupportedStartWorkIntegrationIds = (typeof supportedStartWorkIntegrations)[number];
7381
const instanceCounter = getScopedCounter();
7482

@@ -470,6 +478,7 @@ export class StartWorkCommand extends QuickCommand<State> {
470478

471479
switch (button) {
472480
case OpenOnGitHubQuickInputButton:
481+
case OpenOnGitLabQuickInputButton:
473482
case OpenOnJiraQuickInputButton:
474483
this.sendItemActionTelemetry('soft-open', item, state, context);
475484
this.open(item);
@@ -585,6 +594,8 @@ function getOpenOnWebQuickInputButton(integrationId: string): QuickInputButton |
585594
switch (integrationId) {
586595
case HostingIntegrationId.GitHub:
587596
return OpenOnGitHubQuickInputButton;
597+
case HostingIntegrationId.GitLab:
598+
return OpenOnGitLabQuickInputButton;
588599
case IssueIntegrationId.Jira:
589600
return OpenOnJiraQuickInputButton;
590601
default:

0 commit comments

Comments
 (0)