mirror of https://github.com/go-gitea/gitea
Git with a cup of tea, painless self-hosted git service
Mirror for internal git.with.parts use
https://git.with.parts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.7 KiB
53 lines
1.7 KiB
import $ from 'jquery';
|
|
import {hideElem, showElem} from '../utils/dom.js';
|
|
import {initComboMarkdownEditor} from './comp/ComboMarkdownEditor.js';
|
|
|
|
export function initRepoRelease() {
|
|
$(document).on('click', '.remove-rel-attach', function() {
|
|
const uuid = $(this).data('uuid');
|
|
const id = $(this).data('id');
|
|
$(`input[name='attachment-del-${uuid}']`).attr('value', true);
|
|
hideElem($(`#attachment-${id}`));
|
|
});
|
|
}
|
|
|
|
export function initRepoReleaseNew() {
|
|
const $repoReleaseNew = $('.repository.new.release');
|
|
if (!$repoReleaseNew.length) return;
|
|
|
|
initTagNameEditor();
|
|
initRepoReleaseEditor();
|
|
}
|
|
|
|
function initTagNameEditor() {
|
|
const el = document.getElementById('tag-name-editor');
|
|
if (!el) return;
|
|
|
|
const existingTags = JSON.parse(el.getAttribute('data-existing-tags'));
|
|
if (!Array.isArray(existingTags)) return;
|
|
|
|
const defaultTagHelperText = el.getAttribute('data-tag-helper');
|
|
const newTagHelperText = el.getAttribute('data-tag-helper-new');
|
|
const existingTagHelperText = el.getAttribute('data-tag-helper-existing');
|
|
|
|
document.getElementById('tag-name').addEventListener('keyup', (e) => {
|
|
const value = e.target.value;
|
|
const tagHelper = document.getElementById('tag-helper');
|
|
if (existingTags.includes(value)) {
|
|
// If the tag already exists, hide the target branch selector.
|
|
hideElem('#tag-target-selector');
|
|
tagHelper.textContent = existingTagHelperText;
|
|
} else {
|
|
showElem('#tag-target-selector');
|
|
tagHelper.textContent = value ? newTagHelperText : defaultTagHelperText;
|
|
}
|
|
});
|
|
}
|
|
|
|
function initRepoReleaseEditor() {
|
|
const $editor = $('.repository.new.release .combo-markdown-editor');
|
|
if ($editor.length === 0) {
|
|
return;
|
|
}
|
|
const _promise = initComboMarkdownEditor($editor);
|
|
}
|
|
|