@atlaskit/profilecard 16.12.1 → 17.1.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 +12 -0
- package/dist/cjs/client/ProfileCardClient.js +4 -4
- package/dist/cjs/client/TeamCentralCardClient.js +106 -59
- 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 +4 -4
- package/dist/es2019/client/TeamCentralCardClient.js +101 -59
- 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 +4 -4
- package/dist/esm/client/TeamCentralCardClient.js +106 -59
- 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/TeamCentralCardClient.d.ts +2 -0
- 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 +12 -10
- package/dist/types/util/analytics.d.ts +22 -13
- package/package.json +9 -9
- package/report.api.md +74 -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
|
@@ -15,7 +15,10 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
15
15
|
|
|
16
16
|
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) { _defineProperty(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; }
|
|
17
17
|
|
|
18
|
+
import { userRequestAnalytics } from '../util/analytics';
|
|
19
|
+
import { getPageTime } from '../util/performance';
|
|
18
20
|
import CachingClient from './CachingClient';
|
|
21
|
+
import { getErrorAttributes } from './errorUtils';
|
|
19
22
|
import { graphqlQuery } from './graphqlUtils';
|
|
20
23
|
/**
|
|
21
24
|
* Transform response from GraphQL
|
|
@@ -38,7 +41,6 @@ export var modifyResponse = function modifyResponse(response) {
|
|
|
38
41
|
return {
|
|
39
42
|
isBot: data.isBot,
|
|
40
43
|
isCurrentUser: data.isCurrentUser,
|
|
41
|
-
isNotMentionable: data.isNotMentionable,
|
|
42
44
|
status: data.status,
|
|
43
45
|
statusModifiedDate: data.statusModifiedDate || undefined,
|
|
44
46
|
avatarUrl: data.avatarUrl || undefined,
|
|
@@ -123,7 +125,7 @@ var UserProfileCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
123
125
|
}()
|
|
124
126
|
}, {
|
|
125
127
|
key: "getProfile",
|
|
126
|
-
value: function getProfile(cloudId, userId) {
|
|
128
|
+
value: function getProfile(cloudId, userId, analytics) {
|
|
127
129
|
var _this2 = this;
|
|
128
130
|
|
|
129
131
|
if (!userId) {
|
|
@@ -138,13 +140,31 @@ var UserProfileCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
return new Promise(function (resolve, reject) {
|
|
143
|
+
var startTime = getPageTime();
|
|
144
|
+
|
|
145
|
+
if (analytics) {
|
|
146
|
+
analytics(userRequestAnalytics('triggered'));
|
|
147
|
+
}
|
|
148
|
+
|
|
141
149
|
_this2.makeRequest(cloudId, userId).then(function (data) {
|
|
142
150
|
if (_this2.cache) {
|
|
143
151
|
_this2.setCachedProfile(cacheIdentifier, data);
|
|
144
152
|
}
|
|
145
153
|
|
|
154
|
+
if (analytics) {
|
|
155
|
+
analytics(userRequestAnalytics('succeeded', {
|
|
156
|
+
duration: getPageTime() - startTime
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
|
|
146
160
|
resolve(data);
|
|
147
161
|
}).catch(function (error) {
|
|
162
|
+
if (analytics) {
|
|
163
|
+
analytics(userRequestAnalytics('failed', _objectSpread({
|
|
164
|
+
duration: getPageTime() - startTime
|
|
165
|
+
}, getErrorAttributes(error))));
|
|
166
|
+
}
|
|
167
|
+
|
|
148
168
|
reject(error);
|
|
149
169
|
});
|
|
150
170
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var IGNORED_ERRORS = ['NotPermitted', 'Gone'];
|
|
2
|
+
|
|
3
|
+
function isIgnoredError(error) {
|
|
4
|
+
return !!error && IGNORED_ERRORS.includes(error.reason);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export var getErrorAttributes = function getErrorAttributes(error) {
|
|
8
|
+
var _error$response, _error$response$heade;
|
|
9
|
+
|
|
10
|
+
var traceId = !!error ? (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$heade = _error$response.headers) === null || _error$response$heade === void 0 ? void 0 : _error$response$heade.get('atl-traceid') : undefined;
|
|
11
|
+
return {
|
|
12
|
+
errorStatus: error === null || error === void 0 ? void 0 : error.code,
|
|
13
|
+
errorReason: error === null || error === void 0 ? void 0 : error.reason,
|
|
14
|
+
isSLOFailure: !isIgnoredError(error),
|
|
15
|
+
traceId: traceId !== null && traceId !== void 0 ? traceId : undefined
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -1,86 +1,41 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
-
|
|
11
|
-
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; } }
|
|
12
|
-
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import AkButton from '@atlaskit/button/custom-theme-button';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import Button from '@atlaskit/button/standard-button';
|
|
15
3
|
import IconError from '@atlaskit/icon/glyph/cross-circle';
|
|
16
4
|
import { ErrorText, ErrorTitle, ErrorWrapper } from '../../styled/Error';
|
|
5
|
+
import { profileCardRendered } from '../../util/analytics';
|
|
17
6
|
|
|
18
|
-
var ErrorMessage =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
7
|
+
var ErrorMessage = function ErrorMessage(props) {
|
|
8
|
+
var errorType = props.errorType || {
|
|
9
|
+
reason: 'default'
|
|
10
|
+
};
|
|
11
|
+
var errorReason = errorType.reason;
|
|
12
|
+
var fireAnalytics = props.fireAnalytics,
|
|
13
|
+
reload = props.reload;
|
|
14
|
+
var hasRetry = !!reload;
|
|
15
|
+
useEffect(function () {
|
|
16
|
+
fireAnalytics(profileCardRendered('user', 'error', {
|
|
17
|
+
hasRetry: hasRetry,
|
|
18
|
+
errorType: errorReason
|
|
19
|
+
}));
|
|
20
|
+
}, [errorReason, fireAnalytics, hasRetry]);
|
|
21
|
+
|
|
22
|
+
var errorContent = function errorContent() {
|
|
23
|
+
if (errorReason === 'NotFound') {
|
|
35
24
|
return /*#__PURE__*/React.createElement(ErrorTitle, null, "The user is no longer available for the site");
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
_defineProperty(_assertThisInitialized(_this), "renderDefault", function () {
|
|
39
|
-
return /*#__PURE__*/React.createElement(ErrorTitle, null, "Oops, looks like we\u2019re having issues", /*#__PURE__*/React.createElement("br", null), _this.props.reload ? /*#__PURE__*/React.createElement(ErrorText, null, "Try again and we\u2019ll give it another shot") : null);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
_defineProperty(_assertThisInitialized(_this), "renderRetryButton", function () {
|
|
43
|
-
return _this.props.reload ? /*#__PURE__*/React.createElement(AkButton, {
|
|
44
|
-
appearance: "link",
|
|
45
|
-
onClick: _this.props.reload
|
|
46
|
-
}, "Try again") : null;
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
return _this;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
_createClass(ErrorMessage, [{
|
|
53
|
-
key: "renderErrorContent",
|
|
54
|
-
value: function renderErrorContent() {
|
|
55
|
-
var errorType = this.props.errorType || {
|
|
56
|
-
reason: 'default'
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
switch (errorType.reason) {
|
|
60
|
-
case 'NotFound':
|
|
61
|
-
return this.renderNotFound();
|
|
62
|
-
|
|
63
|
-
default:
|
|
64
|
-
return this.renderDefault();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}, {
|
|
68
|
-
key: "render",
|
|
69
|
-
value: function render() {
|
|
70
|
-
return /*#__PURE__*/React.createElement(ErrorWrapper, null, /*#__PURE__*/React.createElement(IconError, {
|
|
71
|
-
label: "icon error",
|
|
72
|
-
size: "xlarge"
|
|
73
|
-
}), this.renderErrorContent(), this.renderRetryButton());
|
|
74
25
|
}
|
|
75
|
-
}]);
|
|
76
|
-
|
|
77
|
-
return ErrorMessage;
|
|
78
|
-
}(React.PureComponent);
|
|
79
|
-
|
|
80
|
-
_defineProperty(ErrorMessage, "defaultProps", {
|
|
81
|
-
errorType: {
|
|
82
|
-
reason: 'default'
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
26
|
|
|
86
|
-
|
|
27
|
+
return /*#__PURE__*/React.createElement(ErrorTitle, null, "Oops, looks like we\u2019re having issues", /*#__PURE__*/React.createElement("br", null), reload && /*#__PURE__*/React.createElement(ErrorText, null, "Try again and we\u2019ll give it another shot"));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return /*#__PURE__*/React.createElement(ErrorWrapper, {
|
|
31
|
+
"data-testid": "profilecard-error"
|
|
32
|
+
}, /*#__PURE__*/React.createElement(IconError, {
|
|
33
|
+
label: "icon error",
|
|
34
|
+
size: "xlarge"
|
|
35
|
+
}), errorContent(), reload && /*#__PURE__*/React.createElement(Button, {
|
|
36
|
+
appearance: "link",
|
|
37
|
+
onClick: reload
|
|
38
|
+
}, "Try again"));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default ErrorMessage;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import Spinner from '@atlaskit/spinner';
|
|
3
3
|
import { CardContent, CardHeader, CardWrapper, LoadingWrapper } from '../../styled/TeamCard';
|
|
4
|
-
import {
|
|
4
|
+
import { profileCardRendered } from '../../util/analytics';
|
|
5
5
|
export default (function (props) {
|
|
6
6
|
var analytics = props.analytics;
|
|
7
7
|
useEffect(function () {
|
|
8
8
|
analytics(function (duration) {
|
|
9
|
-
return
|
|
9
|
+
return profileCardRendered('team', 'spinner', {
|
|
10
10
|
duration: duration
|
|
11
11
|
});
|
|
12
12
|
});
|
|
@@ -21,7 +21,7 @@ import messages from '../../messages';
|
|
|
21
21
|
import { AnimatedKudosButton, KudosBlobAnimation } from '../../styled/Card';
|
|
22
22
|
import { ErrorWrapper, TeamErrorText, TeamErrorTitle } from '../../styled/Error';
|
|
23
23
|
import { ActionButtons, AvatarSection, CardContent, CardHeader, CardWrapper, Description, DescriptionWrapper, MemberCount, MoreButton, TeamName, WrappedButton } from '../../styled/TeamCard';
|
|
24
|
-
import { errorRetryClicked, moreActionsClicked, moreMembersClicked,
|
|
24
|
+
import { actionClicked, errorRetryClicked, moreActionsClicked, moreMembersClicked, profileCardRendered, teamAvatarClicked } from '../../util/analytics';
|
|
25
25
|
import { isBasicClick } from '../../util/click';
|
|
26
26
|
import { ErrorIllustration } from '../Error';
|
|
27
27
|
import TeamLoadingState from './TeamLoadingState';
|
|
@@ -98,7 +98,7 @@ var TeamMembers = function TeamMembers(_ref) {
|
|
|
98
98
|
function onActionClick(action, analytics, index) {
|
|
99
99
|
return function (event) {
|
|
100
100
|
analytics(function (duration) {
|
|
101
|
-
return
|
|
101
|
+
return actionClicked('team', {
|
|
102
102
|
duration: duration,
|
|
103
103
|
hasHref: !!action.link,
|
|
104
104
|
hasOnClick: !!action.callback,
|
|
@@ -152,7 +152,7 @@ var ExtraActions = function ExtraActions(_ref3) {
|
|
|
152
152
|
if (shouldBeOpen) {
|
|
153
153
|
// Only fire this event when OPENING the dropdown
|
|
154
154
|
analytics(function (duration) {
|
|
155
|
-
return moreActionsClicked({
|
|
155
|
+
return moreActionsClicked('team', {
|
|
156
156
|
duration: duration,
|
|
157
157
|
numActions: count + 2
|
|
158
158
|
});
|
|
@@ -243,7 +243,7 @@ var TeamProfilecardContent = function TeamProfilecardContent(_ref5) {
|
|
|
243
243
|
analytics(function (duration) {
|
|
244
244
|
var _team$members;
|
|
245
245
|
|
|
246
|
-
return
|
|
246
|
+
return profileCardRendered('team', 'content', {
|
|
247
247
|
duration: duration,
|
|
248
248
|
numActions: allActions.length,
|
|
249
249
|
memberCount: (_team$members = team.members) === null || _team$members === void 0 ? void 0 : _team$members.length,
|
|
@@ -276,7 +276,7 @@ var ErrorMessage = function ErrorMessage(_ref6) {
|
|
|
276
276
|
var hasRetry = !!clientFetchProfile;
|
|
277
277
|
useEffect(function () {
|
|
278
278
|
analytics(function (duration) {
|
|
279
|
-
return
|
|
279
|
+
return profileCardRendered('team', 'error', {
|
|
280
280
|
duration: duration,
|
|
281
281
|
hasRetry: hasRetry
|
|
282
282
|
});
|
|
@@ -20,7 +20,7 @@ import Popup from '@atlaskit/popup';
|
|
|
20
20
|
import { layers } from '@atlaskit/theme/constants';
|
|
21
21
|
import _filterActions from '../../internal/filterActions';
|
|
22
22
|
import messages from '../../messages';
|
|
23
|
-
import {
|
|
23
|
+
import { cardTriggered, fireEvent, profileCardRendered } from '../../util/analytics';
|
|
24
24
|
import { isBasicClick } from '../../util/click';
|
|
25
25
|
import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
|
|
26
26
|
import { getPageTime } from '../../util/performance';
|
|
@@ -119,7 +119,7 @@ export var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureCo
|
|
|
119
119
|
_this.showProfilecard(0);
|
|
120
120
|
|
|
121
121
|
if (!_this.state.visible) {
|
|
122
|
-
_this.fireAnalytics(
|
|
122
|
+
_this.fireAnalytics(cardTriggered('team', 'click'));
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
});
|
|
@@ -132,7 +132,7 @@ export var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureCo
|
|
|
132
132
|
if (!_this.state.visible) {
|
|
133
133
|
_this.openedByHover = true;
|
|
134
134
|
|
|
135
|
-
_this.fireAnalytics(
|
|
135
|
+
_this.fireAnalytics(cardTriggered('team', 'hover'));
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
_this.showProfilecard(DELAY_MS_SHOW);
|
|
@@ -234,7 +234,7 @@ export var TeamProfileCardTriggerInternal = /*#__PURE__*/function (_React$PureCo
|
|
|
234
234
|
});
|
|
235
235
|
|
|
236
236
|
_defineProperty(_assertThisInitialized(_this), "onErrorBoundary", function () {
|
|
237
|
-
_this.fireAnalytics(
|
|
237
|
+
_this.fireAnalytics(profileCardRendered('team', 'errorBoundary', {
|
|
238
238
|
duration: 0
|
|
239
239
|
}));
|
|
240
240
|
|
|
@@ -1,22 +1,52 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
4
|
var _excluded = ["triggerRef", "isSelected", "testId"];
|
|
4
|
-
import React from 'react';
|
|
5
|
+
import React, { useCallback, useState } from 'react';
|
|
5
6
|
import { useIntl } from 'react-intl-next';
|
|
6
7
|
import Button from '@atlaskit/button/custom-theme-button';
|
|
7
8
|
import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
8
9
|
import MoreIcon from '@atlaskit/icon/glyph/more';
|
|
9
10
|
import messages from '../../messages';
|
|
10
11
|
import { OverflowActionButtonsWrapper } from '../../styled/Card';
|
|
12
|
+
import { moreActionsClicked } from '../../util/analytics';
|
|
13
|
+
export var ACTION_OVERFLOW_THRESHOLD = 2;
|
|
11
14
|
export var OverflowProfileCardButtons = function OverflowProfileCardButtons(props) {
|
|
12
15
|
var intl = useIntl();
|
|
13
|
-
|
|
16
|
+
|
|
17
|
+
var _useState = useState(false),
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
setOpen = _useState2[1];
|
|
20
|
+
|
|
21
|
+
var actions = props.actions,
|
|
22
|
+
onItemClick = props.onItemClick,
|
|
23
|
+
fireAnalyticsWithDuration = props.fireAnalyticsWithDuration;
|
|
24
|
+
var numActions = actions.length + ACTION_OVERFLOW_THRESHOLD;
|
|
25
|
+
var onOpenChange = useCallback(function (_ref) {
|
|
26
|
+
var nextOpen = _ref.isOpen;
|
|
27
|
+
setOpen(function (prevOpen) {
|
|
28
|
+
if (nextOpen && !prevOpen) {
|
|
29
|
+
fireAnalyticsWithDuration(function (duration) {
|
|
30
|
+
return moreActionsClicked('user', {
|
|
31
|
+
duration: duration,
|
|
32
|
+
numActions: numActions
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return nextOpen;
|
|
38
|
+
});
|
|
39
|
+
}, [numActions, fireAnalyticsWithDuration]);
|
|
40
|
+
return /*#__PURE__*/React.createElement(OverflowActionButtonsWrapper, {
|
|
41
|
+
"data-testid": "profilecard-actions-overflow"
|
|
42
|
+
}, /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
43
|
+
onOpenChange: onOpenChange,
|
|
14
44
|
placement: 'bottom-end',
|
|
15
|
-
trigger: function trigger(
|
|
16
|
-
var triggerRef =
|
|
17
|
-
isSelected =
|
|
18
|
-
testId =
|
|
19
|
-
providedProps = _objectWithoutProperties(
|
|
45
|
+
trigger: function trigger(_ref2) {
|
|
46
|
+
var triggerRef = _ref2.triggerRef,
|
|
47
|
+
isSelected = _ref2.isSelected,
|
|
48
|
+
testId = _ref2.testId,
|
|
49
|
+
providedProps = _objectWithoutProperties(_ref2, _excluded);
|
|
20
50
|
|
|
21
51
|
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
22
52
|
type: "button"
|
|
@@ -27,7 +57,7 @@ export var OverflowProfileCardButtons = function OverflowProfileCardButtons(prop
|
|
|
27
57
|
})
|
|
28
58
|
}));
|
|
29
59
|
}
|
|
30
|
-
}, /*#__PURE__*/React.createElement(DropdownItemGroup, null,
|
|
60
|
+
}, /*#__PURE__*/React.createElement(DropdownItemGroup, null, actions.map(function (action, index) {
|
|
31
61
|
return /*#__PURE__*/React.createElement(DropdownItem, {
|
|
32
62
|
key: action.id,
|
|
33
63
|
onClick: function onClick(event) {
|
|
@@ -35,7 +65,7 @@ export var OverflowProfileCardButtons = function OverflowProfileCardButtons(prop
|
|
|
35
65
|
args[_key - 1] = arguments[_key];
|
|
36
66
|
}
|
|
37
67
|
|
|
38
|
-
|
|
68
|
+
onItemClick(action, args, event, index);
|
|
39
69
|
},
|
|
40
70
|
href: action.link
|
|
41
71
|
}, action.label);
|