@atlaskit/smart-user-picker 6.7.0 → 6.8.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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlassian/smart-user-picker
2
2
 
3
+ ## 6.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#73914](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/73914) [`7acf8bb50dea`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7acf8bb50dea) - Added support for external users being returned by the user-recommendations service. Non-licensed users will have a `type` of `external_user` and have `isExternal` set to `true`. A new prop `overrideByline` was also added to allow for the byline to be customised as SmartUserPicker does not currently set any bylines on options.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
3
13
  ## 6.7.0
4
14
 
5
15
  ### Minor Changes
@@ -11,7 +11,7 @@ var _uuid = require("uuid");
11
11
  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; }
12
12
  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; }
13
13
  var packageName = "@atlaskit/smart-user-picker";
14
- var packageVersion = "6.7.0";
14
+ var packageVersion = "6.8.0";
15
15
  var startSession = exports.startSession = function startSession() {
16
16
  return {
17
17
  id: (0, _uuid.v4)(),
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
@@ -22,13 +23,18 @@ var _analyticsNext = require("@atlaskit/analytics-next");
22
23
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
23
24
  var _reactIntlNext = require("react-intl-next");
24
25
  var _ufo = require("@atlaskit/ufo");
25
- var _userPicker = _interopRequireDefault(require("@atlaskit/user-picker"));
26
+ var _userPicker = _interopRequireWildcard(require("@atlaskit/user-picker"));
26
27
  var _analytics = require("../analytics");
27
28
  var _MessagesIntlProvider = _interopRequireDefault(require("./MessagesIntlProvider"));
28
29
  var _service = require("../service");
29
30
  var _ufoExperiences = require("../ufoExperiences");
31
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
32
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
30
33
  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; }
31
34
  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; }
35
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
36
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
37
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
32
38
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
33
39
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
34
40
  var DEFAULT_DEBOUNCE_TIME_MS = 150;
@@ -105,12 +111,12 @@ var SmartUserPickerWithoutAnalytics = exports.SmartUserPickerWithoutAnalytics =
105
111
  });
