diff --git a/src/plus/integrations/providers/gitlab.ts b/src/plus/integrations/providers/gitlab.ts index e5ac02357cb97..eaff45e70f2a3 100644 --- a/src/plus/integrations/providers/gitlab.ts +++ b/src/plus/integrations/providers/gitlab.ts @@ -23,7 +23,7 @@ import type { import { HostingIntegration } from '../integration'; import { fromGitLabMergeRequestProvidersApi } from './gitlab/models'; import type { ProviderPullRequest } from './models'; -import { ProviderPullRequestReviewState, providersMetadata } from './models'; +import { ProviderPullRequestReviewState, providersMetadata, toSearchedIssue } from './models'; import type { ProvidersApi } from './providersApi'; const metadata = providersMetadata[HostingIntegrationId.GitLab]; @@ -243,11 +243,33 @@ abstract class GitLabIntegrationBase< return results; } - protected override searchProviderMyIssues( - _session: AuthenticationSession, - _repos?: GitLabRepositoryDescriptor[], + protected override async searchProviderMyIssues( + { accessToken }: AuthenticationSession, + repos?: GitLabRepositoryDescriptor[], ): Promise { - return Promise.resolve(undefined); + const api = await this.container.gitlab; + const providerApi = await this.getProvidersApi(); + + if (!api || !repos) { + return undefined; + } + + const repoIdsResult = await Promise.allSettled( + repos.map( + (r: GitLabRepositoryDescriptor): Promise => + api.getProjectId(this, accessToken, r.owner, r.name, this.apiBaseUrl, undefined), + ) ?? [], + ); + const repoInput = repoIdsResult + .map(result => (result.status === 'fulfilled' ? result.value : undefined)) + .filter((r): r is string => r != null); + const apiResult = await providerApi.getIssuesForRepos(this.id, repoInput, { + accessToken: accessToken, + }); + + return apiResult.values + .map(issue => toSearchedIssue(issue, this)) + .filter((result): result is SearchedIssue => result != null); } protected override async mergeProviderPullRequest( diff --git a/src/plus/integrations/providers/gitlab/gitlab.ts b/src/plus/integrations/providers/gitlab/gitlab.ts index 9303f781a1b20..a564e16783b2b 100644 --- a/src/plus/integrations/providers/gitlab/gitlab.ts +++ b/src/plus/integrations/providers/gitlab/gitlab.ts @@ -707,7 +707,7 @@ $search: String! } } - private getProjectId( + public getProjectId( provider: Provider, token: string, group: string, diff --git a/src/plus/integrations/providers/models.ts b/src/plus/integrations/providers/models.ts index 47160355aa4eb..3a88ca79bf184 100644 --- a/src/plus/integrations/providers/models.ts +++ b/src/plus/integrations/providers/models.ts @@ -532,6 +532,7 @@ export function toSearchedIssue( labels: issue.labels.map(label => ({ color: label.color ?? undefined, name: label.name })), commentsCount: issue.commentCount ?? undefined, thumbsUpCount: issue.upvoteCount ?? undefined, + body: issue.description ?? undefined, }, }; } diff --git a/src/plus/startWork/startWork.ts b/src/plus/startWork/startWork.ts index 5e9481d9c9bd2..fc3a81f1fe164 100644 --- a/src/plus/startWork/startWork.ts +++ b/src/plus/startWork/startWork.ts @@ -18,7 +18,11 @@ import { QuickCommand, StepResultBreak, } from '../../commands/quickCommand'; -import { OpenOnGitHubQuickInputButton, OpenOnJiraQuickInputButton } from '../../commands/quickCommand.buttons'; +import { + OpenOnGitHubQuickInputButton, + OpenOnGitLabQuickInputButton, + OpenOnJiraQuickInputButton, +} from '../../commands/quickCommand.buttons'; import { getSteps } from '../../commands/quickWizard.utils'; import { proBadge } from '../../constants'; import type { IntegrationId } from '../../constants.integrations'; @@ -68,7 +72,11 @@ export interface StartWorkCommandArgs { source?: Sources; } -export const supportedStartWorkIntegrations = [HostingIntegrationId.GitHub, IssueIntegrationId.Jira]; +export const supportedStartWorkIntegrations = [ + HostingIntegrationId.GitHub, + HostingIntegrationId.GitLab, + IssueIntegrationId.Jira, +]; export type SupportedStartWorkIntegrationIds = (typeof supportedStartWorkIntegrations)[number]; const instanceCounter = getScopedCounter(); @@ -500,6 +508,7 @@ export class StartWorkCommand extends QuickCommand { switch (button) { case OpenOnGitHubQuickInputButton: + case OpenOnGitLabQuickInputButton: case OpenOnJiraQuickInputButton: this.sendItemActionTelemetry('soft-open', item, state, context); this.open(item); @@ -615,6 +624,8 @@ function getOpenOnWebQuickInputButton(integrationId: string): QuickInputButton | switch (integrationId) { case HostingIntegrationId.GitHub: return OpenOnGitHubQuickInputButton; + case HostingIntegrationId.GitLab: + return OpenOnGitLabQuickInputButton; case IssueIntegrationId.Jira: return OpenOnJiraQuickInputButton; default: