aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/features/repo-migration.js
diff options
context:
space:
mode:
Diffstat (limited to 'web_src/js/features/repo-migration.js')
-rw-r--r--web_src/js/features/repo-migration.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/web_src/js/features/repo-migration.js b/web_src/js/features/repo-migration.js
new file mode 100644
index 0000000000..6e59d65f32
--- /dev/null
+++ b/web_src/js/features/repo-migration.js
@@ -0,0 +1,60 @@
+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]');
+
+export default function initRepoMigration() {
+ checkAuth();
+ setLFSSettingsVisibility();
+
+ $user.on('keyup', () => {checkItems(false)});
+ $pass.on('keyup', () => {checkItems(false)});
+ $token.on('keyup', () => {checkItems(true)});
+ $mirror.on('change', () => {checkItems(true)});
+ $('#lfs_settings_show').on('click', () => { $lfsEndpoint.show(); 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]);
+ }
+ });
+}
+
+function checkAuth() {
+ const serviceType = $service.val();
+
+ checkItems(serviceType !== 1);
+}
+
+function checkItems(tokenAuth) {
+ let enableItems;
+ if (tokenAuth) {
+ enableItems = $token.val() !== '';
+ } else {
+ enableItems = $user.val() !== '' || $pass.val() !== '';
+ }
+ if (enableItems && $service.val() > 1) {
+ if ($mirror.is(':checked')) {
+ $items.not('[name="wiki"]').attr('disabled', true);
+ $items.filter('[name="wiki"]').attr('disabled', false);
+ return;
+ }
+ $items.attr('disabled', false);
+ } else {
+ $items.attr('disabled', true);
+ }
+}
+
+function setLFSSettingsVisibility() {
+ const visible = $lfs.is(':checked');
+ $lfsSettings.toggle(visible);
+ $lfsEndpoint.hide();
+}