106
112
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "memoizedFilterOptions", (0, _memoizeOne.default)(_this.filterOptions));
107
113
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getUsers", (0, _debounce.default)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
108
- var _this$state, query, sessionId, closed, _this$props, baseUrl, childObjectId, containerId, fieldId, includeGroups, includeTeams, includeUsers, includeNonLicensedUsers, intl, maxOptions, objectId, onEmpty, onError, orgId, principalId, productAttributes, productKey, searchQueryFilter, siteId, maxNumberOfResults, startTime, recommendationsRequest, _yield$onEmpty, recommendedUsers, elapsedTimeMilli, displayedUsers, is5xxEvent, onErrorProducedError, defaultUsers, _elapsedTimeMilli;
114
+ var _this$state, query, sessionId, closed, _this$props, baseUrl, childObjectId, containerId, fieldId, includeGroups, includeTeams, includeUsers, includeNonLicensedUsers, intl, maxOptions, objectId, onEmpty, onError, overrideByline, orgId, principalId, productAttributes, productKey, searchQueryFilter, siteId, maxNumberOfResults, startTime, recommendationsRequest, _yield$onEmpty, recommendedUsers, _iterator, _step, option, elapsedTimeMilli, displayedUsers, is5xxEvent, onErrorProducedError, defaultUsers, _elapsedTimeMilli;
109
115
  return _regenerator.default.wrap(function _callee$(_context) {
110
116
  while (1) switch (_context.prev = _context.next) {
111
117
  case 0:
112
118
  _this$state = _this.state, query = _this$state.query, sessionId = _this$state.sessionId, closed = _this$state.closed;
113
- _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, 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, orgId = _this$props.orgId, principalId = _this$props.principalId, productAttributes = _this$props.productAttributes, productKey = _this$props.productKey, searchQueryFilter = _this$props.searchQueryFilter, siteId = _this$props.siteId;
119
+ _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, 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, orgId = _this$props.orgId, principalId = _this$props.principalId, productAttributes = _this$props.productAttributes, productKey = _this$props.productKey, searchQueryFilter = _this$props.searchQueryFilter, siteId = _this$props.siteId;
114
120
  maxNumberOfResults = maxOptions || 100;
115
121
  startTime = window.performance.now();
116
122
  recommendationsRequest = {
@@ -141,38 +147,53 @@ var SmartUserPickerWithoutAnalytics = exports.SmartUserPickerWithoutAnalytics =
141
147
  return (0, _service.getUserRecommendations)(recommendationsRequest, intl);
142
148
  case 9:
143
149
  recommendedUsers = _context.sent;
150
+ if (overrideByline) {
151
+ _iterator = _createForOfIteratorHelper(recommendedUsers);
152
+ try {
153
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
154
+ option = _step.value;
155
+ if ((0, _userPicker.isUser)(option) || (0, _userPicker.isExternalUser)(option) || (0, _userPicker.isTeam)(option)) {
156
+ option.byline = overrideByline(option);
157
+ }
158
+ }
159
+ } catch (err) {
160
+ _iterator.e(err);
161
+ } finally {
162
+ _iterator.f();
163
+ }
164
+ }
144
165
  elapsedTimeMilli = window.performance.now() - startTime;
145
166
  if (!(recommendedUsers.length === 0 && onEmpty)) {
146
- _context.next = 26;
167
+ _context.next = 27;
147
168
  break;
148
169
  }
149
- _context.next = 14;
170
+ _context.next = 15;
150
171
  return onEmpty(query);
151
- case 14:
172
+ case 15:
152
173
  _context.t2 = _yield$onEmpty = _context.sent;
153
174
  _context.t1 = _context.t2 !== null;
154
175
  if (!_context.t1) {
155
- _context.next = 18;
176
+ _context.next = 19;
156
177
  break;
157
178
  }
158
179
  _context.t1 = _yield$onEmpty !== void 0;
159
- case 18:
180
+ case 19:
160
181
  if (!_context.t1) {
161
- _context.next = 22;
182
+ _context.next = 23;
162
183
  break;
163
184
  }
164
185
  _context.t3 = _yield$onEmpty;
165
- _context.next = 23;
186
+ _context.next = 24;
166
187
  break;
167
- case 22:
168
- _context.t3 = [];
169
188
  case 23:
189
+ _context.t3 = [];
190
+ case 24:
170
191
  _context.t0 = _context.t3;
171
- _context.next = 27;
192
+ _context.next = 28;
172
193
  break;
173
- case 26:
174
- _context.t0 = recommendedUsers;
175
194
  case 27:
195
+ _context.t0 = recommendedUsers;
196
+ case 28:
176
197
  displayedUsers = _context.t0;
177
198
  _this.setState(function (state) {
178
199
  var applicable = state.query === query;
@@ -190,10 +211,10 @@ var SmartUserPickerWithoutAnalytics = exports.SmartUserPickerWithoutAnalytics =
190
211
  loading: loading
191
212
  };
192
213
  });
193
- _context.next = 60;
214
+ _context.next = 61;
194
215
  break;
195
- case 31:
196
- _context.prev = 31;
216
+ case 32:
217
+ _context.prev = 32;
197
218
  _context.t4 = _context["catch"](5);
198
219
  is5xxEvent = checkIf500Event(_context.t4.statusCode);
199
220
  if (!closed && !onError && is5xxEvent) {
@@ -206,35 +227,35 @@ var SmartUserPickerWithoutAnalytics = exports.SmartUserPickerWithoutAnalytics =
206
227
  });
207
228
  onErrorProducedError = false;
208
229
  defaultUsers = [];
209
- _context.prev = 38;
230
+ _context.prev = 39;
210
231
  if (!onError) {
211
- _context.next = 48;
232
+ _context.next = 49;
212
233
  break;
213
234
  }
214
- _context.next = 42;
235
+ _context.next = 43;
215
236
  return onError(_context.t4, recommendationsRequest);
216
- case 42:
237
+ case 43:
217
238
  _context.t6 = _context.sent;
218
239
  if (_context.t6) {
219
- _context.next = 45;
240
+ _context.next = 46;
220
241
  break;
221
242
  }
222
243
  _context.t6 = [];
223
- case 45:
244
+ case 46:
224
245
  _context.t5 = _context.t6;
225
- _context.next = 49;
246
+ _context.next = 50;
226
247
  break;
227
- case 48:
228
- _context.t5 = [];
229
248
  case 49:
249
+ _context.t5 = [];
250
+ case 50:
230
251
  defaultUsers = _context.t5;
231
- _context.next = 55;
252
+ _context.next = 56;
232
253
  break;
233
- case 52:
234
- _context.prev = 52;
235
- _context.t7 = _context["catch"](38);
254
+ case 53:
255
+ _context.prev = 53;
256
+ _context.t7 = _context["catch"](39);
236
257
  onErrorProducedError = true;
237
- case 55:
258
+ case 56:
238
259
  if (onErrorProducedError && is5xxEvent) {
239
260
  // Log error from fallback data source `onError` to UFO
240
261
  _this.optionsShownUfoExperienceInstance.failure(ufoEndStateConfig(_this.props.fieldId));
@@ -251,11 +272,11 @@ var SmartUserPickerWithoutAnalytics = exports.SmartUserPickerWithoutAnalytics =
251
272
  elapsedTimeMilli: _elapsedTimeMilli,
252
273
  productAttributes: productAttributes
253
274
  });
