mirror of
https://github.com/go-gitea/gitea.git
synced 2026-06-22 16:29:39 +02:00
- chooseFromApi is now generic over the response shape; each caller declares a typed *SearchResponse, removing four `any` annotations - e2e test prefix: rc- → repo-collab- for legibility in the test DB - web_src/css/modules/search.css: drop the stale leading comment Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
23 lines
862 B
TypeScript
23 lines
862 B
TypeScript
import {chooseFromApi} from '../../modules/search.ts';
|
|
|
|
const {appSubUrl} = window.config;
|
|
|
|
type RepoSearchResponse = {data: Array<{repository: {full_name: string}}>};
|
|
|
|
export async function initCompSearchRepoBox(el: HTMLElement) {
|
|
const uid = el.getAttribute('data-uid');
|
|
const exclusive = el.getAttribute('data-exclusive');
|
|
let url = `${appSubUrl}/repo/search?q={query}&uid=${uid}`;
|
|
if (exclusive === 'true') url += `&exclusive=true`;
|
|
const input = el.querySelector<HTMLInputElement>('input.prompt')!;
|
|
|
|
while (el.isConnected) {
|
|
const pick = await chooseFromApi<RepoSearchResponse>(el, url, (response) => response.data.map((item) => ({
|
|
title: item.repository.full_name.split('/')[1],
|
|
description: item.repository.full_name,
|
|
})));
|
|
input.value = pick.title;
|
|
input.dispatchEvent(new Event('change', {bubbles: true}));
|
|
}
|
|
}
|