-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Remove jQuery from the repo migration form #29229
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f77a7de
Remove jQuery from the repo migration form
yardenshoham 367d69e
Update web_src/js/features/repo-migration.js
yardenshoham 9dd5547
lint
yardenshoham 7c2b293
Merge branch 'main' into repo-migration-jquery
yardenshoham 79999ca
Use Number
yardenshoham 4a2b1e6
Merge branch 'main' into repo-migration-jquery
yardenshoham 9a9cc28
Merge branch 'main' into repo-migration-jquery
yardenshoham ef6a180
Update web_src/js/features/repo-migration.js
yardenshoham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,73 @@ | ||
import $ from 'jquery'; | ||
import {hideElem, showElem, toggleElem} from '../utils/dom.js'; | ||
|
||
const $service = $('#service_type'); | ||
const $user = $('#auth_username'); | ||
const $pass = $('#auth_password'); | ||
const $token = $('#auth_token'); | ||
const $mirror = $('#mirror'); | ||
const $lfs = $('#lfs'); | ||
const $lfsSettings = $('#lfs_settings'); | ||
const $lfsEndpoint = $('#lfs_endpoint'); | ||
const $items = $('#migrate_items').find('input[type=checkbox]'); | ||
const service = document.getElementById('service_type'); | ||
const user = document.getElementById('auth_username'); | ||
const pass = document.getElementById('auth_password'); | ||
const token = document.getElementById('auth_token'); | ||
const mirror = document.getElementById('mirror'); | ||
const lfs = document.getElementById('lfs'); | ||
const lfsSettings = document.getElementById('lfs_settings'); | ||
const lfsEndpoint = document.getElementById('lfs_endpoint'); | ||
const items = document.querySelectorAll('#migrate_items input[type=checkbox]'); | ||
|
||
export function initRepoMigration() { | ||
checkAuth(); | ||
setLFSSettingsVisibility(); | ||
|
||
$user.on('input', () => {checkItems(false)}); | ||
$pass.on('input', () => {checkItems(false)}); | ||
$token.on('input', () => {checkItems(true)}); | ||
$mirror.on('change', () => {checkItems(true)}); | ||
$('#lfs_settings_show').on('click', () => { showElem($lfsEndpoint); return false }); | ||
$lfs.on('change', setLFSSettingsVisibility); | ||
|
||
const $cloneAddr = $('#clone_addr'); | ||
$cloneAddr.on('change', () => { | ||
const $repoName = $('#repo_name'); | ||
if ($cloneAddr.val().length > 0 && $repoName.val().length === 0) { // Only modify if repo_name input is blank | ||
$repoName.val($cloneAddr.val().match(/^(.*\/)?((.+?)(\.git)?)$/)[3]); | ||
user?.addEventListener('input', () => {checkItems(false)}); | ||
pass?.addEventListener('input', () => {checkItems(false)}); | ||
token?.addEventListener('input', () => {checkItems(true)}); | ||
mirror?.addEventListener('change', () => {checkItems(true)}); | ||
document.getElementById('lfs_settings_show')?.addEventListener('click', (e) => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
showElem(lfsEndpoint); | ||
}); | ||
lfs?.addEventListener('change', setLFSSettingsVisibility); | ||
|
||
const cloneAddr = document.getElementById('clone_addr'); | ||
cloneAddr?.addEventListener('change', () => { | ||
const repoName = document.getElementById('repo_name'); | ||
if (cloneAddr.value.length > 0 && repoName?.value.length === 0) { // Only modify if repo_name input is blank | ||
repoName.value = cloneAddr.value.match(/^(.*\/)?((.+?)(\.git)?)$/)[3]; | ||
} | ||
}); | ||
} | ||
|
||
function checkAuth() { | ||
const serviceType = $service.val(); | ||
if (!service) return; | ||
const serviceType = service.value; | ||
|
||
checkItems(serviceType !== 1); | ||
checkItems(serviceType !== '1'); | ||
silverwind marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
function checkItems(tokenAuth) { | ||
let enableItems; | ||
if (tokenAuth) { | ||
enableItems = $token.val() !== ''; | ||
enableItems = token?.value !== ''; | ||
} else { | ||
enableItems = $user.val() !== '' || $pass.val() !== ''; | ||
enableItems = user?.value !== '' || pass?.value !== ''; | ||
} | ||
if (enableItems && $service.val() > 1) { | ||
if ($mirror.is(':checked')) { | ||
$items.not('[name="wiki"]').attr('disabled', true); | ||
$items.filter('[name="wiki"]').attr('disabled', false); | ||
if (enableItems && service?.value > 1) { | ||
silverwind marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (mirror?.checked) { | ||
for (const item of items) { | ||
if (item.name === 'wiki') { | ||
item.disabled = false; | ||
} else { | ||
item.disabled = true; | ||
yardenshoham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
return; | ||
} | ||
$items.attr('disabled', false); | ||
for (const item of items) item.disabled = false; | ||
} else { | ||
$items.attr('disabled', true); | ||
for (const item of items) item.disabled = true; | ||
} | ||
} | ||
|
||
function setLFSSettingsVisibility() { | ||
const visible = $lfs.is(':checked'); | ||
toggleElem($lfsSettings, visible); | ||
hideElem($lfsEndpoint); | ||
if (!lfs) return; | ||
const visible = lfs.checked; | ||
toggleElem(lfsSettings, visible); | ||
hideElem(lfsEndpoint); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.