Skip to content

Commit

Permalink
Shows GitLab issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeibbb committed Nov 21, 2024
1 parent 352262d commit 41f86e0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
32 changes: 27 additions & 5 deletions src/plus/integrations/providers/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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<SearchedIssue[] | undefined> {
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<string | undefined> =>
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(
Expand Down
2 changes: 1 addition & 1 deletion src/plus/integrations/providers/gitlab/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ $search: String!
}
}

private getProjectId(
public getProjectId(
provider: Provider,
token: string,
group: string,
Expand Down
1 change: 1 addition & 0 deletions src/plus/integrations/providers/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
}
Expand Down
6 changes: 5 additions & 1 deletion src/plus/startWork/startWork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,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();

Expand Down

0 comments on commit 41f86e0

Please sign in to comment.