@atlaskit/profilecard 16.12.1 → 17.0.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 (74) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/client/ProfileCardClient.js +2 -2
  3. package/dist/cjs/client/TeamProfileCardClient.js +13 -12
  4. package/dist/cjs/client/UserProfileCardClient.js +25 -2
  5. package/dist/cjs/client/errorUtils.js +25 -0
  6. package/dist/cjs/components/Error/ErrorMessage.js +40 -77
  7. package/dist/cjs/components/Team/TeamLoadingState.js +1 -1
  8. package/dist/cjs/components/Team/TeamProfileCard.js +4 -4
  9. package/dist/cjs/components/Team/TeamProfileCardTrigger.js +3 -3
  10. package/dist/cjs/components/User/OverflowProfileCardButtons.js +44 -10
  11. package/dist/cjs/components/User/ProfileCard.js +195 -362
  12. package/dist/cjs/components/User/ProfileCardDetails.js +142 -0
  13. package/dist/cjs/components/User/ProfileCardResourced.js +25 -20
  14. package/dist/cjs/components/User/ProfileCardTrigger.js +35 -7
  15. package/dist/cjs/components/User/ReportingLinesDetails.js +13 -13
  16. package/dist/cjs/components/User/UserLoadingState.js +14 -2
  17. package/dist/cjs/util/analytics.js +31 -16
  18. package/dist/cjs/version.json +1 -1
  19. package/dist/es2019/client/ProfileCardClient.js +2 -2
  20. package/dist/es2019/client/TeamProfileCardClient.js +3 -9
  21. package/dist/es2019/client/UserProfileCardClient.js +23 -2
  22. package/dist/es2019/client/errorUtils.js +17 -0
  23. package/dist/es2019/components/Error/ErrorMessage.js +38 -42
  24. package/dist/es2019/components/Team/TeamLoadingState.js +2 -2
  25. package/dist/es2019/components/Team/TeamProfileCard.js +5 -5
  26. package/dist/es2019/components/Team/TeamProfileCardTrigger.js +4 -4
  27. package/dist/es2019/components/User/OverflowProfileCardButtons.js +30 -4
  28. package/dist/es2019/components/User/ProfileCard.js +161 -292
  29. package/dist/es2019/components/User/ProfileCardDetails.js +118 -0
  30. package/dist/es2019/components/User/ProfileCardResourced.js +21 -21
  31. package/dist/es2019/components/User/ProfileCardTrigger.js +32 -6
  32. package/dist/es2019/components/User/ReportingLinesDetails.js +10 -11
  33. package/dist/es2019/components/User/UserLoadingState.js +10 -2
  34. package/dist/es2019/util/analytics.js +13 -8
  35. package/dist/es2019/version.json +1 -1
  36. package/dist/esm/client/ProfileCardClient.js +2 -2
  37. package/dist/esm/client/TeamProfileCardClient.js +11 -12
  38. package/dist/esm/client/UserProfileCardClient.js +22 -2
  39. package/dist/esm/client/errorUtils.js +17 -0
  40. package/dist/esm/components/Error/ErrorMessage.js +35 -80
  41. package/dist/esm/components/Team/TeamLoadingState.js +2 -2
  42. package/dist/esm/components/Team/TeamProfileCard.js +5 -5
  43. package/dist/esm/components/Team/TeamProfileCardTrigger.js +4 -4
  44. package/dist/esm/components/User/OverflowProfileCardButtons.js +39 -9
  45. package/dist/esm/components/User/ProfileCard.js +180 -362
  46. package/dist/esm/components/User/ProfileCardDetails.js +120 -0
  47. package/dist/esm/components/User/ProfileCardResourced.js +17 -17
  48. package/dist/esm/components/User/ProfileCardTrigger.js +33 -7
  49. package/dist/esm/components/User/ReportingLinesDetails.js +12 -12
  50. package/dist/esm/components/User/UserLoadingState.js +7 -2
  51. package/dist/esm/util/analytics.js +21 -12
  52. package/dist/esm/version.json +1 -1
  53. package/dist/types/client/ProfileCardClient.d.ts +3 -2
  54. package/dist/types/client/TeamProfileCardClient.d.ts +2 -1
  55. package/dist/types/client/UserProfileCardClient.d.ts +2 -1
  56. package/dist/types/client/errorUtils.d.ts +6 -0
  57. package/dist/types/components/Error/ErrorMessage.d.ts +6 -15
  58. package/dist/types/components/Team/TeamProfileCardTrigger.d.ts +5 -11
  59. package/dist/types/components/User/OverflowProfileCardButtons.d.ts +4 -3
  60. package/dist/types/components/User/ProfileCard.d.ts +5 -29
  61. package/dist/types/components/User/ProfileCardDetails.d.ts +3 -0
  62. package/dist/types/components/User/ProfileCardResourced.d.ts +7 -3
  63. package/dist/types/components/User/ProfileCardTrigger.d.ts +3 -40
  64. package/dist/types/components/User/ReportingLinesDetails.d.ts +2 -4
  65. package/dist/types/components/User/UserLoadingState.d.ts +5 -1
  66. package/dist/types/components/User/lazyProfileCard.d.ts +1 -1
  67. package/dist/types/types.d.ts +11 -10
  68. package/dist/types/util/analytics.d.ts +22 -13
  69. package/package.json +8 -8
  70. package/report.api.md +71 -124
  71. package/dist/cjs/internal/analytics.js +0 -15
  72. package/dist/es2019/internal/analytics.js +0 -8
  73. package/dist/esm/internal/analytics.js +0 -8
  74. package/dist/types/internal/analytics.d.ts +0 -8
