@atlaskit/profilecard 19.0.0 → 19.1.1

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,17 @@
1
1
  # @atlaskit/profilecard
2
2
 
3
+ ## 19.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`f80d2e43a41`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f80d2e43a41) - Added traceId, errorSource and errorMessage to analytic events
8
+
9
+ ## 19.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`13af6ca0e48`](https://bitbucket.org/atlassian/atlassian-frontend/commits/13af6ca0e48) - [ux] TSLA-521 docs(changeset): [ux] This change (TSLA-521) adds keyboard support for the profile card component by adding tabindex, an onKeyPress handler, and setting role="button" when the card is trigged by click. This change also adds unit tests for the profile card trigger as well as notifcations.
14
+
3
15
  ## 19.0.0
4
16
 
5
17
  ### Major Changes
@@ -10,16 +10,16 @@ var IGNORED_ERRORS = [
10
10
  // Error categories from AGG
11
11
  'TEAMS_FORBIDDEN', 'TEAMS_TEAM_DELETED'];
12
12
  function isIgnoredError(error) {
13
- return !!error && IGNORED_ERRORS.includes(error.reason);
13
+ return !!error && !!error.reason && IGNORED_ERRORS.includes(error.reason);
14
14
  }
15
15
  var getErrorAttributes = function getErrorAttributes(error) {
16
- var _error$response, _error$response$heade;
17
- var traceId = !!error ? (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$heade = _error$response.headers) === null || _error$response$heade === void 0 ? void 0 : _error$response$heade.get('atl-traceid') : undefined;
16
+ var _error$traceId;
18
17
  return {
18
+ errorMessage: error === null || error === void 0 ? void 0 : error.message,
19
19
  errorStatus: error === null || error === void 0 ? void 0 : error.code,
20
- errorReason: error === null || error === void 0 ? void 0 : error.reason,
20
+ errorReason: (error === null || error === void 0 ? void 0 : error.reason) || 'default',
21
21
  isSLOFailure: !isIgnoredError(error),
22
- traceId: traceId !== null && traceId !== void 0 ? traceId : undefined
22
+ traceId: (_error$traceId = error === null || error === void 0 ? void 0 : error.traceId) !== null && _error$traceId !== void 0 ? _error$traceId : undefined
23
23
  };
24
24
  };
25
25
  exports.getErrorAttributes = getErrorAttributes;
@@ -29,9 +29,12 @@ function graphqlQuery(serviceUrl, query) {
29
29
  body: JSON.stringify(query)
30
30
  })).then(function (response) {
31
31
  if (!response.ok) {
32
+ var _response$headers;
33
+ var traceIdFromHeaders = response === null || response === void 0 ? void 0 : (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.get('atl-traceid');
32
34
  return Promise.reject({
33
35
  code: response.status,
34
- reason: response.statusText
36
+ reason: response.statusText,
37
+ traceId: traceIdFromHeaders
35
38
  });
36
39
  }
37
40
  return response;
@@ -39,11 +42,13 @@ function graphqlQuery(serviceUrl, query) {
39
42
  return response.json();
40
43
  }).then(function (json) {
41
44
  if (json.errors) {
42
- var _json$errors$, _json$errors$2, _json$errors$2$extens, _json$errors$3, _json$errors$3$extens;
43
- // We need to handle responses from pf-directory and AGG
45
+ var _json$errors$, _json$errors$2, _json$errors$2$extens, _json$errors$3, _json$errors$3$extens, _json$errors$4, _json$errors$4$extens, _json$extensions, _json$extensions$gate;
44
46
  return Promise.reject({
45
47
  reason: ((_json$errors$ = json.errors[0]) === null || _json$errors$ === void 0 ? void 0 : _json$errors$.category) || ((_json$errors$2 = json.errors[0]) === null || _json$errors$2 === void 0 ? void 0 : (_json$errors$2$extens = _json$errors$2.extensions) === null || _json$errors$2$extens === void 0 ? void 0 : _json$errors$2$extens.classification) || 'default',
46
- code: (_json$errors$3 = json.errors[0]) === null || _json$errors$3 === void 0 ? void 0 : (_json$errors$3$extens = _json$errors$3.extensions) === null || _json$errors$3$extens === void 0 ? void 0 : _json$errors$3$extens.statusCode
48
+ code: (_json$errors$3 = json.errors[0]) === null || _json$errors$3 === void 0 ? void 0 : (_json$errors$3$extens = _json$errors$3.extensions) === null || _json$errors$3$extens === void 0 ? void 0 : _json$errors$3$extens.statusCode,
49
+ errorSource: (_json$errors$4 = json.errors[0]) === null || _json$errors$4 === void 0 ? void 0 : (_json$errors$4$extens = _json$errors$4.extensions) === null || _json$errors$4$extens === void 0 ? void 0 : _json$errors$4$extens.errorSource,
50
+ message: json.errors[0].message,
51
+ traceId: (_json$extensions = json.extensions) === null || _json$extensions === void 0 ? void 0 : (_json$extensions$gate = _json$extensions.gateway) === null || _json$extensions$gate === void 0 ? void 0 : _json$extensions$gate.request_id
47
52
  });
48
53
  }
49
54
  return json.data;
@@ -95,11 +95,21 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
95
95
  _this.fireAnalytics((0, _analytics.cardTriggered)('user', 'hover'));
96
96
  }
97
97
  });
98
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onKeyPress", function (event) {
99
+ if (event.key === 'Enter' || event.key === ' ') {
100
+ event.preventDefault();
101
+ _this.showProfilecard();
102
+ if (!_this.state.visible) {
103
+ _this.fireAnalytics((0, _analytics.cardTriggered)('user', 'click'));
104
+ }
105
+ }
106
+ });
98
107
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "containerListeners", _this.props.trigger === 'hover' ? {
99
108
  onMouseEnter: _this.onMouseEnter,
100
109
  onMouseLeave: _this.hideProfilecard
101
110
  } : {
102
- onClick: _this.onClick
111
+ onClick: _this.onClick,
112
+ onKeyPress: _this.onKeyPress
103
113
  });