254
- case 60:
275
+ case 61:
255
276
  case "end":
256
277
  return _context.stop();
257
278
  }
258
- }, _callee, null, [[5, 31], [38, 52]]);
279
+ }, _callee, null, [[5, 32], [39, 53]]);
259
280
  })), (_this$props$debounceT = _this.props.debounceTime) !== null && _this$props$debounceT !== void 0 ? _this$props$debounceT : 0));
260
281
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onInputChange", function (newQuery, sessionId) {
261
282
  var query = newQuery || '';
@@ -6,19 +6,14 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.transformUsers = void 0;
7
7
  var _userPicker = require("@atlaskit/user-picker");
8
8
  var _i18n = require("../i18n");
9
- var EntityType = /*#__PURE__*/function (EntityType) {
10
- EntityType["USER"] = "USER";
11
- EntityType["TEAM"] = "TEAM";
12
- EntityType["GROUP"] = "GROUP";
13
- return EntityType;
14
- }(EntityType || {});
9
+ var _types = require("../types");
15
10
  var getLozenzeProperties = function getLozenzeProperties(entity, intl) {
16
11
  var _entity$attributes, _entity$attributes2;
17
12
  if ((_entity$attributes = entity.attributes) !== null && _entity$attributes !== void 0 && _entity$attributes.workspaceMember) {
18
13
  return intl.formatMessage(_i18n.messages.memberLozengeText);
19
14
  }
20
15
  if ((_entity$attributes2 = entity.attributes) !== null && _entity$attributes2 !== void 0 && _entity$attributes2.isConfluenceExternalCollaborator) {
21
- var lozengeTooltipMessage = entity.entityType === EntityType.GROUP ? _i18n.messages.guestGroupLozengeTooltip : _i18n.messages.guestUserLozengeTooltip;
16
+ var lozengeTooltipMessage = entity.entityType === _types.EntityType.GROUP ? _i18n.messages.guestGroupLozengeTooltip : _i18n.messages.guestUserLozengeTooltip;
22
17
  return {
23
18
  text: intl.formatMessage(_i18n.messages.guestLozengeText),
24
19
  tooltip: intl.formatMessage(lozengeTooltipMessage),
@@ -29,21 +24,23 @@ var getLozenzeProperties = function getLozenzeProperties(entity, intl) {
29
24
  };
30
25
  var transformUser = function transformUser(item, intl) {
31
26
  var type = item.entityType;
32
- if (type === EntityType.USER) {
27
+ if (type === _types.EntityType.USER) {
33
28
  var user = item;
34
29
  var lozenge = getLozenzeProperties(user, intl);
35
30
  return {
36
31
  id: user.id,
37
- type: _userPicker.UserType,
32
+ type: user.nonLicensedUser ? _userPicker.ExternalUserType : _userPicker.UserType,
38
33
  avatarUrl: user.avatarUrl,
39
34
  name: user.name,
40
35
  email: user.email,
41
36
  title: user.title,
42
37
  lozenge: lozenge,
43
- tooltip: user.name
38
+ tooltip: user.name,
39
+ isExternal: Boolean(user.nonLicensedUser),
40
+ sources: user.nonLicensedUser ? ['other-atlassian'] : undefined
44
41
  };
45
42
  }
46
- if (type === EntityType.TEAM) {
43
+ if (type === _types.EntityType.TEAM) {
47
44
  var team = item;
48
45
  return {
49
46
  id: team.id,
@@ -57,7 +54,7 @@ var transformUser = function transformUser(item, intl) {
57
54
  tooltip: team.displayName
58
55
  };
59
56
  }
60
- if (type === EntityType.GROUP) {
57
+ if (type === _types.EntityType.GROUP) {
61
58
  var group = item;
62
59
  var _lozenge = getLozenzeProperties(group, intl);
63
60
  return {
@@ -1,7 +1,7 @@
1
1
  import { createAndFireEvent } from '@atlaskit/analytics-next';
2
2
  import { v4 as uuid } from 'uuid';
3
3
  const packageName = "@atlaskit/smart-user-picker";
4
- const packageVersion = "6.7.0";
4
+ const packageVersion = "6.8.0";
5
5
  export const startSession = () => ({
6
6
  id: uuid(),
7
7
  start: Date.now(),
@@ -7,7 +7,7 @@ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
7
7
  import memoizeOne from 'memoize-one';
8
8
  import { injectIntl } from 'react-intl-next';
9
9
  import { UFOExperienceState } from '@atlaskit/ufo';
10
- import UserPicker from '@atlaskit/user-picker';
10
+ import UserPicker, { isExternalUser, isTeam, isUser } from '@atlaskit/user-picker';
11
11
  import { requestUsersEvent, filterUsersEvent, preparedUsersLoadedEvent, successfulRequestUsersEvent, failedRequestUsersEvent, mountedWithPrefetchEvent, createAndFireEventInElementsChannel } from '../analytics';
12
12
  import MessagesIntlProvider from './MessagesIntlProvider';
13
13
  import { getUserRecommendations, hydrateDefaultValues } from '../service';
@@ -91,6 +91,7 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
91
91
  objectId,
92
92
  onEmpty,
93
93
  onError,
94
+ overrideByline,
94
95
  orgId,
95
96
  principalId,
96
97
  productAttributes,
@@ -126,6 +127,13 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
126
127
  var _await$onEmpty;
127
128
  this.fireEvent(requestUsersEvent);
128
129
  const recommendedUsers = await getUserRecommendations(recommendationsRequest, intl);
130
+ if (overrideByline) {
131
+ for (let option of recommendedUsers) {
132
+ if (isUser(option) || isExternalUser(option) || isTeam(option)) {
133
+ option.byline = overrideByline(option);
134
+ }
135
+ }
136
+ }
129
137
  const elapsedTimeMilli = window.performance.now() - startTime;
130
138
  const displayedUsers = recommendedUsers.length === 0 && onEmpty ? (_await$onEmpty = await onEmpty(query)) !== null && _await$onEmpty !== void 0 ? _await$onEmpty : [] : recommendedUsers;
131
139
  this.setState(state => {
@@ -1,11 +1,6 @@
1
- import { TeamType, UserType, GroupType } from '@atlaskit/user-picker';
1
+ import { ExternalUserType, GroupType, TeamType, UserType } from '@atlaskit/user-picker';
2
2
  import { messages } from '../i18n';
3
- var EntityType = /*#__PURE__*/function (EntityType) {
4
- EntityType["USER"] = "USER";
5
- EntityType["TEAM"] = "TEAM";
6
- EntityType["GROUP"] = "GROUP";
7
- return EntityType;
8
- }(EntityType || {});
3
+ import { EntityType } from '../types';
9
4
  const getLozenzeProperties = (entity, intl) => {
10
5
  var _entity$attributes, _entity$attributes2;
11
6
  if ((_entity$attributes = entity.attributes) !== null && _entity$attributes !== void 0 && _entity$attributes.workspaceMember) {
@@ -28,13 +23,15 @@ const transformUser = (item, intl) => {
28
23
  const lozenge = getLozenzeProperties(user, intl);
29
24
  return {
30
25
  id: user.id,
31
- type: UserType,
26
+ type: user.nonLicensedUser ? ExternalUserType : UserType,
32
27
  avatarUrl: user.avatarUrl,
33
28
  name: user.name,
34
29
  email: user.email,
35
30
  title: user.title,
36
31
  lozenge: lozenge,
37
- tooltip: user.name
32
+ tooltip: user.name,
33
+ isExternal: Boolean(user.nonLicensedUser),
34
+ sources: user.nonLicensedUser ? ['other-atlassian'] : undefined
38
35
  };
39
36
  }
40
37
  if (type === EntityType.TEAM) {
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { createAndFireEvent } from '@atlaskit/analytics-next';
5
5
  import { v4 as uuid } from 'uuid';
6
6
  var packageName = "@atlaskit/smart-user-picker";
7
- var packageVersion = "6.7.0";
7
+ var packageVersion = "6.8.0";
8
8
  export var startSession = function startSession() {
9
9
  return {
10
10
  id: uuid(),
@@ -10,6 +10,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
10
  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; }
11
11
  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; }
12
12
  import _regeneratorRuntime from "@babel/runtime/regenerator";
13
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
14
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
16
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
17
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
15
18
  import React from 'react';
@@ -19,7 +22,7 @@ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
19
22
  import memoizeOne from 'memoize-one';
20
23
  import { injectIntl } from 'react-intl-next';
21
24
  import { UFOExperienceState } from '@atlaskit/ufo';
22
- import UserPicker from '@atlaskit/user-picker';
25
+ import UserPicker, { isExternalUser, isTeam, isUser } from '@atlaskit/user-picker';
23
26
  import { requestUsersEvent, filterUsersEvent, preparedUsersLoadedEvent, successfulRequestUsersEvent, failedRequestUsersEvent, mountedWithPrefetchEvent, createAndFireEventInElementsChannel } from '../analytics';
24
27
  import MessagesIntlProvider from './MessagesIntlProvider';
25
28
  import { getUserRecommendations, hydrateDefaultValues } from '../service';
@@ -98,12 +101,12 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
98
101
  });
99
102
  _defineProperty(_assertThisInitialized(_this), "memoizedFilterOptions", memoizeOne(_this.filterOptions));
100
103
  _defineProperty(_assertThisInitialized(_this), "getUsers", debounce( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
101
- var _this$state, query, sessionId, closed, _this$props, baseUrl, childObjectId, containerId, fieldId, includeGroups, includeTeams, includeUsers, includeNonLicensedUsers, intl, maxOptions, objectId, onEmpty, onError, orgId, principalId, productAttributes, productKey, searchQueryFilter, siteId, maxNumberOfResults, startTime, recommendationsRequest, _yield$onEmpty, recommendedUsers, elapsedTimeMilli, displayedUsers, is5xxEvent, onErrorProducedError, defaultUsers, _elapsedTimeMilli;
104
+ var _this$state, query, sessionId, closed, _this$props, baseUrl, childObjectId, containerId, fieldId, includeGroups, includeTeams, includeUsers, includeNonLicensedUsers, intl, maxOptions, objectId, onEmpty, onError, overrideByline, orgId, principalId, productAttributes, productKey, searchQueryFilter, siteId, maxNumberOfResults, startTime, recommendationsRequest, _yield$onEmpty, recommendedUsers, _iterator, _step, option, elapsedTimeMilli, displayedUsers, is5xxEvent, onErrorProducedError, defaultUsers, _elapsedTimeMilli;
102
105
  return _regeneratorRuntime.wrap(function _callee$(_context) {
103
106
  while (1) switch (_context.prev = _context.next) {
104
107
  case 0:
105
108
  _this$state = _this.state, query = _this$state.query, sessionId = _this$state.sessionId, closed = _this$state.closed;
106
- _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, 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, orgId = _this$props.orgId, principalId = _this$props.principalId, productAttributes = _this$props.productAttributes, productKey = _this$props.productKey, searchQueryFilter = _this$props.searchQueryFilter, siteId = _this$props.siteId;
109
+ _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, 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, orgId = _this$props.orgId, principalId = _this$props.principalId, productAttributes = _this$props.productAttributes, productKey = _this$props.productKey, searchQueryFilter = _this$props.searchQueryFilter, siteId = _this$props.siteId;
107
110
  maxNumberOfResults = maxOptions || 100;
108
111
  startTime = window.performance.now();
109
112
  recommendationsRequest = {
@@ -134,38 +137,53 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
134
137
  return getUserRecommendations(recommendationsRequest, intl);
135
138
  case 9:
136
139
  recommendedUsers = _context.sent;
140
+ if (overrideByline) {
141
+ _iterator = _createForOfIteratorHelper(recommendedUsers);
142
+ try {
143
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
144
+ option = _step.value;
145
+ if (isUser(option) || isExternalUser(option) || isTeam(option)) {
146
+ option.byline = overrideByline(option);
147
+ }
148
+ }
149
+ } catch (err) {
150
+ _iterator.e(err);
151
+ } finally {
152
+ _iterator.f();
153
+ }
154
+ }
137
155
  elapsedTimeMilli = window.performance.now() - startTime;
138
156
  if (!(recommendedUsers.length === 0 && onEmpty)) {
139
- _context.next = 26;
157
+ _context.next = 27;
140
158
  break;
141
159
  }
142
- _context.next = 14;
160
+ _context.next = 15;
143
161
  return onEmpty(query);
144
- case 14:
162
+ case 15:
145
163
  _context.t2 = _yield$onEmpty = _context.sent;
146
164
  _context.t1 = _context.t2 !== null;
147
165
  if (!_context.t1) {
148
- _context.next = 18;
166
+ _context.next = 19;
149
167
  break;
150
168
  }
151
169
  _context.t1 = _yield$onEmpty !== void 0;
152
- case 18:
170
+ case 19:
153
171
  if (!_context.t1) {
154
- _context.next = 22;
172
+ _context.next = 23;
155
173
  break;
156
174
  }
157
175
  _context.t3 = _yield$onEmpty;
158
- _context.next = 23;
176
+ _context.next = 24;
159
177
  break;
160
- case 22:
161
- _context.t3 = [];
162
178
  case 23:
179
+ _context.t3 = [];
180
+ case 24:
163
181
  _context.t0 = _context.t3;
164
- _context.next = 27;
182
+ _context.next = 28;
165
183
  break;
166
- case 26:
167
- _context.t0 = recommendedUsers;
168
184
  case 27:
185
+ _context.t0 = recommendedUsers;
186
+ case 28:
169
187
  displayedUsers = _context.t0;
170
188
  _this.setState(function (state) {
171
189
  var applicable = state.query === query;
@@ -183,10 +201,10 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
183
201
  loading: loading
184
202
  };
185
203
  });
186
- _context.next = 60;
204
+ _context.next = 61;
187
205
  break;
188
- case 31:
189
- _context.prev = 31;
206
+ case 32:
207
+ _context.prev = 32;
190
208
  _context.t4 = _context["catch"](5);
191
209
  is5xxEvent = checkIf500Event(_context.t4.statusCode);
192
210
  if (!closed && !onError && is5xxEvent) {
@@ -199,35 +217,35 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
199
217
  });
200
218
  onErrorProducedError = false;
201
219
  defaultUsers = [];
202
- _context.prev = 38;
220
+ _context.prev = 39;
203
221
  if (!onError) {
204
- _context.next = 48;
222
+ _context.next = 49;
205
223
  break;
206
224
  }
207
- _context.next = 42;
225
+ _context.next = 43;
208
226
  return onError(_context.t4, recommendationsRequest);
209
- case 42:
227
+ case 43:
210
228
  _context.t6 = _context.sent;
211
229
  if (_context.t6) {
212
- _context.next = 45;
230
+ _context.next = 46;
213
231
  break;
214
232
  }
215
233
  _context.t6 = [];
216
- case 45:
234
+ case 46:
217
235
  _context.t5 = _context.t6;
218
- _context.next = 49;
236
+ _context.next = 50;
219
237
  break;
220
- case 48:
221
- _context.t5 = [];
222
238
  case 49:
239
+ _context.t5 = [];
240
+ case 50:
223
241
  defaultUsers = _context.t5;
224
- _context.next = 55;
242
+ _context.next = 56;
225
243
  break;
226
- case 52:
227
- _context.prev = 52;
228
- _context.t7 = _context["catch"](38);
244
+ case 53:
245
+ _context.prev = 53;
246
+ _context.t7 = _context["catch"](39);
229
247
  onErrorProducedError = true;
230
- case 55:
248
+ case 56:
231
249
  if (onErrorProducedError && is5xxEvent) {
232
250
  // Log error from fallback data source `onError` to UFO
233
251
  _this.optionsShownUfoExperienceInstance.failure(ufoEndStateConfig(_this.props.fieldId));
@@ -244,11 +262,11 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
244
262
  elapsedTimeMilli: _elapsedTimeMilli,
245
263
  productAttributes: productAttributes
246
264
  });
247
- case 60:
265
+ case 61:
248
266
  case "end":
249
267
  return _context.stop();
250
268
  }
251
- }, _callee, null, [[5, 31], [38, 52]]);
269
+ }, _callee, null, [[5, 32], [39, 53]]);
252
270
  })), (_this$props$debounceT = _this.props.debounceTime) !== null && _this$props$debounceT !== void 0 ? _this$props$debounceT : 0));
253
271
  _defineProperty(_assertThisInitialized(_this), "onInputChange", function (newQuery, sessionId) {
254
272
  var query = newQuery || '';
@@ -1,11 +1,6 @@
1
- import { TeamType, UserType, GroupType } from '@atlaskit/user-picker';
1
+ import { ExternalUserType, GroupType, TeamType, UserType } from '@atlaskit/user-picker';
2
2
  import { messages } from '../i18n';
3
- var EntityType = /*#__PURE__*/function (EntityType) {
4
- EntityType["USER"] = "USER";
5
- EntityType["TEAM"] = "TEAM";
6
- EntityType["GROUP"] = "GROUP";
7
- return EntityType;
8
- }(EntityType || {});
3
+ import { EntityType } from '../types';
9
4
  var getLozenzeProperties = function getLozenzeProperties(entity, intl) {
10
5
  var _entity$attributes, _entity$attributes2;
11
6
  if ((_entity$attributes = entity.attributes) !== null && _entity$attributes !== void 0 && _entity$attributes.workspaceMember) {
@@ -28,13 +23,15 @@ var transformUser = function transformUser(item, intl) {
28
23
  var lozenge = getLozenzeProperties(user, intl);
29
24
  return {
30
25
  id: user.id,
31
- type: UserType,
26
+ type: user.nonLicensedUser ? ExternalUserType : UserType,
32
27
  avatarUrl: user.avatarUrl,
33
28
  name: user.name,
34
29
  email: user.email,
35
30
  title: user.title,
36
31
  lozenge: lozenge,
37
- tooltip: user.name
32
+ tooltip: user.name,
33
+ isExternal: Boolean(user.nonLicensedUser),
34
+ sources: user.nonLicensedUser ? ['other-atlassian'] : undefined
38
35
  };
39
36
  }
40
37
  if (type === EntityType.TEAM) {
@@ -1,5 +1,6 @@
1
1
  import { OptionData } from '@atlaskit/user-picker';
2
2
  import { IntlShape } from 'react-intl-next';
3
+ import { EntityType } from '../types';
3
4
  interface ServerItem {
4
5
  id: string;
5
6
  name?: string;
@@ -14,10 +15,5 @@ interface ServerResponse {
14
15
  recommendedUsers: ServerItem[];
15
16
  intl: IntlShape;
16
17
  }
17
- declare enum EntityType {
18
- USER = "USER",
19
- TEAM = "TEAM",
20
- GROUP = "GROUP"
21
- }
22
18
  export declare const transformUsers: (serverResponse: ServerResponse, intl: IntlShape) => OptionData[];
23
19
  export {};
@@ -1,5 +1,5 @@
1
1
  import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
2
- import { DefaultValue, OptionData, UserPickerProps } from '@atlaskit/user-picker';
2
+ import { DefaultValue, ExternalUser, OptionData, Team, User, UserPickerProps } from '@atlaskit/user-picker';
3
3
  export interface Context {
4
4
  containerId?: string;
5
5
  contextType: string;
@@ -70,11 +70,13 @@ export interface RecommendationItem {
70
70
  description?: string;
71
71
  teamAri?: string;
72
72
  displayName?: string;
73
+ nonLicensedUser?: boolean;
73
74
  }
74
75
  export interface RecommendationResponse {
75
76
  errors?: any[];
76
77
  recommendedUsers: RecommendationItem[];
77
78
  }
79
+ export type OverrideByline = (option: User | ExternalUser | Team) => string;
78
80
  export interface SmartProps {
79
81
  /**
80
82
  * The base URL of the site eg: hello.atlassian.net
@@ -145,6 +147,11 @@ export interface SmartProps {
145
147
  * Error handler used to provide OptionData[] values when the server fails to hydrate the `defaultValue` prop's values.
146
148
  */
147
149
  onValueError?: OnValueError;
150
+ /**
151
+ * Function to generate the byline of each option. The server response is
152
+ * provided as an argument to the function.
153
+ */
154
+ overrideByline?: OverrideByline;
148
155
  /**
149
156
  * Prefetch the list of suggested assignees before the user picker is focused.
150
157
  * WARNING: please consider carefully before deciding to prefetch your suggestions
@@ -1,5 +1,6 @@
1
1
  import { OptionData } from '@atlaskit/user-picker';
2
2
  import { IntlShape } from 'react-intl-next';
3
+ import { EntityType } from '../types';
3
4
  interface ServerItem {
4
5
  id: string;
5
6
  name?: string;
@@ -14,10 +15,5 @@ interface ServerResponse {
14
15
  recommendedUsers: ServerItem[];
15
16
  intl: IntlShape;
16
17
  }
17
- declare enum EntityType {
18
- USER = "USER",
19
- TEAM = "TEAM",
20
- GROUP = "GROUP"
21
- }
22
18
  export declare const transformUsers: (serverResponse: ServerResponse, intl: IntlShape) => OptionData[];
23
19
  export {};
@@ -1,5 +1,5 @@
1
1
  import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
2
- import { DefaultValue, OptionData, UserPickerProps } from '@atlaskit/user-picker';
2
+ import { DefaultValue, ExternalUser, OptionData, Team, User, UserPickerProps } from '@atlaskit/user-picker';
3
3
  export interface Context {
4
4
  containerId?: string;
5
5
  contextType: string;
@@ -70,11 +70,13 @@ export interface RecommendationItem {
70
70
  description?: string;
71
71
  teamAri?: string;
72
72
  displayName?: string;
73
+ nonLicensedUser?: boolean;
73
74
  }
74
75
  export interface RecommendationResponse {
75
76
  errors?: any[];
76
77
  recommendedUsers: RecommendationItem[];
77
78
  }
79
+ export type OverrideByline = (option: User | ExternalUser | Team) => string;
78
80
  export interface SmartProps {
79
81
  /**
80
82
  * The base URL of the site eg: hello.atlassian.net
@@ -145,6 +147,11 @@ export interface SmartProps {
145
147
  * Error handler used to provide OptionData[] values when the server fails to hydrate the `defaultValue` prop's values.
146
148
  */
147
149
  onValueError?: OnValueError;
150
+ /**
151
+ * Function to generate the byline of each option. The server response is
152
+ * provided as an argument to the function.
153
+ */
154
+ overrideByline?: OverrideByline;
148
155
  /**
149
156
  * Prefetch the list of suggested assignees before the user picker is focused.
150
157
  * WARNING: please consider carefully before deciding to prefetch your suggestions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-user-picker",
3
- "version": "6.7.0",
3
+ "version": "6.8.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/"
6
6
  },
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "@atlaskit/analytics-next": "^9.2.0",
38
38
  "@atlaskit/ufo": "^0.2.0",
39
- "@atlaskit/user-picker": "^10.16.0",
39
+ "@atlaskit/user-picker": "^10.17.0",
40
40
  "@babel/runtime": "^7.0.0",
41
41
  "lodash": "^4.17.21",
42
42
  "memoize-one": "^6.0.0",
@@ -48,7 +48,7 @@
48
48
  "react-dom": "^16.8.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@atlaskit/select": "^17.0.3",
51
+ "@atlaskit/select": "^17.1.0",
52
52
  "@atlaskit/util-data-test": "^17.9.0",
53
53
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
54
54
  "enzyme": "^3.10.0",