@atlaskit/mention 19.8.1 → 19.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @atlaskit/mention
2
2
 
3
+ ## 19.9.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`d1ed723c1e0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d1ed723c1e0) - Fix bug where includeTeams in smartMentionResource was not being passed in correctly
8
+
9
+ ## 19.9.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`570ccaa00bd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/570ccaa00bd) - Add the ability for users in Default Mention Name Resolver to be nullable
14
+
15
+ ## 19.9.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [`a92e3bdb515`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a92e3bdb515) - Relaxed product enum typing to take in any string
20
+
21
+ ## 19.9.0
22
+
23
+ ### Minor Changes
24
+
25
+ - [`e65ada9dbbb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e65ada9dbbb) - Debounce MentionResource when debounceTime is passed in
26
+
3
27
  ## 19.8.1
4
28
 
5
29
  ### Patch Changes
@@ -31,6 +31,8 @@ var _logger = _interopRequireDefault(require("../util/logger"));
31
31
 
32
32
  var _analytics = require("../util/analytics");
33
33
 
34
+ var _debounce = _interopRequireDefault(require("lodash/debounce"));
35
+
34
36
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
35
37
 
36
38
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
@@ -221,6 +223,11 @@ var MentionResource = /*#__PURE__*/function (_AbstractMentionResou) {
221
223
  _this.inviteExperimentCohort = config.inviteExperimentCohort;
222
224
  _this.onInviteItemClick = config.onInviteItemClick;
223
225
  _this.userRole = config.userRole || 'basic';
226
+
227
+ if (_this.config.debounceTime) {
228
+ _this.filter = (0, _debounce.default)(_this.filter, _this.config.debounceTime);
229
+ }
230
+
224
231
  return _this;
225
232
  }
226
233
 
@@ -165,17 +165,22 @@ var SmartMentionResource = /*#__PURE__*/function (_AbstractMentionResou) {
165
165
  maxNumberOfResults = conf.maxNumberOfResults || 100;
166
166
  request = {
167
167
  baseUrl: conf.baseUrl,
168
- context: _objectSpread(_objectSpread({}, conf), {}, {
168
+ context: {
169
+ productKey: conf.productKey,
169
170
  contextType: CONTEXT_TYPE,
170
171
  principalId: conf.principalId || 'context',
171
172
  containerId: contextIdentifier && contextIdentifier.containerId,
173
+ siteId: conf.siteId,
172
174
  objectId: contextIdentifier && contextIdentifier.objectId || 'undefined',
173
175
  childObjectId: contextIdentifier && contextIdentifier.childObjectId || 'undefined',
174
176
  mentionsSessionId: contextIdentifier && contextIdentifier.sessionId || 'undefined',
175
177
  sessionId: contextIdentifier && contextIdentifier.sessionId || 'undefined'
176
- }),
178
+ },
179
+ includeGroups: conf.includeGroups,
180
+ includeTeams: conf.includeTeams,
177
181
  includeUsers: typeof conf.includeUsers === 'undefined' ? true : conf.includeUsers,
178
182
  maxNumberOfResults: maxNumberOfResults,
183
+ searchQueryFilter: conf.searchQueryFilter,
179
184
  query: query
180
185
  };
181
186
  _context2.prev = 4;
@@ -64,7 +64,8 @@ var DefaultMentionNameResolver = /*#__PURE__*/function () {
64
64
  key: "lookupName",
65
65
  value: function () {
66
66
  var _lookupName = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(id) {
67
- var url, data, userInfo;
67
+ var _data$users, url, data, userInfo;
68
+
68
69
  return _regenerator.default.wrap(function _callee2$(_context2) {
69
70
  while (1) {
70
71
  switch (_context2.prev = _context2.next) {
@@ -89,7 +90,7 @@ var DefaultMentionNameResolver = /*#__PURE__*/function () {
89
90
 
90
91
  case 6:
91
92
  data = _context2.sent;
92
- userInfo = data.users.find(function (user) {
93
+ userInfo = (_data$users = data.users) === null || _data$users === void 0 ? void 0 : _data$users.find(function (user) {
93
94
  return user.accountId === id;
94
95
  });
95
96
  return _context2.abrupt("return", userInfo ? {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/mention",
3
- "version": "19.8.1",
3
+ "version": "19.9.3",
4
4
  "sideEffects": false
5
5
  }
@@ -6,6 +6,7 @@ const MAX_NOTIFIED_ITEMS = 20;
6
6
  // Re-exporting types to prevent breaking change
7
7
  // Re-exporting types to prevent breaking change
8
8
  import { SLI_EVENT_TYPE, Actions, SliNames } from '../util/analytics';
9
+ import debounce from 'lodash/debounce';
9
10
 
10
11
  const emptySecurityProvider = () => {
11
12
  return {
@@ -148,6 +149,10 @@ export class MentionResource extends AbstractMentionResource {
148
149
  this.inviteExperimentCohort = config.inviteExperimentCohort;
149
150
  this.onInviteItemClick = config.onInviteItemClick;
150
151
  this.userRole = config.userRole || 'basic';
152
+
153
+ if (this.config.debounceTime) {
154
+ this.filter = debounce(this.filter, this.config.debounceTime);
155
+ }
151
156
  }
152
157
 
153
158
  shouldHighlightMention(mention) {
@@ -74,17 +74,22 @@ class SmartMentionResource extends AbstractMentionResource {
74
74
  const maxNumberOfResults = conf.maxNumberOfResults || 100;
75
75
  const request = {
76
76
  baseUrl: conf.baseUrl,
77
- context: { ...conf,
77
+ context: {
78
+ productKey: conf.productKey,
78
79
  contextType: CONTEXT_TYPE,
79
80
  principalId: conf.principalId || 'context',
80
81
  containerId: contextIdentifier && contextIdentifier.containerId,
82
+ siteId: conf.siteId,
81
83
  objectId: contextIdentifier && contextIdentifier.objectId || 'undefined',
82
84
  childObjectId: contextIdentifier && contextIdentifier.childObjectId || 'undefined',
83
85
  mentionsSessionId: contextIdentifier && contextIdentifier.sessionId || 'undefined',
84
86
  sessionId: contextIdentifier && contextIdentifier.sessionId || 'undefined'
85
87
  },
88
+ includeGroups: conf.includeGroups,
89
+ includeTeams: conf.includeTeams,
86
90
  includeUsers: typeof conf.includeUsers === 'undefined' ? true : conf.includeUsers,
87
91
  maxNumberOfResults: maxNumberOfResults,
92
+ searchQueryFilter: conf.searchQueryFilter,
88
93
  query
89
94
  };
90
95
 
@@ -27,6 +27,8 @@ export class DefaultMentionNameResolver {
27
27
 
28
28
  async lookupName(id) {
29
29
  try {
30
+ var _data$users;
31
+
30
32
  if (this.cache.has(id)) {
31
33
  return {
32
34
  id,
@@ -37,7 +39,7 @@ export class DefaultMentionNameResolver {
37
39
 
38
40
  const url = getConfig().getGraphQLUrl(this.baseUrl);
39
41
  const data = await makeRequest(url, [id]);
40
- const userInfo = data.users.find(user => user.accountId === id);
42
+ const userInfo = (_data$users = data.users) === null || _data$users === void 0 ? void 0 : _data$users.find(user => user.accountId === id);
41
43
  return userInfo ? {
42
44
  id,
43
45
  name: userInfo.name,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/mention",
3
- "version": "19.8.1",
3
+ "version": "19.9.3",
4
4
  "sideEffects": false
5
5
  }
@@ -23,6 +23,7 @@ var MAX_NOTIFIED_ITEMS = 20;
23
23
  // Re-exporting types to prevent breaking change
24
24
  // Re-exporting types to prevent breaking change
25
25
  import { SLI_EVENT_TYPE, Actions, SliNames } from '../util/analytics';
26
+ import debounce from 'lodash/debounce';
26
27
 
27
28
  var emptySecurityProvider = function emptySecurityProvider() {
28
29
  return {
@@ -204,6 +205,11 @@ export var MentionResource = /*#__PURE__*/function (_AbstractMentionResou) {
204
205
  _this.inviteExperimentCohort = config.inviteExperimentCohort;
205
206
  _this.onInviteItemClick = config.onInviteItemClick;
206
207
  _this.userRole = config.userRole || 'basic';
208
+
209
+ if (_this.config.debounceTime) {
210
+ _this.filter = debounce(_this.filter, _this.config.debounceTime);
211
+ }
212
+
207
213
  return _this;
208
214
  }
209
215
 
@@ -143,17 +143,22 @@ var SmartMentionResource = /*#__PURE__*/function (_AbstractMentionResou) {
143
143
  maxNumberOfResults = conf.maxNumberOfResults || 100;
144
144
  request = {
145
145
  baseUrl: conf.baseUrl,
146
- context: _objectSpread(_objectSpread({}, conf), {}, {
146
+ context: {
147
+ productKey: conf.productKey,
147
148
  contextType: CONTEXT_TYPE,
148
149
  principalId: conf.principalId || 'context',
149
150
  containerId: contextIdentifier && contextIdentifier.containerId,
151
+ siteId: conf.siteId,
150
152
  objectId: contextIdentifier && contextIdentifier.objectId || 'undefined',
151
153
  childObjectId: contextIdentifier && contextIdentifier.childObjectId || 'undefined',
152
154
  mentionsSessionId: contextIdentifier && contextIdentifier.sessionId || 'undefined',
153
155
  sessionId: contextIdentifier && contextIdentifier.sessionId || 'undefined'
154
- }),
156
+ },
157
+ includeGroups: conf.includeGroups,
158
+ includeTeams: conf.includeTeams,
155
159
  includeUsers: typeof conf.includeUsers === 'undefined' ? true : conf.includeUsers,
156
160
  maxNumberOfResults: maxNumberOfResults,
161
+ searchQueryFilter: conf.searchQueryFilter,
157
162
  query: query
158
163
  };
159
164
  _context2.prev = 4;
@@ -50,7 +50,8 @@ export var DefaultMentionNameResolver = /*#__PURE__*/function () {
50
50
  key: "lookupName",
51
51
  value: function () {
52
52
  var _lookupName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id) {
53
- var url, data, userInfo;
53
+ var _data$users, url, data, userInfo;
54
+
54
55
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
55
56
  while (1) {
56
57
  switch (_context2.prev = _context2.next) {
@@ -75,7 +76,7 @@ export var DefaultMentionNameResolver = /*#__PURE__*/function () {
75
76
 
76
77
  case 6:
77
78
  data = _context2.sent;
78
- userInfo = data.users.find(function (user) {
79
+ userInfo = (_data$users = data.users) === null || _data$users === void 0 ? void 0 : _data$users.find(function (user) {
79
80
  return user.accountId === id;
80
81
  });
81
82
  return _context2.abrupt("return", userInfo ? {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/mention",
3
- "version": "19.8.1",
3
+ "version": "19.9.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,3 @@
1
- import { SupportedProduct } from './SmartMentionTypes';
2
1
  import { MentionContextIdentifier, MentionsResult, MentionDescription, MentionNameDetails, MentionNameResolver } from '../types';
3
2
  import { AbstractMentionResource, ResolvingMentionProvider } from '../resource';
4
3
  export interface SmartMentionConfig {
@@ -13,12 +12,11 @@ export interface SmartMentionConfig {
13
12
  */
14
13
  principalId?: string;
15
14
  /**
16
- * Use 'people' if you are waiting for a product scope.
17
- * If your product is not part of the SupportedProduct enum,
18
- * and you have a supported product scope, please raise a PR
19
- * to add your product onto the SupportedProduct enum.
15
+ * Platform search is only available for certain products. Please
16
+ * reach out to #help-smart-experiences to check.
17
+ * Use productKey='people' if you are waiting for a product scope.
20
18
  */
21
- productKey: SupportedProduct;
19
+ productKey: string;
22
20
  /**
23
21
  * Lucene-type query to proxy onto the search service.
24
22
  */
@@ -1,4 +1,3 @@
1
- export declare type SupportedProduct = 'jira' | 'confluence' | 'people' | 'bitbucket';
2
1
  export interface RecommendationRequest {
3
2
  baseUrl?: string;
4
3
  context: Context;
@@ -21,7 +20,7 @@ export interface Context {
21
20
  sessionId?: string;
22
21
  principalId: string;
23
22
  childObjectId?: string;
24
- productKey: 'jira' | 'confluence' | 'people' | 'bitbucket';
23
+ productKey: string;
25
24
  siteId: string;
26
25
  productAttributes?: ProductAttributes;
27
26
  }
@@ -31,6 +31,7 @@ export interface MentionResourceConfig extends ServiceConfig {
31
31
  onInviteItemClick?: (flow: InviteFlow) => void;
32
32
  userRole?: UserRole;
33
33
  productName?: string;
34
+ debounceTime?: number;
34
35
  }
35
36
  export interface ResourceProvider<Result> {
36
37
  /**
@@ -9,10 +9,10 @@ import {
9
9
  import SectionMessage from '@atlaskit/section-message';
10
10
 
11
11
  const MentionProps = require('!!extract-react-types-loader!../src/api/extract-react-types/smart-config-props');
12
- import MentionWithEditorExample from '../examples/14-mention-with-editor';
13
- const MentionWithEditorExampleSource = require('!!raw-loader!../examples/14-mention-with-editor');
14
- import SmartMentionWithEditorExample from '../examples/15-smart-mention-resource';
15
- const SmartMentionWithEditorExampleSource = require('!!raw-loader!../examples/15-smart-mention-resource');
12
+ import MentionWithEditorExample from '../examples/14-mention-with-editor-extending-abstract-mention-resource';
13
+ const MentionWithEditorExampleSource = require('!!raw-loader!../examples/14-mention-with-editor-extending-abstract-mention-resource');
14
+ import SmartMentionWithEditorExample from '../examples/16-smart-mention-resource';
15
+ const SmartMentionWithEditorExampleSource = require('!!raw-loader!../examples/16-smart-mention-resource');
16
16
 
17
17
  export default md`
18
18
  ${(<AtlassianInternalWarning />)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/mention",
3
- "version": "19.8.1",
3
+ "version": "19.9.3",
4
4
  "description": "A React component used to display user profiles in a list for 'Mention' functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -36,6 +36,7 @@
36
36
  "@atlaskit/tooltip": "^17.5.0",
37
37
  "@atlaskit/util-service-support": "^6.0.0",
38
38
  "@babel/runtime": "^7.0.0",
39
+ "lodash": "^4.17.15",
39
40
  "uuid": "^3.1.0"
40
41
  },
41
42
  "peerDependencies": {
@@ -48,8 +49,8 @@
48
49
  "@atlaskit/adf-utils": "^14.2.0",
49
50
  "@atlaskit/build-utils": "*",
50
51
  "@atlaskit/docs": "^9.0.0",
51
- "@atlaskit/editor-core": "^150.0.0",
52
- "@atlaskit/editor-test-helpers": "^15.4.0",
52
+ "@atlaskit/editor-core": "^151.2.0",
53
+ "@atlaskit/editor-test-helpers": "^15.5.0",
53
54
  "@atlaskit/elements-test-helpers": "^0.7.0",
54
55
  "@atlaskit/section-message": "^6.0.0",
55
56
  "@atlaskit/ssr": "*",