@atlaskit/smart-user-picker 8.5.0 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/afm-cc/tsconfig.json +2 -1
- package/afm-jira/tsconfig.json +2 -1
- package/afm-products/tsconfig.json +2 -1
- package/dist/cjs/components/SmartUserPicker.js +60 -48
- package/dist/es2019/components/SmartUserPicker.js +5 -1
- package/dist/esm/components/SmartUserPicker.js +60 -48
- package/dist/types/types.d.ts +6 -0
- package/dist/types-ts4.5/types.d.ts +6 -0
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlassian/smart-user-picker
|
|
2
2
|
|
|
3
|
+
## 8.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`0d41d4c92fe89`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0d41d4c92fe89) -
|
|
8
|
+
[ux] Added `fetchOptions` prop to SmartUserPicker to support custom option fetching. When
|
|
9
|
+
provided, this function will be called instead of the default recommendation API, allowing
|
|
10
|
+
consumers to override the default fetching behavior with their own implementation.
|
|
11
|
+
|
|
3
12
|
## 8.5.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/afm-jira/tsconfig.json
CHANGED
|
@@ -32,7 +32,7 @@ var _MessagesIntlProvider = _interopRequireDefault(require("./MessagesIntlProvid
|
|
|
32
32
|
var _types = require("../types");
|
|
33
33
|
var _service = require("../service");
|
|
34
34
|
var _ufoExperiences = require("../ufoExperiences");
|
|
35
|
-
var _excluded = ["allowEmail", "enableEmailSearch", "allowEmailSelectionWhenEmailMatched"];
|
|
35
|
+
var _excluded = ["allowEmail", "enableEmailSearch", "allowEmailSelectionWhenEmailMatched", "fetchOptions"];
|
|
36
36
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
37
37
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
38
38
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -118,12 +118,12 @@ var SmartUserPickerWithoutAnalytics = exports.SmartUserPickerWithoutAnalytics =
|
|
|
118
118
|
});
|
|
119
119
|
(0, _defineProperty2.default)(_this, "memoizedFilterOptions", (0, _memoizeOne.default)(_this.filterOptions));
|
|
120
120
|
(0, _defineProperty2.default)(_this, "getUsers", (0, _debounce.default)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
121
|
-
var _this$state, query, sessionId, closed, _this$props, baseUrl, childObjectId, containerId, fieldId, includeGroups, includeTeams, includeTeamsUpdates, includeUsers, includeNonLicensedUsers, intl, maxOptions, objectId, onEmpty, onError, overrideByline, displayEmailInByline, orgId, principalId, productAttributes, productKey, searchQueryFilter, siteId, transformOptions, userResolvers, enableEmailSearch, maxNumberOfResults, startTime, isEmail, recommendationsRequest, _yield$onEmpty, _query, recommendedUsers, userRecommendationsPromise, userResolversPromises, _yield$Promise$all, _yield$Promise$all2, mainRecommendations, userResolverResults, _iterator, _step, option, _iterator2, _step2, _option, _iterator3, _step3, _option2, elapsedTimeMilli, transformedOptions, displayedUsers, is5xxEvent, onErrorProducedError, defaultUsers, _elapsedTimeMilli;
|
|
121
|
+
var _this$state, query, sessionId, closed, _this$props, baseUrl, childObjectId, containerId, fieldId, includeGroups, includeTeams, includeTeamsUpdates, includeUsers, includeNonLicensedUsers, intl, fetchOptions, maxOptions, objectId, onEmpty, onError, overrideByline, displayEmailInByline, orgId, principalId, productAttributes, productKey, searchQueryFilter, siteId, transformOptions, userResolvers, enableEmailSearch, maxNumberOfResults, startTime, isEmail, recommendationsRequest, _yield$onEmpty, _query, recommendedUsers, userRecommendationsPromise, userResolversPromises, _yield$Promise$all, _yield$Promise$all2, mainRecommendations, userResolverResults, _iterator, _step, option, _iterator2, _step2, _option, _iterator3, _step3, _option2, elapsedTimeMilli, transformedOptions, displayedUsers, is5xxEvent, onErrorProducedError, defaultUsers, _elapsedTimeMilli;
|
|
122
122
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
123
123
|
while (1) switch (_context.prev = _context.next) {
|
|
124
124
|
case 0:
|
|
125
125
|
_this$state = _this.state, query = _this$state.query, sessionId = _this$state.sessionId, closed = _this$state.closed;
|
|
126
|
-
_this$props = _this.props, baseUrl = _this$props.baseUrl, childObjectId = _this$props.childObjectId, containerId = _this$props.containerId, fieldId = _this$props.fieldId, includeGroups = _this$props.includeGroups, includeTeams = _this$props.includeTeams, includeTeamsUpdates = _this$props.includeTeamsUpdates, includeUsers = _this$props.includeUsers, includeNonLicensedUsers = _this$props.includeNonLicensedUsers, intl = _this$props.intl, maxOptions = _this$props.maxOptions, objectId = _this$props.objectId, onEmpty = _this$props.onEmpty, onError = _this$props.onError, overrideByline = _this$props.overrideByline, displayEmailInByline = _this$props.displayEmailInByline, orgId = _this$props.orgId, principalId = _this$props.principalId, productAttributes = _this$props.productAttributes, productKey = _this$props.productKey, searchQueryFilter = _this$props.searchQueryFilter, siteId = _this$props.siteId, transformOptions = _this$props.transformOptions, userResolvers = _this$props.userResolvers, enableEmailSearch = _this$props.enableEmailSearch;
|
|
126
|
+
_this$props = _this.props, baseUrl = _this$props.baseUrl, childObjectId = _this$props.childObjectId, containerId = _this$props.containerId, fieldId = _this$props.fieldId, includeGroups = _this$props.includeGroups, includeTeams = _this$props.includeTeams, includeTeamsUpdates = _this$props.includeTeamsUpdates, includeUsers = _this$props.includeUsers, includeNonLicensedUsers = _this$props.includeNonLicensedUsers, intl = _this$props.intl, fetchOptions = _this$props.fetchOptions, maxOptions = _this$props.maxOptions, objectId = _this$props.objectId, onEmpty = _this$props.onEmpty, onError = _this$props.onError, overrideByline = _this$props.overrideByline, displayEmailInByline = _this$props.displayEmailInByline, orgId = _this$props.orgId, principalId = _this$props.principalId, productAttributes = _this$props.productAttributes, productKey = _this$props.productKey, searchQueryFilter = _this$props.searchQueryFilter, siteId = _this$props.siteId, transformOptions = _this$props.transformOptions, userResolvers = _this$props.userResolvers, enableEmailSearch = _this$props.enableEmailSearch;
|
|
127
127
|
maxNumberOfResults = maxOptions || 100;
|
|
128
128
|
startTime = window.performance.now(); // Check if this is an email search
|
|
129
129
|
isEmail = enableEmailSearch && isEmailQuery(query);
|
|
@@ -160,8 +160,19 @@ var SmartUserPickerWithoutAnalytics = exports.SmartUserPickerWithoutAnalytics =
|
|
|
160
160
|
_context.prev = 6;
|
|
161
161
|
_query = _this.state.query;
|
|
162
162
|
_this.fireEvent(_analytics.requestUsersEvent);
|
|
163
|
+
if (!(fetchOptions && (0, _platformFeatureFlags.fg)('smart-user-picker-load-options-gate'))) {
|
|
164
|
+
_context.next = 15;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
_context.next = 12;
|
|
168
|
+
return fetchOptions(_query);
|
|
169
|
+
case 12:
|
|
170
|
+
recommendedUsers = _context.sent;
|
|
171
|
+
_context.next = 30;
|
|
172
|
+
break;
|
|
173
|
+
case 15:
|
|
163
174
|
if (!(0, _platformFeatureFlags.fg)('twcg-444-invite-usd-improvements-m2-gate')) {
|
|
164
|
-
_context.next =
|
|
175
|
+
_context.next = 27;
|
|
165
176
|
break;
|
|
166
177
|
}
|
|
167
178
|
userRecommendationsPromise = (0, _service.getUserRecommendations)(recommendationsRequest, intl);
|
|
@@ -174,22 +185,22 @@ var SmartUserPickerWithoutAnalytics = exports.SmartUserPickerWithoutAnalytics =
|
|
|
174
185
|
return [];
|
|
175
186
|
});
|
|
176
187
|
});
|
|
177
|
-
_context.next =
|
|
188
|
+
_context.next = 20;
|
|
178
189
|
return Promise.all([userRecommendationsPromise].concat((0, _toConsumableArray2.default)(userResolversPromises)));
|
|
179
|
-
case
|
|
190
|
+
case 20:
|
|
180
191
|
_yield$Promise$all = _context.sent;
|
|
181
192
|
_yield$Promise$all2 = (0, _toArray2.default)(_yield$Promise$all);
|
|
182
193
|
mainRecommendations = _yield$Promise$all2[0];
|
|
183
194
|
userResolverResults = _yield$Promise$all2.slice(1);
|
|
184
195
|
recommendedUsers = [mainRecommendations].concat((0, _toConsumableArray2.default)(userResolverResults)).flat();
|
|
185
|
-
_context.next =
|
|
196
|
+
_context.next = 30;
|
|
186
197
|
break;
|
|
187
|
-
case
|
|
188
|
-
_context.next =
|
|
198
|
+
case 27:
|
|
199
|
+
_context.next = 29;
|
|
189
200
|
return (0, _service.getUserRecommendations)(recommendationsRequest, intl);
|
|
190
|
-
case
|
|
201
|
+
case 29:
|
|
191
202
|
recommendedUsers = _context.sent;
|
|
192
|
-
case
|
|
203
|
+
case 30:
|
|
193
204
|
if (overrideByline) {
|
|
194
205
|
_iterator = _createForOfIteratorHelper(recommendedUsers);
|
|
195
206
|
try {
|
|
@@ -249,50 +260,50 @@ var SmartUserPickerWithoutAnalytics = exports.SmartUserPickerWithoutAnalytics =
|
|
|
249
260
|
}
|
|
250
261
|
elapsedTimeMilli = window.performance.now() - startTime;
|
|
251
262
|
if (!transformOptions) {
|
|
252
|
-
_context.next =
|
|
263
|
+
_context.next = 41;
|
|
253
264
|
break;
|
|
254
265
|
}
|
|
255
|
-
_context.next =
|
|
266
|
+
_context.next = 38;
|
|
256
267
|
return transformOptions(recommendedUsers, _query);
|
|
257
|
-
case
|
|
268
|
+
case 38:
|
|
258
269
|
_context.t0 = _context.sent;
|
|
259
|
-
_context.next =
|
|
270
|
+
_context.next = 42;
|
|
260
271
|
break;
|
|
261
|
-
case
|
|
272
|
+
case 41:
|
|
262
273
|
_context.t0 = recommendedUsers;
|
|
263
|
-
case
|
|
274
|
+
case 42:
|
|
264
275
|
transformedOptions = _context.t0;
|
|
265
276
|
if (!(transformedOptions.length === 0 && onEmpty)) {
|
|
266
|
-
_context.next =
|
|
277
|
+
_context.next = 58;
|
|
267
278
|
break;
|
|
268
279
|
}
|
|
269
|
-
_context.next =
|
|
280
|
+
_context.next = 46;
|
|
270
281
|
return onEmpty(_query);
|
|
271
|
-
case
|
|
282
|
+
case 46:
|
|
272
283
|
_context.t3 = _yield$onEmpty = _context.sent;
|
|
273
284
|
_context.t2 = _context.t3 !== null;
|
|
274
285
|
if (!_context.t2) {
|
|
275
|
-
_context.next =
|
|
286
|
+
_context.next = 50;
|
|
276
287
|
break;
|
|
277
288
|
}
|
|
278
289
|
_context.t2 = _yield$onEmpty !== void 0;
|
|
279
|
-
case
|
|
290
|
+
case 50:
|
|
280
291
|
if (!_context.t2) {
|
|
281
|
-
_context.next =
|
|
292
|
+
_context.next = 54;
|
|
282
293
|
break;
|
|
283
294
|
}
|
|
284
295
|
_context.t4 = _yield$onEmpty;
|
|
285
|
-
_context.next =
|
|
296
|
+
_context.next = 55;
|
|
286
297
|
break;
|
|
287
|
-
case
|
|
298
|
+
case 54:
|
|
288
299
|
_context.t4 = [];
|
|
289
|
-
case
|
|
300
|
+
case 55:
|
|
290
301
|
_context.t1 = _context.t4;
|
|
291
|
-
_context.next =
|
|
302
|
+
_context.next = 59;
|
|
292
303
|
break;
|
|
293
|
-
case
|
|
304
|
+
case 58:
|
|
294
305
|
_context.t1 = transformedOptions;
|
|
295
|
-
case
|
|
306
|
+
case 59:
|
|
296
307
|
displayedUsers = _context.t1;
|
|
297
308
|
_this.setState(function (state) {
|
|
298
309
|
var applicable = state.query === _query;
|
|
@@ -314,10 +325,10 @@ var SmartUserPickerWithoutAnalytics = exports.SmartUserPickerWithoutAnalytics =
|
|
|
314
325
|
loading: loading
|
|
315
326
|
};
|
|
316
327
|
});
|
|
317
|
-
_context.next =
|
|
328
|
+
_context.next = 92;
|
|
318
329
|
break;
|
|
319
|
-
case
|
|
320
|
-
_context.prev =
|
|
330
|
+
case 63:
|
|
331
|
+
_context.prev = 63;
|
|
321
332
|
_context.t5 = _context["catch"](6);
|
|
322
333
|
is5xxEvent = checkIf500Event(_context.t5.statusCode);
|
|
323
334
|
if (!closed && !onError && is5xxEvent) {
|
|
@@ -330,35 +341,35 @@ var SmartUserPickerWithoutAnalytics = exports.SmartUserPickerWithoutAnalytics =
|
|
|
330
341
|
});
|
|
331
342
|
onErrorProducedError = false;
|
|
332
343
|
defaultUsers = [];
|
|
333
|
-
_context.prev =
|
|
344
|
+
_context.prev = 70;
|
|
334
345
|
if (!onError) {
|
|
335
|
-
_context.next =
|
|
346
|
+
_context.next = 80;
|
|
336
347
|
break;
|
|
337
348
|
}
|
|
338
|
-
_context.next =
|
|
349
|
+
_context.next = 74;
|
|
339
350
|
return onError(_context.t5, recommendationsRequest);
|
|
340
|
-
case
|
|
351
|
+
case 74:
|
|
341
352
|
_context.t7 = _context.sent;
|
|
342
353
|
if (_context.t7) {
|
|
343
|
-
_context.next =
|
|
354
|
+
_context.next = 77;
|
|
344
355
|
break;
|
|
345
356
|
}
|
|
346
357
|
_context.t7 = [];
|
|
347
|
-
case
|
|
358
|
+
case 77:
|
|
348
359
|
_context.t6 = _context.t7;
|
|
349
|
-
_context.next =
|
|
360
|
+
_context.next = 81;
|
|
350
361
|
break;
|
|
351
|
-
case
|
|
362
|
+
case 80:
|
|
352
363
|
_context.t6 = [];
|
|
353
|
-
case
|
|
364
|
+
case 81:
|
|
354
365
|
defaultUsers = _context.t6;
|
|
355
|
-
_context.next =
|
|
366
|
+
_context.next = 87;
|
|
356
367
|
break;
|
|
357
|
-
case
|
|
358
|
-
_context.prev =
|
|
359
|
-
_context.t8 = _context["catch"](
|
|
368
|
+
case 84:
|
|
369
|
+
_context.prev = 84;
|
|
370
|
+
_context.t8 = _context["catch"](70);
|
|
360
371
|
onErrorProducedError = true;
|
|
361
|
-
case
|
|
372
|
+
case 87:
|
|
362
373
|
if (onErrorProducedError && is5xxEvent) {
|
|
363
374
|
// Log error from fallback data source `onError` to UFO
|
|
364
375
|
_this.optionsShownUfoExperienceInstance.failure(ufoEndStateConfig(_this.props.fieldId));
|
|
@@ -375,11 +386,11 @@ var SmartUserPickerWithoutAnalytics = exports.SmartUserPickerWithoutAnalytics =
|
|
|
375
386
|
elapsedTimeMilli: _elapsedTimeMilli,
|
|
376
387
|
productAttributes: productAttributes
|
|
377
388
|
});
|
|
378
|
-
case
|
|
389
|
+
case 92:
|
|
379
390
|
case "end":
|
|
380
391
|
return _context.stop();
|
|
381
392
|
}
|
|
382
|
-
}, _callee, null, [[6,
|
|
393
|
+
}, _callee, null, [[6, 63], [70, 84]]);
|
|
383
394
|
})), (_this$props$debounceT = _this.props.debounceTime) !== null && _this$props$debounceT !== void 0 ? _this$props$debounceT : 0));
|
|
384
395
|
(0, _defineProperty2.default)(_this, "onInputChange", function (newQuery, sessionId) {
|
|
385
396
|
var query = newQuery || '';
|
|
@@ -551,6 +562,7 @@ var SmartUserPickerWithoutAnalytics = exports.SmartUserPickerWithoutAnalytics =
|
|
|
551
562
|
allowEmail = _this$props2.allowEmail,
|
|
552
563
|
enableEmailSearch = _this$props2.enableEmailSearch,
|
|
553
564
|
allowEmailSelectionWhenEmailMatched = _this$props2.allowEmailSelectionWhenEmailMatched,
|
|
565
|
+
fetchOptions = _this$props2.fetchOptions,
|
|
554
566
|
restProps = (0, _objectWithoutProperties2.default)(_this$props2, _excluded);
|
|
555
567
|
|
|
556
568
|
// Determine whether to allow email selection based on allowEmailSelectionWhenEmailMatched, if needed
|
|
@@ -96,6 +96,7 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
96
96
|
includeUsers,
|
|
97
97
|
includeNonLicensedUsers,
|
|
98
98
|
intl,
|
|
99
|
+
fetchOptions,
|
|
99
100
|
maxOptions,
|
|
100
101
|
objectId,
|
|
101
102
|
onEmpty,
|
|
@@ -154,7 +155,9 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
154
155
|
} = this.state;
|
|
155
156
|
this.fireEvent(requestUsersEvent);
|
|
156
157
|
let recommendedUsers;
|
|
157
|
-
if (fg('
|
|
158
|
+
if (fetchOptions && fg('smart-user-picker-load-options-gate')) {
|
|
159
|
+
recommendedUsers = await fetchOptions(query);
|
|
160
|
+
} else if (fg('twcg-444-invite-usd-improvements-m2-gate')) {
|
|
158
161
|
const userRecommendationsPromise = getUserRecommendations(recommendationsRequest, intl);
|
|
159
162
|
const userResolversPromises = (userResolvers !== null && userResolvers !== void 0 ? userResolvers : []).map(resolver => resolver(query).catch(error => {
|
|
160
163
|
this.fireEvent(failedUserResolversEvent, {
|
|
@@ -399,6 +402,7 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
399
402
|
allowEmail,
|
|
400
403
|
enableEmailSearch,
|
|
401
404
|
allowEmailSelectionWhenEmailMatched,
|
|
405
|
+
fetchOptions,
|
|
402
406
|
...restProps
|
|
403
407
|
} = this.props;
|
|
404
408
|
|
|
@@ -9,7 +9,7 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
9
9
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
10
10
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
11
11
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
12
|
-
var _excluded = ["allowEmail", "enableEmailSearch", "allowEmailSelectionWhenEmailMatched"];
|
|
12
|
+
var _excluded = ["allowEmail", "enableEmailSearch", "allowEmailSelectionWhenEmailMatched", "fetchOptions"];
|
|
13
13
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
14
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
15
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -110,12 +110,12 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
110
110
|
});
|
|
111
111
|
_defineProperty(_this, "memoizedFilterOptions", memoizeOne(_this.filterOptions));
|
|
112
112
|
_defineProperty(_this, "getUsers", debounce( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
113
|
-
var _this$state, query, sessionId, closed, _this$props, baseUrl, childObjectId, containerId, fieldId, includeGroups, includeTeams, includeTeamsUpdates, includeUsers, includeNonLicensedUsers, intl, maxOptions, objectId, onEmpty, onError, overrideByline, displayEmailInByline, orgId, principalId, productAttributes, productKey, searchQueryFilter, siteId, transformOptions, userResolvers, enableEmailSearch, maxNumberOfResults, startTime, isEmail, recommendationsRequest, _yield$onEmpty, _query, recommendedUsers, userRecommendationsPromise, userResolversPromises, _yield$Promise$all, _yield$Promise$all2, mainRecommendations, userResolverResults, _iterator, _step, option, _iterator2, _step2, _option, _iterator3, _step3, _option2, elapsedTimeMilli, transformedOptions, displayedUsers, is5xxEvent, onErrorProducedError, defaultUsers, _elapsedTimeMilli;
|
|
113
|
+
var _this$state, query, sessionId, closed, _this$props, baseUrl, childObjectId, containerId, fieldId, includeGroups, includeTeams, includeTeamsUpdates, includeUsers, includeNonLicensedUsers, intl, fetchOptions, maxOptions, objectId, onEmpty, onError, overrideByline, displayEmailInByline, orgId, principalId, productAttributes, productKey, searchQueryFilter, siteId, transformOptions, userResolvers, enableEmailSearch, maxNumberOfResults, startTime, isEmail, recommendationsRequest, _yield$onEmpty, _query, recommendedUsers, userRecommendationsPromise, userResolversPromises, _yield$Promise$all, _yield$Promise$all2, mainRecommendations, userResolverResults, _iterator, _step, option, _iterator2, _step2, _option, _iterator3, _step3, _option2, elapsedTimeMilli, transformedOptions, displayedUsers, is5xxEvent, onErrorProducedError, defaultUsers, _elapsedTimeMilli;
|
|
114
114
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
115
115
|
while (1) switch (_context.prev = _context.next) {
|
|
116
116
|
case 0:
|
|
117
117
|
_this$state = _this.state, query = _this$state.query, sessionId = _this$state.sessionId, closed = _this$state.closed;
|
|
118
|
-
_this$props = _this.props, baseUrl = _this$props.baseUrl, childObjectId = _this$props.childObjectId, containerId = _this$props.containerId, fieldId = _this$props.fieldId, includeGroups = _this$props.includeGroups, includeTeams = _this$props.includeTeams, includeTeamsUpdates = _this$props.includeTeamsUpdates, includeUsers = _this$props.includeUsers, includeNonLicensedUsers = _this$props.includeNonLicensedUsers, intl = _this$props.intl, maxOptions = _this$props.maxOptions, objectId = _this$props.objectId, onEmpty = _this$props.onEmpty, onError = _this$props.onError, overrideByline = _this$props.overrideByline, displayEmailInByline = _this$props.displayEmailInByline, orgId = _this$props.orgId, principalId = _this$props.principalId, productAttributes = _this$props.productAttributes, productKey = _this$props.productKey, searchQueryFilter = _this$props.searchQueryFilter, siteId = _this$props.siteId, transformOptions = _this$props.transformOptions, userResolvers = _this$props.userResolvers, enableEmailSearch = _this$props.enableEmailSearch;
|
|
118
|
+
_this$props = _this.props, baseUrl = _this$props.baseUrl, childObjectId = _this$props.childObjectId, containerId = _this$props.containerId, fieldId = _this$props.fieldId, includeGroups = _this$props.includeGroups, includeTeams = _this$props.includeTeams, includeTeamsUpdates = _this$props.includeTeamsUpdates, includeUsers = _this$props.includeUsers, includeNonLicensedUsers = _this$props.includeNonLicensedUsers, intl = _this$props.intl, fetchOptions = _this$props.fetchOptions, maxOptions = _this$props.maxOptions, objectId = _this$props.objectId, onEmpty = _this$props.onEmpty, onError = _this$props.onError, overrideByline = _this$props.overrideByline, displayEmailInByline = _this$props.displayEmailInByline, orgId = _this$props.orgId, principalId = _this$props.principalId, productAttributes = _this$props.productAttributes, productKey = _this$props.productKey, searchQueryFilter = _this$props.searchQueryFilter, siteId = _this$props.siteId, transformOptions = _this$props.transformOptions, userResolvers = _this$props.userResolvers, enableEmailSearch = _this$props.enableEmailSearch;
|
|
119
119
|
maxNumberOfResults = maxOptions || 100;
|
|
120
120
|
startTime = window.performance.now(); // Check if this is an email search
|
|
121
121
|
isEmail = enableEmailSearch && isEmailQuery(query);
|
|
@@ -152,8 +152,19 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
152
152
|
_context.prev = 6;
|
|
153
153
|
_query = _this.state.query;
|
|
154
154
|
_this.fireEvent(requestUsersEvent);
|
|
155
|
+
if (!(fetchOptions && fg('smart-user-picker-load-options-gate'))) {
|
|
156
|
+
_context.next = 15;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
_context.next = 12;
|
|
160
|
+
return fetchOptions(_query);
|
|
161
|
+
case 12:
|
|
162
|
+
recommendedUsers = _context.sent;
|
|
163
|
+
_context.next = 30;
|
|
164
|
+
break;
|
|
165
|
+
case 15:
|
|
155
166
|
if (!fg('twcg-444-invite-usd-improvements-m2-gate')) {
|
|
156
|
-
_context.next =
|
|
167
|
+
_context.next = 27;
|
|
157
168
|
break;
|
|
158
169
|
}
|
|
159
170
|
userRecommendationsPromise = getUserRecommendations(recommendationsRequest, intl);
|
|
@@ -166,22 +177,22 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
166
177
|
return [];
|
|
167
178
|
});
|
|
168
179
|
});
|
|
169
|
-
_context.next =
|
|
180
|
+
_context.next = 20;
|
|
170
181
|
return Promise.all([userRecommendationsPromise].concat(_toConsumableArray(userResolversPromises)));
|
|
171
|
-
case
|
|
182
|
+
case 20:
|
|
172
183
|
_yield$Promise$all = _context.sent;
|
|
173
184
|
_yield$Promise$all2 = _toArray(_yield$Promise$all);
|
|
174
185
|
mainRecommendations = _yield$Promise$all2[0];
|
|
175
186
|
userResolverResults = _yield$Promise$all2.slice(1);
|
|
176
187
|
recommendedUsers = [mainRecommendations].concat(_toConsumableArray(userResolverResults)).flat();
|
|
177
|
-
_context.next =
|
|
188
|
+
_context.next = 30;
|
|
178
189
|
break;
|
|
179
|
-
case
|
|
180
|
-
_context.next =
|
|
190
|
+
case 27:
|
|
191
|
+
_context.next = 29;
|
|
181
192
|
return getUserRecommendations(recommendationsRequest, intl);
|
|
182
|
-
case
|
|
193
|
+
case 29:
|
|
183
194
|
recommendedUsers = _context.sent;
|
|
184
|
-
case
|
|
195
|
+
case 30:
|
|
185
196
|
if (overrideByline) {
|
|
186
197
|
_iterator = _createForOfIteratorHelper(recommendedUsers);
|
|
187
198
|
try {
|
|
@@ -241,50 +252,50 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
241
252
|
}
|
|
242
253
|
elapsedTimeMilli = window.performance.now() - startTime;
|
|
243
254
|
if (!transformOptions) {
|
|
244
|
-
_context.next =
|
|
255
|
+
_context.next = 41;
|
|
245
256
|
break;
|
|
246
257
|
}
|
|
247
|
-
_context.next =
|
|
258
|
+
_context.next = 38;
|
|
248
259
|
return transformOptions(recommendedUsers, _query);
|
|
249
|
-
case
|
|
260
|
+
case 38:
|
|
250
261
|
_context.t0 = _context.sent;
|
|
251
|
-
_context.next =
|
|
262
|
+
_context.next = 42;
|
|
252
263
|
break;
|
|
253
|
-
case
|
|
264
|
+
case 41:
|
|
254
265
|
_context.t0 = recommendedUsers;
|
|
255
|
-
case
|
|
266
|
+
case 42:
|
|
256
267
|
transformedOptions = _context.t0;
|
|
257
268
|
if (!(transformedOptions.length === 0 && onEmpty)) {
|
|
258
|
-
_context.next =
|
|
269
|
+
_context.next = 58;
|
|
259
270
|
break;
|
|
260
271
|
}
|
|
261
|
-
_context.next =
|
|
272
|
+
_context.next = 46;
|
|
262
273
|
return onEmpty(_query);
|
|
263
|
-
case
|
|
274
|
+
case 46:
|
|
264
275
|
_context.t3 = _yield$onEmpty = _context.sent;
|
|
265
276
|
_context.t2 = _context.t3 !== null;
|
|
266
277
|
if (!_context.t2) {
|
|
267
|
-
_context.next =
|
|
278
|
+
_context.next = 50;
|
|
268
279
|
break;
|
|
269
280
|
}
|
|
270
281
|
_context.t2 = _yield$onEmpty !== void 0;
|
|
271
|
-
case
|
|
282
|
+
case 50:
|
|
272
283
|
if (!_context.t2) {
|
|
273
|
-
_context.next =
|
|
284
|
+
_context.next = 54;
|
|
274
285
|
break;
|
|
275
286
|
}
|
|
276
287
|
_context.t4 = _yield$onEmpty;
|
|
277
|
-
_context.next =
|
|
288
|
+
_context.next = 55;
|
|
278
289
|
break;
|
|
279
|
-
case
|
|
290
|
+
case 54:
|
|
280
291
|
_context.t4 = [];
|
|
281
|
-
case
|
|
292
|
+
case 55:
|
|
282
293
|
_context.t1 = _context.t4;
|
|
283
|
-
_context.next =
|
|
294
|
+
_context.next = 59;
|
|
284
295
|
break;
|
|
285
|
-
case
|
|
296
|
+
case 58:
|
|
286
297
|
_context.t1 = transformedOptions;
|
|
287
|
-
case
|
|
298
|
+
case 59:
|
|
288
299
|
displayedUsers = _context.t1;
|
|
289
300
|
_this.setState(function (state) {
|
|
290
301
|
var applicable = state.query === _query;
|
|
@@ -306,10 +317,10 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
306
317
|
loading: loading
|
|
307
318
|
};
|
|
308
319
|
});
|
|
309
|
-
_context.next =
|
|
320
|
+
_context.next = 92;
|
|
310
321
|
break;
|
|
311
|
-
case
|
|
312
|
-
_context.prev =
|
|
322
|
+
case 63:
|
|
323
|
+
_context.prev = 63;
|
|
313
324
|
_context.t5 = _context["catch"](6);
|
|
314
325
|
is5xxEvent = checkIf500Event(_context.t5.statusCode);
|
|
315
326
|
if (!closed && !onError && is5xxEvent) {
|
|
@@ -322,35 +333,35 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
322
333
|
});
|
|
323
334
|
onErrorProducedError = false;
|
|
324
335
|
defaultUsers = [];
|
|
325
|
-
_context.prev =
|
|
336
|
+
_context.prev = 70;
|
|
326
337
|
if (!onError) {
|
|
327
|
-
_context.next =
|
|
338
|
+
_context.next = 80;
|
|
328
339
|
break;
|
|
329
340
|
}
|
|
330
|
-
_context.next =
|
|
341
|
+
_context.next = 74;
|
|
331
342
|
return onError(_context.t5, recommendationsRequest);
|
|
332
|
-
case
|
|
343
|
+
case 74:
|
|
333
344
|
_context.t7 = _context.sent;
|
|
334
345
|
if (_context.t7) {
|
|
335
|
-
_context.next =
|
|
346
|
+
_context.next = 77;
|
|
336
347
|
break;
|
|
337
348
|
}
|
|
338
349
|
_context.t7 = [];
|
|
339
|
-
case
|
|
350
|
+
case 77:
|
|
340
351
|
_context.t6 = _context.t7;
|
|
341
|
-
_context.next =
|
|
352
|
+
_context.next = 81;
|
|
342
353
|
break;
|
|
343
|
-
case
|
|
354
|
+
case 80:
|
|
344
355
|
_context.t6 = [];
|
|
345
|
-
case
|
|
356
|
+
case 81:
|
|
346
357
|
defaultUsers = _context.t6;
|
|
347
|
-
_context.next =
|
|
358
|
+
_context.next = 87;
|
|
348
359
|
break;
|
|
349
|
-
case
|
|
350
|
-
_context.prev =
|
|
351
|
-
_context.t8 = _context["catch"](
|
|
360
|
+
case 84:
|
|
361
|
+
_context.prev = 84;
|
|
362
|
+
_context.t8 = _context["catch"](70);
|
|
352
363
|
onErrorProducedError = true;
|
|
353
|
-
case
|
|
364
|
+
case 87:
|
|
354
365
|
if (onErrorProducedError && is5xxEvent) {
|
|
355
366
|
// Log error from fallback data source `onError` to UFO
|
|
356
367
|
_this.optionsShownUfoExperienceInstance.failure(ufoEndStateConfig(_this.props.fieldId));
|
|
@@ -367,11 +378,11 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
367
378
|
elapsedTimeMilli: _elapsedTimeMilli,
|
|
368
379
|
productAttributes: productAttributes
|
|
369
380
|
});
|
|
370
|
-
case
|
|
381
|
+
case 92:
|
|
371
382
|
case "end":
|
|
372
383
|
return _context.stop();
|
|
373
384
|
}
|
|
374
|
-
}, _callee, null, [[6,
|
|
385
|
+
}, _callee, null, [[6, 63], [70, 84]]);
|
|
375
386
|
})), (_this$props$debounceT = _this.props.debounceTime) !== null && _this$props$debounceT !== void 0 ? _this$props$debounceT : 0));
|
|
376
387
|
_defineProperty(_this, "onInputChange", function (newQuery, sessionId) {
|
|
377
388
|
var query = newQuery || '';
|
|
@@ -543,6 +554,7 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
543
554
|
allowEmail = _this$props2.allowEmail,
|
|
544
555
|
enableEmailSearch = _this$props2.enableEmailSearch,
|
|
545
556
|
allowEmailSelectionWhenEmailMatched = _this$props2.allowEmailSelectionWhenEmailMatched,
|
|
557
|
+
fetchOptions = _this$props2.fetchOptions,
|
|
546
558
|
restProps = _objectWithoutProperties(_this$props2, _excluded);
|
|
547
559
|
|
|
548
560
|
// Determine whether to allow email selection based on allowEmailSelectionWhenEmailMatched, if needed
|
package/dist/types/types.d.ts
CHANGED
|
@@ -228,6 +228,12 @@ export interface SmartProps {
|
|
|
228
228
|
* Optional callback to provide additional user resolvers, such as for fetching and adding users from third party sources
|
|
229
229
|
*/
|
|
230
230
|
userResolvers?: Array<(query: string) => Promise<OptionData[]>>;
|
|
231
|
+
/**
|
|
232
|
+
* Custom fetcher function to load options. When provided, this function will be called
|
|
233
|
+
* instead of the default recommendation API. The function receives the search term
|
|
234
|
+
* and should return a Promise that resolves to an array of OptionData.
|
|
235
|
+
*/
|
|
236
|
+
fetchOptions?: (query: string) => Promise<OptionData[]>;
|
|
231
237
|
/**
|
|
232
238
|
* Whether to include teams UI updates in the resultset. @default false
|
|
233
239
|
*/
|
|
@@ -228,6 +228,12 @@ export interface SmartProps {
|
|
|
228
228
|
* Optional callback to provide additional user resolvers, such as for fetching and adding users from third party sources
|
|
229
229
|
*/
|
|
230
230
|
userResolvers?: Array<(query: string) => Promise<OptionData[]>>;
|
|
231
|
+
/**
|
|
232
|
+
* Custom fetcher function to load options. When provided, this function will be called
|
|
233
|
+
* instead of the default recommendation API. The function receives the search term
|
|
234
|
+
* and should return a Promise that resolves to an array of OptionData.
|
|
235
|
+
*/
|
|
236
|
+
fetchOptions?: (query: string) => Promise<OptionData[]>;
|
|
231
237
|
/**
|
|
232
238
|
* Whether to include teams UI updates in the resultset. @default false
|
|
233
239
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-user-picker",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.6.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/analytics-next": "^11.1.0",
|
|
39
39
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
40
40
|
"@atlaskit/ufo": "^0.4.0",
|
|
41
|
-
"@atlaskit/user-picker": "^11.
|
|
41
|
+
"@atlaskit/user-picker": "^11.18.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0",
|
|
43
43
|
"lodash": "^4.17.21",
|
|
44
44
|
"memoize-one": "^6.0.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"react-dom": "^18.2.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@atlaskit/select": "^21.
|
|
53
|
+
"@atlaskit/select": "^21.6.0",
|
|
54
54
|
"@atlaskit/util-data-test": "^18.3.0",
|
|
55
55
|
"@testing-library/dom": "^10.1.0",
|
|
56
56
|
"@testing-library/react": "^13.4.0",
|
|
@@ -63,6 +63,9 @@
|
|
|
63
63
|
"platform-feature-flags": {
|
|
64
64
|
"twcg-444-invite-usd-improvements-m2-gate": {
|
|
65
65
|
"type": "boolean"
|
|
66
|
+
},
|
|
67
|
+
"smart-user-picker-load-options-gate": {
|
|
68
|
+
"type": "boolean"
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
}
|