Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

repo-release.js 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {hideElem, showElem} from '../utils/dom.js';
  2. import {initComboMarkdownEditor} from './comp/ComboMarkdownEditor.js';
  3. export function initRepoRelease() {
  4. document.addEventListener('click', (e) => {
  5. if (e.target.matches('.remove-rel-attach')) {
  6. const uuid = e.target.getAttribute('data-uuid');
  7. const id = e.target.getAttribute('data-id');
  8. document.querySelector(`input[name='attachment-del-${uuid}']`).value = 'true';
  9. hideElem(`#attachment-${id}`);
  10. }
  11. });
  12. }
  13. export function initRepoReleaseNew() {
  14. if (!document.querySelector('.repository.new.release')) return;
  15. initTagNameEditor();
  16. initRepoReleaseEditor();
  17. }
  18. function initTagNameEditor() {
  19. const el = document.getElementById('tag-name-editor');
  20. if (!el) return;
  21. const existingTags = JSON.parse(el.getAttribute('data-existing-tags'));
  22. if (!Array.isArray(existingTags)) return;
  23. const defaultTagHelperText = el.getAttribute('data-tag-helper');
  24. const newTagHelperText = el.getAttribute('data-tag-helper-new');
  25. const existingTagHelperText = el.getAttribute('data-tag-helper-existing');
  26. const tagNameInput = document.getElementById('tag-name');
  27. const hideTargetInput = function(tagNameInput) {
  28. const value = tagNameInput.value;
  29. const tagHelper = document.getElementById('tag-helper');
  30. if (existingTags.includes(value)) {
  31. // If the tag already exists, hide the target branch selector.
  32. hideElem('#tag-target-selector');
  33. tagHelper.textContent = existingTagHelperText;
  34. } else {
  35. showElem('#tag-target-selector');
  36. tagHelper.textContent = value ? newTagHelperText : defaultTagHelperText;
  37. }
  38. };
  39. hideTargetInput(tagNameInput); // update on page load because the input may have a value
  40. tagNameInput.addEventListener('input', (e) => {
  41. hideTargetInput(e.target);
  42. });
  43. }
  44. function initRepoReleaseEditor() {
  45. const editor = document.querySelector('.repository.new.release .combo-markdown-editor');
  46. if (!editor) {
  47. return;
  48. }
  49. initComboMarkdownEditor(editor);
  50. }