@atlaskit/smart-user-picker 5.0.3 → 5.0.4
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 +6 -0
- package/dist/cjs/components/SmartUserPicker.js +56 -18
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/SmartUserPicker.js +32 -20
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/SmartUserPicker.js +56 -18
- package/dist/esm/version.json +1 -1
- package/dist/types/components/SmartUserPicker.d.ts +0 -1
- package/dist/types/types.d.ts +0 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlassian/smart-user-picker
|
|
2
2
|
|
|
3
|
+
## 5.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`f805f47c19a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f805f47c19a) - Smart User Picker now catches errors emitted from the optional `onError` fallback data source, and also now only sends a UFO failure event if the primary data source (URS) fails AND the `onError` prop either fails or is not provided.
|
|
8
|
+
|
|
3
9
|
## 5.0.3
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -103,7 +103,6 @@ var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
|
103
103
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
104
104
|
users: [],
|
|
105
105
|
loading: false,
|
|
106
|
-
error: false,
|
|
107
106
|
closed: true,
|
|
108
107
|
query: '',
|
|
109
108
|
defaultValue: [],
|
|
@@ -137,21 +136,21 @@ var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
|
137
136
|
});
|
|
138
137
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "memoizedFilterOptions", (0, _memoizeOne.default)(_this.filterOptions));
|
|
139
138
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getUsers", (0, _debounce.default)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
140
|
-
var _this$state, query, sessionId, closed, _this$props,
|
|
139
|
+
var _this$state, query, sessionId, closed, _this$props, baseUrl, childObjectId, containerId, fieldId, includeGroups, includeTeams, includeUsers, intl, maxOptions, objectId, onEmpty, onError, orgId, principalId, productAttributes, productKey, searchQueryFilter, siteId, maxNumberOfResults, startTime, recommendationsRequest, _yield$onEmpty, recommendedUsers, elapsedTimeMilli, displayedUsers, onErrorProducedError, defaultUsers, _elapsedTimeMilli;
|
|
141
140
|
|
|
142
141
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
143
142
|
while (1) {
|
|
144
143
|
switch (_context.prev = _context.next) {
|
|
145
144
|
case 0:
|
|
146
145
|
_this$state = _this.state, query = _this$state.query, sessionId = _this$state.sessionId, closed = _this$state.closed;
|
|
147
|
-
_this$props = _this.props,
|
|
146
|
+
_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, 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;
|
|
148
147
|
maxNumberOfResults = maxOptions || 100;
|
|
149
148
|
startTime = window.performance.now();
|
|
150
149
|
recommendationsRequest = {
|
|
151
150
|
baseUrl: baseUrl,
|
|
152
151
|
context: {
|
|
153
152
|
containerId: containerId,
|
|
154
|
-
contextType:
|
|
153
|
+
contextType: fieldId,
|
|
155
154
|
objectId: objectId,
|
|
156
155
|
principalId: principalId,
|
|
157
156
|
productKey: productKey,
|
|
@@ -241,47 +240,87 @@ var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
|
241
240
|
};
|
|
242
241
|
});
|
|
243
242
|
|
|
244
|
-
_context.next =
|
|
243
|
+
_context.next = 58;
|
|
245
244
|
break;
|
|
246
245
|
|
|
247
246
|
case 31:
|
|
248
247
|
_context.prev = 31;
|
|
249
248
|
_context.t4 = _context["catch"](5);
|
|
250
249
|
|
|
251
|
-
if (!closed) {
|
|
252
|
-
// If the user lookup fails while the menu is open,
|
|
253
|
-
//
|
|
250
|
+
if (!closed && !onError) {
|
|
251
|
+
// If the user lookup fails while the menu is open, and the consumer is not providing a
|
|
252
|
+
// fallback data source via the onError prop, then send UFO failure
|
|
254
253
|
_this.optionsShownUfoExperienceInstance.failure();
|
|
255
254
|
}
|
|
256
255
|
|
|
257
256
|
_this.setState({
|
|
258
|
-
users: []
|
|
259
|
-
error: true
|
|
257
|
+
users: []
|
|
260
258
|
});
|
|
261
259
|
|
|
262
|
-
|
|
263
|
-
|
|
260
|
+
onErrorProducedError = false;
|
|
261
|
+
defaultUsers = [];
|
|
262
|
+
_context.prev = 37;
|
|
264
263
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
264
|
+
if (!onError) {
|
|
265
|
+
_context.next = 47;
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
_context.next = 41;
|
|
270
|
+
return onError(_context.t4, recommendationsRequest);
|
|
271
|
+
|
|
272
|
+
case 41:
|
|
273
|
+
_context.t6 = _context.sent;
|
|
274
|
+
|
|
275
|
+
if (_context.t6) {
|
|
276
|
+
_context.next = 44;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
_context.t6 = [];
|
|
281
|
+
|
|
282
|
+
case 44:
|
|
283
|
+
_context.t5 = _context.t6;
|
|
284
|
+
_context.next = 48;
|
|
285
|
+
break;
|
|
286
|
+
|
|
287
|
+
case 47:
|
|
288
|
+
_context.t5 = [];
|
|
289
|
+
|
|
290
|
+
case 48:
|
|
291
|
+
defaultUsers = _context.t5;
|
|
292
|
+
_context.next = 54;
|
|
293
|
+
break;
|
|
294
|
+
|
|
295
|
+
case 51:
|
|
296
|
+
_context.prev = 51;
|
|
297
|
+
_context.t7 = _context["catch"](37);
|
|
298
|
+
onErrorProducedError = true;
|
|
299
|
+
|
|
300
|
+
case 54:
|
|
301
|
+
if (onErrorProducedError) {
|
|
302
|
+
// Log error from fallback data source `onError` to UFO
|
|
303
|
+
_this.optionsShownUfoExperienceInstance.failure();
|
|
304
|
+
}
|
|
268
305
|
|
|
269
306
|
_this.setState({
|
|
270
307
|
users: defaultUsers,
|
|
271
308
|
loading: false
|
|
272
309
|
});
|
|
273
310
|
|
|
311
|
+
_elapsedTimeMilli = window.performance.now() - startTime;
|
|
312
|
+
|
|
274
313
|
_this.fireEvent(_analytics.failedRequestUsersEvent, {
|
|
275
314
|
elapsedTimeMilli: _elapsedTimeMilli,
|
|
276
315
|
productAttributes: productAttributes
|
|
277
316
|
});
|
|
278
317
|
|
|
279
|
-
case
|
|
318
|
+
case 58:
|
|
280
319
|
case "end":
|
|
281
320
|
return _context.stop();
|
|
282
321
|
}
|
|
283
322
|
}
|
|
284
|
-
}, _callee, null, [[5, 31]]);
|
|
323
|
+
}, _callee, null, [[5, 31], [37, 51]]);
|
|
285
324
|
})), (_this$props$debounceT = _this.props.debounceTime) !== null && _this$props$debounceT !== void 0 ? _this$props$debounceT : 0));
|
|
286
325
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onInputChange", function (newQuery, sessionId) {
|
|
287
326
|
var query = newQuery || '';
|
|
@@ -494,7 +533,6 @@ var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
|
494
533
|
|
|
495
534
|
exports.SmartUserPickerWithoutAnalytics = SmartUserPickerWithoutAnalytics;
|
|
496
535
|
(0, _defineProperty2.default)(SmartUserPickerWithoutAnalytics, "defaultProps", {
|
|
497
|
-
onError: function onError() {},
|
|
498
536
|
baseUrl: '',
|
|
499
537
|
includeUsers: true,
|
|
500
538
|
includeGroups: false,
|
package/dist/cjs/version.json
CHANGED
|
@@ -45,7 +45,6 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
45
45
|
_defineProperty(this, "state", {
|
|
46
46
|
users: [],
|
|
47
47
|
loading: false,
|
|
48
|
-
error: false,
|
|
49
48
|
closed: true,
|
|
50
49
|
query: '',
|
|
51
50
|
defaultValue: [],
|
|
@@ -86,22 +85,24 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
86
85
|
closed
|
|
87
86
|
} = this.state;
|
|
88
87
|
const {
|
|
89
|
-
containerId,
|
|
90
|
-
childObjectId,
|
|
91
|
-
objectId,
|
|
92
|
-
principalId,
|
|
93
|
-
productKey,
|
|
94
|
-
siteId,
|
|
95
|
-
orgId,
|
|
96
88
|
baseUrl,
|
|
97
|
-
|
|
89
|
+
childObjectId,
|
|
90
|
+
containerId,
|
|
91
|
+
fieldId,
|
|
98
92
|
includeGroups,
|
|
99
93
|
includeTeams,
|
|
94
|
+
includeUsers,
|
|
95
|
+
intl,
|
|
100
96
|
maxOptions,
|
|
101
|
-
|
|
97
|
+
objectId,
|
|
102
98
|
onEmpty,
|
|
99
|
+
onError,
|
|
100
|
+
orgId,
|
|
101
|
+
principalId,
|
|
103
102
|
productAttributes,
|
|
104
|
-
|
|
103
|
+
productKey,
|
|
104
|
+
searchQueryFilter,
|
|
105
|
+
siteId
|
|
105
106
|
} = this.props;
|
|
106
107
|
const maxNumberOfResults = maxOptions || 100;
|
|
107
108
|
const startTime = window.performance.now();
|
|
@@ -109,7 +110,7 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
109
110
|
baseUrl,
|
|
110
111
|
context: {
|
|
111
112
|
containerId,
|
|
112
|
-
contextType:
|
|
113
|
+
contextType: fieldId,
|
|
113
114
|
objectId,
|
|
114
115
|
principalId,
|
|
115
116
|
productKey,
|
|
@@ -151,22 +152,34 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
151
152
|
};
|
|
152
153
|
});
|
|
153
154
|
} catch (e) {
|
|
154
|
-
if (!closed) {
|
|
155
|
-
// If the user lookup fails while the menu is open,
|
|
156
|
-
//
|
|
155
|
+
if (!closed && !onError) {
|
|
156
|
+
// If the user lookup fails while the menu is open, and the consumer is not providing a
|
|
157
|
+
// fallback data source via the onError prop, then send UFO failure
|
|
157
158
|
this.optionsShownUfoExperienceInstance.failure();
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
this.setState({
|
|
161
|
-
users: []
|
|
162
|
-
error: true
|
|
162
|
+
users: []
|
|
163
163
|
});
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
let onErrorProducedError = false;
|
|
165
|
+
let defaultUsers = [];
|
|
166
|
+
|
|
167
|
+
try {
|
|
168
|
+
defaultUsers = onError ? (await onError(e, recommendationsRequest)) || [] : [];
|
|
169
|
+
} catch (error) {
|
|
170
|
+
onErrorProducedError = true;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (onErrorProducedError) {
|
|
174
|
+
// Log error from fallback data source `onError` to UFO
|
|
175
|
+
this.optionsShownUfoExperienceInstance.failure();
|
|
176
|
+
}
|
|
177
|
+
|
|
166
178
|
this.setState({
|
|
167
179
|
users: defaultUsers,
|
|
168
180
|
loading: false
|
|
169
181
|
});
|
|
182
|
+
const elapsedTimeMilli = window.performance.now() - startTime;
|
|
170
183
|
this.fireEvent(failedRequestUsersEvent, {
|
|
171
184
|
elapsedTimeMilli,
|
|
172
185
|
productAttributes
|
|
@@ -340,7 +353,6 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
340
353
|
} // TODO: Smart User picker team will have to add a type annotation here
|
|
341
354
|
|
|
342
355
|
_defineProperty(SmartUserPickerWithoutAnalytics, "defaultProps", {
|
|
343
|
-
onError: () => {},
|
|
344
356
|
baseUrl: '',
|
|
345
357
|
includeUsers: true,
|
|
346
358
|
includeGroups: false,
|
package/dist/es2019/version.json
CHANGED
|
@@ -75,7 +75,6 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
75
75
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
76
76
|
users: [],
|
|
77
77
|
loading: false,
|
|
78
|
-
error: false,
|
|
79
78
|
closed: true,
|
|
80
79
|
query: '',
|
|
81
80
|
defaultValue: [],
|
|
@@ -115,21 +114,21 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
115
114
|
_defineProperty(_assertThisInitialized(_this), "memoizedFilterOptions", memoizeOne(_this.filterOptions));
|
|
116
115
|
|
|
117
116
|
_defineProperty(_assertThisInitialized(_this), "getUsers", debounce( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
118
|
-
var _this$state, query, sessionId, closed, _this$props,
|
|
117
|
+
var _this$state, query, sessionId, closed, _this$props, baseUrl, childObjectId, containerId, fieldId, includeGroups, includeTeams, includeUsers, intl, maxOptions, objectId, onEmpty, onError, orgId, principalId, productAttributes, productKey, searchQueryFilter, siteId, maxNumberOfResults, startTime, recommendationsRequest, _yield$onEmpty, recommendedUsers, elapsedTimeMilli, displayedUsers, onErrorProducedError, defaultUsers, _elapsedTimeMilli;
|
|
119
118
|
|
|
120
119
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
121
120
|
while (1) {
|
|
122
121
|
switch (_context.prev = _context.next) {
|
|
123
122
|
case 0:
|
|
124
123
|
_this$state = _this.state, query = _this$state.query, sessionId = _this$state.sessionId, closed = _this$state.closed;
|
|
125
|
-
_this$props = _this.props,
|
|
124
|
+
_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, 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;
|
|
126
125
|
maxNumberOfResults = maxOptions || 100;
|
|
127
126
|
startTime = window.performance.now();
|
|
128
127
|
recommendationsRequest = {
|
|
129
128
|
baseUrl: baseUrl,
|
|
130
129
|
context: {
|
|
131
130
|
containerId: containerId,
|
|
132
|
-
contextType:
|
|
131
|
+
contextType: fieldId,
|
|
133
132
|
objectId: objectId,
|
|
134
133
|
principalId: principalId,
|
|
135
134
|
productKey: productKey,
|
|
@@ -219,47 +218,87 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
219
218
|
};
|
|
220
219
|
});
|
|
221
220
|
|
|
222
|
-
_context.next =
|
|
221
|
+
_context.next = 58;
|
|
223
222
|
break;
|
|
224
223
|
|
|
225
224
|
case 31:
|
|
226
225
|
_context.prev = 31;
|
|
227
226
|
_context.t4 = _context["catch"](5);
|
|
228
227
|
|
|
229
|
-
if (!closed) {
|
|
230
|
-
// If the user lookup fails while the menu is open,
|
|
231
|
-
//
|
|
228
|
+
if (!closed && !onError) {
|
|
229
|
+
// If the user lookup fails while the menu is open, and the consumer is not providing a
|
|
230
|
+
// fallback data source via the onError prop, then send UFO failure
|
|
232
231
|
_this.optionsShownUfoExperienceInstance.failure();
|
|
233
232
|
}
|
|
234
233
|
|
|
235
234
|
_this.setState({
|
|
236
|
-
users: []
|
|
237
|
-
error: true
|
|
235
|
+
users: []
|
|
238
236
|
});
|
|
239
237
|
|
|
240
|
-
|
|
241
|
-
|
|
238
|
+
onErrorProducedError = false;
|
|
239
|
+
defaultUsers = [];
|
|
240
|
+
_context.prev = 37;
|
|
242
241
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
242
|
+
if (!onError) {
|
|
243
|
+
_context.next = 47;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
_context.next = 41;
|
|
248
|
+
return onError(_context.t4, recommendationsRequest);
|
|
249
|
+
|
|
250
|
+
case 41:
|
|
251
|
+
_context.t6 = _context.sent;
|
|
252
|
+
|
|
253
|
+
if (_context.t6) {
|
|
254
|
+
_context.next = 44;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
_context.t6 = [];
|
|
259
|
+
|
|
260
|
+
case 44:
|
|
261
|
+
_context.t5 = _context.t6;
|
|
262
|
+
_context.next = 48;
|
|
263
|
+
break;
|
|
264
|
+
|
|
265
|
+
case 47:
|
|
266
|
+
_context.t5 = [];
|
|
267
|
+
|
|
268
|
+
case 48:
|
|
269
|
+
defaultUsers = _context.t5;
|
|
270
|
+
_context.next = 54;
|
|
271
|
+
break;
|
|
272
|
+
|
|
273
|
+
case 51:
|
|
274
|
+
_context.prev = 51;
|
|
275
|
+
_context.t7 = _context["catch"](37);
|
|
276
|
+
onErrorProducedError = true;
|
|
277
|
+
|
|
278
|
+
case 54:
|
|
279
|
+
if (onErrorProducedError) {
|
|
280
|
+
// Log error from fallback data source `onError` to UFO
|
|
281
|
+
_this.optionsShownUfoExperienceInstance.failure();
|
|
282
|
+
}
|
|
246
283
|
|
|
247
284
|
_this.setState({
|
|
248
285
|
users: defaultUsers,
|
|
249
286
|
loading: false
|
|
250
287
|
});
|
|
251
288
|
|
|
289
|
+
_elapsedTimeMilli = window.performance.now() - startTime;
|
|
290
|
+
|
|
252
291
|
_this.fireEvent(failedRequestUsersEvent, {
|
|
253
292
|
elapsedTimeMilli: _elapsedTimeMilli,
|
|
254
293
|
productAttributes: productAttributes
|
|
255
294
|
});
|
|
256
295
|
|
|
257
|
-
case
|
|
296
|
+
case 58:
|
|
258
297
|
case "end":
|
|
259
298
|
return _context.stop();
|
|
260
299
|
}
|
|
261
300
|
}
|
|
262
|
-
}, _callee, null, [[5, 31]]);
|
|
301
|
+
}, _callee, null, [[5, 31], [37, 51]]);
|
|
263
302
|
})), (_this$props$debounceT = _this.props.debounceTime) !== null && _this$props$debounceT !== void 0 ? _this$props$debounceT : 0));
|
|
264
303
|
|
|
265
304
|
_defineProperty(_assertThisInitialized(_this), "onInputChange", function (newQuery, sessionId) {
|
|
@@ -476,7 +515,6 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
476
515
|
}(React.Component); // TODO: Smart User picker team will have to add a type annotation here
|
|
477
516
|
|
|
478
517
|
_defineProperty(SmartUserPickerWithoutAnalytics, "defaultProps", {
|
|
479
|
-
onError: function onError() {},
|
|
480
518
|
baseUrl: '',
|
|
481
519
|
includeUsers: true,
|
|
482
520
|
includeGroups: false,
|
package/dist/esm/version.json
CHANGED
|
@@ -8,7 +8,6 @@ export declare class SmartUserPickerWithoutAnalytics extends React.Component<Pro
|
|
|
8
8
|
state: State;
|
|
9
9
|
optionsShownUfoExperienceInstance: UFOExperience;
|
|
10
10
|
static defaultProps: {
|
|
11
|
-
onError: () => void;
|
|
12
11
|
baseUrl: string;
|
|
13
12
|
includeUsers: boolean;
|
|
14
13
|
includeGroups: boolean;
|
package/dist/types/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-user-picker",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/"
|
|
6
6
|
},
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"fetch-mock": "^8.0.0",
|
|
51
51
|
"graphql-tag": "^2.10.1",
|
|
52
52
|
"mock-apollo-client": "^0.1.0",
|
|
53
|
-
"typescript": "3.9.
|
|
53
|
+
"typescript": "3.9.10"
|
|
54
54
|
},
|
|
55
55
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|
|
56
56
|
}
|