diff options
author | Luke Bennett <lukeeeebennettplus@gmail.com> | 2018-08-03 20:34:14 +0100 |
---|---|---|
committer | Luke Bennett <lukeeeebennettplus@gmail.com> | 2018-08-03 20:34:14 +0100 |
commit | 4457d98ed240555a3df143d9d11582aa3c4c893a (patch) | |
tree | cce11c2d2c8eae4812182a33185b671d40665f36 /app | |
parent | afca4f6a457c1a9bb6e2857b99c6f9b13f61af6e (diff) | |
download | gitlab-ce-4457d98ed240555a3df143d9d11582aa3c4c893a.tar.gz |
Review changes
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/pages/projects/settings/repository/show/mirror_repos.js | 23 | ||||
-rw-r--r-- | app/views/projects/mirrors/_mirror_repos_form.html.haml | 4 |
2 files changed, 20 insertions, 7 deletions
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 index 91070b3c6f2..76756f76642 100644 --- a/app/assets/javascripts/pages/projects/settings/repository/show/mirror_repos.js +++ b/app/assets/javascripts/pages/projects/settings/repository/show/mirror_repos.js @@ -15,10 +15,17 @@ export default class MirrorRepos { } init() { - this.registerUpdateListeners(); this.initMirrorPush(); + this.registerUpdateListeners(); + } - this.$table.on('click', '.js-delete-mirror', this.deleteMirror.bind(this)); + 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() { @@ -43,11 +50,17 @@ export default class MirrorRepos { 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', this.deleteMirror.bind(this)); } - initMirrorPush() { - this.$password = $('.js-password', this.$form); - this.$password.on('input.updateUrl', () => this.debouncedUpdateUrl()); + togglePassword() { + const isPassword = this.$authMethod.val() === 'password'; + + if (!isPassword) { + this.$password.val(''); + this.updateUrl(); + } + this.$passwordGroup.collapse(isPassword ? 'show' : 'hide'); } deleteMirror(event, existingPayload) { diff --git a/app/views/projects/mirrors/_mirror_repos_form.html.haml b/app/views/projects/mirrors/_mirror_repos_form.html.haml index 6641376b677..7927e459123 100644 --- a/app/views/projects/mirrors/_mirror_repos_form.html.haml +++ b/app/views/projects/mirrors/_mirror_repos_form.html.haml @@ -11,8 +11,8 @@ .form-group = label_tag :auth_method, _('Authentication method'), class: 'label-bold' - = select_tag :auth_method, options_for_select([[_('Password'), 'password']], 'password'), { class: "form-control js-auth-method", disabled: true } + = select_tag :auth_method, options_for_select([[_('None'), 'none'], [_('Password'), 'password']], 'none'), { class: "form-control js-auth-method", disabled: true } -.form-group +.form-group.js-password-group.collapse = label_tag :password, _('Password'), class: 'label-bold' = text_field_tag :password, '', class: 'form-control js-password' |