@@ -4,6 +4,7 @@ import { GlCollapsibleListbox, GlButton, GlAvatar, GlIcon } from '@gitlab/ui';
4
4
import { __ } from ' ~/locale' ;
5
5
import { InternalEvents } from ' ~/tracking' ;
6
6
import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from ' ~/lib/utils/constants' ;
7
+ import { uuids } from ' ~/lib/utils/uuids' ;
7
8
import { TYPENAME_MERGE_REQUEST } from ' ~/graphql_shared/constants' ;
8
9
import { convertToGraphQLId } from ' ~/graphql_shared/utils' ;
9
10
import userAutocompleteWithMRPermissionsQuery from ' ~/graphql_shared/queries/project_autocomplete_users_with_mr_permissions.query.graphql' ;
@@ -14,6 +15,11 @@ import {
14
15
SEARCH_SELECT_REVIEWER_EVENT ,
15
16
SELECT_REVIEWER_EVENT ,
16
17
} from ' ../../constants' ;
18
+ import {
19
+ getReviewersForList ,
20
+ suggestedPosition ,
21
+ setReviewersForList ,
22
+ } from ' ../../utils/reviewer_positions' ;
17
23
18
24
import UpdateReviewers from ' ./update_reviewers.vue' ;
19
25
import userPermissionsQuery from ' ./queries/user_permissions.query.graphql' ;
@@ -66,6 +72,11 @@ export default {
66
72
required: false ,
67
73
default : () => ' complex' ,
68
74
},
75
+ uniqueId: {
76
+ type: String ,
77
+ required: false ,
78
+ default : () => uuids ()[0 ],
79
+ },
69
80
},
70
81
data () {
71
82
return {
@@ -159,6 +170,17 @@ export default {
159
170
},
160
171
});
161
172
173
+ if (! search) {
174
+ const theseUsers = toUsernames (users);
175
+ const newOptions = difference (theseUsers, this .currentSelectedReviewers );
176
+
177
+ setReviewersForList ({
178
+ issuableId: this .issuableId ,
179
+ listId: this .uniqueId ,
180
+ reviewers: newOptions,
181
+ });
182
+ }
183
+
162
184
this .fetchedUsers = users;
163
185
this .searching = false ;
164
186
},
@@ -169,6 +191,10 @@ export default {
169
191
const telemetryEvent = this .search ? SEARCH_SELECT_REVIEWER_EVENT : SELECT_REVIEWER_EVENT ;
170
192
const previousUsernames = toUsernames (this .selectedReviewers );
171
193
const listUsernames = toUsernames (this .usersForList );
194
+ const suggested = getReviewersForList ({
195
+ issuableId: this .issuableId ,
196
+ listId: this .uniqueId ,
197
+ });
172
198
// Reviewers are always shown first if they are in the list,
173
199
// so we should exclude them for when we check the position
174
200
const selectableList = difference (listUsernames, previousUsernames);
@@ -177,9 +203,11 @@ export default {
177
203
additions .forEach ((added ) => {
178
204
// Convert from 0- to 1-index
179
205
const listPosition = selectableList .findIndex ((user ) => user === added) + 1 ;
206
+ const suggestedPos = suggestedPosition ({ username: added, list: suggested });
180
207
181
208
this .trackEvent (telemetryEvent, {
182
209
value: listPosition,
210
+ suggested_position: suggestedPos,
183
211
selectable_reviewers_count: selectableList .length ,
184
212
});
185
213
});
0 commit comments