Some checks failed
cache-seeder / prune (push) Has been skipped
cache-seeder / frontend (push) Failing after 3s
cache-seeder / python (push) Failing after 3s
cache-seeder / gobuild (push) Failing after 4s
cache-seeder / lint (bindata, lint-backend) (push) Failing after 3s
giteabot backport / giteabot (push) Has been skipped
giteabot / giteabot (push) Has been skipped
cache-prune / prune (push) Has been skipped
release-nightly-snapcraft / build-and-publish (ubuntu-24.04) (push) Has been cancelled
release-nightly-snapcraft / build-and-publish (ubuntu-24.04-arm) (push) Has been cancelled
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
19 lines
888 B
TypeScript
19 lines
888 B
TypeScript
import {attachSearchBox} from '../../modules/search.ts';
|
|
|
|
const {appSubUrl} = window.config;
|
|
|
|
type RepoSearchResponse = {data: Array<{repository: {full_name: string}}>};
|
|
|
|
export function initCompSearchRepoBox(el: HTMLElement) {
|
|
const uid = el.getAttribute('data-uid');
|
|
const exclusive = el.getAttribute('data-exclusive');
|
|
// when set, the selected value is the full "owner/name" rather than the bare repo name, so a cross-owner search can be resolved unambiguously
|
|
const fullName = el.getAttribute('data-full-name') === 'true';
|
|
let url = `${appSubUrl}/repo/search?q={query}&uid=${uid}`;
|
|
if (exclusive === 'true') url += `&exclusive=true`;
|
|
attachSearchBox(el, url, (response: RepoSearchResponse) => response.data.map((item) => ({
|
|
title: fullName ? item.repository.full_name : item.repository.full_name.split('/')[1],
|
|
description: item.repository.full_name,
|
|
})));
|
|
}
|