@atlaskit/smart-user-picker 4.0.1 → 5.0.2
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 +18 -0
- package/dist/cjs/components/SmartUserPicker.js +50 -16
- package/dist/cjs/components/index.js +5 -2
- package/dist/cjs/config/index.js +2 -2
- package/dist/cjs/ufoExperiences.js +66 -5
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/SmartUserPicker.js +41 -4
- package/dist/es2019/components/index.js +6 -3
- package/dist/es2019/config/index.js +2 -2
- package/dist/es2019/ufoExperiences.js +27 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/SmartUserPicker.js +50 -15
- package/dist/esm/components/index.js +6 -3
- package/dist/esm/config/index.js +2 -2
- package/dist/esm/ufoExperiences.js +52 -4
- package/dist/esm/version.json +1 -1
- package/dist/types/components/SmartUserPicker.d.ts +5 -0
- package/dist/types/ufoExperiences.d.ts +8 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlassian/smart-user-picker
|
|
2
2
|
|
|
3
|
+
## 5.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`6fc78303271`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6fc78303271) - UFO measurement of how long it takes the list of users to be shown
|
|
8
|
+
|
|
9
|
+
## 5.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`0850fe46fc8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0850fe46fc8) - Track mount errors in Smart User Picker
|
|
14
|
+
|
|
15
|
+
## 5.0.0
|
|
16
|
+
|
|
17
|
+
### Major Changes
|
|
18
|
+
|
|
19
|
+
- [`67ca990e9cf`](https://bitbucket.org/atlassian/atlassian-frontend/commits/67ca990e9cf) - Changing the URL for default value hydration from /graphql to /api/gateway/graphql
|
|
20
|
+
|
|
3
21
|
## 4.0.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -39,6 +39,8 @@ var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
|
39
39
|
|
|
40
40
|
var _reactIntlNext = require("react-intl-next");
|
|
41
41
|
|
|
42
|
+
var _ufo = require("@atlaskit/ufo");
|
|
43
|
+
|
|
42
44
|
var _userPicker = _interopRequireDefault(require("@atlaskit/user-picker"));
|
|
43
45
|
|
|
44
46
|
var _analytics = require("../analytics");
|
|
@@ -47,6 +49,8 @@ var _MessagesIntlProvider = _interopRequireDefault(require("./MessagesIntlProvid
|
|
|
47
49
|
|
|
48
50
|
var _service = require("../service");
|
|
49
51
|
|
|
52
|
+
var _ufoExperiences = require("../ufoExperiences");
|
|
53
|
+
|
|
50
54
|
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; }
|
|
51
55
|
|
|
52
56
|
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) { (0, _defineProperty2.default)(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; }
|
|
@@ -89,18 +93,13 @@ var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
|
89
93
|
|
|
90
94
|
var _super = _createSuper(SmartUserPickerWithoutAnalytics);
|
|
91
95
|
|
|
92
|
-
function SmartUserPickerWithoutAnalytics() {
|
|
96
|
+
function SmartUserPickerWithoutAnalytics(props) {
|
|
93
97
|
var _this$props$debounceT;
|
|
94
98
|
|
|
95
99
|
var _this;
|
|
96
100
|
|
|
97
101
|
(0, _classCallCheck2.default)(this, SmartUserPickerWithoutAnalytics);
|
|
98
|
-
|
|
99
|
-
for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
100
|
-
_args[_key] = arguments[_key];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
_this = _super.call.apply(_super, [this].concat(_args));
|
|
102
|
+
_this = _super.call(this, props);
|
|
104
103
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
105
104
|
users: [],
|
|
106
105
|
loading: false,
|
|
@@ -110,12 +109,24 @@ var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
|
110
109
|
defaultValue: [],
|
|
111
110
|
bootstrapOptions: []
|
|
112
111
|
});
|
|
112
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "abortOptionsShownUfoExperience", function () {
|
|
113
|
+
if (_this.optionsShownUfoExperienceInstance.state.id === _ufo.UFOExperienceState.STARTED.id) {
|
|
114
|
+
// There may be an existing UFO timing running from previous key entry or focus,
|
|
115
|
+
// so abort it and restart it just in case.
|
|
116
|
+
_this.optionsShownUfoExperienceInstance.abort();
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "startOptionsShownUfoExperience", function () {
|
|
120
|
+
_this.abortOptionsShownUfoExperience();
|
|
121
|
+
|
|
122
|
+
_this.optionsShownUfoExperienceInstance.start();
|
|
123
|
+
});
|
|
113
124
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fireEvent", function (eventCreator) {
|
|
114
125
|
var createAnalyticsEvent = _this.props.createAnalyticsEvent;
|
|
115
126
|
|
|
116
127
|
if (createAnalyticsEvent) {
|
|
117
|
-
for (var
|
|
118
|
-
args[
|
|
128
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
129
|
+
args[_key - 1] = arguments[_key];
|
|
119
130
|
}
|
|
120
131
|
|
|
121
132
|
(0, _analytics.createAndFireEventInElementsChannel)(eventCreator.apply(void 0, [_this.props, _this.state].concat(args)))(createAnalyticsEvent);
|
|
@@ -126,13 +137,13 @@ var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
|
126
137
|
});
|
|
127
138
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "memoizedFilterOptions", (0, _memoizeOne.default)(_this.filterOptions));
|
|
128
139
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getUsers", (0, _debounce.default)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
129
|
-
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;
|
|
140
|
+
var _this$state, query, sessionId, closed, _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;
|
|
130
141
|
|
|
131
142
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
132
143
|
while (1) {
|
|
133
144
|
switch (_context.prev = _context.next) {
|
|
134
145
|
case 0:
|
|
135
|
-
_this$state = _this.state, query = _this$state.query, sessionId = _this$state.sessionId;
|
|
146
|
+
_this$state = _this.state, query = _this$state.query, sessionId = _this$state.sessionId, closed = _this$state.closed;
|
|
136
147
|
_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;
|
|
137
148
|
maxNumberOfResults = maxOptions || 100;
|
|
138
149
|
startTime = window.performance.now();
|
|
@@ -230,22 +241,28 @@ var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
|
230
241
|
};
|
|
231
242
|
});
|
|
232
243
|
|
|
233
|
-
_context.next =
|
|
244
|
+
_context.next = 41;
|
|
234
245
|
break;
|
|
235
246
|
|
|
236
247
|
case 31:
|
|
237
248
|
_context.prev = 31;
|
|
238
249
|
_context.t4 = _context["catch"](5);
|
|
239
250
|
|
|
251
|
+
if (!closed) {
|
|
252
|
+
// If the user lookup fails while the menu is open, send UFO failure
|
|
253
|
+
// TODO handle with-option-failovers example here (falls back to alt data source)
|
|
254
|
+
_this.optionsShownUfoExperienceInstance.failure();
|
|
255
|
+
}
|
|
256
|
+
|
|
240
257
|
_this.setState({
|
|
241
258
|
users: [],
|
|
242
259
|
error: true
|
|
243
260
|
});
|
|
244
261
|
|
|
245
|
-
_context.next =
|
|
262
|
+
_context.next = 37;
|
|
246
263
|
return _this.props.onError ? _this.props.onError(_context.t4, recommendationsRequest) || Promise.resolve([]) : Promise.resolve([]);
|
|
247
264
|
|
|
248
|
-
case
|
|
265
|
+
case 37:
|
|
249
266
|
defaultUsers = _context.sent;
|
|
250
267
|
_elapsedTimeMilli = window.performance.now() - startTime;
|
|
251
268
|
|
|
@@ -259,7 +276,7 @@ var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
|
259
276
|
productAttributes: productAttributes
|
|
260
277
|
});
|
|
261
278
|
|
|
262
|
-
case
|
|
279
|
+
case 41:
|
|
263
280
|
case "end":
|
|
264
281
|
return _context.stop();
|
|
265
282
|
}
|
|
@@ -275,6 +292,12 @@ var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
|
275
292
|
}
|
|
276
293
|
|
|
277
294
|
if (!closed) {
|
|
295
|
+
// If the input has been typed into and the dropdown has not been closed
|
|
296
|
+
// (i.e. input blurred) then start the UFO timer.
|
|
297
|
+
// If there's a previous UFO timer running for the same "options shown" experience,
|
|
298
|
+
// it will be aborted first.
|
|
299
|
+
_this.startOptionsShownUfoExperience();
|
|
300
|
+
|
|
278
301
|
_this.setState({
|
|
279
302
|
loading: true,
|
|
280
303
|
query: query,
|
|
@@ -329,6 +352,8 @@ var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
|
329
352
|
closed: false
|
|
330
353
|
};
|
|
331
354
|
|
|
355
|
+
_this.startOptionsShownUfoExperience();
|
|
356
|
+
|
|
332
357
|
if (_this.state.users.length === 0) {
|
|
333
358
|
state.sessionId = sessionId;
|
|
334
359
|
state.loading = true;
|
|
@@ -349,7 +374,9 @@ var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
|
349
374
|
}
|
|
350
375
|
});
|
|
351
376
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBlur", function (sessionId) {
|
|
352
|
-
_this.getUsers.cancel();
|
|
377
|
+
_this.getUsers.cancel();
|
|
378
|
+
|
|
379
|
+
_this.abortOptionsShownUfoExperience(); // clear old users if query is populated so that on refocus,
|
|
353
380
|
// the old list is not shown
|
|
354
381
|
|
|
355
382
|
|
|
@@ -365,6 +392,7 @@ var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
|
365
392
|
_this.props.onBlur(sessionId);
|
|
366
393
|
}
|
|
367
394
|
});
|
|
395
|
+
_this.optionsShownUfoExperienceInstance = _ufoExperiences.smartUserPickerOptionsShownUfoExperience.getInstance(props.inputId || props.fieldId);
|
|
368
396
|
return _this;
|
|
369
397
|
}
|
|
370
398
|
|
|
@@ -439,6 +467,12 @@ var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
|
439
467
|
|
|
440
468
|
if ((this.state.sessionId !== prevState.sessionId || this.state.query !== prevState.query) && (this.state.query !== '' || !this.props.bootstrapOptions)) {
|
|
441
469
|
this.getUsers();
|
|
470
|
+
} else if (!this.state.closed && !this.state.loading) {
|
|
471
|
+
// If the component has rendered (including its dropdown list) and it
|
|
472
|
+
// is not loading anything further, send the success UFO event
|
|
473
|
+
if (![_ufo.UFOExperienceState.FAILED.id, _ufo.UFOExperienceState.SUCCEEDED.id].includes(this.optionsShownUfoExperienceInstance.state.id)) {
|
|
474
|
+
this.optionsShownUfoExperienceInstance.success();
|
|
475
|
+
}
|
|
442
476
|
}
|
|
443
477
|
}
|
|
444
478
|
}, {
|
|
@@ -16,8 +16,11 @@ var _MessagesIntlProvider = _interopRequireDefault(require("./MessagesIntlProvid
|
|
|
16
16
|
var _ufoExperiences = require("../ufoExperiences");
|
|
17
17
|
|
|
18
18
|
var SmartUserPickerWithIntlProvider = function SmartUserPickerWithIntlProvider(props) {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
var ufoId = props.inputId || props.fieldId;
|
|
20
|
+
(0, _ufoExperiences.useUFOConcurrentExperience)(_ufoExperiences.smartUserPickerRenderedUfoExperience, ufoId);
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement(_ufoExperiences.UfoErrorBoundary, {
|
|
22
|
+
id: ufoId
|
|
23
|
+
}, /*#__PURE__*/_react.default.createElement(_MessagesIntlProvider.default, null, /*#__PURE__*/_react.default.createElement(_SmartUserPicker.SmartUserPicker, props)));
|
|
21
24
|
};
|
|
22
25
|
|
|
23
26
|
var _default = SmartUserPickerWithIntlProvider;
|
package/dist/cjs/config/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var LOCAL_CONFIG = {
|
|
|
14
14
|
return productKey === 'jira' ? "https://jdog.jira-dev.com/rest/api/3/user/bulk" : "https://pug.jira-dev.com/wiki/rest/api/user/bulk";
|
|
15
15
|
},
|
|
16
16
|
getGraphQLUrl: function getGraphQLUrl(baseUrl) {
|
|
17
|
-
return baseUrl ? "".concat(STG_INSTANCE, "/").concat(baseUrl, "/graphql") : "".concat(STG_INSTANCE, "/graphql");
|
|
17
|
+
return baseUrl ? "".concat(STG_INSTANCE, "/").concat(baseUrl, "/gateway/api/graphql") : "".concat(STG_INSTANCE, "/gateway/api/graphql");
|
|
18
18
|
},
|
|
19
19
|
getTeamsUrl: function getTeamsUrl(baseUrl) {
|
|
20
20
|
return baseUrl ? "".concat(STG_INSTANCE, "/").concat(baseUrl, "/gateway/api/v3/teams") : "".concat(STG_INSTANCE, "/gateway/api/v3/teams");
|
|
@@ -29,7 +29,7 @@ var PRD_CONFIG = {
|
|
|
29
29
|
return productKey === 'jira' ? "".concat(baseUrl, "/rest/api/3/user/bulk") : "".concat(baseUrl, "/wiki/rest/api/user/bulk");
|
|
30
30
|
},
|
|
31
31
|
getGraphQLUrl: function getGraphQLUrl(baseUrl) {
|
|
32
|
-
return baseUrl ? "".concat(baseUrl, "/graphql") : "/graphql";
|
|
32
|
+
return baseUrl ? "".concat(baseUrl, "/gateway/api/graphql") : "/gateway/api/graphql";
|
|
33
33
|
},
|
|
34
34
|
getTeamsUrl: function getTeamsUrl(baseUrl) {
|
|
35
35
|
return baseUrl ? "".concat(baseUrl, "/gateway/api/v3/teams") : "/gateway/api/v3/teams";
|
|
@@ -1,13 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
3
7
|
Object.defineProperty(exports, "__esModule", {
|
|
4
8
|
value: true
|
|
5
9
|
});
|
|
6
|
-
exports.useUFOConcurrentExperience = exports.smartUserPickerRenderedUfoExperience = void 0;
|
|
10
|
+
exports.useUFOConcurrentExperience = exports.smartUserPickerRenderedUfoExperience = exports.smartUserPickerOptionsShownUfoExperience = exports.UfoErrorBoundary = void 0;
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
7
23
|
|
|
8
24
|
var _ufo = require("@atlaskit/ufo");
|
|
9
25
|
|
|
10
|
-
|
|
26
|
+
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); }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
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); }; }
|
|
31
|
+
|
|
32
|
+
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; } }
|
|
11
33
|
|
|
12
34
|
var COMPONENT_NAME = 'smart-user-picker';
|
|
13
35
|
var smartUserPickerRenderedUfoExperience = new _ufo.ConcurrentExperience('smart-user-picker-rendered', {
|
|
@@ -18,6 +40,14 @@ var smartUserPickerRenderedUfoExperience = new _ufo.ConcurrentExperience('smart-
|
|
|
18
40
|
performanceType: _ufo.ExperiencePerformanceTypes.PageSegmentLoad
|
|
19
41
|
});
|
|
20
42
|
exports.smartUserPickerRenderedUfoExperience = smartUserPickerRenderedUfoExperience;
|
|
43
|
+
var smartUserPickerOptionsShownUfoExperience = new _ufo.ConcurrentExperience('smart-user-picker-options-shown', {
|
|
44
|
+
platform: {
|
|
45
|
+
component: COMPONENT_NAME
|
|
46
|
+
},
|
|
47
|
+
type: _ufo.ExperienceTypes.Operation,
|
|
48
|
+
performanceType: _ufo.ExperiencePerformanceTypes.InlineResult
|
|
49
|
+
});
|
|
50
|
+
exports.smartUserPickerOptionsShownUfoExperience = smartUserPickerOptionsShownUfoExperience;
|
|
21
51
|
|
|
22
52
|
var useUFOConcurrentExperience = function useUFOConcurrentExperience(experience, id) {
|
|
23
53
|
var experienceForId = experience.getInstance(id); // Equivalent to componentWillMount - replace with @atlaskit/ufo's
|
|
@@ -28,12 +58,43 @@ var useUFOConcurrentExperience = function useUFOConcurrentExperience(experience,
|
|
|
28
58
|
}); // Replace with @atlaskit/ufo's <ExperienceSuccess> when it supports ConcurrentExperience
|
|
29
59
|
|
|
30
60
|
(0, _react.useEffect)(function () {
|
|
31
|
-
experienceForId.
|
|
61
|
+
if (experienceForId.state !== _ufo.UFOExperienceState['FAILED']) {
|
|
62
|
+
experienceForId.success();
|
|
63
|
+
}
|
|
64
|
+
|
|
32
65
|
return function () {
|
|
33
|
-
experienceForId.
|
|
66
|
+
if ([_ufo.UFOExperienceState['STARTED'], _ufo.UFOExperienceState['IN_PROGRESS']].includes(experienceForId.state)) {
|
|
67
|
+
experienceForId.abort();
|
|
68
|
+
}
|
|
34
69
|
}; // We only want this useEffect to run once after component mount, so no deps are needed.
|
|
35
70
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
71
|
}, []);
|
|
37
72
|
};
|
|
38
73
|
|
|
39
|
-
exports.useUFOConcurrentExperience = useUFOConcurrentExperience;
|
|
74
|
+
exports.useUFOConcurrentExperience = useUFOConcurrentExperience;
|
|
75
|
+
|
|
76
|
+
var UfoErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
77
|
+
(0, _inherits2.default)(UfoErrorBoundary, _React$Component);
|
|
78
|
+
|
|
79
|
+
var _super = _createSuper(UfoErrorBoundary);
|
|
80
|
+
|
|
81
|
+
function UfoErrorBoundary() {
|
|
82
|
+
(0, _classCallCheck2.default)(this, UfoErrorBoundary);
|
|
83
|
+
return _super.apply(this, arguments);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
(0, _createClass2.default)(UfoErrorBoundary, [{
|
|
87
|
+
key: "componentDidCatch",
|
|
88
|
+
value: function componentDidCatch() {
|
|
89
|
+
smartUserPickerRenderedUfoExperience.getInstance(this.props.id).failure();
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "render",
|
|
93
|
+
value: function render() {
|
|
94
|
+
return this.props.children;
|
|
95
|
+
}
|
|
96
|
+
}]);
|
|
97
|
+
return UfoErrorBoundary;
|
|
98
|
+
}(_react.default.Component);
|
|
99
|
+
|
|
100
|
+
exports.UfoErrorBoundary = UfoErrorBoundary;
|
package/dist/cjs/version.json
CHANGED
|
@@ -6,10 +6,12 @@ import { v4 as uuidV4 } from 'uuid';
|
|
|
6
6
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
7
7
|
import memoizeOne from 'memoize-one';
|
|
8
8
|
import { injectIntl } from 'react-intl-next';
|
|
9
|
+
import { UFOExperienceState } from '@atlaskit/ufo';
|
|
9
10
|
import UserPicker from '@atlaskit/user-picker';
|
|
10
11
|
import { requestUsersEvent, filterUsersEvent, preparedUsersLoadedEvent, successfulRequestUsersEvent, failedRequestUsersEvent, mountedWithPrefetchEvent, createAndFireEventInElementsChannel } from '../analytics';
|
|
11
12
|
import MessagesIntlProvider from './MessagesIntlProvider';
|
|
12
13
|
import { getUserRecommendations, hydrateDefaultValues } from '../service';
|
|
14
|
+
import { smartUserPickerOptionsShownUfoExperience } from '../ufoExperiences';
|
|
13
15
|
const DEFAULT_DEBOUNCE_TIME_MS = 150;
|
|
14
16
|
|
|
15
17
|
const hasContextChanged = (oldContext, newContext) => 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,10 +37,10 @@ const getUsersForAnalytics = users => (users || []).map(({
|
|
|
35
37
|
}));
|
|
36
38
|
|
|
37
39
|
export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
38
|
-
constructor(
|
|
40
|
+
constructor(props) {
|
|
39
41
|
var _this$props$debounceT;
|
|
40
42
|
|
|
41
|
-
super(
|
|
43
|
+
super(props);
|
|
42
44
|
|
|
43
45
|
_defineProperty(this, "state", {
|
|
44
46
|
users: [],
|
|
@@ -50,6 +52,19 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
50
52
|
bootstrapOptions: []
|
|
51
53
|
});
|
|
52
54
|
|
|
55
|
+
_defineProperty(this, "abortOptionsShownUfoExperience", () => {
|
|
56
|
+
if (this.optionsShownUfoExperienceInstance.state.id === UFOExperienceState.STARTED.id) {
|
|
57
|
+
// There may be an existing UFO timing running from previous key entry or focus,
|
|
58
|
+
// so abort it and restart it just in case.
|
|
59
|
+
this.optionsShownUfoExperienceInstance.abort();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
_defineProperty(this, "startOptionsShownUfoExperience", () => {
|
|
64
|
+
this.abortOptionsShownUfoExperience();
|
|
65
|
+
this.optionsShownUfoExperienceInstance.start();
|
|
66
|
+
});
|
|
67
|
+
|
|
53
68
|
_defineProperty(this, "fireEvent", (eventCreator, ...args) => {
|
|
54
69
|
const {
|
|
55
70
|
createAnalyticsEvent
|
|
@@ -67,7 +82,8 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
67
82
|
_defineProperty(this, "getUsers", debounce(async () => {
|
|
68
83
|
const {
|
|
69
84
|
query,
|
|
70
|
-
sessionId
|
|
85
|
+
sessionId,
|
|
86
|
+
closed
|
|
71
87
|
} = this.state;
|
|
72
88
|
const {
|
|
73
89
|
containerId,
|
|
@@ -135,6 +151,12 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
135
151
|
};
|
|
136
152
|
});
|
|
137
153
|
} catch (e) {
|
|
154
|
+
if (!closed) {
|
|
155
|
+
// If the user lookup fails while the menu is open, send UFO failure
|
|
156
|
+
// TODO handle with-option-failovers example here (falls back to alt data source)
|
|
157
|
+
this.optionsShownUfoExperienceInstance.failure();
|
|
158
|
+
}
|
|
159
|
+
|
|
138
160
|
this.setState({
|
|
139
161
|
users: [],
|
|
140
162
|
error: true
|
|
@@ -163,6 +185,11 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
163
185
|
}
|
|
164
186
|
|
|
165
187
|
if (!closed) {
|
|
188
|
+
// If the input has been typed into and the dropdown has not been closed
|
|
189
|
+
// (i.e. input blurred) then start the UFO timer.
|
|
190
|
+
// If there's a previous UFO timer running for the same "options shown" experience,
|
|
191
|
+
// it will be aborted first.
|
|
192
|
+
this.startOptionsShownUfoExperience();
|
|
166
193
|
this.setState({
|
|
167
194
|
loading: true,
|
|
168
195
|
query,
|
|
@@ -211,6 +238,7 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
211
238
|
query: '',
|
|
212
239
|
closed: false
|
|
213
240
|
};
|
|
241
|
+
this.startOptionsShownUfoExperience();
|
|
214
242
|
|
|
215
243
|
if (this.state.users.length === 0) {
|
|
216
244
|
state.sessionId = sessionId;
|
|
@@ -233,7 +261,8 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
233
261
|
});
|
|
234
262
|
|
|
235
263
|
_defineProperty(this, "onBlur", sessionId => {
|
|
236
|
-
this.getUsers.cancel();
|
|
264
|
+
this.getUsers.cancel();
|
|
265
|
+
this.abortOptionsShownUfoExperience(); // clear old users if query is populated so that on refocus,
|
|
237
266
|
// the old list is not shown
|
|
238
267
|
|
|
239
268
|
const users = this.state.query.length === 0 ? this.state.users : [];
|
|
@@ -247,6 +276,8 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
247
276
|
this.props.onBlur(sessionId);
|
|
248
277
|
}
|
|
249
278
|
});
|
|
279
|
+
|
|
280
|
+
this.optionsShownUfoExperienceInstance = smartUserPickerOptionsShownUfoExperience.getInstance(props.inputId || props.fieldId);
|
|
250
281
|
}
|
|
251
282
|
|
|
252
283
|
async componentDidMount() {
|
|
@@ -286,6 +317,12 @@ export class SmartUserPickerWithoutAnalytics extends React.Component {
|
|
|
286
317
|
|
|
287
318
|
if ((this.state.sessionId !== prevState.sessionId || this.state.query !== prevState.query) && (this.state.query !== '' || !this.props.bootstrapOptions)) {
|
|
288
319
|
this.getUsers();
|
|
320
|
+
} else if (!this.state.closed && !this.state.loading) {
|
|
321
|
+
// If the component has rendered (including its dropdown list) and it
|
|
322
|
+
// is not loading anything further, send the success UFO event
|
|
323
|
+
if (![UFOExperienceState.FAILED.id, UFOExperienceState.SUCCEEDED.id].includes(this.optionsShownUfoExperienceInstance.state.id)) {
|
|
324
|
+
this.optionsShownUfoExperienceInstance.success();
|
|
325
|
+
}
|
|
289
326
|
}
|
|
290
327
|
}
|
|
291
328
|
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SmartUserPicker } from './SmartUserPicker';
|
|
3
3
|
import MessagesIntlProvider from './MessagesIntlProvider';
|
|
4
|
-
import { useUFOConcurrentExperience, smartUserPickerRenderedUfoExperience } from '../ufoExperiences';
|
|
4
|
+
import { useUFOConcurrentExperience, smartUserPickerRenderedUfoExperience, UfoErrorBoundary } from '../ufoExperiences';
|
|
5
5
|
|
|
6
6
|
const SmartUserPickerWithIntlProvider = props => {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const ufoId = props.inputId || props.fieldId;
|
|
8
|
+
useUFOConcurrentExperience(smartUserPickerRenderedUfoExperience, ufoId);
|
|
9
|
+
return /*#__PURE__*/React.createElement(UfoErrorBoundary, {
|
|
10
|
+
id: ufoId
|
|
11
|
+
}, /*#__PURE__*/React.createElement(MessagesIntlProvider, null, /*#__PURE__*/React.createElement(SmartUserPicker, props)));
|
|
9
12
|
};
|
|
10
13
|
|
|
11
14
|
export default SmartUserPickerWithIntlProvider;
|
|
@@ -10,7 +10,7 @@ const LOCAL_CONFIG = {
|
|
|
10
10
|
},
|
|
11
11
|
|
|
12
12
|
getGraphQLUrl(baseUrl) {
|
|
13
|
-
return baseUrl ? `${STG_INSTANCE}/${baseUrl}/graphql` : `${STG_INSTANCE}/graphql`;
|
|
13
|
+
return baseUrl ? `${STG_INSTANCE}/${baseUrl}/gateway/api/graphql` : `${STG_INSTANCE}/gateway/api/graphql`;
|
|
14
14
|
},
|
|
15
15
|
|
|
16
16
|
getTeamsUrl(baseUrl) {
|
|
@@ -28,7 +28,7 @@ const PRD_CONFIG = {
|
|
|
28
28
|
},
|
|
29
29
|
|
|
30
30
|
getGraphQLUrl(baseUrl) {
|
|
31
|
-
return baseUrl ? `${baseUrl}/graphql` : `/graphql`;
|
|
31
|
+
return baseUrl ? `${baseUrl}/gateway/api/graphql` : `/gateway/api/graphql`;
|
|
32
32
|
},
|
|
33
33
|
|
|
34
34
|
getTeamsUrl(baseUrl) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ExperiencePerformanceTypes, ExperienceTypes, ConcurrentExperience, UFOExperienceState } from '@atlaskit/ufo';
|
|
2
3
|
import { useEffect, useState } from 'react';
|
|
3
4
|
const COMPONENT_NAME = 'smart-user-picker';
|
|
4
5
|
export const smartUserPickerRenderedUfoExperience = new ConcurrentExperience('smart-user-picker-rendered', {
|
|
@@ -8,6 +9,13 @@ export const smartUserPickerRenderedUfoExperience = new ConcurrentExperience('sm
|
|
|
8
9
|
type: ExperienceTypes.Load,
|
|
9
10
|
performanceType: ExperiencePerformanceTypes.PageSegmentLoad
|
|
10
11
|
});
|
|
12
|
+
export const smartUserPickerOptionsShownUfoExperience = new ConcurrentExperience('smart-user-picker-options-shown', {
|
|
13
|
+
platform: {
|
|
14
|
+
component: COMPONENT_NAME
|
|
15
|
+
},
|
|
16
|
+
type: ExperienceTypes.Operation,
|
|
17
|
+
performanceType: ExperiencePerformanceTypes.InlineResult
|
|
18
|
+
});
|
|
11
19
|
export const useUFOConcurrentExperience = (experience, id) => {
|
|
12
20
|
const experienceForId = experience.getInstance(id); // Equivalent to componentWillMount - replace with @atlaskit/ufo's
|
|
13
21
|
// useUFOComponentExperience when it supports ConcurrentExperience.
|
|
@@ -17,10 +25,25 @@ export const useUFOConcurrentExperience = (experience, id) => {
|
|
|
17
25
|
}); // Replace with @atlaskit/ufo's <ExperienceSuccess> when it supports ConcurrentExperience
|
|
18
26
|
|
|
19
27
|
useEffect(() => {
|
|
20
|
-
experienceForId.
|
|
28
|
+
if (experienceForId.state !== UFOExperienceState['FAILED']) {
|
|
29
|
+
experienceForId.success();
|
|
30
|
+
}
|
|
31
|
+
|
|
21
32
|
return () => {
|
|
22
|
-
experienceForId.
|
|
33
|
+
if ([UFOExperienceState['STARTED'], UFOExperienceState['IN_PROGRESS']].includes(experienceForId.state)) {
|
|
34
|
+
experienceForId.abort();
|
|
35
|
+
}
|
|
23
36
|
}; // We only want this useEffect to run once after component mount, so no deps are needed.
|
|
24
37
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
38
|
}, []);
|
|
26
|
-
};
|
|
39
|
+
};
|
|
40
|
+
export class UfoErrorBoundary extends React.Component {
|
|
41
|
+
componentDidCatch() {
|
|
42
|
+
smartUserPickerRenderedUfoExperience.getInstance(this.props.id).failure();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
render() {
|
|
46
|
+
return this.props.children;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -23,10 +23,12 @@ import { v4 as uuidV4 } from 'uuid';
|
|
|
23
23
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
24
24
|
import memoizeOne from 'memoize-one';
|
|
25
25
|
import { injectIntl } from 'react-intl-next';
|
|
26
|
+
import { UFOExperienceState } from '@atlaskit/ufo';
|
|
26
27
|
import UserPicker from '@atlaskit/user-picker';
|
|
27
28
|
import { requestUsersEvent, filterUsersEvent, preparedUsersLoadedEvent, successfulRequestUsersEvent, failedRequestUsersEvent, mountedWithPrefetchEvent, createAndFireEventInElementsChannel } from '../analytics';
|
|
28
29
|
import MessagesIntlProvider from './MessagesIntlProvider';
|
|
29
30
|
import { getUserRecommendations, hydrateDefaultValues } from '../service';
|
|
31
|
+
import { smartUserPickerOptionsShownUfoExperience } from '../ufoExperiences';
|
|
30
32
|
var DEFAULT_DEBOUNCE_TIME_MS = 150;
|
|
31
33
|
|
|
32
34
|
var hasContextChanged = function hasContextChanged(oldContext, newContext) {
|
|
@@ -61,18 +63,14 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
61
63
|
|
|
62
64
|
var _super = _createSuper(SmartUserPickerWithoutAnalytics);
|
|
63
65
|
|
|
64
|
-
function SmartUserPickerWithoutAnalytics() {
|
|
66
|
+
function SmartUserPickerWithoutAnalytics(props) {
|
|
65
67
|
var _this$props$debounceT;
|
|
66
68
|
|
|
67
69
|
var _this;
|
|
68
70
|
|
|
69
71
|
_classCallCheck(this, SmartUserPickerWithoutAnalytics);
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
_args[_key] = arguments[_key];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
_this = _super.call.apply(_super, [this].concat(_args));
|
|
73
|
+
_this = _super.call(this, props);
|
|
76
74
|
|
|
77
75
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
78
76
|
users: [],
|
|
@@ -84,12 +82,26 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
84
82
|
bootstrapOptions: []
|
|
85
83
|
});
|
|
86
84
|
|
|
85
|
+
_defineProperty(_assertThisInitialized(_this), "abortOptionsShownUfoExperience", function () {
|
|
86
|
+
if (_this.optionsShownUfoExperienceInstance.state.id === UFOExperienceState.STARTED.id) {
|
|
87
|
+
// There may be an existing UFO timing running from previous key entry or focus,
|
|
88
|
+
// so abort it and restart it just in case.
|
|
89
|
+
_this.optionsShownUfoExperienceInstance.abort();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
_defineProperty(_assertThisInitialized(_this), "startOptionsShownUfoExperience", function () {
|
|
94
|
+
_this.abortOptionsShownUfoExperience();
|
|
95
|
+
|
|
96
|
+
_this.optionsShownUfoExperienceInstance.start();
|
|
97
|
+
});
|
|
98
|
+
|
|
87
99
|
_defineProperty(_assertThisInitialized(_this), "fireEvent", function (eventCreator) {
|
|
88
100
|
var createAnalyticsEvent = _this.props.createAnalyticsEvent;
|
|
89
101
|
|
|
90
102
|
if (createAnalyticsEvent) {
|
|
91
|
-
for (var
|
|
92
|
-
args[
|
|
103
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
104
|
+
args[_key - 1] = arguments[_key];
|
|
93
105
|
}
|
|
94
106
|
|
|
95
107
|
createAndFireEventInElementsChannel(eventCreator.apply(void 0, [_this.props, _this.state].concat(args)))(createAnalyticsEvent);
|
|
@@ -103,13 +115,13 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
103
115
|
_defineProperty(_assertThisInitialized(_this), "memoizedFilterOptions", memoizeOne(_this.filterOptions));
|
|
104
116
|
|
|
105
117
|
_defineProperty(_assertThisInitialized(_this), "getUsers", debounce( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
106
|
-
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;
|
|
118
|
+
var _this$state, query, sessionId, closed, _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;
|
|
107
119
|
|
|
108
120
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
109
121
|
while (1) {
|
|
110
122
|
switch (_context.prev = _context.next) {
|
|
111
123
|
case 0:
|
|
112
|
-
_this$state = _this.state, query = _this$state.query, sessionId = _this$state.sessionId;
|
|
124
|
+
_this$state = _this.state, query = _this$state.query, sessionId = _this$state.sessionId, closed = _this$state.closed;
|
|
113
125
|
_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;
|
|
114
126
|
maxNumberOfResults = maxOptions || 100;
|
|
115
127
|
startTime = window.performance.now();
|
|
@@ -207,22 +219,28 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
207
219
|
};
|
|
208
220
|
});
|
|
209
221
|
|
|
210
|
-
_context.next =
|
|
222
|
+
_context.next = 41;
|
|
211
223
|
break;
|
|
212
224
|
|
|
213
225
|
case 31:
|
|
214
226
|
_context.prev = 31;
|
|
215
227
|
_context.t4 = _context["catch"](5);
|
|
216
228
|
|
|
229
|
+
if (!closed) {
|
|
230
|
+
// If the user lookup fails while the menu is open, send UFO failure
|
|
231
|
+
// TODO handle with-option-failovers example here (falls back to alt data source)
|
|
232
|
+
_this.optionsShownUfoExperienceInstance.failure();
|
|
233
|
+
}
|
|
234
|
+
|
|
217
235
|
_this.setState({
|
|
218
236
|
users: [],
|
|
219
237
|
error: true
|
|
220
238
|
});
|
|
221
239
|
|
|
222
|
-
_context.next =
|
|
240
|
+
_context.next = 37;
|
|
223
241
|
return _this.props.onError ? _this.props.onError(_context.t4, recommendationsRequest) || Promise.resolve([]) : Promise.resolve([]);
|
|
224
242
|
|
|
225
|
-
case
|
|
243
|
+
case 37:
|
|
226
244
|
defaultUsers = _context.sent;
|
|
227
245
|
_elapsedTimeMilli = window.performance.now() - startTime;
|
|
228
246
|
|
|
@@ -236,7 +254,7 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
236
254
|
productAttributes: productAttributes
|
|
237
255
|
});
|
|
238
256
|
|
|
239
|
-
case
|
|
257
|
+
case 41:
|
|
240
258
|
case "end":
|
|
241
259
|
return _context.stop();
|
|
242
260
|
}
|
|
@@ -253,6 +271,12 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
253
271
|
}
|
|
254
272
|
|
|
255
273
|
if (!closed) {
|
|
274
|
+
// If the input has been typed into and the dropdown has not been closed
|
|
275
|
+
// (i.e. input blurred) then start the UFO timer.
|
|
276
|
+
// If there's a previous UFO timer running for the same "options shown" experience,
|
|
277
|
+
// it will be aborted first.
|
|
278
|
+
_this.startOptionsShownUfoExperience();
|
|
279
|
+
|
|
256
280
|
_this.setState({
|
|
257
281
|
loading: true,
|
|
258
282
|
query: query,
|
|
@@ -309,6 +333,8 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
309
333
|
closed: false
|
|
310
334
|
};
|
|
311
335
|
|
|
336
|
+
_this.startOptionsShownUfoExperience();
|
|
337
|
+
|
|
312
338
|
if (_this.state.users.length === 0) {
|
|
313
339
|
state.sessionId = sessionId;
|
|
314
340
|
state.loading = true;
|
|
@@ -330,7 +356,9 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
330
356
|
});
|
|
331
357
|
|
|
332
358
|
_defineProperty(_assertThisInitialized(_this), "onBlur", function (sessionId) {
|
|
333
|
-
_this.getUsers.cancel();
|
|
359
|
+
_this.getUsers.cancel();
|
|
360
|
+
|
|
361
|
+
_this.abortOptionsShownUfoExperience(); // clear old users if query is populated so that on refocus,
|
|
334
362
|
// the old list is not shown
|
|
335
363
|
|
|
336
364
|
|
|
@@ -347,6 +375,7 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
347
375
|
}
|
|
348
376
|
});
|
|
349
377
|
|
|
378
|
+
_this.optionsShownUfoExperienceInstance = smartUserPickerOptionsShownUfoExperience.getInstance(props.inputId || props.fieldId);
|
|
350
379
|
return _this;
|
|
351
380
|
}
|
|
352
381
|
|
|
@@ -421,6 +450,12 @@ export var SmartUserPickerWithoutAnalytics = /*#__PURE__*/function (_React$Compo
|
|
|
421
450
|
|
|
422
451
|
if ((this.state.sessionId !== prevState.sessionId || this.state.query !== prevState.query) && (this.state.query !== '' || !this.props.bootstrapOptions)) {
|
|
423
452
|
this.getUsers();
|
|
453
|
+
} else if (!this.state.closed && !this.state.loading) {
|
|
454
|
+
// If the component has rendered (including its dropdown list) and it
|
|
455
|
+
// is not loading anything further, send the success UFO event
|
|
456
|
+
if (![UFOExperienceState.FAILED.id, UFOExperienceState.SUCCEEDED.id].includes(this.optionsShownUfoExperienceInstance.state.id)) {
|
|
457
|
+
this.optionsShownUfoExperienceInstance.success();
|
|
458
|
+
}
|
|
424
459
|
}
|
|
425
460
|
}
|
|
426
461
|
}, {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SmartUserPicker } from './SmartUserPicker';
|
|
3
3
|
import MessagesIntlProvider from './MessagesIntlProvider';
|
|
4
|
-
import { useUFOConcurrentExperience, smartUserPickerRenderedUfoExperience } from '../ufoExperiences';
|
|
4
|
+
import { useUFOConcurrentExperience, smartUserPickerRenderedUfoExperience, UfoErrorBoundary } from '../ufoExperiences';
|
|
5
5
|
|
|
6
6
|
var SmartUserPickerWithIntlProvider = function SmartUserPickerWithIntlProvider(props) {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
var ufoId = props.inputId || props.fieldId;
|
|
8
|
+
useUFOConcurrentExperience(smartUserPickerRenderedUfoExperience, ufoId);
|
|
9
|
+
return /*#__PURE__*/React.createElement(UfoErrorBoundary, {
|
|
10
|
+
id: ufoId
|
|
11
|
+
}, /*#__PURE__*/React.createElement(MessagesIntlProvider, null, /*#__PURE__*/React.createElement(SmartUserPicker, props)));
|
|
9
12
|
};
|
|
10
13
|
|
|
11
14
|
export default SmartUserPickerWithIntlProvider;
|
package/dist/esm/config/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var LOCAL_CONFIG = {
|
|
|
8
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
9
|
},
|
|
10
10
|
getGraphQLUrl: function getGraphQLUrl(baseUrl) {
|
|
11
|
-
return baseUrl ? "".concat(STG_INSTANCE, "/").concat(baseUrl, "/graphql") : "".concat(STG_INSTANCE, "/graphql");
|
|
11
|
+
return baseUrl ? "".concat(STG_INSTANCE, "/").concat(baseUrl, "/gateway/api/graphql") : "".concat(STG_INSTANCE, "/gateway/api/graphql");
|
|
12
12
|
},
|
|
13
13
|
getTeamsUrl: function getTeamsUrl(baseUrl) {
|
|
14
14
|
return baseUrl ? "".concat(STG_INSTANCE, "/").concat(baseUrl, "/gateway/api/v3/teams") : "".concat(STG_INSTANCE, "/gateway/api/v3/teams");
|
|
@@ -23,7 +23,7 @@ var PRD_CONFIG = {
|
|
|
23
23
|
return productKey === 'jira' ? "".concat(baseUrl, "/rest/api/3/user/bulk") : "".concat(baseUrl, "/wiki/rest/api/user/bulk");
|
|
24
24
|
},
|
|
25
25
|
getGraphQLUrl: function getGraphQLUrl(baseUrl) {
|
|
26
|
-
return baseUrl ? "".concat(baseUrl, "/graphql") : "/graphql";
|
|
26
|
+
return baseUrl ? "".concat(baseUrl, "/gateway/api/graphql") : "/gateway/api/graphql";
|
|
27
27
|
},
|
|
28
28
|
getTeamsUrl: function getTeamsUrl(baseUrl) {
|
|
29
29
|
return baseUrl ? "".concat(baseUrl, "/gateway/api/v3/teams") : "/gateway/api/v3/teams";
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
|
|
7
|
+
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); }; }
|
|
8
|
+
|
|
9
|
+
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; } }
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { ExperiencePerformanceTypes, ExperienceTypes, ConcurrentExperience, UFOExperienceState } from '@atlaskit/ufo';
|
|
2
13
|
import { useEffect, useState } from 'react';
|
|
3
14
|
var COMPONENT_NAME = 'smart-user-picker';
|
|
4
15
|
export var smartUserPickerRenderedUfoExperience = new ConcurrentExperience('smart-user-picker-rendered', {
|
|
@@ -8,6 +19,13 @@ export var smartUserPickerRenderedUfoExperience = new ConcurrentExperience('smar
|
|
|
8
19
|
type: ExperienceTypes.Load,
|
|
9
20
|
performanceType: ExperiencePerformanceTypes.PageSegmentLoad
|
|
10
21
|
});
|
|
22
|
+
export var smartUserPickerOptionsShownUfoExperience = new ConcurrentExperience('smart-user-picker-options-shown', {
|
|
23
|
+
platform: {
|
|
24
|
+
component: COMPONENT_NAME
|
|
25
|
+
},
|
|
26
|
+
type: ExperienceTypes.Operation,
|
|
27
|
+
performanceType: ExperiencePerformanceTypes.InlineResult
|
|
28
|
+
});
|
|
11
29
|
export var useUFOConcurrentExperience = function useUFOConcurrentExperience(experience, id) {
|
|
12
30
|
var experienceForId = experience.getInstance(id); // Equivalent to componentWillMount - replace with @atlaskit/ufo's
|
|
13
31
|
// useUFOComponentExperience when it supports ConcurrentExperience.
|
|
@@ -17,10 +35,40 @@ export var useUFOConcurrentExperience = function useUFOConcurrentExperience(expe
|
|
|
17
35
|
}); // Replace with @atlaskit/ufo's <ExperienceSuccess> when it supports ConcurrentExperience
|
|
18
36
|
|
|
19
37
|
useEffect(function () {
|
|
20
|
-
experienceForId.
|
|
38
|
+
if (experienceForId.state !== UFOExperienceState['FAILED']) {
|
|
39
|
+
experienceForId.success();
|
|
40
|
+
}
|
|
41
|
+
|
|
21
42
|
return function () {
|
|
22
|
-
experienceForId.
|
|
43
|
+
if ([UFOExperienceState['STARTED'], UFOExperienceState['IN_PROGRESS']].includes(experienceForId.state)) {
|
|
44
|
+
experienceForId.abort();
|
|
45
|
+
}
|
|
23
46
|
}; // We only want this useEffect to run once after component mount, so no deps are needed.
|
|
24
47
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
48
|
}, []);
|
|
26
|
-
};
|
|
49
|
+
};
|
|
50
|
+
export var UfoErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
51
|
+
_inherits(UfoErrorBoundary, _React$Component);
|
|
52
|
+
|
|
53
|
+
var _super = _createSuper(UfoErrorBoundary);
|
|
54
|
+
|
|
55
|
+
function UfoErrorBoundary() {
|
|
56
|
+
_classCallCheck(this, UfoErrorBoundary);
|
|
57
|
+
|
|
58
|
+
return _super.apply(this, arguments);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
_createClass(UfoErrorBoundary, [{
|
|
62
|
+
key: "componentDidCatch",
|
|
63
|
+
value: function componentDidCatch() {
|
|
64
|
+
smartUserPickerRenderedUfoExperience.getInstance(this.props.id).failure();
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "render",
|
|
68
|
+
value: function render() {
|
|
69
|
+
return this.props.children;
|
|
70
|
+
}
|
|
71
|
+
}]);
|
|
72
|
+
|
|
73
|
+
return UfoErrorBoundary;
|
|
74
|
+
}(React.Component);
|
package/dist/esm/version.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { WrappedComponentProps } from 'react-intl-next';
|
|
4
|
+
import { UFOExperience } from '@atlaskit/ufo';
|
|
4
5
|
import { OptionData } from '@atlaskit/user-picker';
|
|
5
6
|
import { Props, State, FilterOptions } from '../types';
|
|
6
7
|
export declare class SmartUserPickerWithoutAnalytics extends React.Component<Props & WrappedComponentProps, State> {
|
|
7
8
|
state: State;
|
|
9
|
+
optionsShownUfoExperienceInstance: UFOExperience;
|
|
8
10
|
static defaultProps: {
|
|
9
11
|
onError: () => void;
|
|
10
12
|
baseUrl: string;
|
|
@@ -15,8 +17,11 @@ export declare class SmartUserPickerWithoutAnalytics extends React.Component<Pro
|
|
|
15
17
|
principalId: string;
|
|
16
18
|
debounceTime: number;
|
|
17
19
|
};
|
|
20
|
+
constructor(props: Props & WrappedComponentProps);
|
|
18
21
|
componentDidMount(): Promise<void>;
|
|
19
22
|
componentDidUpdate(prevProps: Props, prevState: State): void;
|
|
23
|
+
abortOptionsShownUfoExperience: () => void;
|
|
24
|
+
startOptionsShownUfoExperience: () => void;
|
|
20
25
|
private fireEvent;
|
|
21
26
|
filterOptions: (users: OptionData[], query: string, propFilterOptions?: FilterOptions | undefined) => OptionData[];
|
|
22
27
|
memoizedFilterOptions: import("memoize-one").MemoizedFn<(users: OptionData[], query: string, propFilterOptions?: FilterOptions | undefined) => OptionData[]>;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { ConcurrentExperience } from '@atlaskit/ufo';
|
|
2
3
|
export declare const smartUserPickerRenderedUfoExperience: ConcurrentExperience;
|
|
4
|
+
export declare const smartUserPickerOptionsShownUfoExperience: ConcurrentExperience;
|
|
3
5
|
export declare const useUFOConcurrentExperience: (experience: ConcurrentExperience, id: string) => void;
|
|
6
|
+
export declare class UfoErrorBoundary extends React.Component<{
|
|
7
|
+
id: string;
|
|
8
|
+
}> {
|
|
9
|
+
componentDidCatch(): void;
|
|
10
|
+
render(): React.ReactNode;
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-user-picker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/"
|
|
6
6
|
},
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@atlaskit/analytics-next": "^8.2.0",
|
|
26
26
|
"@atlaskit/ufo": "^0.1.0",
|
|
27
|
-
"@atlaskit/user-picker": "^8.
|
|
27
|
+
"@atlaskit/user-picker": "^8.7.0",
|
|
28
28
|
"@babel/runtime": "^7.0.0",
|
|
29
29
|
"lodash": "^4.17.21",
|
|
30
30
|
"memoize-one": "^6.0.0",
|