@atlaskit/profilecard 16.8.0 → 16.10.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/components/Team/TeamProfileCard.js +15 -3
  3. package/dist/cjs/components/Team/TeamProfileCardTrigger.js +77 -12
  4. package/dist/cjs/components/User/ProfileCardResourced.js +0 -1
  5. package/dist/cjs/components/User/ProfileCardTrigger.js +0 -1
  6. package/dist/cjs/i18n/en.js +1 -0
  7. package/dist/cjs/i18n/en_GB.js +1 -0
  8. package/dist/cjs/i18n/en_ZZ.js +1 -0
  9. package/dist/cjs/styled/Card.js +1 -1
  10. package/dist/cjs/util/analytics.js +1 -1
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/es2019/components/Team/TeamProfileCard.js +13 -3
  13. package/dist/es2019/components/Team/TeamProfileCardTrigger.js +68 -9
  14. package/dist/es2019/components/User/ProfileCardResourced.js +0 -1
  15. package/dist/es2019/components/User/ProfileCardTrigger.js +0 -1
  16. package/dist/es2019/i18n/en.js +1 -0
  17. package/dist/es2019/i18n/en_GB.js +1 -0
  18. package/dist/es2019/i18n/en_ZZ.js +1 -0
  19. package/dist/es2019/styled/Card.js +1 -0
  20. package/dist/es2019/util/analytics.js +1 -1
  21. package/dist/es2019/version.json +1 -1
  22. package/dist/esm/client/TeamCentralCardClient.js +1 -1
  23. package/dist/esm/client/UserProfileCardClient.js +1 -1
  24. package/dist/esm/client/getTeamFromAGG.js +1 -1
  25. package/dist/esm/components/Team/TeamProfileCard.js +13 -3
  26. package/dist/esm/components/Team/TeamProfileCardTrigger.js +77 -12
  27. package/dist/esm/components/User/ProfileCardResourced.js +0 -1
  28. package/dist/esm/components/User/ProfileCardTrigger.js +0 -1
  29. package/dist/esm/i18n/en.js +1 -0
  30. package/dist/esm/i18n/en_GB.js +1 -0
  31. package/dist/esm/i18n/en_ZZ.js +1 -0
  32. package/dist/esm/styled/Card.js +1 -1
  33. package/dist/esm/util/analytics.js +1 -1
  34. package/dist/esm/version.json +1 -1
  35. package/dist/types/components/Team/TeamProfileCardTrigger.d.ts +5 -1
  36. package/dist/types/i18n/en.d.ts +1 -0
  37. package/dist/types/i18n/en_GB.d.ts +1 -0
  38. package/dist/types/i18n/en_ZZ.d.ts +1 -0
  39. package/dist/types/types.d.ts +11 -0
  40. package/package.json +2 -2
  41. package/report.api.md +614 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @atlaskit/profilecard
2
2
 
3
+ ## 16.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`e5fbc101e73`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e5fbc101e73) - Remove analytics prop from give kudos component
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
13
+ ## 16.9.1
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
19
+ ## 16.9.0
20
+
21
+ ### Minor Changes
22
+
23
+ - [`1f16cd80413`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1f16cd80413) - [ux] Add give kudos to Team profile card.
24
+
3
25
  ## 16.8.0
4
26
 
5
27
  ### Minor Changes
@@ -39,6 +39,8 @@ var _constants = require("@atlaskit/theme/constants");
39
39
 
40
40
  var _messages = _interopRequireDefault(require("../../messages"));
41
41
 
42
+ var _Card = require("../../styled/Card");
43
+
42
44
  var _Error = require("../../styled/Error");
43
45
 
44
46
  var _TeamCard = require("../../styled/TeamCard");
@@ -60,6 +62,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
60
62
  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; }
61
63
 
62
64
  var LARGE_MEMBER_COUNT = 50;
65
+ var GIVE_KUDOS_ACTION_ID = 'give-kudos';
63
66
 
64
67
  function onMemberClick(callback, userId, analytics, index, hasHref) {
65
68
  return function (event) {
@@ -156,11 +159,20 @@ var ActionButton = function ActionButton(_ref2) {
156
159
  var action = _ref2.action,
157
160
  analytics = _ref2.analytics,
158
161
  index = _ref2.index;
159
- return /*#__PURE__*/_react.default.createElement(_TeamCard.WrappedButton, null, /*#__PURE__*/_react.default.createElement(_standardButton.default, {
160
- href: action.link,
162
+ var isGiveKudosActionButton = action.id === GIVE_KUDOS_ACTION_ID;
163
+
164
+ var actionButton = /*#__PURE__*/_react.default.createElement(_standardButton.default, {
165
+ key: action.id || index,
161
166
  onClick: onActionClick(action, analytics, index),
167
+ href: action.link,
162
168
  shouldFitContainer: true
163
- }, action.label));
169
+ }, action.label, isGiveKudosActionButton && /*#__PURE__*/_react.default.createElement(_Card.KudosBlobAnimation, null));
170
+
171
+ if (isGiveKudosActionButton) {
172
+ return /*#__PURE__*/_react.default.createElement(_Card.AnimatedKudosButton, null, actionButton);
173
+ }
174
+
175
+ return /*#__PURE__*/_react.default.createElement(_TeamCard.WrappedButton, null, actionButton);
164
176
  };
165
177
 
166
178
  var ExtraActions = function ExtraActions(_ref3) {
@@ -11,6 +11,8 @@ exports.default = exports.TeamProfileCardTriggerInternal = void 0;
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
+
14
16
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
17
 
16
18
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -27,14 +29,20 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
27
29
 
28
30
  var _react = _interopRequireWildcard(require("react"));
29
31
 
32
+ var _reactIntlNext = require("react-intl-next");
33
+
30
34
  var _analyticsNext = require("@atlaskit/analytics-next");
31
35
 
36
+ var _giveKudos = require("@atlaskit/give-kudos");
37
+
32
38
  var _popup = _interopRequireDefault(require("@atlaskit/popup"));
33
39
 
34
40
  var _constants = require("@atlaskit/theme/constants");
35
41
 
36
42
  var _filterActions2 = _interopRequireDefault(require("../../internal/filterActions"));
37
43
 
44
+ var _messages = _interopRequireDefault(require("../../messages"));
45
+
38
46
  var _analytics = require("../../util/analytics");
39
47
 
40
48
  var _click = require("../../util/click");
@@ -165,6 +173,23 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
165
173
  _this.hideProfilecard(_config.DELAY_MS_HIDE);
166
174
  }
167
175
  });
176
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "openKudosDrawer", function () {
177
+ _this.hideProfilecard(_config.DELAY_MS_HIDE);
178
+
179
+ _this.setState({
180
+ kudosDrawerOpen: true
181
+ });
182
+ });
183
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "closeKudosDrawer", function () {
184
+ _this.setState({
185
+ kudosDrawerOpen: false
186
+ });
187
+ });
188
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "kudosUrl", function () {
189
+ var recipientId = _this.props.teamId && "&recipientId=".concat(_this.props.teamId) || '';
190
+ var cloudId = _this.props.cloudId && "&cloudId=".concat(_this.props.cloudId) || '';
191
+ return "".concat(_this.state.teamCentralBaseUrl, "/kudos/give?type=team").concat(recipientId).concat(cloudId);
192
+ });
168
193
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "stopPropagation", function (event) {
169
194
  // We need to stop propagation when users click on the card, so that it
170
195
  // doesn't trigger any special effects that occur when clicking the trigger.
@@ -185,7 +210,10 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
185
210
  isLoading: undefined,
186
211
  hasError: false,
187
212
  error: null,
188
- data: null
213
+ data: null,
214
+ shouldShowGiveKudos: false,
215
+ teamCentralBaseUrl: undefined,
216
+ kudosDrawerOpen: false
189
217
  });
190
218
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clientFetchProfile", function () {
191
219
  var _this$props = _this.props,
@@ -206,8 +234,11 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
206
234
  _this.fireAnalytics(event);
207
235
  };
208
236
 
209
- _this.props.resourceClient.getTeamProfile(teamId, orgId, fireEvent).then(function (res) {
210
- return _this.handleClientSuccess(res);
237
+ var requests = Promise.all([_this.props.resourceClient.getTeamProfile(teamId, orgId, fireEvent), _this.props.resourceClient.shouldShowGiveKudos()]);
238
+ requests.then(function (res) {
239
+ var _this2;
240
+
241
+ return (_this2 = _this).handleClientSuccess.apply(_this2, (0, _toConsumableArray2.default)(res));
211
242
  }, function (err) {
212
243
  return _this.handleClientError(err);
213
244
  }).catch(function (err) {
@@ -257,6 +288,22 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
257
288
  errorType: error
258
289
  }))));
259
290
  });
291
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderKudosLauncher", function () {
292
+ return _this.state.shouldShowGiveKudos && /*#__PURE__*/_react.default.createElement(_react.Suspense, {
293
+ fallback: null
294
+ }, /*#__PURE__*/_react.default.createElement(_giveKudos.GiveKudosLauncherLazy, {
295
+ isOpen: _this.state.kudosDrawerOpen,
296
+ recipient: {
297
+ type: _giveKudos.KudosType.TEAM,
298
+ recipientId: _this.props.teamId
299
+ },
300
+ analyticsSource: "team-profile-card",
301
+ teamCentralBaseUrl: _this.state.teamCentralBaseUrl,
302
+ cloudId: _this.props.cloudId || '',
303
+ addFlag: _this.props.addFlag,
304
+ onClose: _this.closeKudosDrawer
305
+ }));
306
+ });
260
307
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderTrigger", function (triggerProps) {
261
308
  var _this$props3 = _this.props,
262
309
  children = _this$props3.children,
@@ -264,12 +311,12 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
264
311
  viewProfileLink = _this$props3.viewProfileLink;
265
312
 
266
313
  if (triggerLinkType === 'none') {
267
- return /*#__PURE__*/_react.default.createElement("span", (0, _extends2.default)({
314
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, _this.renderKudosLauncher(), /*#__PURE__*/_react.default.createElement("span", (0, _extends2.default)({
268
315
  "data-testid": "team-profilecard-trigger-wrapper"
269
- }, triggerProps, _this.triggerListeners), children);
316
+ }, triggerProps, _this.triggerListeners), children));
270
317
  }
271
318
 
272
- return /*#__PURE__*/_react.default.createElement("a", (0, _extends2.default)({
319
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, _this.renderKudosLauncher(), /*#__PURE__*/_react.default.createElement("a", (0, _extends2.default)({
273
320
  "data-testid": "team-profilecard-trigger-wrapper",
274
321
  style: {
275
322
  color: 'initial',
@@ -278,7 +325,7 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
278
325
  href: viewProfileLink
279
326
  }, triggerProps, {
280
327
  ref: triggerProps.ref
281
- }, _this.triggerListeners), children);
328
+ }, _this.triggerListeners), children));
282
329
  });
283
330
  return _this;
284
331
  }
@@ -312,7 +359,7 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
312
359
  }
313
360
  }, {
314
361
  key: "handleClientSuccess",
315
- value: function handleClientSuccess(res) {
362
+ value: function handleClientSuccess(team, shouldShowGiveKudos) {
316
363
  if (!this._isMounted) {
317
364
  return;
318
365
  }
@@ -320,7 +367,9 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
320
367
  this.setState({
321
368
  isLoading: false,
322
369
  hasError: false,
323
- data: res
370
+ data: team,
371
+ shouldShowGiveKudos: shouldShowGiveKudos,
372
+ teamCentralBaseUrl: this.props.resourceClient.getTeamCentralBaseUrl()
324
373
  });
325
374
  }
326
375
  }, {
@@ -339,12 +388,28 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
339
388
  }, {
340
389
  key: "filterActions",
341
390
  value: function filterActions() {
342
- return (0, _filterActions2.default)(this.props.actions, this.state.data);
391
+ var _this3 = this;
392
+
393
+ var actions = (0, _filterActions2.default)(this.props.actions, this.state.data);
394
+
395
+ if (this.state.shouldShowGiveKudos) {
396
+ var kudosAction = {
397
+ label: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.default.giveKudosButton),
398
+ id: 'give-kudos',
399
+ callback: function callback() {
400
+ _this3.openKudosDrawer();
401
+ },
402
+ link: this.kudosUrl()
403
+ };
404
+ return actions.concat([kudosAction]);
405
+ }
406
+
407
+ return actions;
343
408
  }
344
409
  }, {
345
410
  key: "renderPopup",
346
411
  value: function renderPopup() {
347
- var _this2 = this;
412
+ var _this4 = this;
348
413
 
349
414
  if (this.state.renderError) {
350
415
  return this.props.children;
@@ -358,7 +423,7 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
358
423
  placement: this.props.position,
359
424
  content: this.renderProfileCard,
360
425
  trigger: function trigger(triggerProps) {
361
- return _this2.renderTrigger(triggerProps);
426
+ return _this4.renderTrigger(triggerProps);
362
427
  },
363
428
  zIndex: _constants.layers.modal(),
364
429
  shouldFlip: true
@@ -242,7 +242,6 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
242
242
  type: _giveKudos.KudosType.INDIVIDUAL,
243
243
  recipientId: this.props.userId
244
244
  },
245
- analytics: this.props.analytics,
246
245
  analyticsSource: "profile-card",
247
246
  teamCentralBaseUrl: newProps.teamCentralBaseUrl,
248
247
  cloudId: this.props.cloudId,
@@ -308,7 +308,6 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
308
308
  type: _giveKudos.KudosType.INDIVIDUAL,
309
309
  recipientId: this.props.userId
310
310
  },
311
- analytics: this.props.analytics,
312
311
  analyticsSource: "profile-card",
313
312
  teamCentralBaseUrl: this.state.teamCentralBaseUrl,
314
313
  cloudId: this.props.cloudId,
@@ -32,6 +32,7 @@ var _default = {
32
32
  'pt.profile-card.inactive.account.has.date.this.month': 'Their account was deactivated this month.',
33
33
  'pt.profile-card.inactive.account.has.date.this.week': 'Their account was deactivated this week.',
34
34
  'pt.profile-card.inactive.account.no.date': 'Their account has been deactivated.',
35
+ 'pt.profile-card.more-icon-label': 'More',
35
36
  'pt.team-profile-card.directReports.heading': 'Direct reports',
36
37
  'pt.team-profile-card.error.refresh-button': 'Try again',
37
38
  'pt.team-profile-card.error.suggestion': 'Wait a few moments, then try again.',
@@ -32,6 +32,7 @@ var _default = {
32
32
  'pt.profile-card.inactive.account.has.date.this.month': 'Their account was deactivated this month.',
33
33
  'pt.profile-card.inactive.account.has.date.this.week': 'Their account was deactivated this week.',
34
34
  'pt.profile-card.inactive.account.no.date': 'Their account has been deactivated.',
35
+ 'pt.profile-card.more-icon-label': 'More',
35
36
  'pt.team-profile-card.directReports.heading': 'Direct reports',
36
37
  'pt.team-profile-card.error.refresh-button': 'Try again',
37
38
  'pt.team-profile-card.error.suggestion': 'Wait a few moments, then try again.',
@@ -32,6 +32,7 @@ var _default = {
32
32
  'pt.profile-card.inactive.account.has.date.this.month': '⁣⁢Their account was deactivated this month.‍‌⁡⁡؜⁠‍‍⁣⁤',
33
33
  'pt.profile-card.inactive.account.has.date.this.week': '⁣⁢Their account was deactivated this week.⁠‍⁠‍⁡؜⁣⁤',
34
34
  'pt.profile-card.inactive.account.no.date': '⁣⁢Their account has been deactivated.‌⁠⁠⁠‌⁡‌؜⁠⁠‌⁣⁤',
35
+ 'pt.profile-card.more-icon-label': '⁣⁢More‌‌‍؜⁡؜⁠⁠؜؜⁣⁤',
35
36
  'pt.team-profile-card.directReports.heading': '⁣⁢Direct reports⁠‍⁡⁠؜⁠‌؜⁣⁤',
36
37
  'pt.team-profile-card.error.refresh-button': '⁣⁢Try again⁡⁠‍‌⁠⁠⁡⁠؜⁠⁡‍⁣⁤',
37
38
  'pt.team-profile-card.error.suggestion': '⁣⁢Wait a few moments, then try again.‌⁡‌‌‍⁠⁠⁡‍؜‌⁡⁠⁠⁡⁠‍‍⁣⁤',
@@ -50,7 +50,7 @@ var KudosBlobAnimation = _styledComponents.default.div(_templateObject6 || (_tem
50
50
 
51
51
  exports.KudosBlobAnimation = KudosBlobAnimation;
52
52
 
53
- var AnimatedKudosButton = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n margin-left: ", "px;\n &:hover ", " {\n display: block;\n }\n\n button,\n a {\n clip-path: inset(0px 0px 0px 0px round ", "px);\n }\n"])), _constants.gridSize, KudosBlobAnimation, _constants.borderRadius);
53
+ var AnimatedKudosButton = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n margin-left: ", "px;\n &:hover ", " {\n display: block;\n }\n\n button,\n a {\n clip-path: inset(0px 0px 0px 0px round ", "px);\n }\n overflow: hidden;\n"])), _constants.gridSize, KudosBlobAnimation, _constants.borderRadius);
54
54
 
55
55
  exports.AnimatedKudosButton = AnimatedKudosButton;
56
56
 
@@ -56,7 +56,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
56
56
  actionSubjectId: actionSubjectId,
57
57
  attributes: _objectSpread(_objectSpread({
58
58
  packageName: "@atlaskit/profilecard",
59
- packageVersion: "16.8.0"
59
+ packageVersion: "16.10.0"
60
60
  }, attributes), {}, {
61
61
  firedAt: (0, _performance.getPageTime)()
62
62
  })
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "16.8.0"
3
+ "version": "16.10.0"
4
4
  }
@@ -10,6 +10,7 @@ import { LinkItem, MenuGroup } from '@atlaskit/menu';
10
10
  import Popup from '@atlaskit/popup';
11
11
  import { layers } from '@atlaskit/theme/constants';
12
12
  import messages from '../../messages';
13
+ import { AnimatedKudosButton, KudosBlobAnimation } from '../../styled/Card';
13
14
  import { ErrorWrapper, TeamErrorText, TeamErrorTitle } from '../../styled/Error';
14
15
  import { ActionButtons, AvatarSection, CardContent, CardHeader, CardWrapper, Description, DescriptionWrapper, MemberCount, MoreButton, TeamName, WrappedButton } from '../../styled/TeamCard';
15
16
  import { errorRetryClicked, moreActionsClicked, moreMembersClicked, teamActionClicked, teamAvatarClicked, teamProfileCardRendered } from '../../util/analytics';
@@ -17,6 +18,7 @@ import { isBasicClick } from '../../util/click';
17
18
  import { ErrorIllustration } from '../Error';
18
19
  import TeamLoadingState from './TeamLoadingState';
19
20
  const LARGE_MEMBER_COUNT = 50;
21
+ const GIVE_KUDOS_ACTION_ID = 'give-kudos';
20
22
 
21
23
  function onMemberClick(callback, userId, analytics, index, hasHref) {
22
24
  return event => {
@@ -106,11 +108,19 @@ const ActionButton = ({
106
108
  analytics,
107
109
  index
108
110
  }) => {
109
- return /*#__PURE__*/React.createElement(WrappedButton, null, /*#__PURE__*/React.createElement(Button, {
110
- href: action.link,
111
+ const isGiveKudosActionButton = action.id === GIVE_KUDOS_ACTION_ID;
112
+ const actionButton = /*#__PURE__*/React.createElement(Button, {
113
+ key: action.id || index,
111
114
  onClick: onActionClick(action, analytics, index),
115
+ href: action.link,
112
116
  shouldFitContainer: true
113
- }, action.label));
117
+ }, action.label, isGiveKudosActionButton && /*#__PURE__*/React.createElement(KudosBlobAnimation, null));
118
+
119
+ if (isGiveKudosActionButton) {
120
+ return /*#__PURE__*/React.createElement(AnimatedKudosButton, null, actionButton);
121
+ }
122
+
123
+ return /*#__PURE__*/React.createElement(WrappedButton, null, actionButton);
114
124
  };
115
125
 
116
126
  const ExtraActions = ({
@@ -1,10 +1,13 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import React, { Suspense } from 'react';
4
+ import { FormattedMessage } from 'react-intl-next';
4
5
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
6
+ import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
5
7
  import Popup from '@atlaskit/popup';
6
8
  import { layers } from '@atlaskit/theme/constants';
7
9
  import filterActions from '../../internal/filterActions';
10
+ import messages from '../../messages';
8
11
  import { fireEvent, teamCardTriggered, teamProfileCardRendered } from '../../util/analytics';
9
12
  import { isBasicClick } from '../../util/click';
10
13
  import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
@@ -114,6 +117,25 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
114
117
  }
115
118
  });
116
119
 
120
+ _defineProperty(this, "openKudosDrawer", () => {
121
+ this.hideProfilecard(DELAY_MS_HIDE);
122
+ this.setState({
123
+ kudosDrawerOpen: true
124
+ });
125
+ });
126
+
127
+ _defineProperty(this, "closeKudosDrawer", () => {
128
+ this.setState({
129
+ kudosDrawerOpen: false
130
+ });
131
+ });
132
+
133
+ _defineProperty(this, "kudosUrl", () => {
134
+ const recipientId = this.props.teamId && `&recipientId=${this.props.teamId}` || '';
135
+ const cloudId = this.props.cloudId && `&cloudId=${this.props.cloudId}` || '';
136
+ return `${this.state.teamCentralBaseUrl}/kudos/give?type=team${recipientId}${cloudId}`;
137
+ });
138
+
117
139
  _defineProperty(this, "stopPropagation", event => {
118
140
  // We need to stop propagation when users click on the card, so that it
119
141
  // doesn't trigger any special effects that occur when clicking the trigger.
@@ -137,7 +159,10 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
137
159
  isLoading: undefined,
138
160
  hasError: false,
139
161
  error: null,
140
- data: null
162
+ data: null,
163
+ shouldShowGiveKudos: false,
164
+ teamCentralBaseUrl: undefined,
165
+ kudosDrawerOpen: false
141
166
  });
142
167
 
143
168
  _defineProperty(this, "clientFetchProfile", () => {
@@ -162,7 +187,8 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
162
187
  this.fireAnalytics(event);
163
188
  };
164
189
 
165
- this.props.resourceClient.getTeamProfile(teamId, orgId, fireEvent).then(res => this.handleClientSuccess(res), err => this.handleClientError(err)).catch(err => this.handleClientError(err));
190
+ const requests = Promise.all([this.props.resourceClient.getTeamProfile(teamId, orgId, fireEvent), this.props.resourceClient.shouldShowGiveKudos()]);
191
+ requests.then(res => this.handleClientSuccess(...res), err => this.handleClientError(err)).catch(err => this.handleClientError(err));
166
192
  });
167
193
  });
168
194
 
@@ -211,6 +237,23 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
211
237
  }))));
212
238
  });
213
239
 
240
+ _defineProperty(this, "renderKudosLauncher", () => {
241
+ return this.state.shouldShowGiveKudos && /*#__PURE__*/React.createElement(Suspense, {
242
+ fallback: null
243
+ }, /*#__PURE__*/React.createElement(GiveKudosLauncherLazy, {
244
+ isOpen: this.state.kudosDrawerOpen,
245
+ recipient: {
246
+ type: KudosType.TEAM,
247
+ recipientId: this.props.teamId
248
+ },
249
+ analyticsSource: "team-profile-card",
250
+ teamCentralBaseUrl: this.state.teamCentralBaseUrl,
251
+ cloudId: this.props.cloudId || '',
252
+ addFlag: this.props.addFlag,
253
+ onClose: this.closeKudosDrawer
254
+ }));
255
+ });
256
+
214
257
  _defineProperty(this, "renderTrigger", triggerProps => {
215
258
  const {
216
259
  children,
@@ -219,12 +262,12 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
219
262
  } = this.props;
220
263
 
221
264
  if (triggerLinkType === 'none') {
222
- return /*#__PURE__*/React.createElement("span", _extends({
265
+ return /*#__PURE__*/React.createElement(React.Fragment, null, this.renderKudosLauncher(), /*#__PURE__*/React.createElement("span", _extends({
223
266
  "data-testid": "team-profilecard-trigger-wrapper"
224
- }, triggerProps, this.triggerListeners), children);
267
+ }, triggerProps, this.triggerListeners), children));
225
268
  }
226
269
 
227
- return /*#__PURE__*/React.createElement("a", _extends({
270
+ return /*#__PURE__*/React.createElement(React.Fragment, null, this.renderKudosLauncher(), /*#__PURE__*/React.createElement("a", _extends({
228
271
  "data-testid": "team-profilecard-trigger-wrapper",
229
272
  style: {
230
273
  color: 'initial',
@@ -233,7 +276,7 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
233
276
  href: viewProfileLink
234
277
  }, triggerProps, {
235
278
  ref: triggerProps.ref
236
- }, this.triggerListeners), children);
279
+ }, this.triggerListeners), children));
237
280
  });
238
281
  }
239
282
 
@@ -264,7 +307,7 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
264
307
  clearTimeout(this.hideTimer);
265
308
  }
266
309
 
267
- handleClientSuccess(res) {
310
+ handleClientSuccess(team, shouldShowGiveKudos) {
268
311
  if (!this._isMounted) {
269
312
  return;
270
313
  }
@@ -272,7 +315,9 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
272
315
  this.setState({
273
316
  isLoading: false,
274
317
  hasError: false,
275
- data: res
318
+ data: team,
319
+ shouldShowGiveKudos,
320
+ teamCentralBaseUrl: this.props.resourceClient.getTeamCentralBaseUrl()
276
321
  });
277
322
  }
278
323
 
@@ -289,7 +334,21 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
289
334
  }
290
335
 
291
336
  filterActions() {
292
- return filterActions(this.props.actions, this.state.data);
337
+ const actions = filterActions(this.props.actions, this.state.data);
338
+
339
+ if (this.state.shouldShowGiveKudos) {
340
+ const kudosAction = {
341
+ label: /*#__PURE__*/React.createElement(FormattedMessage, messages.giveKudosButton),
342
+ id: 'give-kudos',
343
+ callback: () => {
344
+ this.openKudosDrawer();
345
+ },
346
+ link: this.kudosUrl()
347
+ };
348
+ return actions.concat([kudosAction]);
349
+ }
350
+
351
+ return actions;
293
352
  }
294
353
 
295
354
  renderPopup() {
@@ -180,7 +180,6 @@ export default class ProfileCardResourced extends React.PureComponent {
180
180
  type: KudosType.INDIVIDUAL,
181
181
  recipientId: this.props.userId
182
182
  },
183
- analytics: this.props.analytics,
184
183
  analyticsSource: "profile-card",
185
184
  teamCentralBaseUrl: newProps.teamCentralBaseUrl,
186
185
  cloudId: this.props.cloudId,
@@ -245,7 +245,6 @@ class ProfilecardTrigger extends React.PureComponent {
245
245
  type: KudosType.INDIVIDUAL,
246
246
  recipientId: this.props.userId
247
247
  },
248
- analytics: this.props.analytics,
249
248
  analyticsSource: "profile-card",
250
249
  teamCentralBaseUrl: this.state.teamCentralBaseUrl,
251
250
  cloudId: this.props.cloudId,
@@ -25,6 +25,7 @@ export default {
25
25
  'pt.profile-card.inactive.account.has.date.this.month': 'Their account was deactivated this month.',
26
26
  'pt.profile-card.inactive.account.has.date.this.week': 'Their account was deactivated this week.',
27
27
  'pt.profile-card.inactive.account.no.date': 'Their account has been deactivated.',
28
+ 'pt.profile-card.more-icon-label': 'More',
28
29
  'pt.team-profile-card.directReports.heading': 'Direct reports',
29
30
  'pt.team-profile-card.error.refresh-button': 'Try again',
30
31
  'pt.team-profile-card.error.suggestion': 'Wait a few moments, then try again.',
@@ -25,6 +25,7 @@ export default {
25
25
  'pt.profile-card.inactive.account.has.date.this.month': 'Their account was deactivated this month.',
26
26
  'pt.profile-card.inactive.account.has.date.this.week': 'Their account was deactivated this week.',
27
27
  'pt.profile-card.inactive.account.no.date': 'Their account has been deactivated.',
28
+ 'pt.profile-card.more-icon-label': 'More',
28
29
  'pt.team-profile-card.directReports.heading': 'Direct reports',
29
30
  'pt.team-profile-card.error.refresh-button': 'Try again',
30
31
  'pt.team-profile-card.error.suggestion': 'Wait a few moments, then try again.',
@@ -25,6 +25,7 @@ export default {
25
25
  'pt.profile-card.inactive.account.has.date.this.month': '⁣⁢Their account was deactivated this month.‍‌⁡⁡؜⁠‍‍⁣⁤',
26
26
  'pt.profile-card.inactive.account.has.date.this.week': '⁣⁢Their account was deactivated this week.⁠‍⁠‍⁡؜⁣⁤',
27
27
  'pt.profile-card.inactive.account.no.date': '⁣⁢Their account has been deactivated.‌⁠⁠⁠‌⁡‌؜⁠⁠‌⁣⁤',
28
+ 'pt.profile-card.more-icon-label': '⁣⁢More‌‌‍؜⁡؜⁠⁠؜؜⁣⁤',
28
29
  'pt.team-profile-card.directReports.heading': '⁣⁢Direct reports⁠‍⁡⁠؜⁠‌؜⁣⁤',
29
30
  'pt.team-profile-card.error.refresh-button': '⁣⁢Try again⁡⁠‍‌⁠⁠⁡⁠؜⁠⁡‍⁣⁤',
30
31
  'pt.team-profile-card.error.suggestion': '⁣⁢Wait a few moments, then try again.‌⁡‌‌‍⁠⁠⁡‍؜‌⁡⁠⁠⁡⁠‍‍⁣⁤',
@@ -50,6 +50,7 @@ export const AnimatedKudosButton = styled.div`
50
50
  a {
51
51
  clip-path: inset(0px 0px 0px 0px round ${borderRadius}px);
52
52
  }
53
+ overflow: hidden;
53
54
  `;
54
55
  export const ActionButtonGroup = styled.div`
55
56
  user-select: none;
@@ -35,7 +35,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
35
35
  actionSubjectId,
36
36
  attributes: {
37
37
  packageName: "@atlaskit/profilecard",
38
- packageVersion: "16.8.0",
38
+ packageVersion: "16.10.0",
39
39
  ...attributes,
40
40
  firedAt: getPageTime()
41
41
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "16.8.0"
3
+ "version": "16.10.0"
4
4
  }
@@ -1,10 +1,10 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/createClass";
5
4
  import _inherits from "@babel/runtime/helpers/inherits";
6
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
 
9
9
  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); }; }
10
10
 
@@ -1,4 +1,3 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/createClass";
@@ -6,6 +5,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
6
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
9
9
 
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
 
@@ -1,6 +1,6 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
 
5
5
  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; }
6
6