-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Hide target selector if tag exists when creating new release #23171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
155b8b5
bda5bb2
1d9a907
e72b39c
993d74e
5e37565
f9c6c8e
e6adfce
c56daa5
6ce1e51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {hideElem, showElem} from '../utils/dom.js'; | ||
|
||
export 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; | ||
if (existingTags.includes(value)) { | ||
// If the tag already exists, hide the target branch selector. | ||
hideElem('#tag-target-selector'); | ||
document.getElementById('tag-helper').innerText = existingTagHelperText; | ||
} else { | ||
showElem('#tag-target-selector'); | ||
if (value) { | ||
document.getElementById('tag-helper').innerText = newTagHelperText; | ||
} else { | ||
document.getElementById('tag-helper').innerText = defaultTagHelperText; | ||
} | ||
} | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,7 @@ import {initFormattingReplacements} from './features/formatting.js'; | |
import {initCopyContent} from './features/copycontent.js'; | ||
import {initCaptcha} from './features/captcha.js'; | ||
import {initRepositoryActionView} from './components/RepoActionView.vue'; | ||
import {initTagNameEditor} from './features/tag-name-editor.js'; | ||
|
||
// Run time-critical code as soon as possible. This is safe to do because this | ||
// script appears at the end of <body> and rendered HTML is accessible at that point. | ||
|
@@ -198,4 +199,6 @@ $(document).ready(() => { | |
initUserAuthWebAuthnRegister(); | ||
initUserSettings(); | ||
initViewedCheckboxListenerFor(); | ||
|
||
initTagNameEditor(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO we do not need to make more global The So the exiting export function initRepoReleaseNew() {
const $repoReleaseNew = $('.repository.new.release');
if (!$repoReleaseNew.length) return;
// init tag name editor
// init content editor
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea. I refactored the |
||
}); |
Uh oh!
There was an error while loading. Please reload this page.