feat(ui): forge user lookup — assignee combobox, @-mentions, repo-scoped user search
Repo-scoped assignable-user search for GitHub, GitLab, and Gitea, surfaced as
an assignee combobox in the metadata editor and @-mention autocomplete in
forge comment/reply/review surfaces.
- server: GET /api/{provider}/users/search (assignees / project members),
query + directory/override repo resolution, 429 -> 503, connected:false
degradation; GitLab assignee writes resolve login -> ID server-side
- wire: searchUsers (+ searchLabels/milestones/branches/tags) on the three
API clients with tests
- facade: userSearch capability (all three), searchUsers adapters,
mapGithubAssignee/mapGitlabMember/mapGiteaAssignee -> ForgeUser
- ui: ForgeLookupCombobox (keyboard nav, debounced 30s-TTL cache,
connected-only caching), ForgeMentionTextarea (@ token parsing, caret
restore), free-text fallback when lookup is unavailable; i18n in 12 locales
- extras sharing the same infrastructure: GitLab create-issue dialog and
label/milestone/branch/tag lookups in the metadata editor
This commit is contained in:
@@ -2,13 +2,18 @@ import type {
|
||||
GiteaAPI,
|
||||
GiteaAuthStatus,
|
||||
GiteaBranchesResult,
|
||||
GiteaBranchesSearchResult,
|
||||
GiteaIssueCommentInput,
|
||||
GiteaIssueCommentResult,
|
||||
GiteaIssueCommentsResult,
|
||||
GiteaIssueCreateInput,
|
||||
GiteaIssueCreateResult,
|
||||
GiteaIssueGetResult,
|
||||
GiteaIssuesListResult,
|
||||
GiteaIssueUpdateInput,
|
||||
GiteaIssueUpdateResult,
|
||||
GiteaLabelsSearchResult,
|
||||
GiteaMilestonesSearchResult,
|
||||
GiteaPullRequest,
|
||||
GiteaPullRequestCommitsResult,
|
||||
GiteaPullRequestContextResult,
|
||||
@@ -22,7 +27,9 @@ import type {
|
||||
GiteaPullReviewInput,
|
||||
GiteaPullReviewResult,
|
||||
GiteaRepoLabelsResult,
|
||||
GiteaTagsSearchResult,
|
||||
GiteaUserSummary,
|
||||
GiteaUsersSearchResult,
|
||||
} from '@openchamber/ui/lib/api/types';
|
||||
import { runtimeFetch } from '@openchamber/ui/lib/runtime-fetch';
|
||||
import type { RuntimeUrlResolver } from '@openchamber/ui/lib/runtime-url';
|
||||
@@ -98,6 +105,66 @@ export const createWebGiteaAPI = ({ urls }: WebGiteaAPIOptions): GiteaAPI => ({
|
||||
return payload;
|
||||
},
|
||||
|
||||
async searchUsers(directory, query, options): Promise<GiteaUsersSearchResult> {
|
||||
const params = new URLSearchParams({ directory, query });
|
||||
if (options?.owner) params.set('owner', options.owner);
|
||||
if (options?.repo) params.set('repo', options.repo);
|
||||
const response = await runtimeFetch(urls.api('/api/gitea/users/search', params), { method: 'GET', headers: { Accept: 'application/json' } });
|
||||
const body = await jsonOrNull<GiteaUsersSearchResult & { error?: string }>(response);
|
||||
if (!response.ok || !body) {
|
||||
throw new Error(body?.error || response.statusText || 'Failed to search Gitea users');
|
||||
}
|
||||
return { connected: body.connected, repo: body.repo ?? null, users: body.users ?? [] };
|
||||
},
|
||||
|
||||
async searchLabels(directory, query, options): Promise<GiteaLabelsSearchResult> {
|
||||
const params = new URLSearchParams({ directory, query });
|
||||
if (options?.owner) params.set('owner', options.owner);
|
||||
if (options?.repo) params.set('repo', options.repo);
|
||||
const response = await runtimeFetch(urls.api('/api/gitea/labels/search', params), { method: 'GET', headers: { Accept: 'application/json' } });
|
||||
const body = await jsonOrNull<GiteaLabelsSearchResult & { error?: string }>(response);
|
||||
if (!response.ok || !body) {
|
||||
throw new Error(body?.error || response.statusText || 'Failed to search Gitea labels');
|
||||
}
|
||||
return { connected: body.connected, repo: body.repo ?? null, labels: body.labels ?? [] };
|
||||
},
|
||||
|
||||
async searchMilestones(directory, query, options): Promise<GiteaMilestonesSearchResult> {
|
||||
const params = new URLSearchParams({ directory, query });
|
||||
if (options?.owner) params.set('owner', options.owner);
|
||||
if (options?.repo) params.set('repo', options.repo);
|
||||
const response = await runtimeFetch(urls.api('/api/gitea/milestones/search', params), { method: 'GET', headers: { Accept: 'application/json' } });
|
||||
const body = await jsonOrNull<GiteaMilestonesSearchResult & { error?: string }>(response);
|
||||
if (!response.ok || !body) {
|
||||
throw new Error(body?.error || response.statusText || 'Failed to search Gitea milestones');
|
||||
}
|
||||
return { connected: body.connected, repo: body.repo ?? null, milestones: body.milestones ?? [] };
|
||||
},
|
||||
|
||||
async searchBranches(directory, query, options): Promise<GiteaBranchesSearchResult> {
|
||||
const params = new URLSearchParams({ directory, query });
|
||||
if (options?.owner) params.set('owner', options.owner);
|
||||
if (options?.repo) params.set('repo', options.repo);
|
||||
const response = await runtimeFetch(urls.api('/api/gitea/branches/search', params), { method: 'GET', headers: { Accept: 'application/json' } });
|
||||
const body = await jsonOrNull<GiteaBranchesSearchResult & { error?: string }>(response);
|
||||
if (!response.ok || !body) {
|
||||
throw new Error(body?.error || response.statusText || 'Failed to search Gitea branches');
|
||||
}
|
||||
return { connected: body.connected, repo: body.repo ?? null, branches: body.branches ?? [] };
|
||||
},
|
||||
|
||||
async searchTags(directory, query, options): Promise<GiteaTagsSearchResult> {
|
||||
const params = new URLSearchParams({ directory, query });
|
||||
if (options?.owner) params.set('owner', options.owner);
|
||||
if (options?.repo) params.set('repo', options.repo);
|
||||
const response = await runtimeFetch(urls.api('/api/gitea/tags/search', params), { method: 'GET', headers: { Accept: 'application/json' } });
|
||||
const body = await jsonOrNull<GiteaTagsSearchResult & { error?: string }>(response);
|
||||
if (!response.ok || !body) {
|
||||
throw new Error(body?.error || response.statusText || 'Failed to search Gitea tags');
|
||||
}
|
||||
return { connected: body.connected, repo: body.repo ?? null, tags: body.tags ?? [] };
|
||||
},
|
||||
|
||||
async issuesList(directory: string, options?: { page?: number; query?: string }): Promise<GiteaIssuesListResult> {
|
||||
const page = options?.page ?? 1;
|
||||
const params = new URLSearchParams({
|
||||
@@ -307,6 +374,19 @@ export const createWebGiteaAPI = ({ urls }: WebGiteaAPIOptions): GiteaAPI => ({
|
||||
return body;
|
||||
},
|
||||
|
||||
async issueCreate(input: GiteaIssueCreateInput): Promise<GiteaIssueCreateResult> {
|
||||
const response = await runtimeFetch('/api/gitea/issues/create', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
const body = await jsonOrNull<GiteaIssueCreateResult & { error?: string }>(response);
|
||||
if (!response.ok || !body) {
|
||||
throw new Error(body?.error || response.statusText || 'Failed to create Gitea issue');
|
||||
}
|
||||
return body;
|
||||
},
|
||||
|
||||
async issueUpdate(input: GiteaIssueUpdateInput): Promise<GiteaIssueUpdateResult> {
|
||||
const response = await runtimeFetch('/api/gitea/issues/update', {
|
||||
method: 'PATCH',
|
||||
|
||||
Reference in New Issue
Block a user