summaryrefslogtreecommitdiffstats
path: root/web_src/js/features/org-team.js
blob: 9b059b3a46f8090ed73ea701489a3ed557daca41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import $ from 'jquery';

const {appSubUrl} = window.config;

export function initOrgTeamSearchRepoBox() {
  const $searchRepoBox = $('#search-repo-box');
  $searchRepoBox.search({
    minCharacters: 2,
    apiSettings: {
      url: `${appSubUrl}/repo/search?q={query}&uid=${$searchRepoBox.data('uid')}`,
      onResponse(response) {
        const items = [];
        $.each(response.data, (_i, item) => {
          items.push({
            title: item.repository.full_name.split('/')[1],
            description: item.repository.full_name,
          });
        });

        return {results: items};
      },
    },
    searchFields: ['full_name'],
    showNoResults: false,
  });
}