104
114
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "layerListeners", {
105
115
  handleClickOutside: _this.hideProfilecard,
@@ -269,7 +279,9 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
269
279
  innerProps = (0, _objectWithoutProperties2.default)(triggerProps, _excluded);
270
280
  return /*#__PURE__*/_react.default.createElement("span", (0, _extends2.default)({}, innerProps, _this3.containerListeners, {
271
281
  ref: ref,
272
- "data-testid": _this3.props.testId
282
+ "data-testid": _this3.props.testId,
283
+ tabIndex: 0,
284
+ role: _this3.props.trigger !== 'hover' ? 'button' : ''
273
285
  }), _this3.props.children);
274
286
  },
275
287
  zIndex: _constants.layers.modal(),
@@ -44,7 +44,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
44
44
  actionSubjectId: actionSubjectId,
45
45
  attributes: _objectSpread(_objectSpread({
46
46
  packageName: "@atlaskit/profilecard",
47
- packageVersion: "19.0.0"
47
+ packageVersion: "19.1.1"
48
48
  }, attributes), {}, {
49
49
  firedAt: Math.round((0, _performance.getPageTime)())
50
50
  })
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "19.0.0"
3
+ "version": "19.1.1"
4
4
  }
@@ -4,15 +4,15 @@ const IGNORED_ERRORS = [
4
4
  // Error categories from AGG
5
5
  'TEAMS_FORBIDDEN', 'TEAMS_TEAM_DELETED'];
6
6
  function isIgnoredError(error) {
7
- return !!error && IGNORED_ERRORS.includes(error.reason);
7
+ return !!error && !!error.reason && IGNORED_ERRORS.includes(error.reason);
8
8
  }
9
9
  export const getErrorAttributes = error => {
10
- var _error$response, _error$response$heade;
11
- const traceId = !!error ? (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$heade = _error$response.headers) === null || _error$response$heade === void 0 ? void 0 : _error$response$heade.get('atl-traceid') : undefined;
10
+ var _error$traceId;
12
11
  return {
12
+ errorMessage: error === null || error === void 0 ? void 0 : error.message,
13
13
  errorStatus: error === null || error === void 0 ? void 0 : error.code,
14
- errorReason: error === null || error === void 0 ? void 0 : error.reason,
14
+ errorReason: (error === null || error === void 0 ? void 0 : error.reason) || 'default',
15
15
  isSLOFailure: !isIgnoredError(error),
16
- traceId: traceId !== null && traceId !== void 0 ? traceId : undefined
16
+ traceId: (_error$traceId = error === null || error === void 0 ? void 0 : error.traceId) !== null && _error$traceId !== void 0 ? _error$traceId : undefined
17
17
  };
18
18
  };
