Commit d5599865 authored by Natalia Tepluhina's avatar Natalia Tepluhina Committed by Phil Hughes

Resolve "Skip fetching project members until assignees dropdown is open"

parent aff7a452
...@@ -229,7 +229,7 @@ export default { ...@@ -229,7 +229,7 @@ export default {
@expand-widget="expandWidget" @expand-widget="expandWidget"
/> />
</template> </template>
<template #default> <template #default="{ edit }">
<user-select <user-select
ref="userSelect" ref="userSelect"
v-model="selected" v-model="selected"
...@@ -240,6 +240,7 @@ export default { ...@@ -240,6 +240,7 @@ export default {
:allow-multiple-assignees="allowMultipleAssignees" :allow-multiple-assignees="allowMultipleAssignees"
:current-user="currentUser" :current-user="currentUser"
:issuable-type="issuableType" :issuable-type="issuableType"
:is-editing="edit"
class="gl-w-full dropdown-menu-user" class="gl-w-full dropdown-menu-user"
@toggle="collapseWidget" @toggle="collapseWidget"
@error="showError" @error="showError"
......
...@@ -60,6 +60,11 @@ export default { ...@@ -60,6 +60,11 @@ export default {
required: false, required: false,
default: 'issue', default: 'issue',
}, },
isEditing: {
type: Boolean,
required: false,
default: true,
},
}, },
data() { data() {
return { return {
...@@ -75,7 +80,7 @@ export default { ...@@ -75,7 +80,7 @@ export default {
return participantsQueries[this.issuableType].query; return participantsQueries[this.issuableType].query;
}, },
skip() { skip() {
return Boolean(participantsQueries[this.issuableType].skipQuery); return Boolean(participantsQueries[this.issuableType].skipQuery) || !this.isEditing;
}, },
variables() { variables() {
return { return {
...@@ -102,6 +107,9 @@ export default { ...@@ -102,6 +107,9 @@ export default {
first: 20, first: 20,
}; };
}, },
skip() {
return !this.isEditing;
},
update(data) { update(data) {
// TODO Remove null filter (BE fix required) // TODO Remove null filter (BE fix required)
// https://gitlab.com/gitlab-org/gitlab/-/issues/329750 // https://gitlab.com/gitlab-org/gitlab/-/issues/329750
......
...@@ -49,10 +49,13 @@ describe('User select dropdown', () => { ...@@ -49,10 +49,13 @@ describe('User select dropdown', () => {
const findUnassignLink = () => wrapper.find('[data-testid="unassign"]'); const findUnassignLink = () => wrapper.find('[data-testid="unassign"]');
const findEmptySearchResults = () => wrapper.find('[data-testid="empty-results"]'); const findEmptySearchResults = () => wrapper.find('[data-testid="empty-results"]');
const searchQueryHandlerSuccess = jest.fn().mockResolvedValue(projectMembersResponse);
const participantsQueryHandlerSuccess = jest.fn().mockResolvedValue(participantsQueryResponse);
const createComponent = ({ const createComponent = ({
props = {}, props = {},
searchQueryHandler = jest.fn().mockResolvedValue(projectMembersResponse), searchQueryHandler = searchQueryHandlerSuccess,
participantsQueryHandler = jest.fn().mockResolvedValue(participantsQueryResponse), participantsQueryHandler = participantsQueryHandlerSuccess,
} = {}) => { } = {}) => {
fakeApollo = createMockApollo([ fakeApollo = createMockApollo([
[searchUsersQuery, searchQueryHandler], [searchUsersQuery, searchQueryHandler],
...@@ -91,6 +94,14 @@ describe('User select dropdown', () => { ...@@ -91,6 +94,14 @@ describe('User select dropdown', () => {
expect(findParticipantsLoading().exists()).toBe(true); expect(findParticipantsLoading().exists()).toBe(true);
}); });
it('skips the queries if `isEditing` prop is false', () => {
createComponent({ props: { isEditing: false } });
expect(findParticipantsLoading().exists()).toBe(false);
expect(searchQueryHandlerSuccess).not.toHaveBeenCalled();
expect(participantsQueryHandlerSuccess).not.toHaveBeenCalled();
});
it('emits an `error` event if participants query was rejected', async () => { it('emits an `error` event if participants query was rejected', async () => {
createComponent({ participantsQueryHandler: mockError }); createComponent({ participantsQueryHandler: mockError });
await waitForPromises(); await waitForPromises();
......
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