@@ -1,392 +1,210 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
4
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
5
- import _createClass from "@babel/runtime/helpers/createClass";
6
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
7
- import _inherits from "@babel/runtime/helpers/inherits";
8
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
9
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
10
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
11
- var _excluded = ["text"];
12
-
13
- 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); }; }
14
-
15
- 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; } }
16
-
17
- import React from 'react';
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
18
5
  import { FormattedMessage } from 'react-intl-next';
6
+ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
19
7
  import Avatar from '@atlaskit/avatar';
20
8
  import Button from '@atlaskit/button/custom-theme-button';
21
- import Lozenge from '@atlaskit/lozenge';
22
9
  import Spinner from '@atlaskit/spinner';
23
10
  import { N0 } from '@atlaskit/theme/colors';
24
11
  import { token } from '@atlaskit/tokens';
25
- import { AnalyticsName } from '../../internal/analytics';
26
- import relativeDate from '../../internal/relative-date';
27
12
  import messages from '../../messages';
28
- import { ActionButtonGroup, ActionsFlexSpacer, AnimatedKudosButton, AppTitleLabel, CardContainer, CardContent, CardWrapper, CustomLozengeContainer, DetailsGroup, DisabledInfo, FullNameLabel, JobTitleLabel, KudosBlobAnimation, LozengeWrapper, ProfileImage, SpinnerContainer } from '../../styled/Card';
13
+ import { ActionButtonGroup, ActionsFlexSpacer, AnimatedKudosButton, CardContainer, CardContent, CardWrapper, KudosBlobAnimation, ProfileImage, SpinnerContainer } from '../../styled/Card';
14
+ import { actionClicked, fireEvent, profileCardRendered } from '../../util/analytics';
29
15
  import { isBasicClick } from '../../util/click';
16
+ import { getPageTime } from '../../util/performance';
30
17
  import { ErrorMessage } from '../Error';
