@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.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/client/ProfileCardClient.js +2 -2
- package/dist/cjs/client/TeamProfileCardClient.js +13 -12
- package/dist/cjs/client/UserProfileCardClient.js +25 -2
- package/dist/cjs/client/errorUtils.js +25 -0
- package/dist/cjs/components/Error/ErrorMessage.js +40 -77
- package/dist/cjs/components/Team/TeamLoadingState.js +1 -1
- package/dist/cjs/components/Team/TeamProfileCard.js +4 -4
- package/dist/cjs/components/Team/TeamProfileCardTrigger.js +3 -3
- package/dist/cjs/components/User/OverflowProfileCardButtons.js +44 -10
- package/dist/cjs/components/User/ProfileCard.js +195 -362
- package/dist/cjs/components/User/ProfileCardDetails.js +142 -0
- package/dist/cjs/components/User/ProfileCardResourced.js +25 -20
- package/dist/cjs/components/User/ProfileCardTrigger.js +35 -7
- package/dist/cjs/components/User/ReportingLinesDetails.js +13 -13
- package/dist/cjs/components/User/UserLoadingState.js +14 -2
- package/dist/cjs/util/analytics.js +31 -16
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/ProfileCardClient.js +2 -2
- package/dist/es2019/client/TeamProfileCardClient.js +3 -9
- package/dist/es2019/client/UserProfileCardClient.js +23 -2
- package/dist/es2019/client/errorUtils.js +17 -0
- package/dist/es2019/components/Error/ErrorMessage.js +38 -42
- package/dist/es2019/components/Team/TeamLoadingState.js +2 -2
- package/dist/es2019/components/Team/TeamProfileCard.js +5 -5
- package/dist/es2019/components/Team/TeamProfileCardTrigger.js +4 -4
- package/dist/es2019/components/User/OverflowProfileCardButtons.js +30 -4
- package/dist/es2019/components/User/ProfileCard.js +161 -292
- package/dist/es2019/components/User/ProfileCardDetails.js +118 -0
- package/dist/es2019/components/User/ProfileCardResourced.js +21 -21
- package/dist/es2019/components/User/ProfileCardTrigger.js +32 -6
- package/dist/es2019/components/User/ReportingLinesDetails.js +10 -11
- package/dist/es2019/components/User/UserLoadingState.js +10 -2
- package/dist/es2019/util/analytics.js +13 -8
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/ProfileCardClient.js +2 -2
- package/dist/esm/client/TeamProfileCardClient.js +11 -12
- package/dist/esm/client/UserProfileCardClient.js +22 -2
- package/dist/esm/client/errorUtils.js +17 -0
- package/dist/esm/components/Error/ErrorMessage.js +35 -80
- package/dist/esm/components/Team/TeamLoadingState.js +2 -2
- package/dist/esm/components/Team/TeamProfileCard.js +5 -5
- package/dist/esm/components/Team/TeamProfileCardTrigger.js +4 -4
- package/dist/esm/components/User/OverflowProfileCardButtons.js +39 -9
- package/dist/esm/components/User/ProfileCard.js +180 -362
- package/dist/esm/components/User/ProfileCardDetails.js +120 -0
- package/dist/esm/components/User/ProfileCardResourced.js +17 -17
- package/dist/esm/components/User/ProfileCardTrigger.js +33 -7
- package/dist/esm/components/User/ReportingLinesDetails.js +12 -12
- package/dist/esm/components/User/UserLoadingState.js +7 -2
- package/dist/esm/util/analytics.js +21 -12
- package/dist/esm/version.json +1 -1
- package/dist/types/client/ProfileCardClient.d.ts +3 -2
- package/dist/types/client/TeamProfileCardClient.d.ts +2 -1
- package/dist/types/client/UserProfileCardClient.d.ts +2 -1
- package/dist/types/client/errorUtils.d.ts +6 -0
- package/dist/types/components/Error/ErrorMessage.d.ts +6 -15
- package/dist/types/components/Team/TeamProfileCardTrigger.d.ts +5 -11
- package/dist/types/components/User/OverflowProfileCardButtons.d.ts +4 -3
- package/dist/types/components/User/ProfileCard.d.ts +5 -29
- package/dist/types/components/User/ProfileCardDetails.d.ts +3 -0
- package/dist/types/components/User/ProfileCardResourced.d.ts +7 -3
- package/dist/types/components/User/ProfileCardTrigger.d.ts +3 -40
- package/dist/types/components/User/ReportingLinesDetails.d.ts +2 -4
- package/dist/types/components/User/UserLoadingState.d.ts +5 -1
- package/dist/types/components/User/lazyProfileCard.d.ts +1 -1
- package/dist/types/types.d.ts +11 -10
- package/dist/types/util/analytics.d.ts +22 -13
- package/package.json +8 -8
- package/report.api.md +71 -124
- package/dist/cjs/internal/analytics.js +0 -15
- package/dist/es2019/internal/analytics.js +0 -8
- package/dist/esm/internal/analytics.js +0 -8
- 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
|
|
5
|
-
import
|
|
6
|
-
import
|
|
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,
|
|
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 {
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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
|
-
|
|
261
|
-
|
|
262
|
-
|
|
112
|
+
if (isLoading) {
|
|
113
|
+
return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(LoadingView, {
|
|
114
|
+
fireAnalyticsWithDuration: fireAnalyticsWithDuration
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
263
117
|
|
|
264
|
-
|
|
118
|
+
if (!canRender) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
265
121
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
|
|
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
|
-
|
|
286
|
-
|
|
287
|
-
|
|
159
|
+
if (!actions || actions.length === 0) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
288
162
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
-
|
|
304
|
-
|
|
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
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
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
|
|
210
|
+
export default withAnalyticsEvents()(ProfilecardInternal);
|