@@ -20,19 +20,24 @@ export function graphqlQuery(serviceUrl, query, processHeaders = id) {
20
20
  body: JSON.stringify(query)
21
21
  })).then(response => {
22
22
  if (!response.ok) {
23
+ var _response$headers;
24
+ const traceIdFromHeaders = response === null || response === void 0 ? void 0 : (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.get('atl-traceid');
23
25
  return Promise.reject({
24
26
  code: response.status,
25
- reason: response.statusText
27
+ reason: response.statusText,
28
+ traceId: traceIdFromHeaders
26
29
  });
27
30
  }
28
31
  return response;
29
32
  }).then(response => response.json()).then(json => {
30
33
  if (json.errors) {
31
- var _json$errors$, _json$errors$2, _json$errors$2$extens, _json$errors$3, _json$errors$3$extens;
32
- // We need to handle responses from pf-directory and AGG
34
+ var _json$errors$, _json$errors$2, _json$errors$2$extens, _json$errors$3, _json$errors$3$extens, _json$errors$4, _json$errors$4$extens, _json$extensions, _json$extensions$gate;
33
35
  return Promise.reject({
34
36
  reason: ((_json$errors$ = json.errors[0]) === null || _json$errors$ === void 0 ? void 0 : _json$errors$.category) || ((_json$errors$2 = json.errors[0]) === null || _json$errors$2 === void 0 ? void 0 : (_json$errors$2$extens = _json$errors$2.extensions) === null || _json$errors$2$extens === void 0 ? void 0 : _json$errors$2$extens.classification) || 'default',
35
- code: (_json$errors$3 = json.errors[0]) === null || _json$errors$3 === void 0 ? void 0 : (_json$errors$3$extens = _json$errors$3.extensions) === null || _json$errors$3$extens === void 0 ? void 0 : _json$errors$3$extens.statusCode
37
+ code: (_json$errors$3 = json.errors[0]) === null || _json$errors$3 === void 0 ? void 0 : (_json$errors$3$extens = _json$errors$3.extensions) === null || _json$errors$3$extens === void 0 ? void 0 : _json$errors$3$extens.statusCode,
38
+ errorSource: (_json$errors$4 = json.errors[0]) === null || _json$errors$4 === void 0 ? void 0 : (_json$errors$4$extens = _json$errors$4.extensions) === null || _json$errors$4$extens === void 0 ? void 0 : _json$errors$4$extens.errorSource,
39
+ message: json.errors[0].message,
40
+ traceId: (_json$extensions = json.extensions) === null || _json$extensions === void 0 ? void 0 : (_json$extensions$gate = _json$extensions.gateway) === null || _json$extensions$gate === void 0 ? void 0 : _json$extensions$gate.request_id
36
41
  });
37
42
  }
38
43
  return json.data;
@@ -65,11 +65,21 @@ class ProfilecardTrigger extends React.PureComponent {
65
65
  this.fireAnalytics(cardTriggered('user', 'hover'));
66
66
  }
67
67
  });
68
+ _defineProperty(this, "onKeyPress", event => {
69
+ if (event.key === 'Enter' || event.key === ' ') {
70
+ event.preventDefault();
71
+ this.showProfilecard();
72
+ if (!this.state.visible) {
73
+ this.fireAnalytics(cardTriggered('user', 'click'));
74
+ }
75
+ }
76
+ });
68
77
  _defineProperty(this, "containerListeners", this.props.trigger === 'hover' ? {
69
78
  onMouseEnter: this.onMouseEnter,
70
79
  onMouseLeave: this.hideProfilecard
71
80
  } : {
72
- onClick: this.onClick
81
+ onClick: this.onClick,
82
+ onKeyPress: this.onKeyPress
73
83
  });
74
84
  _defineProperty(this, "layerListeners", {
75
85
  handleClickOutside: this.hideProfilecard,
@@ -224,7 +234,9 @@ class ProfilecardTrigger extends React.PureComponent {
224
234
  } = triggerProps;
225
235
  return /*#__PURE__*/React.createElement("span", _extends({}, innerProps, this.containerListeners, {
226
236
  ref: ref,
227
- "data-testid": this.props.testId
237
+ "data-testid": this.props.testId,
238
+ tabIndex: 0,
239
+ role: this.props.trigger !== 'hover' ? 'button' : ''
228
240
  }), this.props.children);
229
241
  },
230
242
  zIndex: layers.modal(),
@@ -31,7 +31,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
31
31
  actionSubjectId,
32
32
  attributes: {
33
33
  packageName: "@atlaskit/profilecard",
34
- packageVersion: "19.0.0",
34
+ packageVersion: "19.1.1",
35
35
  ...attributes,
36
36
  firedAt: Math.round(getPageTime())
37
37
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "19.0.0"
3
+ "version": "19.1.1"
4
4
  }
@@ -4,15 +4,15 @@ var IGNORED_ERRORS = [
4
4
  // Error categories from AGG
5
5
  'TEAMS_FORBIDDEN', 'TEAMS_TEAM_DELETED'];
6
6
  function isIgnoredError(error) {
7
- return !!error && IGNORED_ERRORS.includes(error.reason);
7
+ return !!error && !!error.reason && IGNORED_ERRORS.includes(error.reason);
8
8
  }
9
9
  export var getErrorAttributes = function getErrorAttributes(error) {
10
- var _error$response, _error$response$heade;
11
- var traceId = !!error ? (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$heade = _error$response.headers) === null || _error$response$heade === void 0 ? void 0 : _error$response$heade.get('atl-traceid') : undefined;
10
+ var _error$traceId;
12
11
  return {
12
+ errorMessage: error === null || error === void 0 ? void 0 : error.message,
13
13
  errorStatus: error === null || error === void 0 ? void 0 : error.code,
14
- errorReason: error === null || error === void 0 ? void 0 : error.reason,
14
+ errorReason: (error === null || error === void 0 ? void 0 : error.reason) || 'default',
15
15
  isSLOFailure: !isIgnoredError(error),
16
- traceId: traceId !== null && traceId !== void 0 ? traceId : undefined
16
+ traceId: (_error$traceId = error === null || error === void 0 ? void 0 : error.traceId) !== null && _error$traceId !== void 0 ? _error$traceId : undefined
17
17
  };
18
18
  };
@@ -23,9 +23,12 @@ export function graphqlQuery(serviceUrl, query) {
23
23
  body: JSON.stringify(query)
24
24
  })).then(function (response) {
25
25
  if (!response.ok) {
26
+ var _response$headers;
27
+ var traceIdFromHeaders = response === null || response === void 0 ? void 0 : (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.get('atl-traceid');
26
28
  return Promise.reject({
27
29
  code: response.status,
28
- reason: response.statusText
30
+ reason: response.statusText,
31
+ traceId: traceIdFromHeaders
29
32
  });
30
33
  }
31
34
  return response;
@@ -33,11 +36,13 @@ export function graphqlQuery(serviceUrl, query) {
33
36
  return response.json();
34
37
  }).then(function (json) {
35
38
  if (json.errors) {
36
- var _json$errors$, _json$errors$2, _json$errors$2$extens, _json$errors$3, _json$errors$3$extens;
37
- // We need to handle responses from pf-directory and AGG
39
+ var _json$errors$, _json$errors$2, _json$errors$2$extens, _json$errors$3, _json$errors$3$extens, _json$errors$4, _json$errors$4$extens, _json$extensions, _json$extensions$gate;
38
40
  return Promise.reject({
39
41
  reason: ((_json$errors$ = json.errors[0]) === null || _json$errors$ === void 0 ? void 0 : _json$errors$.category) || ((_json$errors$2 = json.errors[0]) === null || _json$errors$2 === void 0 ? void 0 : (_json$errors$2$extens = _json$errors$2.extensions) === null || _json$errors$2$extens === void 0 ? void 0 : _json$errors$2$extens.classification) || 'default',
40
- code: (_json$errors$3 = json.errors[0]) === null || _json$errors$3 === void 0 ? void 0 : (_json$errors$3$extens = _json$errors$3.extensions) === null || _json$errors$3$extens === void 0 ? void 0 : _json$errors$3$extens.statusCode
42
+ code: (_json$errors$3 = json.errors[0]) === null || _json$errors$3 === void 0 ? void 0 : (_json$errors$3$extens = _json$errors$3.extensions) === null || _json$errors$3$extens === void 0 ? void 0 : _json$errors$3$extens.statusCode,
43
+ errorSource: (_json$errors$4 = json.errors[0]) === null || _json$errors$4 === void 0 ? void 0 : (_json$errors$4$extens = _json$errors$4.extensions) === null || _json$errors$4$extens === void 0 ? void 0 : _json$errors$4$extens.errorSource,
44
+ message: json.errors[0].message,
45
+ traceId: (_json$extensions = json.extensions) === null || _json$extensions === void 0 ? void 0 : (_json$extensions$gate = _json$extensions.gateway) === null || _json$extensions$gate === void 0 ? void 0 : _json$extensions$gate.request_id
41
46
  });
42
47
  }
43
48
  return json.data;
@@ -85,11 +85,21 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
85
85
  _this.fireAnalytics(cardTriggered('user', 'hover'));
86
86
  }
87
87
  });
88
+ _defineProperty(_assertThisInitialized(_this), "onKeyPress", function (event) {
89
+ if (event.key === 'Enter' || event.key === ' ') {
90
+ event.preventDefault();
91
+ _this.showProfilecard();
92
+ if (!_this.state.visible) {
93
+ _this.fireAnalytics(cardTriggered('user', 'click'));
94
+ }
95
+ }
96
+ });
88
97
  _defineProperty(_assertThisInitialized(_this), "containerListeners", _this.props.trigger === 'hover' ? {
89
98
  onMouseEnter: _this.onMouseEnter,
90
99
  onMouseLeave: _this.hideProfilecard
91
100
  } : {
92
- onClick: _this.onClick
101
+ onClick: _this.onClick,
102
+ onKeyPress: _this.onKeyPress
93
103
  });
94
104
  _defineProperty(_assertThisInitialized(_this), "layerListeners", {
95
105
  handleClickOutside: _this.hideProfilecard,
@@ -259,7 +269,9 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
259
269
  innerProps = _objectWithoutProperties(triggerProps, _excluded);
260
270
  return /*#__PURE__*/React.createElement("span", _extends({}, innerProps, _this3.containerListeners, {
261
271
  ref: ref,
262
- "data-testid": _this3.props.testId
272
+ "data-testid": _this3.props.testId,
273
+ tabIndex: 0,
274
+ role: _this3.props.trigger !== 'hover' ? 'button' : ''
263
275
  }), _this3.props.children);
264
276
  },
265
277
  zIndex: layers.modal(),
@@ -38,7 +38,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
38
38
  actionSubjectId: actionSubjectId,
39
39
  attributes: _objectSpread(_objectSpread({
40
40
  packageName: "@atlaskit/profilecard",
41
- packageVersion: "19.0.0"
41
+ packageVersion: "19.1.1"
42
42
  }, attributes), {}, {
43
43
  firedAt: Math.round(getPageTime())
44
44
  })
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "19.0.0"
3
+ "version": "19.1.1"
4
4
  }
@@ -1,6 +1,8 @@
1
- export declare const getErrorAttributes: (error?: any) => {
2
- errorStatus: any;
3
- errorReason: any;
1
+ import { GraphQLError } from './graphqlUtils';
2
+ export declare const getErrorAttributes: (error?: GraphQLError | undefined) => {
3
+ errorMessage: string | undefined;
4
+ errorStatus: number | undefined;
5
+ errorReason: string;
4
6
  isSLOFailure: boolean;
5
7
  traceId: string | undefined;
6
8
  };
@@ -4,7 +4,10 @@ interface Query {
4
4
  }
5
5
  export interface GraphQLError {
6
6
  code?: number;
7
- reason: string;
7
+ reason?: string;
8
+ errorSource?: string;
9
+ message?: string;
10
+ traceId?: string;
8
11
  }
9
12
  declare type HeaderProcessor = (headers: Headers) => Headers;
10
13
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "19.0.0",
3
+ "version": "19.1.1",
4
4
  "description": "A React component to display a card with user information.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"