Commit d03b3941 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch '224692-allow-modal-to-be-called-globally' into 'master'

Ensure invite members modal has a unique ID

See merge request gitlab-org/gitlab!73485
parents 176c82e9 e1b1ace5
...@@ -12,7 +12,7 @@ import { ...@@ -12,7 +12,7 @@ import {
GlFormInput, GlFormInput,
GlFormCheckboxGroup, GlFormCheckboxGroup,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { partition, isString, unescape } from 'lodash'; import { partition, isString, unescape, uniqueId } from 'lodash';
import Api from '~/api'; import Api from '~/api';
import ExperimentTracking from '~/experimentation/experiment_tracking'; import ExperimentTracking from '~/experimentation/experiment_tracking';
import { sanitize } from '~/lib/dompurify'; import { sanitize } from '~/lib/dompurify';
...@@ -117,7 +117,7 @@ export default { ...@@ -117,7 +117,7 @@ export default {
data() { data() {
return { return {
visible: true, visible: true,
modalId: 'invite-members-modal', modalId: uniqueId('invite-members-modal-'),
selectedAccessLevel: this.defaultAccessLevel, selectedAccessLevel: this.defaultAccessLevel,
inviteeType: 'members', inviteeType: 'members',
newUsersToInvite: [], newUsersToInvite: [],
...@@ -444,6 +444,7 @@ export default { ...@@ -444,6 +444,7 @@ export default {
:modal-id="modalId" :modal-id="modalId"
size="sm" size="sm"
data-qa-selector="invite_members_modal_content" data-qa-selector="invite_members_modal_content"
data-testid="invite-members-modal"
:title="$options.labels[inviteeType].modalTitle" :title="$options.labels[inviteeType].modalTitle"
:header-close-label="$options.labels.headerCloseLabel" :header-close-label="$options.labels.headerCloseLabel"
@hidden="resetFields" @hidden="resetFields"
...@@ -597,11 +598,9 @@ export default { ...@@ -597,11 +598,9 @@ export default {
</div> </div>
<template #modal-footer> <template #modal-footer>
<div class="gl-display-flex gl-flex-direction-row gl-justify-content-end gl-flex-wrap gl-m-0">
<gl-button data-testid="cancel-button" @click="closeModal"> <gl-button data-testid="cancel-button" @click="closeModal">
{{ $options.labels.cancelButtonText }} {{ $options.labels.cancelButtonText }}
</gl-button> </gl-button>
<div class="gl-mr-3"></div>
<gl-button <gl-button
:disabled="inviteDisabled" :disabled="inviteDisabled"
:loading="isLoading" :loading="isLoading"
...@@ -609,9 +608,9 @@ export default { ...@@ -609,9 +608,9 @@ export default {
data-qa-selector="invite_button" data-qa-selector="invite_button"
data-testid="invite-button" data-testid="invite-button"
@click="sendInvite" @click="sendInvite"
>{{ $options.labels.inviteButtonText }}</gl-button
> >
</div> {{ $options.labels.inviteButtonText }}
</gl-button>
</template> </template>
</gl-modal> </gl-modal>
</template> </template>
...@@ -6,6 +6,10 @@ import { parseBoolean } from '~/lib/utils/common_utils'; ...@@ -6,6 +6,10 @@ import { parseBoolean } from '~/lib/utils/common_utils';
Vue.use(GlToast); Vue.use(GlToast);
export default function initInviteMembersModal() { export default function initInviteMembersModal() {
// https://gitlab.com/gitlab-org/gitlab/-/issues/344955
// bug lying in wait here for someone to put group and project invite in same screen
// once that happens we'll need to mount these differently, perhaps split
// group/project to each mount one, with many ways to open it.
const el = document.querySelector('.js-invite-members-modal'); const el = document.querySelector('.js-invite-members-modal');
if (!el) { if (!el) {
......
...@@ -42,9 +42,3 @@ ...@@ -42,9 +42,3 @@
svg g { fill: $gray-600; } svg g { fill: $gray-600; }
} }
} }
#invite-members-modal {
.modal-footer {
flex-direction: row;
}
}
...@@ -66,7 +66,7 @@ RSpec.describe 'Groups > Members > List members' do ...@@ -66,7 +66,7 @@ RSpec.describe 'Groups > Members > List members' do
click_on 'Invite members' click_on 'Invite members'
page.within '#invite-members-modal' do page.within '[data-testid="invite-members-modal"]' do
field = find('[data-testid="members-token-select-input"]') field = find('[data-testid="members-token-select-input"]')
field.native.send_keys :tab field.native.send_keys :tab
field.click field.click
......
...@@ -8,7 +8,7 @@ module Spec ...@@ -8,7 +8,7 @@ module Spec
def invite_member(name, role: 'Guest', expires_at: nil, area_of_focus: false) def invite_member(name, role: 'Guest', expires_at: nil, area_of_focus: false)
click_on 'Invite members' click_on 'Invite members'
page.within '#invite-members-modal' do page.within '[data-testid="invite-members-modal"]' do
find('[data-testid="members-token-select-input"]').set(name) find('[data-testid="members-token-select-input"]').set(name)
wait_for_requests wait_for_requests
......
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