diff options
author | Nick Thomas <nick@gitlab.com> | 2018-11-12 13:52:48 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-11-19 14:46:39 +0300 |
commit | f1bc7b6eb5cb9beab55e4edac87cc5e0b7ceb069 (patch) | |
tree | 2e5aedd22e2fd05909c1e97c5bc52602feadc825 /app/assets/javascripts/pages/projects/settings/repository | |
parent | b1b4c94484b0613a6a457e32218d4f62b9eb2029 (diff) |
SSH public-key authentication for push mirroring
Diffstat (limited to 'app/assets/javascripts/pages/projects/settings/repository')
-rw-r--r-- | app/assets/javascripts/pages/projects/settings/repository/show/index.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/pages/projects/settings/repository/show/mirror_repos.js | 94 |
2 files changed, 1 insertions, 95 deletions
diff --git a/app/assets/javascripts/pages/projects/settings/repository/show/index.js b/app/assets/javascripts/pages/projects/settings/repository/show/index.js index 78cf5406e43..1ef4b460263 100644 --- a/app/assets/javascripts/pages/projects/settings/repository/show/index.js +++ b/app/assets/javascripts/pages/projects/settings/repository/show/index.js @@ -1,5 +1,5 @@ import initForm from '../form'; -import MirrorRepos from './mirror_repos'; +import MirrorRepos from '~/mirrors/mirror_repos'; document.addEventListener('DOMContentLoaded', () => { initForm(); diff --git a/app/assets/javascripts/pages/projects/settings/repository/show/mirror_repos.js b/app/assets/javascripts/pages/projects/settings/repository/show/mirror_repos.js deleted file mode 100644 index 4c56af20cc3..00000000000 --- a/app/assets/javascripts/pages/projects/settings/repository/show/mirror_repos.js +++ /dev/null @@ -1,94 +0,0 @@ -import $ from 'jquery'; -import _ from 'underscore'; -import { __ } from '~/locale'; -import Flash from '~/flash'; -import axios from '~/lib/utils/axios_utils'; - -export default class MirrorRepos { - constructor(container) { - this.$container = $(container); - this.$form = $('.js-mirror-form', this.$container); - this.$urlInput = $('.js-mirror-url', this.$form); - this.$protectedBranchesInput = $('.js-mirror-protected', this.$form); - this.$table = $('.js-mirrors-table-body', this.$container); - this.mirrorEndpoint = this.$form.data('projectMirrorEndpoint'); - } - - init() { - this.initMirrorPush(); - this.registerUpdateListeners(); - } - - initMirrorPush() { - this.$passwordGroup = $('.js-password-group', this.$container); - this.$password = $('.js-password', this.$passwordGroup); - this.$authMethod = $('.js-auth-method', this.$form); - - this.$authMethod.on('change', () => this.togglePassword()); - this.$password.on('input.updateUrl', () => this.debouncedUpdateUrl()); - } - - updateUrl() { - let val = this.$urlInput.val(); - - if (this.$password) { - const password = this.$password.val(); - if (password) val = val.replace('@', `:${password}@`); - } - - $('.js-mirror-url-hidden', this.$form).val(val); - } - - updateProtectedBranches() { - const val = this.$protectedBranchesInput.get(0).checked - ? this.$protectedBranchesInput.val() - : '0'; - $('.js-mirror-protected-hidden', this.$form).val(val); - } - - registerUpdateListeners() { - this.debouncedUpdateUrl = _.debounce(() => this.updateUrl(), 200); - this.$urlInput.on('input', () => this.debouncedUpdateUrl()); - this.$protectedBranchesInput.on('change', () => this.updateProtectedBranches()); - this.$table.on('click', '.js-delete-mirror', event => this.deleteMirror(event)); - } - - togglePassword() { - const isPassword = this.$authMethod.val() === 'password'; - - if (!isPassword) { - this.$password.val(''); - this.updateUrl(); - } - this.$passwordGroup.collapse(isPassword ? 'show' : 'hide'); - } - - deleteMirror(event, existingPayload) { - const $target = $(event.currentTarget); - let payload = existingPayload; - - if (!payload) { - payload = { - project: { - remote_mirrors_attributes: { - id: $target.data('mirrorId'), - enabled: 0, - }, - }, - }; - } - - return axios - .put(this.mirrorEndpoint, payload) - .then(() => this.removeRow($target)) - .catch(() => Flash(__('Failed to remove mirror.'))); - } - - /* eslint-disable class-methods-use-this */ - removeRow($target) { - const row = $target.closest('tr'); - $('.js-delete-mirror', row).tooltip('hide'); - row.remove(); - } - /* eslint-enable class-methods-use-this */ -} |