2022-01-28 14:00:11 -07:00
|
|
|
import $ from 'jquery';
|
2023-02-18 21:06:14 -07:00
|
|
|
import {hideElem, showElem} from '../utils/dom.js';
|
2022-01-28 14:00:11 -07:00
|
|
|
|
2021-10-21 01:37:43 -06:00
|
|
|
const {appSubUrl} = window.config;
|
2021-10-16 11:28:04 -06:00
|
|
|
|
|
|
|
export function initOrgTeamSettings() {
|
|
|
|
// Change team access mode
|
|
|
|
$('.organization.new.team input[name=permission]').on('change', () => {
|
|
|
|
const val = $('input[name=permission]:checked', '.organization.new.team').val();
|
|
|
|
if (val === 'admin') {
|
2023-02-18 21:06:14 -07:00
|
|
|
hideElem($('.organization.new.team .team-units'));
|
2021-10-16 11:28:04 -06:00
|
|
|
} else {
|
2023-02-18 21:06:14 -07:00
|
|
|
showElem($('.organization.new.team .team-units'));
|
2021-10-16 11:28:04 -06:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export function initOrgTeamSearchRepoBox() {
|
|
|
|
const $searchRepoBox = $('#search-repo-box');
|
|
|
|
$searchRepoBox.search({
|
|
|
|
minCharacters: 2,
|
|
|
|
apiSettings: {
|
2022-04-07 12:59:56 -06:00
|
|
|
url: `${appSubUrl}/repo/search?q={query}&uid=${$searchRepoBox.data('uid')}`,
|
2021-10-16 11:28:04 -06:00
|
|
|
onResponse(response) {
|
|
|
|
const items = [];
|
|
|
|
$.each(response.data, (_i, item) => {
|
|
|
|
items.push({
|
2023-05-13 15:59:01 -06:00
|
|
|
title: item.repository.full_name.split('/')[1],
|
2024-03-22 08:06:53 -06:00
|
|
|
description: item.repository.full_name,
|
2021-10-16 11:28:04 -06:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return {results: items};
|
2024-03-22 08:06:53 -06:00
|
|
|
},
|
2021-10-16 11:28:04 -06:00
|
|
|
},
|
|
|
|
searchFields: ['full_name'],
|
2024-03-22 08:06:53 -06:00
|
|
|
showNoResults: false,
|
2021-10-16 11:28:04 -06:00
|
|
|
});
|
|
|
|
}
|