Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

repo-settings.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import {createMonaco} from './codeeditor.js';
  2. import {initRepoCommonFilterSearchDropdown} from './repo-common.js';
  3. const {appSubUrl, csrfToken} = window.config;
  4. export function initRepoSettingsCollaboration() {
  5. // Change collaborator access mode
  6. $('.access-mode.menu .item').on('click', function () {
  7. const $menu = $(this).parent();
  8. $.post($menu.data('url'), {
  9. _csrf: csrfToken,
  10. uid: $menu.data('uid'),
  11. mode: $(this).data('value')
  12. });
  13. });
  14. }
  15. export function initRepoSettingSearchTeamBox() {
  16. const $searchTeamBox = $('#search-team-box');
  17. $searchTeamBox.search({
  18. minCharacters: 2,
  19. apiSettings: {
  20. url: `${appSubUrl}/api/v1/orgs/${$searchTeamBox.data('org')}/teams/search?q={query}`,
  21. headers: {'X-Csrf-Token': csrfToken},
  22. onResponse(response) {
  23. const items = [];
  24. $.each(response.data, (_i, item) => {
  25. const title = `${item.name} (${item.permission} access)`;
  26. items.push({
  27. title,
  28. });
  29. });
  30. return {results: items};
  31. }
  32. },
  33. searchFields: ['name', 'description'],
  34. showNoResults: false
  35. });
  36. }
  37. export function initRepoSettingGitHook() {
  38. if ($('.edit.githook').length === 0) return;
  39. const filename = document.querySelector('.hook-filename').textContent;
  40. const _promise = createMonaco($('#content')[0], filename, {language: 'shell'});
  41. }
  42. export function initRepoSettingBranches() {
  43. // Branches
  44. if ($('.repository.settings.branches').length > 0) {
  45. initRepoCommonFilterSearchDropdown('.protected-branches .dropdown');
  46. $('.enable-protection, .enable-whitelist, .enable-statuscheck').on('change', function () {
  47. if (this.checked) {
  48. $($(this).data('target')).removeClass('disabled');
  49. } else {
  50. $($(this).data('target')).addClass('disabled');
  51. }
  52. });
  53. $('.disable-whitelist').on('change', function () {
  54. if (this.checked) {
  55. $($(this).data('target')).addClass('disabled');
  56. }
  57. });
  58. }
  59. }