@atlaskit/mention 22.0.0 → 22.1.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 +16 -0
- package/dist/cjs/api/MentionResource.js +111 -112
- package/dist/cjs/api/PresenceResource.js +1 -1
- package/dist/cjs/api/TeamMentionResource.js +95 -101
- package/dist/cjs/api/analytics.js +4 -4
- package/dist/cjs/components/LockCircleIcon/index.js +1 -1
- package/dist/cjs/components/Mention/PrimitiveMention.js +1 -0
- package/dist/cjs/components/MentionItem/index.js +1 -0
- package/dist/cjs/components/MentionList/index.js +1 -2
- package/dist/cjs/components/MentionListError/GenericErrorIllustration.js +1 -1
- package/dist/cjs/components/MentionPicker/index.js +8 -8
- package/dist/cjs/components/NoAccessTooltip/index.js +1 -1
- package/dist/cjs/components/ResourcedMentionList/index.js +2 -4
- package/dist/cjs/components/Scrollable/index.js +1 -0
- package/dist/cjs/types.js +16 -16
- package/dist/cjs/util/analytics.js +12 -12
- package/dist/cjs/util/i18n.js +194 -196
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/api/MentionResource.js +5 -1
- package/dist/es2019/api/analytics.js +3 -3
- package/dist/es2019/components/MentionItem/index.js +1 -0
- package/dist/es2019/components/MentionList/index.js +1 -2
- package/dist/es2019/components/MentionPicker/index.js +8 -9
- package/dist/es2019/components/ResourcedMentionList/index.js +2 -6
- package/dist/es2019/components/Scrollable/index.js +1 -0
- package/dist/es2019/types.js +12 -12
- package/dist/es2019/util/analytics.js +9 -9
- package/dist/es2019/version.json +1 -1
- package/dist/esm/api/MentionResource.js +109 -113
- package/dist/esm/api/PresenceResource.js +1 -1
- package/dist/esm/api/TeamMentionResource.js +95 -101
- package/dist/esm/api/analytics.js +3 -3
- package/dist/esm/components/MentionItem/index.js +1 -0
- package/dist/esm/components/MentionList/index.js +1 -2
- package/dist/esm/components/MentionPicker/index.js +8 -8
- package/dist/esm/components/ResourcedMentionList/index.js +2 -4
- package/dist/esm/components/Scrollable/index.js +1 -0
- package/dist/esm/types.js +12 -12
- package/dist/esm/util/analytics.js +9 -9
- package/dist/esm/util/i18n.js +134 -136
- package/dist/esm/version.json +1 -1
- package/package.json +19 -19
|
@@ -33,6 +33,7 @@ function extractPresences(mentions) {
|
|
|
33
33
|
export class ResourcedMentionListWithoutAnalytics extends React.PureComponent {
|
|
34
34
|
constructor(props) {
|
|
35
35
|
super(props);
|
|
36
|
+
// API
|
|
36
37
|
_defineProperty(this, "selectNext", () => {
|
|
37
38
|
if (this.mentionListRef) {
|
|
38
39
|
this.mentionListRef.selectNext();
|
|
@@ -64,6 +65,7 @@ export class ResourcedMentionListWithoutAnalytics extends React.PureComponent {
|
|
|
64
65
|
}
|
|
65
66
|
return 0;
|
|
66
67
|
});
|
|
68
|
+
// internal, used for callbacks
|
|
67
69
|
_defineProperty(this, "filterChange", mentions => {
|
|
68
70
|
// Retain known presence
|
|
69
71
|
const currentPresences = extractPresences(this.state.mentions);
|
|
@@ -116,9 +118,6 @@ export class ResourcedMentionListWithoutAnalytics extends React.PureComponent {
|
|
|
116
118
|
this.unsubscribeMentionProvider(this.props.resourceProvider);
|
|
117
119
|
this.unsubscribePresenceProvider(this.props.presenceProvider);
|
|
118
120
|
}
|
|
119
|
-
|
|
120
|
-
// API
|
|
121
|
-
|
|
122
121
|
// internal
|
|
123
122
|
subscribeMentionProvider(mentionProvider) {
|
|
124
123
|
if (mentionProvider) {
|
|
@@ -173,9 +172,6 @@ export class ResourcedMentionListWithoutAnalytics extends React.PureComponent {
|
|
|
173
172
|
this.props.presenceProvider.refreshPresence(ids);
|
|
174
173
|
}
|
|
175
174
|
}
|
|
176
|
-
|
|
177
|
-
// internal, used for callbacks
|
|
178
|
-
|
|
179
175
|
render() {
|
|
180
176
|
const {
|
|
181
177
|
mentions,
|
|
@@ -5,6 +5,7 @@ import { ScrollableStyle } from './styles';
|
|
|
5
5
|
export default class Scrollable extends React.PureComponent {
|
|
6
6
|
constructor(...args) {
|
|
7
7
|
super(...args);
|
|
8
|
+
// API
|
|
8
9
|
_defineProperty(this, "reveal", child => {
|
|
9
10
|
if (child && this.scrollableDiv) {
|
|
10
11
|
const childNode = findDOMNode(child);
|
package/dist/es2019/types.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
// data is returned from team search service
|
|
2
2
|
|
|
3
|
-
export let MentionType
|
|
4
|
-
(function (MentionType) {
|
|
3
|
+
export let MentionType = /*#__PURE__*/function (MentionType) {
|
|
5
4
|
MentionType[MentionType["SELF"] = 0] = "SELF";
|
|
6
5
|
MentionType[MentionType["RESTRICTED"] = 1] = "RESTRICTED";
|
|
7
6
|
MentionType[MentionType["DEFAULT"] = 2] = "DEFAULT";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
return MentionType;
|
|
8
|
+
}({});
|
|
9
|
+
export let UserAccessLevel = /*#__PURE__*/function (UserAccessLevel) {
|
|
11
10
|
UserAccessLevel[UserAccessLevel["NONE"] = 0] = "NONE";
|
|
12
11
|
UserAccessLevel[UserAccessLevel["SITE"] = 1] = "SITE";
|
|
13
12
|
UserAccessLevel[UserAccessLevel["APPLICATION"] = 2] = "APPLICATION";
|
|
14
13
|
UserAccessLevel[UserAccessLevel["CONTAINER"] = 3] = "CONTAINER";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
return UserAccessLevel;
|
|
15
|
+
}({});
|
|
16
|
+
export let UserType = /*#__PURE__*/function (UserType) {
|
|
18
17
|
UserType[UserType["DEFAULT"] = 0] = "DEFAULT";
|
|
19
18
|
UserType[UserType["SPECIAL"] = 1] = "SPECIAL";
|
|
20
19
|
UserType[UserType["APP"] = 2] = "APP";
|
|
21
20
|
UserType[UserType["TEAM"] = 3] = "TEAM";
|
|
22
21
|
UserType[UserType["SYSTEM"] = 4] = "SYSTEM";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
return UserType;
|
|
23
|
+
}({});
|
|
24
|
+
export let MentionNameStatus = /*#__PURE__*/function (MentionNameStatus) {
|
|
26
25
|
MentionNameStatus[MentionNameStatus["UNKNOWN"] = 0] = "UNKNOWN";
|
|
27
26
|
MentionNameStatus[MentionNameStatus["SERVICE_ERROR"] = 1] = "SERVICE_ERROR";
|
|
28
27
|
MentionNameStatus[MentionNameStatus["OK"] = 2] = "OK";
|
|
29
|
-
|
|
28
|
+
return MentionNameStatus;
|
|
29
|
+
}({});
|
|
30
30
|
export function isRestricted(accessLevel) {
|
|
31
31
|
return !!accessLevel && accessLevel === UserAccessLevel[UserAccessLevel.NONE];
|
|
32
32
|
}
|
|
@@ -4,27 +4,27 @@ import { name as packageName, version as packageVersion } from '../version.json'
|
|
|
4
4
|
import { isSpecialMentionText } from '../types';
|
|
5
5
|
export const SLI_EVENT_TYPE = 'sli';
|
|
6
6
|
export const SMART_EVENT_TYPE = 'smart';
|
|
7
|
-
export let SliNames
|
|
8
|
-
(function (SliNames) {
|
|
7
|
+
export let SliNames = /*#__PURE__*/function (SliNames) {
|
|
9
8
|
SliNames["SEARCH"] = "searchUser";
|
|
10
9
|
SliNames["SEARCH_TEAM"] = "searchTeam";
|
|
11
10
|
SliNames["INITIAL_STATE"] = "initialState";
|
|
12
11
|
SliNames["SELECT"] = "select";
|
|
13
12
|
SliNames["SELECT_TEAM"] = "selectTeam";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
return SliNames;
|
|
14
|
+
}({});
|
|
15
|
+
export let ComponentNames = /*#__PURE__*/function (ComponentNames) {
|
|
17
16
|
ComponentNames["TYPEAHEAD"] = "mentionTypeahead";
|
|
18
17
|
ComponentNames["MENTION"] = "mention";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
return ComponentNames;
|
|
19
|
+
}({});
|
|
20
|
+
export let Actions = /*#__PURE__*/function (Actions) {
|
|
22
21
|
Actions["VIEWED"] = "viewed";
|
|
23
22
|
Actions["CLICKED"] = "clicked";
|
|
24
23
|
Actions["CLOSED"] = "closed";
|
|
25
24
|
Actions["SUCCEEDED"] = "succeeded";
|
|
26
25
|
Actions["FAILED"] = "failed";
|
|
27
|
-
|
|
26
|
+
return Actions;
|
|
27
|
+
}({});
|
|
28
28
|
export const fireAnalyticsMentionTypeaheadEvent = props => (action, duration, userIds = [], query) => {
|
|
29
29
|
if (props.createAnalyticsEvent) {
|
|
30
30
|
const eventPayload = {
|
package/dist/es2019/version.json
CHANGED
|
@@ -17,9 +17,13 @@ var MAX_QUERY_ITEMS = 100;
|
|
|
17
17
|
var MAX_NOTIFIED_ITEMS = 20;
|
|
18
18
|
// Re-exporting types to prevent breaking change
|
|
19
19
|
// Re-exporting types to prevent breaking change
|
|
20
|
-
|
|
21
20
|
import { SLI_EVENT_TYPE, Actions, SliNames } from '../util/analytics';
|
|
22
21
|
import debounce from 'lodash/debounce';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Support
|
|
25
|
+
*/
|
|
26
|
+
|
|
23
27
|
var emptySecurityProvider = function emptySecurityProvider() {
|
|
24
28
|
return {
|
|
25
29
|
params: {},
|
|
@@ -223,40 +227,38 @@ export var MentionResource = /*#__PURE__*/function (_AbstractMentionResou) {
|
|
|
223
227
|
var _filter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(query, contextIdentifier) {
|
|
224
228
|
var searchTime, results, searchResponse;
|
|
225
229
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
226
|
-
while (1) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
_context.next = 8;
|
|
233
|
-
break;
|
|
234
|
-
}
|
|
235
|
-
_context.next = 5;
|
|
236
|
-
return this.initialState(contextIdentifier);
|
|
237
|
-
case 5:
|
|
238
|
-
results = _context.sent;
|
|
239
|
-
_context.next = 13;
|
|
230
|
+
while (1) switch (_context.prev = _context.next) {
|
|
231
|
+
case 0:
|
|
232
|
+
_context.prev = 0;
|
|
233
|
+
searchTime = Date.now();
|
|
234
|
+
if (query) {
|
|
235
|
+
_context.next = 8;
|
|
240
236
|
break;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
237
|
+
}
|
|
238
|
+
_context.next = 5;
|
|
239
|
+
return this.initialState(contextIdentifier);
|
|
240
|
+
case 5:
|
|
241
|
+
results = _context.sent;
|
|
242
|
+
_context.next = 13;
|
|
243
|
+
break;
|
|
244
|
+
case 8:
|
|
245
|
+
this.activeSearches.add(query);
|
|
246
|
+
searchResponse = this.search(query, contextIdentifier);
|
|
247
|
+
_context.next = 12;
|
|
248
|
+
return searchResponse.mentions;
|
|
249
|
+
case 12:
|
|
250
|
+
results = _context.sent;
|
|
251
|
+
case 13:
|
|
252
|
+
this.notify(searchTime, results, query);
|
|
253
|
+
_context.next = 19;
|
|
254
|
+
break;
|
|
255
|
+
case 16:
|
|
256
|
+
_context.prev = 16;
|
|
257
|
+
_context.t0 = _context["catch"](0);
|
|
258
|
+
this.notifyError(_context.t0, query);
|
|
259
|
+
case 19:
|
|
260
|
+
case "end":
|
|
261
|
+
return _context.stop();
|
|
260
262
|
}
|
|
261
263
|
}, _callee, this, [[0, 16]]);
|
|
262
264
|
}));
|
|
@@ -368,30 +370,28 @@ export var MentionResource = /*#__PURE__*/function (_AbstractMentionResou) {
|
|
|
368
370
|
var _remoteInitialState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(contextIdentifier) {
|
|
369
371
|
var queryParams, options, result;
|
|
370
372
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
371
|
-
while (1) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
return _context2.stop();
|
|
394
|
-
}
|
|
373
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
374
|
+
case 0:
|
|
375
|
+
queryParams = this.getQueryParams(contextIdentifier);
|
|
376
|
+
options = {
|
|
377
|
+
path: 'bootstrap',
|
|
378
|
+
queryParams: queryParams
|
|
379
|
+
};
|
|
380
|
+
_context2.prev = 2;
|
|
381
|
+
_context2.next = 5;
|
|
382
|
+
return serviceUtils.requestService(this.config, options);
|
|
383
|
+
case 5:
|
|
384
|
+
result = _context2.sent;
|
|
385
|
+
this._notifyAnalyticsListeners(SLI_EVENT_TYPE, SliNames.INITIAL_STATE, Actions.SUCCEEDED);
|
|
386
|
+
return _context2.abrupt("return", this.transformServiceResponse(result, ''));
|
|
387
|
+
case 10:
|
|
388
|
+
_context2.prev = 10;
|
|
389
|
+
_context2.t0 = _context2["catch"](2);
|
|
390
|
+
this._notifyAnalyticsListeners(SLI_EVENT_TYPE, SliNames.INITIAL_STATE, Actions.FAILED);
|
|
391
|
+
throw _context2.t0;
|
|
392
|
+
case 14:
|
|
393
|
+
case "end":
|
|
394
|
+
return _context2.stop();
|
|
395
395
|
}
|
|
396
396
|
}, _callee2, this, [[2, 10]]);
|
|
397
397
|
}));
|
|
@@ -413,32 +413,30 @@ export var MentionResource = /*#__PURE__*/function (_AbstractMentionResou) {
|
|
|
413
413
|
var _remoteSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(query, contextIdentifier) {
|
|
414
414
|
var options, result;
|
|
415
415
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
416
|
-
while (1) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
return _context3.stop();
|
|
441
|
-
}
|
|
416
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
417
|
+
case 0:
|
|
418
|
+
options = {
|
|
419
|
+
path: 'search',
|
|
420
|
+
queryParams: _objectSpread({
|
|
421
|
+
query: query,
|
|
422
|
+
limit: MAX_QUERY_ITEMS
|
|
423
|
+
}, this.getQueryParams(contextIdentifier))
|
|
424
|
+
};
|
|
425
|
+
_context3.prev = 1;
|
|
426
|
+
_context3.next = 4;
|
|
427
|
+
return serviceUtils.requestService(this.config, options);
|
|
428
|
+
case 4:
|
|
429
|
+
result = _context3.sent;
|
|
430
|
+
this._notifyAnalyticsListeners(SLI_EVENT_TYPE, SliNames.SEARCH, Actions.SUCCEEDED);
|
|
431
|
+
return _context3.abrupt("return", this.transformServiceResponse(result, query));
|
|
432
|
+
case 9:
|
|
433
|
+
_context3.prev = 9;
|
|
434
|
+
_context3.t0 = _context3["catch"](1);
|
|
435
|
+
this._notifyAnalyticsListeners(SLI_EVENT_TYPE, SliNames.SEARCH, Actions.FAILED);
|
|
436
|
+
throw _context3.t0;
|
|
437
|
+
case 13:
|
|
438
|
+
case "end":
|
|
439
|
+
return _context3.stop();
|
|
442
440
|
}
|
|
443
441
|
}, _callee3, this, [[1, 9]]);
|
|
444
442
|
}));
|
|
@@ -473,35 +471,33 @@ export var MentionResource = /*#__PURE__*/function (_AbstractMentionResou) {
|
|
|
473
471
|
var _recordSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(mention, contextIdentifier) {
|
|
474
472
|
var options, sliName, result;
|
|
475
473
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
476
|
-
while (1) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
return _context4.stop();
|
|
504
|
-
}
|
|
474
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
475
|
+
case 0:
|
|
476
|
+
options = {
|
|
477
|
+
path: 'record',
|
|
478
|
+
queryParams: _objectSpread({
|
|
479
|
+
selectedUserId: mention.id
|
|
480
|
+
}, this.getQueryParams(contextIdentifier)),
|
|
481
|
+
requestInit: {
|
|
482
|
+
method: 'POST'
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
sliName = isTeamMention(mention) ? SliNames.SELECT_TEAM : SliNames.SELECT;
|
|
486
|
+
_context4.prev = 2;
|
|
487
|
+
_context4.next = 5;
|
|
488
|
+
return serviceUtils.requestService(this.config, options);
|
|
489
|
+
case 5:
|
|
490
|
+
result = _context4.sent;
|
|
491
|
+
this._notifyAnalyticsListeners(SLI_EVENT_TYPE, sliName, Actions.SUCCEEDED);
|
|
492
|
+
return _context4.abrupt("return", result);
|
|
493
|
+
case 10:
|
|
494
|
+
_context4.prev = 10;
|
|
495
|
+
_context4.t0 = _context4["catch"](2);
|
|
496
|
+
this._notifyAnalyticsListeners(SLI_EVENT_TYPE, sliName, Actions.FAILED);
|
|
497
|
+
throw _context4.t0;
|
|
498
|
+
case 14:
|
|
499
|
+
case "end":
|
|
500
|
+
return _context4.stop();
|
|
505
501
|
}
|
|
506
502
|
}, _callee4, this, [[2, 10]]);
|
|
507
503
|
}));
|
|
@@ -6,7 +6,7 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
6
6
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
7
7
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
8
8
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
10
|
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); }; }
|
|
11
11
|
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; } }
|
|
12
12
|
import debug from '../util/logger';
|
|
@@ -64,22 +64,20 @@ var TeamMentionResource = /*#__PURE__*/function (_MentionResource) {
|
|
|
64
64
|
var _remoteInitialStateTeamAndUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(contextIdentifier) {
|
|
65
65
|
var emptyQuery, getUserPromise, queryParams, options, getTeamsPromise;
|
|
66
66
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
67
|
-
while (1) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return _context.stop();
|
|
82
|
-
}
|
|
67
|
+
while (1) switch (_context.prev = _context.next) {
|
|
68
|
+
case 0:
|
|
69
|
+
emptyQuery = '';
|
|
70
|
+
getUserPromise = _get(_getPrototypeOf(TeamMentionResource.prototype), "remoteInitialState", this).call(this, contextIdentifier);
|
|
71
|
+
queryParams = this.getQueryParamsOfTeamMentionConfig(contextIdentifier);
|
|
72
|
+
options = {
|
|
73
|
+
path: 'bootstrap',
|
|
74
|
+
queryParams: queryParams
|
|
75
|
+
};
|
|
76
|
+
getTeamsPromise = serviceUtils.requestService(this.teamMentionConfig, options);
|
|
77
|
+
this.handleBothRequests(emptyQuery, getUserPromise, getTeamsPromise);
|
|
78
|
+
case 6:
|
|
79
|
+
case "end":
|
|
80
|
+
return _context.stop();
|
|
83
81
|
}
|
|
84
82
|
}, _callee, this);
|
|
85
83
|
}));
|
|
@@ -102,70 +100,68 @@ var TeamMentionResource = /*#__PURE__*/function (_MentionResource) {
|
|
|
102
100
|
var _this2 = this;
|
|
103
101
|
var searchTime, accumulatedResults, notifyWhenOneRequestDone, userResults, userRequestError, teamRequestError, teamsResult;
|
|
104
102
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
105
|
-
while (1) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
104
|
+
case 0:
|
|
105
|
+
searchTime = Date.now();
|
|
106
|
+
accumulatedResults = {
|
|
107
|
+
mentions: [],
|
|
108
|
+
query: query
|
|
109
|
+
};
|
|
110
|
+
notifyWhenOneRequestDone = function notifyWhenOneRequestDone(results, hasTeamResults) {
|
|
111
|
+
// just update UI for the last query string
|
|
112
|
+
if (query !== _this2.lastSearchQuery) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
109
115
|
accumulatedResults = {
|
|
110
|
-
mentions: [],
|
|
116
|
+
mentions: [].concat(_toConsumableArray(accumulatedResults.mentions), _toConsumableArray(results.mentions)),
|
|
111
117
|
query: query
|
|
112
118
|
};
|
|
113
|
-
notifyWhenOneRequestDone = function notifyWhenOneRequestDone(results, hasTeamResults) {
|
|
114
|
-
// just update UI for the last query string
|
|
115
|
-
if (query !== _this2.lastSearchQuery) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
accumulatedResults = {
|
|
119
|
-
mentions: [].concat(_toConsumableArray(accumulatedResults.mentions), _toConsumableArray(results.mentions)),
|
|
120
|
-
query: query
|
|
121
|
-
};
|
|
122
119
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
userRequestError = null;
|
|
131
|
-
teamRequestError = null;
|
|
132
|
-
_context2.prev = 5;
|
|
133
|
-
_context2.next = 8;
|
|
134
|
-
return userRequest;
|
|
135
|
-
case 8:
|
|
136
|
-
userResults = _context2.sent;
|
|
137
|
-
notifyWhenOneRequestDone(userResults, false);
|
|
138
|
-
_context2.next = 15;
|
|
139
|
-
break;
|
|
140
|
-
case 12:
|
|
141
|
-
_context2.prev = 12;
|
|
142
|
-
_context2.t0 = _context2["catch"](5);
|
|
143
|
-
userRequestError = _context2.t0;
|
|
144
|
-
case 15:
|
|
145
|
-
_context2.prev = 15;
|
|
146
|
-
_context2.next = 18;
|
|
147
|
-
return teamRequest;
|
|
148
|
-
case 18:
|
|
149
|
-
teamsResult = _context2.sent;
|
|
150
|
-
// update search time after team results returns
|
|
151
|
-
notifyWhenOneRequestDone(Array.isArray(teamsResult) ? this.convertTeamResultToMentionResult(teamsResult, query) : teamsResult, true);
|
|
152
|
-
_context2.next = 25;
|
|
153
|
-
break;
|
|
154
|
-
case 22:
|
|
155
|
-
_context2.prev = 22;
|
|
156
|
-
_context2.t1 = _context2["catch"](15);
|
|
157
|
-
teamRequestError = _context2.t1;
|
|
158
|
-
case 25:
|
|
159
|
-
// both requests fail, show one of errors in UI
|
|
160
|
-
if (userRequestError && teamRequestError) {
|
|
161
|
-
this.notifyError(userRequestError, query);
|
|
162
|
-
debug('User mention request fails. ', userRequestError);
|
|
163
|
-
debug('Team mention request fails. ', teamRequestError);
|
|
120
|
+
// we need to calculate different `duration` for user and team request.
|
|
121
|
+
if (hasTeamResults) {
|
|
122
|
+
_this2.notify(searchTime, accumulatedResults, query);
|
|
123
|
+
} else {
|
|
124
|
+
_get(_getPrototypeOf(TeamMentionResource.prototype), "notify", _this2).call(_this2, searchTime, accumulatedResults, query);
|
|
164
125
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
126
|
+
};
|
|
127
|
+
userRequestError = null;
|
|
128
|
+
teamRequestError = null;
|
|
129
|
+
_context2.prev = 5;
|
|
130
|
+
_context2.next = 8;
|
|
131
|
+
return userRequest;
|
|
132
|
+
case 8:
|
|
133
|
+
userResults = _context2.sent;
|
|
134
|
+
notifyWhenOneRequestDone(userResults, false);
|
|
135
|
+
_context2.next = 15;
|
|
136
|
+
break;
|
|
137
|
+
case 12:
|
|
138
|
+
_context2.prev = 12;
|
|
139
|
+
_context2.t0 = _context2["catch"](5);
|
|
140
|
+
userRequestError = _context2.t0;
|
|
141
|
+
case 15:
|
|
142
|
+
_context2.prev = 15;
|
|
143
|
+
_context2.next = 18;
|
|
144
|
+
return teamRequest;
|
|
145
|
+
case 18:
|
|
146
|
+
teamsResult = _context2.sent;
|
|
147
|
+
// update search time after team results returns
|
|
148
|
+
notifyWhenOneRequestDone(Array.isArray(teamsResult) ? this.convertTeamResultToMentionResult(teamsResult, query) : teamsResult, true);
|
|
149
|
+
_context2.next = 25;
|
|
150
|
+
break;
|
|
151
|
+
case 22:
|
|
152
|
+
_context2.prev = 22;
|
|
153
|
+
_context2.t1 = _context2["catch"](15);
|
|
154
|
+
teamRequestError = _context2.t1;
|
|
155
|
+
case 25:
|
|
156
|
+
// both requests fail, show one of errors in UI
|
|
157
|
+
if (userRequestError && teamRequestError) {
|
|
158
|
+
this.notifyError(userRequestError, query);
|
|
159
|
+
debug('User mention request fails. ', userRequestError);
|
|
160
|
+
debug('Team mention request fails. ', teamRequestError);
|
|
161
|
+
}
|
|
162
|
+
case 26:
|
|
163
|
+
case "end":
|
|
164
|
+
return _context2.stop();
|
|
169
165
|
}
|
|
170
166
|
}, _callee2, this, [[5, 12], [15, 22]]);
|
|
171
167
|
}));
|
|
@@ -214,32 +210,30 @@ var TeamMentionResource = /*#__PURE__*/function (_MentionResource) {
|
|
|
214
210
|
var _remoteTeamSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(query, contextIdentifier) {
|
|
215
211
|
var options, teamResult;
|
|
216
212
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
217
|
-
while (1) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
return _context3.stop();
|
|
242
|
-
}
|
|
213
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
214
|
+
case 0:
|
|
215
|
+
options = {
|
|
216
|
+
path: 'search',
|
|
217
|
+
queryParams: _objectSpread({
|
|
218
|
+
query: query,
|
|
219
|
+
limit: MAX_QUERY_TEAMS
|
|
220
|
+
}, this.getQueryParamsOfTeamMentionConfig(contextIdentifier))
|
|
221
|
+
};
|
|
222
|
+
_context3.prev = 1;
|
|
223
|
+
_context3.next = 4;
|
|
224
|
+
return serviceUtils.requestService(this.teamMentionConfig, options);
|
|
225
|
+
case 4:
|
|
226
|
+
teamResult = _context3.sent;
|
|
227
|
+
this._notifyAnalyticsListeners(SLI_EVENT_TYPE, SliNames.SEARCH_TEAM, Actions.SUCCEEDED);
|
|
228
|
+
return _context3.abrupt("return", this.convertTeamResultToMentionResult(teamResult, query));
|
|
229
|
+
case 9:
|
|
230
|
+
_context3.prev = 9;
|
|
231
|
+
_context3.t0 = _context3["catch"](1);
|
|
232
|
+
this._notifyAnalyticsListeners(SLI_EVENT_TYPE, SliNames.SEARCH_TEAM, Actions.FAILED);
|
|
233
|
+
throw _context3.t0;
|
|
234
|
+
case 13:
|
|
235
|
+
case "end":
|
|
236
|
+
return _context3.stop();
|
|
243
237
|
}
|
|
244
238
|
}, _callee3, this, [[1, 9]]);
|
|
245
239
|
}));
|