31
- import { IconLabel } from '../Icon';
32
- import { OverflowProfileCardButtons } from './OverflowProfileCardButtons';
33
- import ReportingLinesDetails from './ReportingLinesDetails';
34
-
35
- var Profilecard = /*#__PURE__*/function (_React$PureComponent) {
36
- _inherits(Profilecard, _React$PureComponent);
37
-
38
- var _super = _createSuper(Profilecard);
39
-
40
- function Profilecard(props) {
41
- var _this;
42
-
43
- _classCallCheck(this, Profilecard);
44
-
45
- _this = _super.call(this, props);
46
-
47
- _defineProperty(_assertThisInitialized(_this), "GIVE_KUDOS_ACTION_ID", 'give-kudos');
48
-
49
- _defineProperty(_assertThisInitialized(_this), "durationSince", function (from) {
50
- var fromParsed = from || 0;
51
- return fromParsed > 0 ? Date.now() - fromParsed : null;
52
- });
53
-
54
- _defineProperty(_assertThisInitialized(_this), "callClientFetchProfile", function () {
55
- if (_this.props.clientFetchProfile) {
56
- var _this$props;
57
-
58
- (_this$props = _this.props).clientFetchProfile.apply(_this$props, arguments);
59
- }
60
- });
61
-
62
- _defineProperty(_assertThisInitialized(_this), "callAnalytics", function (id, options) {
63
- if (_this.props.analytics) {
64
- _this.props.analytics(id, options);
65
- }
66
- });
67
-
68
- _defineProperty(_assertThisInitialized(_this), "kudosUrl", function () {
69
- var recipientId = _this.props.userId && "&recipientId=".concat(_this.props.userId) || '';
70
- var cloudId = _this.props.cloudId && "&cloudId=".concat(_this.props.cloudId) || '';
71
- return "".concat(_this.props.teamCentralBaseUrl, "/kudos/give?type=individual").concat(recipientId).concat(cloudId);
72
- });
73
-
74
- _defineProperty(_assertThisInitialized(_this), "kudosButtonCallback", function () {
75
- if (_this.props.openKudosDrawer) {
76
- _this.props.openKudosDrawer();
77
- } else {
78
- window.open(_this.kudosUrl());
79
- }
80
- });
81
-
82
- _defineProperty(_assertThisInitialized(_this), "renderButton", function (action, idx) {
83
- var isGiveKudosActionButton = action.id === _this.GIVE_KUDOS_ACTION_ID;
84
- var actionButton = /*#__PURE__*/React.createElement(Button, {
85
- appearance: "default",
86
- key: action.id || idx,
87
- onClick: function onClick(event) {
88
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
89
- args[_key - 1] = arguments[_key];
90
- }
91
-
92
- return _this.onActionClick(action, args, event);
93
- },
94
- href: action.link
95
- }, action.label, isGiveKudosActionButton && /*#__PURE__*/React.createElement(KudosBlobAnimation, null));
96
-
97
- if (isGiveKudosActionButton) {
98
- return /*#__PURE__*/React.createElement(AnimatedKudosButton, null, actionButton);
99
- }
100
-
101
- return actionButton;
102
- });
103
-
104
- _this.timeOpen = null;
105
-
106
- _this.clientFetchProfile = function () {
107
- var _this2;
108
-
109
- _this.callAnalytics(AnalyticsName.PROFILE_CARD_RELOAD, {});
110
-
111
- (_this2 = _this).callClientFetchProfile.apply(_this2, arguments);
112
- };
113
-
114
- return _this;
115
- }
116
-
117
- _createClass(Profilecard, [{
118
- key: "componentDidMount",
119
- value: function componentDidMount() {
120
- this.timeOpen = Date.now();
121
- this.callAnalytics(AnalyticsName.PROFILE_CARD_VIEW, {});
18
+ import { ACTION_OVERFLOW_THRESHOLD, OverflowProfileCardButtons } from './OverflowProfileCardButtons';
19
+ import { ProfileCardDetails } from './ProfileCardDetails';
20
+ var GIVE_KUDOS_ACTION_ID = 'give-kudos';
21
+
22
+ var useKudos = function useKudos(cloudId, userId, teamCentralBaseUrl, openKudosDrawer) {
23
+ var kudosUrl = useMemo(function () {
24
+ var recipientId = userId ? "&recipientId=".concat(userId) : '';
25
+ var cloudIdParam = cloudId ? "&cloudId=".concat(cloudId) : '';
26
+ return "".concat(teamCentralBaseUrl || '', "/kudos/give?type=individual").concat(recipientId).concat(cloudIdParam);
27
+ }, [cloudId, teamCentralBaseUrl, userId]);
28
+ var kudosButtonCallback = useCallback(function () {
29
+ if (openKudosDrawer) {
30
+ openKudosDrawer();
31
+ } else {
32
+ window.open(kudosUrl);
122
33
  }
123
- }, {
124
- key: "renderErrorMessage",
125
- value: function renderErrorMessage() {
126
- return /*#__PURE__*/React.createElement(ErrorMessage, {
127
- reload: this.props.clientFetchProfile && this.clientFetchProfile,
128
- errorType: this.props.errorType
129
- });
34
+ }, [kudosUrl, openKudosDrawer]);
35
+ var kudosAction = useMemo(function () {
36
+ return {
37
+ label: /*#__PURE__*/React.createElement(FormattedMessage, messages.giveKudosButton),
38
+ id: GIVE_KUDOS_ACTION_ID,
39
+ callback: kudosButtonCallback,
40
+ link: kudosUrl
41
+ };
42
+ }, [kudosButtonCallback, kudosUrl]);
43
+ return {
44
+ kudosAction: kudosAction,
45
+ kudosButtonCallback: kudosButtonCallback,
46
+ kudosUrl: kudosUrl
47
+ };
48
+ };
49
+
50
+ var Wrapper = function Wrapper(props) {
51
+ return /*#__PURE__*/React.createElement(CardWrapper, {
52
+ "data-testid": "profilecard"
53
+ }, props.children);
54
+ };
55
+
56
+ export var ProfilecardInternal = function ProfilecardInternal(props) {
57
+ var _useState = useState(getPageTime()),
58
+ _useState2 = _slicedToArray(_useState, 1),
59
+ openTime = _useState2[0];
60
+
61
+ var createAnalyticsEvent = props.createAnalyticsEvent;
62
+ var fireAnalytics = useCallback(function (payload) {
63
+ if (createAnalyticsEvent) {
64
+ fireEvent(createAnalyticsEvent, payload);
130
65
  }
131
- }, {
132
- key: "getActions",
133
- value: function getActions() {
134
- var _this3 = this;
135
-
136
- var actions = this.props.actions || [];
137
-
138
- if (!this.props.isCurrentUser && this.props.status === 'active' && this.props.isKudosEnabled) {
139
- var kudosAction = {
140
- label: /*#__PURE__*/React.createElement(FormattedMessage, messages.giveKudosButton),
141
- id: this.GIVE_KUDOS_ACTION_ID,
142
- callback: function callback() {
143
- _this3.kudosButtonCallback();
144
- },
145
- link: this.kudosUrl()
146
- };
147
- return actions.concat([kudosAction]);
148
- }
149
-
66
+ }, [createAnalyticsEvent]);
67
+ var fireAnalyticsWithDuration = useCallback(function (generator) {
68
+ var elapsed = getPageTime() - openTime;
69
+ var event = generator(elapsed);
70
+ fireAnalytics(event);
71
+ }, [fireAnalytics, openTime]);
72
+
73
+ var _useKudos = useKudos(props.cloudId, props.userId, props.teamCentralBaseUrl, props.openKudosDrawer),
74
+ kudosAction = _useKudos.kudosAction;
75
+
76
+ var _props$actions = props.actions,
77
+ actions = _props$actions === void 0 ? [] : _props$actions,
78
+ isCurrentUser = props.isCurrentUser,
79
+ isKudosEnabled = props.isKudosEnabled,
80
+ _props$status = props.status,
81
+ status = _props$status === void 0 ? 'active' : _props$status;
82
+ var realActions = useMemo(function () {
83
+ if (isCurrentUser || !isKudosEnabled || status !== 'active') {
150
84
  return actions;
151
85
  }
152
- }, {
153
- key: "renderActionsButtons",
154
- value: function renderActionsButtons() {
155
- var _this4 = this;
156
-
157
- if (this.props.actions && this.props.actions.length === 0) {
158
- return null;
159
- }
160
86
 
161
- var actions = this.getActions();
162
- var firstTwoActions = actions.slice(0, 2);
163
- var restOfActions = actions && actions.length > 2 ? actions.slice(2) : undefined;
164
- return /*#__PURE__*/React.createElement(ActionButtonGroup, null, firstTwoActions.map(function (action, idx) {
165
- return _this4.renderButton(action, idx);
166
- }), restOfActions && /*#__PURE__*/React.createElement(OverflowProfileCardButtons, {
167
- actions: restOfActions,
168
- onItemClick: function onItemClick(action, args, event) {
169
- return _this4.onActionClick(action, args, event);
170
- }
171
- }));
172
- }
173
- }, {
174
- key: "onActionClick",
175
- value: function onActionClick(action, args, event) {
176
- this.callAnalytics(AnalyticsName.PROFILE_CARD_CLICK, {
177
- id: action.id || null,
178
- duration: this.durationSince(this.timeOpen)
87
+ return actions.concat([kudosAction]);
88
+ }, [actions, isCurrentUser, isKudosEnabled, kudosAction, status]);
89
+ var isLoading = props.isLoading,
90
+ fullName = props.fullName,
91
+ hasError = props.hasError;
92
+ var canRender = !hasError && !isLoading && !!(fullName || status === 'closed');
93
+ useEffect(function () {
94
+ if (canRender) {
95
+ fireAnalyticsWithDuration(function (duration) {
96
+ return profileCardRendered('user', 'content', {
97
+ duration: duration,
98
+ numActions: realActions.length
99
+ });
179
100
  });
180
-
181
- if (action.callback && isBasicClick(event)) {
182
- event.preventDefault();
183
- action.callback.apply(action, [event].concat(_toConsumableArray(args)));
184
- }
185
- }
186
- }, {
187
- key: "renderCardDetailsDefault",
188
- value: function renderCardDetailsDefault() {
189
- var _this5 = this;
190
-
191
- var _this$props2 = this.props,
192
- meta = _this$props2.meta,
193
- location = _this$props2.location,
194
- email = _this$props2.email,
195
- timestring = _this$props2.timestring,
196
- companyName = _this$props2.companyName,
197
- customLozenges = _this$props2.customLozenges;
198
- return /*#__PURE__*/React.createElement(DetailsGroup, null, this.renderFullNameAndPublicName(meta), meta && /*#__PURE__*/React.createElement(JobTitleLabel, null, meta), customLozenges && this.renderCustomLozenges(customLozenges), /*#__PURE__*/React.createElement(IconLabel, {
199
- icon: "email"
200
- }, email), /*#__PURE__*/React.createElement(IconLabel, {
201
- icon: "time"
202
- }, timestring), /*#__PURE__*/React.createElement(IconLabel, {
203
- icon: "companyName"
204
- }, companyName), /*#__PURE__*/React.createElement(IconLabel, {
205
- icon: "location"
206
- }, location), /*#__PURE__*/React.createElement(ReportingLinesDetails, {
207
- reportingLines: this.props.reportingLines,
208
- reportingLinesProfileUrl: this.props.reportingLinesProfileUrl,
209
- onReportingLinesClick: this.props.onReportingLinesClick,
210
- analytics: this.props.analytics,
211
- getDuration: function getDuration() {
212
- return _this5.durationSince(_this5.timeOpen);
213
- }
214
- }));
215
- }
216
- }, {
217
- key: "renderCardDetailsForDisabledAccount",
218
- value: function renderCardDetailsForDisabledAccount() {
219
- var _this$props3 = this.props,
220
- status = _this$props3.status,
221
- companyName = _this$props3.companyName,
222
- hasDisabledAccountLozenge = _this$props3.hasDisabledAccountLozenge;
223
- return /*#__PURE__*/React.createElement(DetailsGroup, null, /*#__PURE__*/React.createElement(FullNameLabel, {
224
- noMeta: true,
225
- isDisabledAccount: true
226
- }, this.getDisabledAccountName()), hasDisabledAccountLozenge && /*#__PURE__*/React.createElement(LozengeWrapper, null, /*#__PURE__*/React.createElement(Lozenge, {
227
- appearance: "default",
228
- isBold: true
229
- }, status === 'inactive' && /*#__PURE__*/React.createElement(FormattedMessage, messages.inactiveAccountMsg), status === 'closed' && /*#__PURE__*/React.createElement(FormattedMessage, messages.closedAccountMsg))), /*#__PURE__*/React.createElement(DisabledInfo, null, this.getDisabledAccountDesc()), status === 'inactive' && /*#__PURE__*/React.createElement(IconLabel, {
230
- icon: "companyName"
231
- }, companyName));
232
101
  }
233
- }, {
234
- key: "getDisabledAccountName",
235
- value: function getDisabledAccountName() {
236
- var _this$props4 = this.props,
237
- nickname = _this$props4.nickname,
238
- fullName = _this$props4.fullName,
239
- status = _this$props4.status;
240
-
241
- if (status === 'inactive') {
242
- return fullName || nickname;
243
- } else if (status === 'closed') {
244
- return nickname || /*#__PURE__*/React.createElement(FormattedMessage, messages.disabledAccountDefaultName);
245
- }
246
-
247
- return null;
248
- }
249
- }, {
250
- key: "getDisabledAccountDesc",
251
- value: function getDisabledAccountDesc() {
252
- var _this$props5 = this.props,
253
- _this$props5$status = _this$props5.status,
254
- status = _this$props5$status === void 0 ? 'closed' : _this$props5$status,
255
- statusModifiedDate = _this$props5.statusModifiedDate,
256
- disabledAccountMessage = _this$props5.disabledAccountMessage;
257
- var date = statusModifiedDate ? new Date(statusModifiedDate * 1000) : null;
258
- var relativeDateKey = relativeDate(date); // consumer does not want to use built-in message
102
+ }, [canRender, fireAnalyticsWithDuration, realActions]);
103
+
104
+ if (hasError) {
105
+ return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(ErrorMessage, {
106
+ reload: props.clientFetchProfile,
107
+ errorType: props.errorType || null,
108
+ fireAnalytics: fireAnalytics
109
+ }));
110
+ }
259
111
 
260
- if (disabledAccountMessage) {
261
- return disabledAccountMessage;
262
- }
112
+ if (isLoading) {
113
+ return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(LoadingView, {
114
+ fireAnalyticsWithDuration: fireAnalyticsWithDuration
115
+ }));
116
+ }
263
117
 
264
- var secondSentence = null;
118
+ if (!canRender) {
119
+ return null;
120
+ }
265
121
 
266
- if (relativeDateKey) {
267
- secondSentence = /*#__PURE__*/React.createElement(FormattedMessage // @ts-ignore
268
- , messages["".concat(status, "AccountDescMsgHasDate").concat(relativeDateKey)]);
269
- } else {
270
- secondSentence =
271
- /*#__PURE__*/
272
- // @ts-ignore
273
- React.createElement(FormattedMessage, messages["".concat(status, "AccountDescMsgNoDate")]);
274
- }
122
+ var isDisabledUser = status === 'inactive' || status === 'closed';
123
+ return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(CardContainer, {
124
+ isDisabledUser: isDisabledUser,
125
+ withoutElevation: props.withoutElevation
126
+ }, /*#__PURE__*/React.createElement(ProfileImage, null, /*#__PURE__*/React.createElement(Avatar, {
127
+ size: "xlarge",
128
+ src: status !== 'closed' ? props.avatarUrl : undefined,
129
+ borderColor: token('elevation.shadow.overlay', N0)
130
+ })), /*#__PURE__*/React.createElement(CardContent, null, /*#__PURE__*/React.createElement(ProfileCardDetails, _extends({}, props, {
131
+ status: status,
132
+ fireAnalyticsWithDuration: fireAnalyticsWithDuration
133
+ })), realActions && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ActionsFlexSpacer, null), /*#__PURE__*/React.createElement(Actions, {
134
+ actions: realActions,
135
+ fireAnalyticsWithDuration: fireAnalyticsWithDuration
136
+ })))));
137
+ };
138
+
139
+ var Actions = function Actions(_ref) {
140
+ var actions = _ref.actions,
141
+ fireAnalyticsWithDuration = _ref.fireAnalyticsWithDuration;
142
+ var onActionClick = useCallback(function (action, args, event, index) {
143
+ fireAnalyticsWithDuration(function (duration) {
144
+ return actionClicked('user', {
145
+ duration: duration,
146
+ hasHref: !!action.link,
147
+ hasOnClick: !!action.callback,
148
+ index: index,
149
+ actionId: action.id || 'no-id-specified'
150
+ });
151
+ });
275
152
 
276
- return /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(FormattedMessage, messages.generalDescMsgForDisabledUser), ' ', secondSentence);
153
+ if (action.callback && isBasicClick(event)) {
154
+ event.preventDefault();
155
+ action.callback.apply(action, [event].concat(_toConsumableArray(args)));
277
156
  }
278
- }, {
279
- key: "renderFullNameAndPublicName",
280
- value: function renderFullNameAndPublicName(meta) {
281
- var _this$props6 = this.props,
282
- nickname = _this$props6.nickname,
283
- fullName = _this$props6.fullName;
157
+ }, [fireAnalyticsWithDuration]);
284
158
 
285
- if (!fullName && !nickname) {
286
- return null;
287
- }
159
+ if (!actions || actions.length === 0) {
160
+ return null;
161
+ }
288
162
 
289
- var displayName = fullName === nickname ? fullName : "".concat(fullName).concat(nickname ? " (".concat(nickname, ") ") : '');
290
- return /*#__PURE__*/React.createElement(FullNameLabel, {
291
- noMeta: !meta
292
- }, displayName);
293
- } // Pass lozenges as an array rather taking it from the props. This will allow us combine the
294
- // other lozenges (like the "deactivated" lozenge) if we need to.
163
+ var regularActions = actions.slice(0, ACTION_OVERFLOW_THRESHOLD);
164
+ var overflowActions = actions.length > ACTION_OVERFLOW_THRESHOLD ? actions.slice(ACTION_OVERFLOW_THRESHOLD) : undefined;
165
+ return /*#__PURE__*/React.createElement(ActionButtonGroup, {
166
+ "data-testid": "profilecard-actions"
167
+ }, regularActions.map(function (action, index) {
168
+ var isKudos = action.id === GIVE_KUDOS_ACTION_ID;
169
+ var button = /*#__PURE__*/React.createElement(Button, {
170
+ appearance: "default",
171
+ key: action.id || index,
172
+ onClick: function onClick(event) {
173
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
174
+ args[_key - 1] = arguments[_key];
175
+ }
295
176
 
296
- }, {
297
- key: "renderCustomLozenges",
298
- value: function renderCustomLozenges(lozenges) {
299
- return lozenges.length > 0 ? /*#__PURE__*/React.createElement(CustomLozengeContainer, null, lozenges.map(function (_ref, index) {
300
- var text = _ref.text,
301
- otherProps = _objectWithoutProperties(_ref, _excluded);
177
+ return onActionClick(action, args, event, index);
178
+ },
179
+ href: action.link
180
+ }, action.label, isKudos && /*#__PURE__*/React.createElement(KudosBlobAnimation, null));
302
181
 
303
- return /*#__PURE__*/React.createElement(Lozenge, _extends({}, otherProps, {
304
- key: index
305
- }), text);
306
- })) : null;
182
+ if (isKudos) {
183
+ return /*#__PURE__*/React.createElement(AnimatedKudosButton, null, button);
307
184
  }
308
- }, {
309
- key: "renderCardDetailsApp",
310
- value: function renderCardDetailsApp() {
311
- return /*#__PURE__*/React.createElement(DetailsGroup, null, this.renderFullNameAndPublicName(), /*#__PURE__*/React.createElement(AppTitleLabel, null, "App"));
312
- }
313
- }, {
314
- key: "renderCardDetails",
315
- value: function renderCardDetails() {
316
- var _this$props7 = this.props,
317
- isBot = _this$props7.isBot,
318
- status = _this$props7.status;
319
-
320
- if (isBot) {
321
- return this.renderCardDetailsApp();
322
- }
323
185
 
324
- if (status === 'inactive' || status === 'closed') {
325
- return this.renderCardDetailsForDisabledAccount();
326
- }
327
-
328
- return this.renderCardDetailsDefault();
186
+ return button;
187
+ }), overflowActions && /*#__PURE__*/React.createElement(OverflowProfileCardButtons, {
188
+ actions: overflowActions,
189
+ fireAnalyticsWithDuration: fireAnalyticsWithDuration,
190
+ onItemClick: function onItemClick(action, args, event, index) {
191
+ return onActionClick(action, args, event, index + ACTION_OVERFLOW_THRESHOLD);
329
192
  }
330
- }, {
331
- key: "render",
332
- value: function render() {
333
- var _this$props8 = this.props,
334
- fullName = _this$props8.fullName,
335
- status = _this$props8.status,
336
- withoutElevation = _this$props8.withoutElevation,
337
- reportingLines = _this$props8.reportingLines;
338
- var cardContent = null; // @FIXME do closed users have empty fullName field?
339
-
340
- var canRender = fullName || status === 'closed';
341
-
342
- if (this.props.hasError) {
343
- this.callAnalytics(AnalyticsName.PROFILE_CARD_ERROR, {});
344
- cardContent = this.renderErrorMessage();
345
- } else if (this.props.isLoading) {
346
- cardContent = /*#__PURE__*/React.createElement(SpinnerContainer, null, /*#__PURE__*/React.createElement(Spinner, null));
347
- } else if (canRender) {
348
- var _reportingLines$manag, _reportingLines$repor;
349
-
350
- var isDisabledUser = status === 'inactive' || status === 'closed';
351
- var actions = this.renderActionsButtons();
352
- this.callAnalytics(AnalyticsName.PROFILE_CARD_LOADED, {
353
- duration: this.durationSince(this.timeOpen),
354
- managersCount: (reportingLines === null || reportingLines === void 0 ? void 0 : (_reportingLines$manag = reportingLines.managers) === null || _reportingLines$manag === void 0 ? void 0 : _reportingLines$manag.length) || 0,
355
- directReportsCount: (reportingLines === null || reportingLines === void 0 ? void 0 : (_reportingLines$repor = reportingLines.reports) === null || _reportingLines$repor === void 0 ? void 0 : _reportingLines$repor.length) || 0
356
- });
357
- cardContent = /*#__PURE__*/React.createElement(CardContainer, {
358
- isDisabledUser: isDisabledUser,
359
- withoutElevation: withoutElevation
360
- }, /*#__PURE__*/React.createElement(ProfileImage, null, /*#__PURE__*/React.createElement(Avatar, {
361
- size: "xlarge",
362
- src: this.props.status !== 'closed' ? this.props.avatarUrl : undefined,
363
- borderColor: token('elevation.surface.overlay', N0)
364
- })), /*#__PURE__*/React.createElement(CardContent, null, this.renderCardDetails(), actions ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ActionsFlexSpacer, null), actions) : null));
365
- }
366
-
367
- return /*#__PURE__*/React.createElement(CardWrapper, null, cardContent);
368
- }
369
- }]);
370
-
371
- return Profilecard;
372
- }(React.PureComponent);
373
-
374
- _defineProperty(Profilecard, "defaultProps", {
375
- isLoading: false,
376
- hasError: false,
377
- errorType: null,
378
- status: 'active',
379
- isBot: false,
380
- isNotMentionable: false,
381
- actions: [],
382
- hasDisabledAccountLozenge: true,
383
- customLozenges: [],
384
- analytics: function analytics() {
385
- return null;
386
- },
387
- clientFetchProfile: function clientFetchProfile() {
388
- return null;
389
- }
390
- });
193
+ }));
194
+ };
195
+
196
+ var LoadingView = function LoadingView(_ref2) {
197
+ var fireAnalyticsWithDuration = _ref2.fireAnalyticsWithDuration;
198
+ useEffect(function () {
199
+ fireAnalyticsWithDuration(function (duration) {
200
+ return profileCardRendered('user', 'spinner', {
201
+ duration: duration
202
+ });
203
+ });
204
+ }, [fireAnalyticsWithDuration]);
205
+ return /*#__PURE__*/React.createElement(SpinnerContainer, {
206
+ "data-testid": "profilecard-spinner-container"
207
+ }, /*#__PURE__*/React.createElement(Spinner, null));
208
+ };
391
209
 
392
- export { Profilecard as default };
210
+ export default withAnalyticsEvents()(ProfilecardInternal);