Commit ff346be2 authored by Scott Hampton's avatar Scott Hampton

Merge branch '322879-change-assignee-dropdown-invite-to-utilize-invite-modal' into 'master'

Change assignee dropdown invite to utilize invite modal

See merge request gitlab-org/gitlab!57002
parents 5d2c154f 56cc90e0
<script> <script>
import { GlButton } from '@gitlab/ui'; import { GlButton, GlLink } from '@gitlab/ui';
import ExperimentTracking from '~/experimentation/experiment_tracking'; import ExperimentTracking from '~/experimentation/experiment_tracking';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
export default { export default {
components: { GlButton }, components: { GlButton, GlLink },
props: { props: {
displayText: { displayText: {
type: String, type: String,
...@@ -37,6 +37,42 @@ export default { ...@@ -37,6 +37,42 @@ export default {
required: false, required: false,
default: undefined, default: undefined,
}, },
triggerElement: {
type: String,
required: false,
default: 'button',
},
event: {
type: String,
required: false,
default: '',
},
label: {
type: String,
required: false,
default: '',
},
},
computed: {
isButton() {
return this.triggerElement === 'button';
},
componentAttributes() {
const baseAttributes = {
class: this.classes,
'data-qa-selector': 'invite_members_button',
};
if (this.event && this.label) {
return {
...baseAttributes,
'data-track-event': this.event,
'data-track-label': this.label,
};
}
return baseAttributes;
},
}, },
mounted() { mounted() {
this.trackExperimentOnShow(); this.trackExperimentOnShow();
...@@ -57,12 +93,15 @@ export default { ...@@ -57,12 +93,15 @@ export default {
<template> <template>
<gl-button <gl-button
:class="classes" v-if="isButton"
:icon="icon" v-bind="componentAttributes"
:variant="variant" :variant="variant"
data-qa-selector="invite_members_button" :icon="icon"
@click="openModal" @click="openModal"
> >
{{ displayText }} {{ displayText }}
</gl-button> </gl-button>
<gl-link v-else v-bind="componentAttributes" data-is-link="true" @click="openModal">
{{ displayText }}
</gl-link>
</template> </template>
...@@ -4,6 +4,7 @@ import initIssuableSidebar from '~/init_issuable_sidebar'; ...@@ -4,6 +4,7 @@ import initIssuableSidebar from '~/init_issuable_sidebar';
import initInviteMemberModal from '~/invite_member/init_invite_member_modal'; import initInviteMemberModal from '~/invite_member/init_invite_member_modal';
import initInviteMemberTrigger from '~/invite_member/init_invite_member_trigger'; import initInviteMemberTrigger from '~/invite_member/init_invite_member_trigger';
import initInviteMembersModal from '~/invite_members/init_invite_members_modal'; import initInviteMembersModal from '~/invite_members/init_invite_members_modal';
import initInviteMembersTrigger from '~/invite_members/init_invite_members_trigger';
import { IssuableType } from '~/issuable_show/constants'; import { IssuableType } from '~/issuable_show/constants';
import Issue from '~/issue'; import Issue from '~/issue';
import '~/notes/index'; import '~/notes/index';
...@@ -36,6 +37,7 @@ export default function initShowIssue() { ...@@ -36,6 +37,7 @@ export default function initShowIssue() {
initSentryErrorStackTraceApp(); initSentryErrorStackTraceApp();
initRelatedMergeRequestsApp(); initRelatedMergeRequestsApp();
initInviteMembersModal(); initInviteMembersModal();
initInviteMembersTrigger();
import(/* webpackChunkName: 'design_management' */ '~/design_management') import(/* webpackChunkName: 'design_management' */ '~/design_management')
.then((module) => module.default()) .then((module) => module.default())
......
...@@ -6,6 +6,7 @@ import initIssuableSidebar from '~/init_issuable_sidebar'; ...@@ -6,6 +6,7 @@ import initIssuableSidebar from '~/init_issuable_sidebar';
import initInviteMemberModal from '~/invite_member/init_invite_member_modal'; import initInviteMemberModal from '~/invite_member/init_invite_member_modal';
import initInviteMemberTrigger from '~/invite_member/init_invite_member_trigger'; import initInviteMemberTrigger from '~/invite_member/init_invite_member_trigger';
import initInviteMembersModal from '~/invite_members/init_invite_members_modal'; import initInviteMembersModal from '~/invite_members/init_invite_members_modal';
import initInviteMembersTrigger from '~/invite_members/init_invite_members_trigger';
import { handleLocationHash } from '~/lib/utils/common_utils'; import { handleLocationHash } from '~/lib/utils/common_utils';
import StatusBox from '~/merge_request/components/status_box.vue'; import StatusBox from '~/merge_request/components/status_box.vue';
import initSourcegraph from '~/sourcegraph'; import initSourcegraph from '~/sourcegraph';
...@@ -22,6 +23,7 @@ export default function initMergeRequestShow() { ...@@ -22,6 +23,7 @@ export default function initMergeRequestShow() {
initInviteMemberModal(); initInviteMemberModal();
initInviteMemberTrigger(); initInviteMemberTrigger();
initInviteMembersModal(); initInviteMembersModal();
initInviteMembersTrigger();
const el = document.querySelector('.js-mr-status-box'); const el = document.querySelector('.js-mr-status-box');
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
......
...@@ -53,10 +53,10 @@ ...@@ -53,10 +53,10 @@
%ul.dropdown-footer-list %ul.dropdown-footer-list
%li %li
- if directly_invite_members? - if directly_invite_members?
= link_to invite_text, .js-invite-members-trigger{ data: { trigger_element: 'anchor',
project_project_members_path(@project), display_text: invite_text,
title: invite_text, event: 'click_invite_members',
data: { 'is-link': true, 'track-event': 'click_invite_members', 'track-label': track_label } label: track_label } }
- else - else
.js-invite-member-trigger{ data: { display_text: invite_text, event: 'click_invite_members_version_b', label: track_label } } .js-invite-member-trigger{ data: { display_text: invite_text, event: 'click_invite_members_version_b', label: track_label } }
- else - else
......
---
title: Change assignee dropdown invite to utilize invite modal
merge_request: 57002
author:
type: changed
import { GlButton } from '@gitlab/ui'; import { GlButton, GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import ExperimentTracking from '~/experimentation/experiment_tracking'; import ExperimentTracking from '~/experimentation/experiment_tracking';
import InviteMembersTrigger from '~/invite_members/components/invite_members_trigger.vue'; import InviteMembersTrigger from '~/invite_members/components/invite_members_trigger.vue';
...@@ -8,22 +8,29 @@ jest.mock('~/experimentation/experiment_tracking'); ...@@ -8,22 +8,29 @@ jest.mock('~/experimentation/experiment_tracking');
const displayText = 'Invite team members'; const displayText = 'Invite team members';
let wrapper; let wrapper;
let triggerProps;
let findButton;
const triggerComponent = {
button: GlButton,
anchor: GlLink,
};
const createComponent = (props = {}) => { const createComponent = (props = {}) => {
wrapper = shallowMount(InviteMembersTrigger, { wrapper = shallowMount(InviteMembersTrigger, {
propsData: { propsData: {
displayText, displayText,
...triggerProps,
...props, ...props,
}, },
}); });
}; };
describe('InviteMembersTrigger', () => { describe.each(['button', 'anchor'])('with triggerElement as %s', (triggerElement) => {
const findButton = () => wrapper.findComponent(GlButton); triggerProps = { triggerElement };
findButton = () => wrapper.findComponent(triggerComponent[triggerElement]);
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
describe('displayText', () => { describe('displayText', () => {
...@@ -74,5 +81,19 @@ describe('InviteMembersTrigger', () => { ...@@ -74,5 +81,19 @@ describe('InviteMembersTrigger', () => {
expect(ExperimentTracking).not.toHaveBeenCalledWith('_track_experiment_'); expect(ExperimentTracking).not.toHaveBeenCalledWith('_track_experiment_');
}); });
it('does not add tracking attributes', () => {
createComponent();
expect(findButton().attributes('data-track-event')).toBeUndefined();
expect(findButton().attributes('data-track-label')).toBeUndefined();
});
it('adds tracking attributes', () => {
createComponent({ label: '_label_', event: '_event_' });
expect(findButton().attributes('data-track-event')).toBe('_event_');
expect(findButton().attributes('data-track-label')).toBe('_label_');
});
}); });
}); });
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
RSpec.shared_examples 'issuable invite members experiments' do RSpec.shared_examples 'issuable invite members experiments' do
context 'when a privileged user can invite' do context 'when a privileged user can invite' do
it 'shows a link for inviting members and follows through to the members page' do it 'shows a link for inviting members and launches invite modal' do
project.add_maintainer(user) project.add_maintainer(user)
visit issuable_path visit issuable_path
...@@ -11,14 +11,14 @@ RSpec.shared_examples 'issuable invite members experiments' do ...@@ -11,14 +11,14 @@ RSpec.shared_examples 'issuable invite members experiments' do
wait_for_requests wait_for_requests
page.within '.dropdown-menu-user' do page.within '.dropdown-menu-user' do
expect(page).to have_link('Invite Members', href: project_project_members_path(project)) expect(page).to have_link('Invite Members')
expect(page).to have_selector('[data-track-event="click_invite_members"]') expect(page).to have_selector('[data-track-event="click_invite_members"]')
expect(page).to have_selector('[data-track-label="edit_assignee"]') expect(page).to have_selector('[data-track-label="edit_assignee"]')
end end
click_link 'Invite Members' click_link 'Invite Members'
expect(current_path).to eq project_project_members_path(project) expect(page).to have_content("You're inviting members to the")
end end
end end
......
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