Commit d60cc09b authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents 67d1be5c 43a40ac9
...@@ -14,7 +14,7 @@ export default class TransferDropdown { ...@@ -14,7 +14,7 @@ export default class TransferDropdown {
} }
buildDropdown() { buildDropdown() {
const extraOptions = [{ id: '', text: __('No parent group') }, 'divider']; const extraOptions = [{ id: '-1', text: __('No parent group') }, 'divider'];
this.groupDropdown.glDropdown({ this.groupDropdown.glDropdown({
selectable: true, selectable: true,
...@@ -33,5 +33,6 @@ export default class TransferDropdown { ...@@ -33,5 +33,6 @@ export default class TransferDropdown {
assignSelected(selected) { assignSelected(selected) {
this.parentInput.val(selected.id); this.parentInput.val(selected.id);
this.parentInput.change();
} }
} }
...@@ -2,6 +2,7 @@ import initAvatarPicker from '~/avatar_picker'; ...@@ -2,6 +2,7 @@ import initAvatarPicker from '~/avatar_picker';
import TransferDropdown from '~/groups/transfer_dropdown'; import TransferDropdown from '~/groups/transfer_dropdown';
import initConfirmDangerModal from '~/confirm_danger_modal'; import initConfirmDangerModal from '~/confirm_danger_modal';
import initSettingsPanels from '~/settings_panels'; import initSettingsPanels from '~/settings_panels';
import setupTransferEdit from '~/transfer_edit';
import dirtySubmitFactory from '~/dirty_submit/dirty_submit_factory'; import dirtySubmitFactory from '~/dirty_submit/dirty_submit_factory';
import mountBadgeSettings from '~/pages/shared/mount_badge_settings'; import mountBadgeSettings from '~/pages/shared/mount_badge_settings';
import { GROUP_BADGE } from '~/badges/constants'; import { GROUP_BADGE } from '~/badges/constants';
...@@ -17,6 +18,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -17,6 +18,7 @@ document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('.js-general-settings-form, .js-general-permissions-form'), document.querySelectorAll('.js-general-settings-form, .js-general-permissions-form'),
); );
mountBadgeSettings(GROUP_BADGE); mountBadgeSettings(GROUP_BADGE);
setupTransferEdit('.js-group-transfer-form', '#new_parent_group_id');
// Initialize Subgroups selector // Initialize Subgroups selector
groupsSelect(); groupsSelect();
......
import { PROJECT_BADGE } from '~/badges/constants'; import { PROJECT_BADGE } from '~/badges/constants';
import initSettingsPanels from '~/settings_panels'; import initSettingsPanels from '~/settings_panels';
import setupProjectEdit from '~/project_edit'; import setupTransferEdit from '~/transfer_edit';
import initConfirmDangerModal from '~/confirm_danger_modal'; import initConfirmDangerModal from '~/confirm_danger_modal';
import mountBadgeSettings from '~/pages/shared/mount_badge_settings'; import mountBadgeSettings from '~/pages/shared/mount_badge_settings';
import dirtySubmitFactory from '~/dirty_submit/dirty_submit_factory'; import dirtySubmitFactory from '~/dirty_submit/dirty_submit_factory';
...@@ -16,7 +16,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -16,7 +16,7 @@ document.addEventListener('DOMContentLoaded', () => {
initProjectLoadingSpinner(); initProjectLoadingSpinner();
initProjectPermissionsSettings(); initProjectPermissionsSettings();
setupProjectEdit(); setupTransferEdit('.js-project-transfer-form', 'select.select2');
dirtySubmitFactory( dirtySubmitFactory(
document.querySelectorAll( document.querySelectorAll(
......
import $ from 'jquery'; import $ from 'jquery';
export default function setupProjectEdit() { export default function setupTransferEdit(formSelector, targetSelector) {
const $transferForm = $('.js-project-transfer-form'); const $transferForm = $(formSelector);
const $selectNamespace = $transferForm.find('select.select2'); const $selectNamespace = $transferForm.find(targetSelector);
$selectNamespace.on('change', () => { $selectNamespace.on('change', () => {
$transferForm.find(':submit').prop('disabled', !$selectNamespace.val()); $transferForm.find(':submit').prop('disabled', !$selectNamespace.val());
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
.sub-section .sub-section
%h4.warning-title Transfer group %h4.warning-title Transfer group
= form_for @group, url: transfer_group_path(@group), method: :put do |f| = form_for @group, url: transfer_group_path(@group), method: :put, html: { class: 'js-group-transfer-form' } do |f|
.form-group .form-group
= dropdown_tag('Select parent group', options: { toggle_class: 'js-groups-dropdown', title: 'Parent Group', filter: true, dropdown_class: 'dropdown-open-top dropdown-group-transfer', placeholder: 'Search groups', data: { data: parent_group_options(@group) } }) = dropdown_tag('Select parent group', options: { toggle_class: 'js-groups-dropdown', title: 'Parent Group', filter: true, dropdown_class: 'dropdown-open-top dropdown-group-transfer', placeholder: 'Search groups', data: { data: parent_group_options(@group) } })
= hidden_field_tag 'new_parent_group_id' = hidden_field_tag 'new_parent_group_id'
......
---
title: Disable "Transfer group" button when no group is selected
merge_request: 31387
author: Jan Beckmann
type: fixed
import $ from 'jquery';
import setupTransferEdit from '~/transfer_edit';
import { loadHTMLFixture } from 'helpers/fixtures';
describe('setupTransferEdit', () => {
const formSelector = '.js-project-transfer-form';
const targetSelector = 'select.select2';
beforeEach(() => {
loadHTMLFixture('projects/edit.html');
setupTransferEdit(formSelector, targetSelector);
});
it('disables submit button on load', () => {
expect(
$(formSelector)
.find(':submit')
.prop('disabled'),
).toBe(true);
});
it('enables submit button when selection changes to non-empty value', () => {
const nonEmptyValue = $(formSelector)
.find(targetSelector)
.find('option')
.not(':empty')
.val();
$(formSelector)
.find(targetSelector)
.val(nonEmptyValue)
.trigger('change');
expect(
$(formSelector)
.find(':submit')
.prop('disabled'),
).toBeFalsy();
});
it('disables submit button when selection changes to empty value', () => {
$(formSelector)
.find(targetSelector)
.val('')
.trigger('change');
expect(
$(formSelector)
.find(':submit')
.prop('disabled'),
).toBe(true);
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment