@atlaskit/profilecard 16.8.0 → 16.9.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/profilecard
2
2
 
3
+ ## 16.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`1f16cd80413`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1f16cd80413) - [ux] Add give kudos to Team profile card.
8
+
3
9
  ## 16.8.0
4
10
 
5
11
  ### 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,23 @@ 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
+ analytics: _this.fireAnalytics,
301
+ analyticsSource: "team-profile-card",
302
+ teamCentralBaseUrl: _this.state.teamCentralBaseUrl,
303
+ cloudId: _this.props.cloudId || '',
304
+ addFlag: _this.props.addFlag,
305
+ onClose: _this.closeKudosDrawer
306
+ }));
307
+ });
260
308
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderTrigger", function (triggerProps) {
261
309
  var _this$props3 = _this.props,
262
310
  children = _this$props3.children,
@@ -264,12 +312,12 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
264
312
  viewProfileLink = _this$props3.viewProfileLink;
265
313
 
266
314
  if (triggerLinkType === 'none') {
267
- return /*#__PURE__*/_react.default.createElement("span", (0, _extends2.default)({
315
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, _this.renderKudosLauncher(), /*#__PURE__*/_react.default.createElement("span", (0, _extends2.default)({
268
316
  "data-testid": "team-profilecard-trigger-wrapper"
269
- }, triggerProps, _this.triggerListeners), children);
317
+ }, triggerProps, _this.triggerListeners), children));
270
318
  }
271
319
 
272
- return /*#__PURE__*/_react.default.createElement("a", (0, _extends2.default)({
320
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, _this.renderKudosLauncher(), /*#__PURE__*/_react.default.createElement("a", (0, _extends2.default)({
273
321
  "data-testid": "team-profilecard-trigger-wrapper",
274
322
  style: {
275
323
  color: 'initial',
@@ -278,7 +326,7 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
278
326
  href: viewProfileLink
279
327
  }, triggerProps, {
280
328
  ref: triggerProps.ref
281
- }, _this.triggerListeners), children);
329
+ }, _this.triggerListeners), children));
282
330
  });
283
331
  return _this;
284
332
  }
@@ -312,7 +360,7 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
312
360
  }
313
361
  }, {
314
362
  key: "handleClientSuccess",
315
- value: function handleClientSuccess(res) {
363
+ value: function handleClientSuccess(team, shouldShowGiveKudos) {
316
364
  if (!this._isMounted) {
317
365
  return;
318
366
  }
@@ -320,7 +368,9 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
320
368
  this.setState({
321
369
  isLoading: false,
322
370
  hasError: false,
323
- data: res
371
+ data: team,
372
+ shouldShowGiveKudos: shouldShowGiveKudos,
373
+ teamCentralBaseUrl: this.props.resourceClient.getTeamCentralBaseUrl()
324
374
  });
325
375
  }
326
376
  }, {
@@ -339,12 +389,28 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
339
389
  }, {
340
390
  key: "filterActions",
341
391
  value: function filterActions() {
342
- return (0, _filterActions2.default)(this.props.actions, this.state.data);
392
+ var _this3 = this;
393
+
394
+ var actions = (0, _filterActions2.default)(this.props.actions, this.state.data);
395
+
396
+ if (this.state.shouldShowGiveKudos) {
397
+ var kudosAction = {
398
+ label: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.default.giveKudosButton),
399
+ id: 'give-kudos',
400
+ callback: function callback() {
401
+ _this3.openKudosDrawer();
402
+ },
403
+ link: this.kudosUrl()
404
+ };
405
+ return actions.concat([kudosAction]);
406
+ }
407
+
408
+ return actions;
343
409
  }
344
410
  }, {
345
411
  key: "renderPopup",
346
412
  value: function renderPopup() {
347
- var _this2 = this;
413
+ var _this4 = this;
348
414
 
349
415
  if (this.state.renderError) {
350
416
  return this.props.children;
@@ -358,7 +424,7 @@ var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureComponent
358
424
  placement: this.props.position,
359
425
  content: this.renderProfileCard,
360
426
  trigger: function trigger(triggerProps) {
361
- return _this2.renderTrigger(triggerProps);
427
+ return _this4.renderTrigger(triggerProps);
362
428
  },
363
429
  zIndex: _constants.layers.modal(),
364
430
  shouldFlip: true
@@ -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.9.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.9.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,24 @@ 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
+ analytics: this.fireAnalytics,
250
+ analyticsSource: "team-profile-card",
251
+ teamCentralBaseUrl: this.state.teamCentralBaseUrl,
252
+ cloudId: this.props.cloudId || '',
253
+ addFlag: this.props.addFlag,
254
+ onClose: this.closeKudosDrawer
255
+ }));
256
+ });
257
+
214
258
  _defineProperty(this, "renderTrigger", triggerProps => {
215
259
  const {
216
260
  children,
@@ -219,12 +263,12 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
219
263
  } = this.props;
220
264
 
221
265
  if (triggerLinkType === 'none') {
222
- return /*#__PURE__*/React.createElement("span", _extends({
266
+ return /*#__PURE__*/React.createElement(React.Fragment, null, this.renderKudosLauncher(), /*#__PURE__*/React.createElement("span", _extends({
223
267
  "data-testid": "team-profilecard-trigger-wrapper"
224
- }, triggerProps, this.triggerListeners), children);
268
+ }, triggerProps, this.triggerListeners), children));
225
269
  }
226
270
 
227
- return /*#__PURE__*/React.createElement("a", _extends({
271
+ return /*#__PURE__*/React.createElement(React.Fragment, null, this.renderKudosLauncher(), /*#__PURE__*/React.createElement("a", _extends({
228
272
  "data-testid": "team-profilecard-trigger-wrapper",
229
273
  style: {
230
274
  color: 'initial',
@@ -233,7 +277,7 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
233
277
  href: viewProfileLink
234
278
  }, triggerProps, {
235
279
  ref: triggerProps.ref
236
- }, this.triggerListeners), children);
280
+ }, this.triggerListeners), children));
237
281
  });
238
282
  }
239
283
 
@@ -264,7 +308,7 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
264
308
  clearTimeout(this.hideTimer);
265
309
  }
266
310
 
267
- handleClientSuccess(res) {
311
+ handleClientSuccess(team, shouldShowGiveKudos) {
268
312
  if (!this._isMounted) {
269
313
  return;
270
314
  }
@@ -272,7 +316,9 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
272
316
  this.setState({
273
317
  isLoading: false,
274
318
  hasError: false,
275
- data: res
319
+ data: team,
320
+ shouldShowGiveKudos,
321
+ teamCentralBaseUrl: this.props.resourceClient.getTeamCentralBaseUrl()
276
322
  });
277
323
  }
278
324
 
@@ -289,7 +335,21 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
289
335
  }
290
336
 
291
337
  filterActions() {
292
- return filterActions(this.props.actions, this.state.data);
338
+ const actions = filterActions(this.props.actions, this.state.data);
339
+
340
+ if (this.state.shouldShowGiveKudos) {
341
+ const kudosAction = {
342
+ label: /*#__PURE__*/React.createElement(FormattedMessage, messages.giveKudosButton),
343
+ id: 'give-kudos',
344
+ callback: () => {
345
+ this.openKudosDrawer();
346
+ },
347
+ link: this.kudosUrl()
348
+ };
349
+ return actions.concat([kudosAction]);
350
+ }
351
+
352
+ return actions;
293
353
  }
294
354
 
295
355
  renderPopup() {
@@ -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.9.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.9.0"
4
4
  }
@@ -18,6 +18,7 @@ import { LinkItem, MenuGroup } from '@atlaskit/menu';
18
18
  import Popup from '@atlaskit/popup';
19
19
  import { layers } from '@atlaskit/theme/constants';
20
20
  import messages from '../../messages';
21
+ import { AnimatedKudosButton, KudosBlobAnimation } from '../../styled/Card';
21
22
  import { ErrorWrapper, TeamErrorText, TeamErrorTitle } from '../../styled/Error';
22
23
  import { ActionButtons, AvatarSection, CardContent, CardHeader, CardWrapper, Description, DescriptionWrapper, MemberCount, MoreButton, TeamName, WrappedButton } from '../../styled/TeamCard';
23
24
  import { errorRetryClicked, moreActionsClicked, moreMembersClicked, teamActionClicked, teamAvatarClicked, teamProfileCardRendered } from '../../util/analytics';
@@ -25,6 +26,7 @@ import { isBasicClick } from '../../util/click';
25
26
  import { ErrorIllustration } from '../Error';
26
27
  import TeamLoadingState from './TeamLoadingState';
27
28
  var LARGE_MEMBER_COUNT = 50;
29
+ var GIVE_KUDOS_ACTION_ID = 'give-kudos';
28
30
 
29
31
  function onMemberClick(callback, userId, analytics, index, hasHref) {
30
32
  return function (event) {
@@ -121,11 +123,19 @@ var ActionButton = function ActionButton(_ref2) {
121
123
  var action = _ref2.action,
122
124
  analytics = _ref2.analytics,
123
125
  index = _ref2.index;
124
- return /*#__PURE__*/React.createElement(WrappedButton, null, /*#__PURE__*/React.createElement(Button, {
125
- href: action.link,
126
+ var isGiveKudosActionButton = action.id === GIVE_KUDOS_ACTION_ID;
127
+ var actionButton = /*#__PURE__*/React.createElement(Button, {
128
+ key: action.id || index,
126
129
  onClick: onActionClick(action, analytics, index),
130
+ href: action.link,
127
131
  shouldFitContainer: true
128
- }, action.label));
132
+ }, action.label, isGiveKudosActionButton && /*#__PURE__*/React.createElement(KudosBlobAnimation, null));
133
+
134
+ if (isGiveKudosActionButton) {
135
+ return /*#__PURE__*/React.createElement(AnimatedKudosButton, null, actionButton);
136
+ }
137
+
138
+ return /*#__PURE__*/React.createElement(WrappedButton, null, actionButton);
129
139
  };
130
140
 
131
141
  var ExtraActions = function ExtraActions(_ref3) {
@@ -1,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
3
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/createClass";
4
5
  import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
@@ -12,10 +13,13 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
12
13
  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; } }
13
14
 
14
15
  import React, { Suspense } from 'react';
16
+ import { FormattedMessage } from 'react-intl-next';
15
17
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
18
+ import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
16
19
  import Popup from '@atlaskit/popup';
17
20
  import { layers } from '@atlaskit/theme/constants';
18
21
  import _filterActions from '../../internal/filterActions';
22
+ import messages from '../../messages';
19
23
  import { fireEvent, teamCardTriggered, teamProfileCardRendered } from '../../util/analytics';
20
24
  import { isBasicClick } from '../../util/click';
21
25
  import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
@@ -144,6 +148,26 @@ export var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureCo
144
148
  }
145
149
  });
146
150
 
151
+ _defineProperty(_assertThisInitialized(_this), "openKudosDrawer", function () {
152
+ _this.hideProfilecard(DELAY_MS_HIDE);
153
+
154
+ _this.setState({
155
+ kudosDrawerOpen: true
156
+ });
157
+ });
158
+
159
+ _defineProperty(_assertThisInitialized(_this), "closeKudosDrawer", function () {
160
+ _this.setState({
161
+ kudosDrawerOpen: false
162
+ });
163
+ });
164
+
165
+ _defineProperty(_assertThisInitialized(_this), "kudosUrl", function () {
166
+ var recipientId = _this.props.teamId && "&recipientId=".concat(_this.props.teamId) || '';
167
+ var cloudId = _this.props.cloudId && "&cloudId=".concat(_this.props.cloudId) || '';
168
+ return "".concat(_this.state.teamCentralBaseUrl, "/kudos/give?type=team").concat(recipientId).concat(cloudId);
169
+ });
170
+
147
171
  _defineProperty(_assertThisInitialized(_this), "stopPropagation", function (event) {
148
172
  // We need to stop propagation when users click on the card, so that it
149
173
  // doesn't trigger any special effects that occur when clicking the trigger.
@@ -167,7 +191,10 @@ export var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureCo
167
191
  isLoading: undefined,
168
192
  hasError: false,
169
193
  error: null,
170
- data: null
194
+ data: null,
195
+ shouldShowGiveKudos: false,
196
+ teamCentralBaseUrl: undefined,
197
+ kudosDrawerOpen: false
171
198
  });
172
199
 
173
200
  _defineProperty(_assertThisInitialized(_this), "clientFetchProfile", function () {
@@ -189,8 +216,11 @@ export var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureCo
189
216
  _this.fireAnalytics(event);
190
217
  };
191
218
 
192
- _this.props.resourceClient.getTeamProfile(teamId, orgId, fireEvent).then(function (res) {
193
- return _this.handleClientSuccess(res);
219
+ var requests = Promise.all([_this.props.resourceClient.getTeamProfile(teamId, orgId, fireEvent), _this.props.resourceClient.shouldShowGiveKudos()]);
220
+ requests.then(function (res) {
221
+ var _this2;
222
+
223
+ return (_this2 = _this).handleClientSuccess.apply(_this2, _toConsumableArray(res));
194
224
  }, function (err) {
195
225
  return _this.handleClientError(err);
196
226
  }).catch(function (err) {
@@ -243,6 +273,24 @@ export var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureCo
243
273
  }))));
244
274
  });
245
275
 
276
+ _defineProperty(_assertThisInitialized(_this), "renderKudosLauncher", function () {
277
+ return _this.state.shouldShowGiveKudos && /*#__PURE__*/React.createElement(Suspense, {
278
+ fallback: null
279
+ }, /*#__PURE__*/React.createElement(GiveKudosLauncherLazy, {
280
+ isOpen: _this.state.kudosDrawerOpen,
281
+ recipient: {
282
+ type: KudosType.TEAM,
283
+ recipientId: _this.props.teamId
284
+ },
285
+ analytics: _this.fireAnalytics,
286
+ analyticsSource: "team-profile-card",
287
+ teamCentralBaseUrl: _this.state.teamCentralBaseUrl,
288
+ cloudId: _this.props.cloudId || '',
289
+ addFlag: _this.props.addFlag,
290
+ onClose: _this.closeKudosDrawer
291
+ }));
292
+ });
293
+
246
294
  _defineProperty(_assertThisInitialized(_this), "renderTrigger", function (triggerProps) {
247
295
  var _this$props3 = _this.props,
248
296
  children = _this$props3.children,
@@ -250,12 +298,12 @@ export var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureCo
250
298
  viewProfileLink = _this$props3.viewProfileLink;
251
299
 
252
300
  if (triggerLinkType === 'none') {
253
- return /*#__PURE__*/React.createElement("span", _extends({
301
+ return /*#__PURE__*/React.createElement(React.Fragment, null, _this.renderKudosLauncher(), /*#__PURE__*/React.createElement("span", _extends({
254
302
  "data-testid": "team-profilecard-trigger-wrapper"
255
- }, triggerProps, _this.triggerListeners), children);
303
+ }, triggerProps, _this.triggerListeners), children));
256
304
  }
257
305
 
258
- return /*#__PURE__*/React.createElement("a", _extends({
306
+ return /*#__PURE__*/React.createElement(React.Fragment, null, _this.renderKudosLauncher(), /*#__PURE__*/React.createElement("a", _extends({
259
307
  "data-testid": "team-profilecard-trigger-wrapper",
260
308
  style: {
261
309
  color: 'initial',
@@ -264,7 +312,7 @@ export var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureCo
264
312
  href: viewProfileLink
265
313
  }, triggerProps, {
266
314
  ref: triggerProps.ref
267
- }, _this.triggerListeners), children);
315
+ }, _this.triggerListeners), children));
268
316
  });
269
317
 
270
318
  return _this;
@@ -299,7 +347,7 @@ export var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureCo
299
347
  }
300
348
  }, {
301
349
  key: "handleClientSuccess",
302
- value: function handleClientSuccess(res) {
350
+ value: function handleClientSuccess(team, shouldShowGiveKudos) {
303
351
  if (!this._isMounted) {
304
352
  return;
305
353
  }
@@ -307,7 +355,9 @@ export var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureCo
307
355
  this.setState({
308
356
  isLoading: false,
309
357
  hasError: false,
310
- data: res
358
+ data: team,
359
+ shouldShowGiveKudos: shouldShowGiveKudos,
360
+ teamCentralBaseUrl: this.props.resourceClient.getTeamCentralBaseUrl()
311
361
  });
312
362
  }
313
363
  }, {
@@ -326,12 +376,28 @@ export var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureCo
326
376
  }, {
327
377
  key: "filterActions",
328
378
  value: function filterActions() {
329
- return _filterActions(this.props.actions, this.state.data);
379
+ var _this3 = this;
380
+
381
+ var actions = _filterActions(this.props.actions, this.state.data);
382
+
383
+ if (this.state.shouldShowGiveKudos) {
384
+ var kudosAction = {
385
+ label: /*#__PURE__*/React.createElement(FormattedMessage, messages.giveKudosButton),
386
+ id: 'give-kudos',
387
+ callback: function callback() {
388
+ _this3.openKudosDrawer();
389
+ },
390
+ link: this.kudosUrl()
391
+ };
392
+ return actions.concat([kudosAction]);
393
+ }
394
+
395
+ return actions;
330
396
  }
331
397
  }, {
332
398
  key: "renderPopup",
333
399
  value: function renderPopup() {
334
- var _this2 = this;
400
+ var _this4 = this;
335
401
 
336
402
  if (this.state.renderError) {
337
403
  return this.props.children;
@@ -345,7 +411,7 @@ export var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureCo
345
411
  placement: this.props.position,
346
412
  content: this.renderProfileCard,
347
413
  trigger: function trigger(triggerProps) {
348
- return _this2.renderTrigger(triggerProps);
414
+ return _this4.renderTrigger(triggerProps);
349
415
  },
350
416
  zIndex: layers.modal(),
351
417
  shouldFlip: true
@@ -17,7 +17,7 @@ export var ProfileImage = styled.div(_templateObject3 || (_templateObject3 = _ta
17
17
  export var ActionsFlexSpacer = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n flex: 1 0 auto;\n"])));
18
18
  var kudosButtonAnimationTransformation = keyframes(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["{\n 0% { transform: translate(-80px, -50px); }\n 100% { transform: translate(90px, -70px); }\n}"])));
19
19
  export var KudosBlobAnimation = styled.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: none;\n height: 150px;\n width: 150px;\n z-index: -1;\n position: absolute;\n animation-name: ", ";\n animation-iteration-count: 1;\n animation-duration: 3s;\n background-image: radial-gradient(\n circle,\n ", " 0%,\n ", " 25%,\n transparent 50%\n );\n overflow: hidden;\n"])), kudosButtonAnimationTransformation, token('color.background.information.pressed', '#85B8FF'), token('color.background.discovery.pressed', '#B8ACF6'));
20
- export var AnimatedKudosButton = styled.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\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"])), gridSize, KudosBlobAnimation, borderRadius);
20
+ export var AnimatedKudosButton = styled.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\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"])), gridSize, KudosBlobAnimation, borderRadius);
21
21
  export var ActionButtonGroup = styled.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n user-select: none;\n margin: ", "px 0 0 0;\n text-align: right;\n display: flex;\n justify-content: flex-end;\n\n button,\n a,\n span {\n margin-left: ", "px;\n\n &:first-child {\n margin-left: 0;\n }\n }\n"])), 2 * gridSize(), gridSize);
22
22
  export var OverflowActionButtonsWrapper = styled.div(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n display: inline-block;\n width: 32px;\n height: 32px;\n margin-left: ", "px;\n"])), gridSize);
23
23
  export var CardContent = styled.div(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n min-height: ", "px;\n"])), gridSize() * 17);
@@ -45,7 +45,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
45
45
  actionSubjectId: actionSubjectId,
46
46
  attributes: _objectSpread(_objectSpread({
47
47
  packageName: "@atlaskit/profilecard",
48
- packageVersion: "16.8.0"
48
+ packageVersion: "16.9.0"
49
49
  }, attributes), {}, {
50
50
  firedAt: getPageTime()
51
51
  })
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "16.8.0"
3
+ "version": "16.9.0"
4
4
  }
@@ -18,6 +18,9 @@ export declare class TeamProfileCardTriggerInternal extends React.PureComponent<
18
18
  onClick: (event: React.MouseEvent<HTMLElement>) => void;
19
19
  onMouseEnter: () => void;
20
20
  onMouseLeave: () => void;
21
+ openKudosDrawer: () => void;
22
+ closeKudosDrawer: () => void;
23
+ kudosUrl: () => string;
21
24
  stopPropagation: (event: React.MouseEvent<HTMLElement>) => void;
22
25
  triggerListeners: {
23
26
  onClick: (event: React.MouseEvent<HTMLElement>) => void;
@@ -35,10 +38,11 @@ export declare class TeamProfileCardTriggerInternal extends React.PureComponent<
35
38
  componentWillUnmount(): void;
36
39
  clientFetchProfile: () => void;
37
40
  onErrorBoundary: () => void;
38
- handleClientSuccess(res: Team): void;
41
+ handleClientSuccess(team: Team, shouldShowGiveKudos: boolean): void;
39
42
  handleClientError(err: any): void;
40
43
  filterActions(): ProfileCardAction[];
41
44
  renderProfileCard: () => JSX.Element;
45
+ renderKudosLauncher: () => false | JSX.Element | undefined;
42
46
  renderTrigger: (triggerProps: TriggerProps) => JSX.Element;
43
47
  renderPopup(): React.ReactNode;
44
48
  render(): React.ReactNode;
@@ -133,6 +133,9 @@ export interface TeamProfileCardTriggerState {
133
133
  error?: any;
134
134
  data: Team | null;
135
135
  renderError?: boolean;
136
+ shouldShowGiveKudos?: boolean;
137
+ teamCentralBaseUrl?: string;
138
+ kudosDrawerOpen: boolean;
136
139
  }
137
140
  export interface TeamProfilecardCoreProps {
138
141
  /**
@@ -236,6 +239,14 @@ export interface TeamProfileCardTriggerProps extends TeamProfilecardCoreProps {
236
239
  interacted with according to the method specified by the trigger prop.
237
240
  */
238
241
  children?: React.ReactNode;
242
+ /**
243
+ * Used by the card to show Flags.
244
+ */
245
+ addFlag?: (flag: any) => void;
246
+ /**
247
+ * Optional cloudId. Pass this if rendering card within a sited context.
248
+ */
249
+ cloudId?: string;
239
250
  }
240
251
  export declare type StatusType = 'active' | 'inactive' | 'closed';
241
252
  export declare type TriggerType = 'hover' | 'click';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "16.8.0",
3
+ "version": "16.9.0",
4
4
  "description": "A React component to display a card with user information.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"