Skip to content
Snippets Groups Projects
Commit 4d9a05a2 authored by Natalia Tepluhina's avatar Natalia Tepluhina
Browse files

Merge branch 'dg-fix-work-item-issues' into 'master'

Show participants as well in assignees widget

See merge request !145901



Merged-by: default avatarNatalia Tepluhina <ntepluhina@gitlab.com>
Approved-by: Nick Leonard's avatarNick Leonard <nleonard@gitlab.com>
Approved-by: default avatarNatalia Tepluhina <ntepluhina@gitlab.com>
Reviewed-by: default avatarNatalia Tepluhina <ntepluhina@gitlab.com>
Reviewed-by: default avatarCoung Ngo <cngo@gitlab.com>
Reviewed-by: Nick Leonard's avatarNick Leonard <nleonard@gitlab.com>
Co-authored-by: Deepika Guliani's avatarDeepika Guliani <dguliani@gitlab.com>
parents 137bac31 f85f207e
No related branches found
No related tags found
1 merge request!145901Show participants as well in assignees widget
Pipeline #1195540413 passed
......@@ -54,6 +54,16 @@ export default {
required: false,
default: false,
},
participants: {
type: Array,
required: false,
default: () => [],
},
workItemAuthor: {
type: Object,
required: false,
default: () => ({}),
},
},
data() {
return {
......@@ -63,6 +73,7 @@ export default {
users: [],
currentUser: null,
updateInProgress: false,
localUsers: [],
};
},
apollo: {
......@@ -83,6 +94,14 @@ export default {
update(data) {
return this.isGroup ? data.groupWorkspace?.users : data.workspace?.users;
},
result({ data }) {
if (!data) {
// when data is not available, skip the update
return;
}
const users = this.isGroup ? data?.groupWorkspace?.users : data?.workspace?.users;
this.localUsers = unionBy(this.localUsers, users, 'id');
},
error() {
this.$emit('error', i18n.fetchError);
},
......@@ -92,16 +111,19 @@ export default {
},
},
computed: {
shouldShowParticipants() {
return this.searchKey === '';
},
searchUsers() {
return this.users.map((user) => ({
const allUsers = this.shouldShowParticipants
? unionBy(this.users, this.participants, 'id')
: this.users;
return allUsers.map((user) => ({
...user,
value: user.id,
text: user.name,
value: user?.id,
text: user?.name,
}));
},
pageInfo() {
return this.users.pageInfo;
},
tracking() {
return {
category: TRACKING_CATEGORY_SHOW,
......@@ -112,9 +134,6 @@ export default {
isLoadingUsers() {
return this.$apollo.queries.users.loading;
},
hasNextPage() {
return this.pageInfo?.hasNextPage;
},
selectedAssigneeIds() {
return this.allowsMultipleAssignees ? this.localAssigneeIds : this.localAssigneeIds[0];
},
......@@ -136,7 +155,12 @@ export default {
return this.allowsMultipleAssignees ? __('Select assignees') : __('Select assignee');
},
filteredAssignees() {
return unionBy(this.assignees, this.searchUsers, 'id');
// assignees are the ones already assigned to the work item detail
// search users are the ones returned by the autocomplete query which can never be more than 20 , context
// https://gitlab.com/gitlab-org/gitlab/-/issues/417757#note_1480434390
// we need the previous results of users after resetting the search since we want to show the name of thes user out of the 20 results searched as well
// participants are the ones which have sometime commented on the work item, same logic as legacy issues
return unionBy(this.assignees, this.searchUsers, this.participants, this.localUsers, 'id');
},
localAssignees() {
return (
......
......@@ -122,6 +122,12 @@ export default {
workItemColor() {
return this.isWidgetPresent(WIDGET_TYPE_COLOR);
},
workItemParticipantNodes() {
return this.workItemParticipants?.participants?.nodes ?? [];
},
workItemAuthor() {
return this.workItem?.author;
},
},
methods: {
isWidgetPresent(type) {
......@@ -141,6 +147,8 @@ export default {
:full-path="fullPath"
:work-item-id="workItem.id"
:assignees="workItemAssignees.assignees.nodes"
:participants="workItemParticipantNodes"
:work-item-author="workItemAuthor"
:allows-multiple-assignees="workItemAssignees.allowsMultipleAssignees"
:work-item-type="workItemType"
:can-invite-members="workItemAssignees.canInviteMembers"
......
......@@ -124,6 +124,7 @@ export default {
:can-delete="canDelete"
:can-update="canUpdate"
:is-confidential="workItem.confidential"
:is-discussion-locked="isDiscussionLocked"
:is-parent-confidential="parentWorkItemConfidentiality"
:work-item-reference="workItem.reference"
:work-item-create-note-email="workItem.createNoteEmail"
......
......@@ -160,7 +160,7 @@ describe('WorkItemAssigneesWithEdit component', () => {
expect(findSidebarDropdownWidget().props('loading')).toBe(true);
});
it('shows the iterations in dropdown when the items have finished fetching', async () => {
it('shows the assignees in dropdown when the items have finished fetching', async () => {
showDropdown();
await waitForPromises();
......
......@@ -1936,33 +1936,27 @@ export const projectMembersResponseWithCurrentUser = {
export const projectMembersAutocompleteResponseWithCurrentUser = {
data: {
workspace: {
id: '1',
id: 'gid://gitlab/Project/7',
__typename: 'Project',
users: [
{
id: 'user-2',
user: {
__typename: 'UserCore',
id: 'gid://gitlab/User/5',
avatarUrl: '/avatar2',
name: 'rookie',
username: 'rookie',
webUrl: 'rookie',
status: null,
},
__typename: 'AutocompletedUser',
id: 'gid://gitlab/User/5',
avatarUrl: '/avatar2',
name: 'rookie',
username: 'rookie',
webUrl: 'rookie',
status: null,
},
{
id: 'user-1',
user: {
__typename: 'UserCore',
id: 'gid://gitlab/User/1',
avatarUrl:
'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
name: 'Administrator',
username: 'root',
webUrl: '/root',
status: null,
},
__typename: 'AutocompletedUser',
id: 'gid://gitlab/User/1',
avatarUrl:
'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
name: 'Administrator',
username: 'root',
webUrl: '/root',
status: null,
},
],
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment