@atlaskit/user-picker 8.8.4 → 9.0.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 +26 -0
- package/dist/cjs/analytics.js +1 -84
- package/dist/cjs/components/EmailOption/main.js +2 -2
- package/dist/cjs/components/ExternalUserOption/InfoIcon.js +1 -1
- package/dist/cjs/components/ExternalUserOption/main.js +2 -2
- package/dist/cjs/components/GroupOption/main.js +2 -2
- package/dist/cjs/components/TeamOption/main.js +2 -2
- package/dist/cjs/components/UserOption.js +3 -3
- package/dist/cjs/components/i18n.js +1 -1
- package/dist/cjs/index.js +0 -26
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics.js +0 -62
- package/dist/es2019/components/EmailOption/main.js +2 -2
- package/dist/es2019/components/ExternalUserOption/InfoIcon.js +1 -1
- package/dist/es2019/components/ExternalUserOption/main.js +2 -2
- package/dist/es2019/components/GroupOption/main.js +2 -2
- package/dist/es2019/components/TeamOption/main.js +2 -2
- package/dist/es2019/components/UserOption.js +3 -3
- package/dist/es2019/components/i18n.js +1 -1
- package/dist/es2019/index.js +0 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics.js +0 -66
- package/dist/esm/components/EmailOption/main.js +2 -2
- package/dist/esm/components/ExternalUserOption/InfoIcon.js +1 -1
- package/dist/esm/components/ExternalUserOption/main.js +2 -2
- package/dist/esm/components/GroupOption/main.js +2 -2
- package/dist/esm/components/TeamOption/main.js +2 -2
- package/dist/esm/components/UserOption.js +3 -3
- package/dist/esm/components/i18n.js +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics.d.ts +0 -10
- package/dist/types/components/BaseUserPicker.d.ts +1 -1
- package/dist/types/components/PopupUserPicker.d.ts +1 -1
- package/dist/types/components/UserPicker.d.ts +1 -1
- package/dist/types/index.d.ts +0 -2
- package/docs/1-smart-user-picker.tsx +1 -1
- package/package.json +2 -2
- package/dist/cjs/components/smart-user-picker/components/index.js +0 -602
- package/dist/cjs/components/smart-user-picker/config/index.js +0 -50
- package/dist/cjs/components/smart-user-picker/index.js +0 -41
- package/dist/cjs/components/smart-user-picker/service/UsersClient.js +0 -85
- package/dist/cjs/components/smart-user-picker/service/index.js +0 -15
- package/dist/cjs/components/smart-user-picker/service/recommendationClient.js +0 -75
- package/dist/cjs/components/smart-user-picker/service/users-transformer.js +0 -98
- package/dist/es2019/components/smart-user-picker/components/index.js +0 -398
- package/dist/es2019/components/smart-user-picker/config/index.js +0 -37
- package/dist/es2019/components/smart-user-picker/index.js +0 -7
- package/dist/es2019/components/smart-user-picker/service/UsersClient.js +0 -65
- package/dist/es2019/components/smart-user-picker/service/index.js +0 -1
- package/dist/es2019/components/smart-user-picker/service/recommendationClient.js +0 -56
- package/dist/es2019/components/smart-user-picker/service/users-transformer.js +0 -77
- package/dist/esm/components/smart-user-picker/components/index.js +0 -582
- package/dist/esm/components/smart-user-picker/config/index.js +0 -38
- package/dist/esm/components/smart-user-picker/index.js +0 -7
- package/dist/esm/components/smart-user-picker/service/UsersClient.js +0 -79
- package/dist/esm/components/smart-user-picker/service/index.js +0 -1
- package/dist/esm/components/smart-user-picker/service/recommendationClient.js +0 -64
- package/dist/esm/components/smart-user-picker/service/users-transformer.js +0 -87
- package/dist/types/components/smart-user-picker/components/index.d.ts +0 -196
- package/dist/types/components/smart-user-picker/config/index.d.ts +0 -17
- package/dist/types/components/smart-user-picker/index.d.ts +0 -8
- package/dist/types/components/smart-user-picker/service/UsersClient.d.ts +0 -14
- package/dist/types/components/smart-user-picker/service/index.d.ts +0 -1
- package/dist/types/components/smart-user-picker/service/recommendationClient.d.ts +0 -23
- package/dist/types/components/smart-user-picker/service/users-transformer.d.ts +0 -25
|
@@ -1,582 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
11
|
-
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
-
|
|
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); }; }
|
|
17
|
-
|
|
18
|
-
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; } }
|
|
19
|
-
|
|
20
|
-
import React from 'react';
|
|
21
|
-
import debounce from 'lodash/debounce';
|
|
22
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
23
|
-
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
24
|
-
import memoizeOne from 'memoize-one';
|
|
25
|
-
import { injectIntl } from 'react-intl-next';
|
|
26
|
-
import { requestUsersEvent, filterUsersEvent, preparedUsersLoadedEvent, successfulRequestUsersEvent, failedRequestUsersEvent, mountedWithPrefetchEvent, createAndFireEventInElementsChannel } from '../../../analytics';
|
|
27
|
-
import { UserType } from '../../../types';
|
|
28
|
-
import { UserPicker } from '../../UserPicker';
|
|
29
|
-
import getUserRecommendations from '../service/recommendationClient';
|
|
30
|
-
import getUsersById from '../service/UsersClient';
|
|
31
|
-
import MessagesIntlProvider from '../../MessagesIntlProvider';
|
|
32
|
-
|
|
33
|
-
var hasContextChanged = function hasContextChanged(oldContext, newContext) {
|
|
34
|
-
return oldContext.siteId !== newContext.siteId || oldContext.orgId !== newContext.orgId || oldContext.productKey !== newContext.productKey || oldContext.principalId !== newContext.principalId || oldContext.containerId !== newContext.containerId || oldContext.objectId !== newContext.objectId || oldContext.childObjectId !== newContext.childObjectId;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
var stringContains = function stringContains(str, substr) {
|
|
38
|
-
if (str === null || str === undefined) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (substr === null || substr === '' || substr === undefined) {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return str.toLowerCase().includes(substr.toLowerCase());
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
var getUsersForAnalytics = function getUsersForAnalytics(users) {
|
|
50
|
-
return (users || []).map(function (_ref) {
|
|
51
|
-
var id = _ref.id,
|
|
52
|
-
type = _ref.type;
|
|
53
|
-
return {
|
|
54
|
-
id: id,
|
|
55
|
-
type: type
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
var sortResults = function sortResults(users, sortIds) {
|
|
61
|
-
var resultsMap = new Map(users.map(function (user) {
|
|
62
|
-
return [user.id, user];
|
|
63
|
-
}));
|
|
64
|
-
return sortIds.map(function (id) {
|
|
65
|
-
var user = resultsMap.get(id);
|
|
66
|
-
|
|
67
|
-
if (user) {
|
|
68
|
-
return user;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
id: id,
|
|
73
|
-
type: UserType,
|
|
74
|
-
name: 'Unknown'
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
function isOptionData(option) {
|
|
80
|
-
return option.name !== undefined;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* @deprecated Please use @atlaskit/smart-user-picker. Alternatively, @atlaskit/smart-hooks will be ready by end of FY22Q4. Contact #help-smart-experiences for further details.
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
export function hydrateDefaultValues(_x, _x2, _x3) {
|
|
88
|
-
return _hydrateDefaultValues.apply(this, arguments);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* @deprecated
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
|
-
function _hydrateDefaultValues() {
|
|
95
|
-
_hydrateDefaultValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(value, productKey, baseUrl) {
|
|
96
|
-
var accountIds, results;
|
|
97
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
98
|
-
while (1) {
|
|
99
|
-
switch (_context3.prev = _context3.next) {
|
|
100
|
-
case 0:
|
|
101
|
-
if (value) {
|
|
102
|
-
_context3.next = 2;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return _context3.abrupt("return", []);
|
|
107
|
-
|
|
108
|
-
case 2:
|
|
109
|
-
if (!(!Array.isArray(value) && isOptionData(value))) {
|
|
110
|
-
_context3.next = 4;
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return _context3.abrupt("return", [value]);
|
|
115
|
-
|
|
116
|
-
case 4:
|
|
117
|
-
if (!(Array.isArray(value) && (value.length === 0 || isOptionData(value[0])))) {
|
|
118
|
-
_context3.next = 6;
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return _context3.abrupt("return", value);
|
|
123
|
-
|
|
124
|
-
case 6:
|
|
125
|
-
if (!(productKey !== 'jira' && productKey !== 'confluence')) {
|
|
126
|
-
_context3.next = 12;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (!Array.isArray(value)) {
|
|
131
|
-
_context3.next = 11;
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return _context3.abrupt("return", value);
|
|
136
|
-
|
|
137
|
-
case 11:
|
|
138
|
-
return _context3.abrupt("return", [value]);
|
|
139
|
-
|
|
140
|
-
case 12:
|
|
141
|
-
//hydrate
|
|
142
|
-
accountIds = [];
|
|
143
|
-
|
|
144
|
-
if (Array.isArray(value)) {
|
|
145
|
-
accountIds = value.map(function (a) {
|
|
146
|
-
return a.id;
|
|
147
|
-
});
|
|
148
|
-
} else {
|
|
149
|
-
accountIds = [value.id];
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
_context3.next = 16;
|
|
153
|
-
return getUsersById({
|
|
154
|
-
productKey: productKey,
|
|
155
|
-
accountIds: accountIds,
|
|
156
|
-
baseUrl: baseUrl
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
case 16:
|
|
160
|
-
results = _context3.sent;
|
|
161
|
-
return _context3.abrupt("return", sortResults(results, accountIds));
|
|
162
|
-
|
|
163
|
-
case 18:
|
|
164
|
-
case "end":
|
|
165
|
-
return _context3.stop();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}, _callee3);
|
|
169
|
-
}));
|
|
170
|
-
return _hydrateDefaultValues.apply(this, arguments);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
var SmartUserPicker = /*#__PURE__*/function (_React$Component) {
|
|
174
|
-
_inherits(SmartUserPicker, _React$Component);
|
|
175
|
-
|
|
176
|
-
var _super = _createSuper(SmartUserPicker);
|
|
177
|
-
|
|
178
|
-
function SmartUserPicker() {
|
|
179
|
-
var _this$props$debounceT;
|
|
180
|
-
|
|
181
|
-
var _this;
|
|
182
|
-
|
|
183
|
-
_classCallCheck(this, SmartUserPicker);
|
|
184
|
-
|
|
185
|
-
for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
186
|
-
_args[_key] = arguments[_key];
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
_this = _super.call.apply(_super, [this].concat(_args));
|
|
190
|
-
|
|
191
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
192
|
-
users: [],
|
|
193
|
-
loading: false,
|
|
194
|
-
error: false,
|
|
195
|
-
closed: true,
|
|
196
|
-
query: '',
|
|
197
|
-
defaultValue: [],
|
|
198
|
-
bootstrapOptions: []
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
_defineProperty(_assertThisInitialized(_this), "fireEvent", function (eventCreator) {
|
|
202
|
-
var createAnalyticsEvent = _this.props.createAnalyticsEvent;
|
|
203
|
-
|
|
204
|
-
if (createAnalyticsEvent) {
|
|
205
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
206
|
-
args[_key2 - 1] = arguments[_key2];
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
createAndFireEventInElementsChannel(eventCreator.apply(void 0, [_this.props, _this.state].concat(args)))(createAnalyticsEvent);
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
_defineProperty(_assertThisInitialized(_this), "filterOptions", function (users, query, propFilterOptions) {
|
|
214
|
-
return propFilterOptions ? propFilterOptions(users, query) : users;
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
_defineProperty(_assertThisInitialized(_this), "memoizedFilterOptions", memoizeOne(_this.filterOptions));
|
|
218
|
-
|
|
219
|
-
_defineProperty(_assertThisInitialized(_this), "getUsers", debounce( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
220
|
-
var _this$state, query, sessionId, _this$props, containerId, childObjectId, objectId, principalId, productKey, siteId, orgId, baseUrl, includeUsers, includeGroups, includeTeams, maxOptions, searchQueryFilter, onEmpty, productAttributes, intl, maxNumberOfResults, startTime, recommendationsRequest, _yield$onEmpty, recommendedUsers, elapsedTimeMilli, displayedUsers, defaultUsers, _elapsedTimeMilli;
|
|
221
|
-
|
|
222
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
223
|
-
while (1) {
|
|
224
|
-
switch (_context.prev = _context.next) {
|
|
225
|
-
case 0:
|
|
226
|
-
_this$state = _this.state, query = _this$state.query, sessionId = _this$state.sessionId;
|
|
227
|
-
_this$props = _this.props, containerId = _this$props.containerId, childObjectId = _this$props.childObjectId, objectId = _this$props.objectId, principalId = _this$props.principalId, productKey = _this$props.productKey, siteId = _this$props.siteId, orgId = _this$props.orgId, baseUrl = _this$props.baseUrl, includeUsers = _this$props.includeUsers, includeGroups = _this$props.includeGroups, includeTeams = _this$props.includeTeams, maxOptions = _this$props.maxOptions, searchQueryFilter = _this$props.searchQueryFilter, onEmpty = _this$props.onEmpty, productAttributes = _this$props.productAttributes, intl = _this$props.intl;
|
|
228
|
-
maxNumberOfResults = maxOptions || 100;
|
|
229
|
-
startTime = window.performance.now();
|
|
230
|
-
recommendationsRequest = {
|
|
231
|
-
baseUrl: baseUrl,
|
|
232
|
-
context: {
|
|
233
|
-
containerId: containerId,
|
|
234
|
-
contextType: _this.props.fieldId,
|
|
235
|
-
objectId: objectId,
|
|
236
|
-
principalId: principalId,
|
|
237
|
-
productKey: productKey,
|
|
238
|
-
siteId: siteId,
|
|
239
|
-
orgId: orgId,
|
|
240
|
-
childObjectId: childObjectId,
|
|
241
|
-
sessionId: sessionId,
|
|
242
|
-
productAttributes: productAttributes
|
|
243
|
-
},
|
|
244
|
-
includeUsers: includeUsers,
|
|
245
|
-
includeGroups: includeGroups,
|
|
246
|
-
includeTeams: includeTeams,
|
|
247
|
-
maxNumberOfResults: maxNumberOfResults,
|
|
248
|
-
query: query,
|
|
249
|
-
searchQueryFilter: searchQueryFilter
|
|
250
|
-
};
|
|
251
|
-
_context.prev = 5;
|
|
252
|
-
|
|
253
|
-
_this.fireEvent(requestUsersEvent);
|
|
254
|
-
|
|
255
|
-
_context.next = 9;
|
|
256
|
-
return getUserRecommendations(recommendationsRequest, intl);
|
|
257
|
-
|
|
258
|
-
case 9:
|
|
259
|
-
recommendedUsers = _context.sent;
|
|
260
|
-
elapsedTimeMilli = window.performance.now() - startTime;
|
|
261
|
-
|
|
262
|
-
if (!(recommendedUsers.length === 0 && onEmpty)) {
|
|
263
|
-
_context.next = 26;
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
_context.next = 14;
|
|
268
|
-
return onEmpty(query);
|
|
269
|
-
|
|
270
|
-
case 14:
|
|
271
|
-
_context.t2 = _yield$onEmpty = _context.sent;
|
|
272
|
-
_context.t1 = _context.t2 !== null;
|
|
273
|
-
|
|
274
|
-
if (!_context.t1) {
|
|
275
|
-
_context.next = 18;
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
_context.t1 = _yield$onEmpty !== void 0;
|
|
280
|
-
|
|
281
|
-
case 18:
|
|
282
|
-
if (!_context.t1) {
|
|
283
|
-
_context.next = 22;
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
_context.t3 = _yield$onEmpty;
|
|
288
|
-
_context.next = 23;
|
|
289
|
-
break;
|
|
290
|
-
|
|
291
|
-
case 22:
|
|
292
|
-
_context.t3 = [];
|
|
293
|
-
|
|
294
|
-
case 23:
|
|
295
|
-
_context.t0 = _context.t3;
|
|
296
|
-
_context.next = 27;
|
|
297
|
-
break;
|
|
298
|
-
|
|
299
|
-
case 26:
|
|
300
|
-
_context.t0 = recommendedUsers;
|
|
301
|
-
|
|
302
|
-
case 27:
|
|
303
|
-
displayedUsers = _context.t0;
|
|
304
|
-
|
|
305
|
-
_this.setState(function (state) {
|
|
306
|
-
var applicable = state.query === query;
|
|
307
|
-
var users = applicable ? displayedUsers : state.users;
|
|
308
|
-
var loading = !applicable;
|
|
309
|
-
|
|
310
|
-
_this.fireEvent(successfulRequestUsersEvent, {
|
|
311
|
-
users: getUsersForAnalytics(recommendedUsers),
|
|
312
|
-
elapsedTimeMilli: elapsedTimeMilli,
|
|
313
|
-
displayedUsers: getUsersForAnalytics(displayedUsers),
|
|
314
|
-
productAttributes: productAttributes,
|
|
315
|
-
applicable: applicable
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
return {
|
|
319
|
-
users: users,
|
|
320
|
-
loading: loading
|
|
321
|
-
};
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
_context.next = 40;
|
|
325
|
-
break;
|
|
326
|
-
|
|
327
|
-
case 31:
|
|
328
|
-
_context.prev = 31;
|
|
329
|
-
_context.t4 = _context["catch"](5);
|
|
330
|
-
|
|
331
|
-
_this.setState({
|
|
332
|
-
users: [],
|
|
333
|
-
error: true
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
_context.next = 36;
|
|
337
|
-
return _this.props.onError ? _this.props.onError(_context.t4, recommendationsRequest) || Promise.resolve([]) : Promise.resolve([]);
|
|
338
|
-
|
|
339
|
-
case 36:
|
|
340
|
-
defaultUsers = _context.sent;
|
|
341
|
-
_elapsedTimeMilli = window.performance.now() - startTime;
|
|
342
|
-
|
|
343
|
-
_this.setState({
|
|
344
|
-
users: defaultUsers,
|
|
345
|
-
loading: false
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
_this.fireEvent(failedRequestUsersEvent, {
|
|
349
|
-
elapsedTimeMilli: _elapsedTimeMilli,
|
|
350
|
-
productAttributes: productAttributes
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
case 40:
|
|
354
|
-
case "end":
|
|
355
|
-
return _context.stop();
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}, _callee, null, [[5, 31]]);
|
|
359
|
-
})), (_this$props$debounceT = _this.props.debounceTime) !== null && _this$props$debounceT !== void 0 ? _this$props$debounceT : 0));
|
|
360
|
-
|
|
361
|
-
_defineProperty(_assertThisInitialized(_this), "onInputChange", function (newQuery, sessionId) {
|
|
362
|
-
var query = newQuery || '';
|
|
363
|
-
var closed = _this.state.closed;
|
|
364
|
-
|
|
365
|
-
if (query === _this.state.query) {
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
if (!closed) {
|
|
370
|
-
_this.setState({
|
|
371
|
-
loading: true,
|
|
372
|
-
query: query,
|
|
373
|
-
sessionId: sessionId
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
if (_this.props.onInputChange) {
|
|
377
|
-
_this.props.onInputChange(query, sessionId);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
_defineProperty(_assertThisInitialized(_this), "filterUsers", function () {
|
|
383
|
-
var _this$state2 = _this.state,
|
|
384
|
-
loading = _this$state2.loading,
|
|
385
|
-
users = _this$state2.users,
|
|
386
|
-
query = _this$state2.query;
|
|
387
|
-
|
|
388
|
-
var filteredUsers = _this.memoizedFilterOptions(users, query, _this.props.filterOptions); //If bootstrapOptions have been passed in and it is bootstrap
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
if (_this.props.bootstrapOptions && _this.props.bootstrapOptions.length !== 0 && query === '') {
|
|
392
|
-
var bootstrapFilteredUsers = _this.memoizedFilterOptions(_this.props.bootstrapOptions, query, _this.props.filterOptions);
|
|
393
|
-
|
|
394
|
-
_this.fireEvent(filterUsersEvent, {
|
|
395
|
-
filtered: getUsersForAnalytics(bootstrapFilteredUsers),
|
|
396
|
-
all: getUsersForAnalytics(_this.props.bootstrapOptions)
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
return bootstrapFilteredUsers;
|
|
400
|
-
} // while when not loading just return already filtered result from server.
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
if (!loading) {
|
|
404
|
-
return filteredUsers;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
var queryFilteredUsers = filteredUsers.filter(function (user) {
|
|
408
|
-
return stringContains(user.name, query);
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
_this.fireEvent(filterUsersEvent, {
|
|
412
|
-
filtered: getUsersForAnalytics(queryFilteredUsers),
|
|
413
|
-
all: getUsersForAnalytics(users)
|
|
414
|
-
}); // when loading filter previous result.
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
return filteredUsers;
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
_defineProperty(_assertThisInitialized(_this), "onFocus", function (sessionId) {
|
|
421
|
-
var state = {
|
|
422
|
-
query: '',
|
|
423
|
-
closed: false
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
if (_this.state.users.length === 0) {
|
|
427
|
-
state.sessionId = sessionId;
|
|
428
|
-
state.loading = true;
|
|
429
|
-
} else {
|
|
430
|
-
_this.fireEvent(preparedUsersLoadedEvent, {
|
|
431
|
-
users: getUsersForAnalytics(_this.state.users),
|
|
432
|
-
preparedSessionId: _this.state.sessionId,
|
|
433
|
-
sessionId: sessionId
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
_this.setState(function (currentState) {
|
|
438
|
-
return _objectSpread(_objectSpread({}, currentState), state);
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
if (_this.props.onFocus) {
|
|
442
|
-
_this.props.onFocus(sessionId);
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
_defineProperty(_assertThisInitialized(_this), "onBlur", function (sessionId) {
|
|
447
|
-
_this.getUsers.cancel(); // clear old users if query is populated so that on refocus,
|
|
448
|
-
// the old list is not shown
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
var users = _this.state.query.length === 0 ? _this.state.users : [];
|
|
452
|
-
|
|
453
|
-
_this.setState({
|
|
454
|
-
loading: false,
|
|
455
|
-
closed: true,
|
|
456
|
-
users: users
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
if (_this.props.onBlur) {
|
|
460
|
-
_this.props.onBlur(sessionId);
|
|
461
|
-
}
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
return _this;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
_createClass(SmartUserPicker, [{
|
|
468
|
-
key: "componentDidMount",
|
|
469
|
-
value: function () {
|
|
470
|
-
var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
471
|
-
var value, _defaultValue, prefetch, sessionId;
|
|
472
|
-
|
|
473
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
474
|
-
while (1) {
|
|
475
|
-
switch (_context2.prev = _context2.next) {
|
|
476
|
-
case 0:
|
|
477
|
-
_context2.prev = 0;
|
|
478
|
-
_context2.next = 3;
|
|
479
|
-
return hydrateDefaultValues(this.props.defaultValue, this.props.productKey, this.props.baseUrl);
|
|
480
|
-
|
|
481
|
-
case 3:
|
|
482
|
-
value = _context2.sent;
|
|
483
|
-
this.setState({
|
|
484
|
-
defaultValue: value
|
|
485
|
-
});
|
|
486
|
-
_context2.next = 13;
|
|
487
|
-
break;
|
|
488
|
-
|
|
489
|
-
case 7:
|
|
490
|
-
_context2.prev = 7;
|
|
491
|
-
_context2.t0 = _context2["catch"](0);
|
|
492
|
-
_context2.next = 11;
|
|
493
|
-
return this.props.onValueError ? this.props.onValueError(_context2.t0, this.props.defaultValue) || Promise.resolve([]) : Promise.resolve([]);
|
|
494
|
-
|
|
495
|
-
case 11:
|
|
496
|
-
_defaultValue = _context2.sent;
|
|
497
|
-
this.setState({
|
|
498
|
-
defaultValue: _defaultValue
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
case 13:
|
|
502
|
-
prefetch = this.props.prefetch;
|
|
503
|
-
|
|
504
|
-
if (prefetch) {
|
|
505
|
-
sessionId = uuidv4();
|
|
506
|
-
this.fireEvent(mountedWithPrefetchEvent, {
|
|
507
|
-
sessionId: sessionId
|
|
508
|
-
});
|
|
509
|
-
this.setState({
|
|
510
|
-
sessionId: sessionId
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
case 15:
|
|
515
|
-
case "end":
|
|
516
|
-
return _context2.stop();
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
}, _callee2, this, [[0, 7]]);
|
|
520
|
-
}));
|
|
521
|
-
|
|
522
|
-
function componentDidMount() {
|
|
523
|
-
return _componentDidMount.apply(this, arguments);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
return componentDidMount;
|
|
527
|
-
}()
|
|
528
|
-
}, {
|
|
529
|
-
key: "componentDidUpdate",
|
|
530
|
-
value: function componentDidUpdate(prevProps, prevState) {
|
|
531
|
-
if (hasContextChanged(prevProps, this.props) || this.props.fieldId !== prevProps.fieldId) {
|
|
532
|
-
this.setState({
|
|
533
|
-
users: []
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
if ((this.state.sessionId !== prevState.sessionId || this.state.query !== prevState.query) && (this.state.query !== '' || !this.props.bootstrapOptions)) {
|
|
538
|
-
this.getUsers();
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
}, {
|
|
542
|
-
key: "render",
|
|
543
|
-
value: function render() {
|
|
544
|
-
return /*#__PURE__*/React.createElement(UserPicker, _extends({}, this.props, {
|
|
545
|
-
onInputChange: this.onInputChange,
|
|
546
|
-
onBlur: this.onBlur,
|
|
547
|
-
onFocus: this.onFocus,
|
|
548
|
-
defaultValue: this.state.defaultValue,
|
|
549
|
-
isLoading: this.props.isLoading || this.state.loading && !this.state.closed && (!this.props.bootstrapOptions || this.state.query !== ''),
|
|
550
|
-
options: this.filterUsers()
|
|
551
|
-
}));
|
|
552
|
-
}
|
|
553
|
-
}]);
|
|
554
|
-
|
|
555
|
-
return SmartUserPicker;
|
|
556
|
-
}(React.Component);
|
|
557
|
-
|
|
558
|
-
_defineProperty(SmartUserPicker, "defaultProps", {
|
|
559
|
-
onError: function onError() {},
|
|
560
|
-
baseUrl: '',
|
|
561
|
-
includeUsers: true,
|
|
562
|
-
includeGroups: false,
|
|
563
|
-
includeTeams: false,
|
|
564
|
-
prefetch: false,
|
|
565
|
-
principalId: 'Context'
|
|
566
|
-
});
|
|
567
|
-
|
|
568
|
-
var WrappedSmartUserPicker = withAnalyticsEvents()(injectIntl(SmartUserPicker));
|
|
569
|
-
/**
|
|
570
|
-
* @deprecated
|
|
571
|
-
*/
|
|
572
|
-
|
|
573
|
-
var SmartUserPickerWithIntlProvider = function SmartUserPickerWithIntlProvider(props) {
|
|
574
|
-
return /*#__PURE__*/React.createElement(MessagesIntlProvider, null, /*#__PURE__*/React.createElement(WrappedSmartUserPicker, props));
|
|
575
|
-
};
|
|
576
|
-
/**
|
|
577
|
-
* Please use AK/SUP instead
|
|
578
|
-
* @deprecated
|
|
579
|
-
*/
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
export default SmartUserPickerWithIntlProvider;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
var env = 'prod';
|
|
2
|
-
var STG_INSTANCE = 'https://api-private.stg.atlassian.com';
|
|
3
|
-
var LOCAL_CONFIG = {
|
|
4
|
-
getRecommendationServiceUrl: function getRecommendationServiceUrl(baseUrl) {
|
|
5
|
-
return baseUrl ? "".concat(STG_INSTANCE, "/").concat(baseUrl, "/gateway/api/v1/recommendations") : "".concat(STG_INSTANCE, "/gateway/api/v1/recommendations");
|
|
6
|
-
},
|
|
7
|
-
getUsersServiceUrl: function getUsersServiceUrl(productKey) {
|
|
8
|
-
return productKey === 'jira' ? "https://jdog.jira-dev.com/rest/api/3/user/bulk" : "https://pug.jira-dev.com/wiki/rest/api/user/bulk";
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
var PRD_CONFIG = {
|
|
12
|
-
getRecommendationServiceUrl: function getRecommendationServiceUrl(baseUrl) {
|
|
13
|
-
return baseUrl ? "".concat(baseUrl, "/gateway/api/v1/recommendations") : '/gateway/api/v1/recommendations';
|
|
14
|
-
},
|
|
15
|
-
getUsersServiceUrl: function getUsersServiceUrl(productKey) {
|
|
16
|
-
var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
17
|
-
return productKey === 'jira' ? "".concat(baseUrl, "/rest/api/3/user/bulk") : "".concat(baseUrl, "/wiki/rest/api/user/bulk");
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Please use @atlaskit/smart-user-picker. Alternatively, @atlaskit/smart-hooks will be ready by end of FY22Q4. Contact #help-smart-experiences for further details.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
export var setSmartUserPickerEnv = function setSmartUserPickerEnv(newEnv) {
|
|
25
|
-
return env = newEnv;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated Please use @atlaskit/smart-user-picker. Alternatively, @atlaskit/smart-hooks will be ready by end of FY22Q4. Contact #help-smart-experiences for further details.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
export var getConfig = function getConfig() {
|
|
32
|
-
return env === 'local' ? LOCAL_CONFIG : PRD_CONFIG;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* @deprecated Please use @atlaskit/smart-user-picker. Alternatively, @atlaskit/smart-hooks will be ready by end of FY22Q4. Contact #help-smart-experiences for further details.
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
export var JDOG_CLOUD_ID = '49d8b9d6-ee7d-4931-a0ca-7fcae7d1c3b5';
|