@atlaskit/profilecard 19.17.0 → 19.17.1
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 +8 -0
- package/dist/cjs/client/getTeamFromAGG.js +1 -1
- package/dist/cjs/components/User/ProfileCardTrigger.js +319 -308
- package/dist/cjs/util/analytics.js +1 -1
- package/dist/es2019/client/getTeamFromAGG.js +1 -1
- package/dist/es2019/components/User/ProfileCardTrigger.js +267 -276
- package/dist/es2019/util/analytics.js +1 -1
- package/dist/esm/client/getTeamFromAGG.js +1 -1
- package/dist/esm/components/User/ProfileCardTrigger.js +320 -309
- package/dist/esm/util/analytics.js +1 -1
- package/dist/types/components/User/ProfileCardTrigger.d.ts +1 -1
- package/dist/types-ts4.5/components/User/ProfileCardTrigger.d.ts +1 -1
- package/package.json +5 -8
- package/dist/cjs/components/User/ProfileCardTriggerNext.js +0 -362
- package/dist/es2019/components/User/ProfileCardTriggerNext.js +0 -289
- package/dist/esm/components/User/ProfileCardTriggerNext.js +0 -352
- package/dist/types/components/User/ProfileCardTriggerNext.d.ts +0 -3
- package/dist/types-ts4.5/components/User/ProfileCardTriggerNext.d.ts +0 -3
|
@@ -1,333 +1,344 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
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
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
|
-
|
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
5
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
6
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
7
|
+
var _excluded = ["ref"],
|
|
8
|
+
_excluded2 = ["aria-expanded", "aria-haspopup"];
|
|
12
9
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
11
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
12
|
+
import React, { Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
13
|
+
import { useIntl } from 'react-intl-next';
|
|
14
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
18
15
|
import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
|
|
19
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
20
16
|
import Popup from '@atlaskit/popup';
|
|
21
17
|
import { layers } from '@atlaskit/theme/constants';
|
|
22
|
-
import
|
|
18
|
+
import filterActionsInner from '../../internal/filterActions';
|
|
19
|
+
import getLabelMessage from '../../internal/getLabelMessage';
|
|
23
20
|
import { CardWrapper } from '../../styled/Card';
|
|
24
21
|
import { cardTriggered, fireEvent } from '../../util/analytics';
|
|
25
22
|
import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
|
|
26
23
|
import { ProfileCardLazy } from './lazyProfileCard';
|
|
27
|
-
import ProfilecardTriggerNext from './ProfileCardTriggerNext';
|
|
28
24
|
import UserLoadingState from './UserLoadingState';
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
export default function ProfilecardTriggerNext(_ref) {
|
|
26
|
+
var autoFocus = _ref.autoFocus,
|
|
27
|
+
_ref$trigger = _ref.trigger,
|
|
28
|
+
trigger = _ref$trigger === void 0 ? 'hover' : _ref$trigger,
|
|
29
|
+
userId = _ref.userId,
|
|
30
|
+
cloudId = _ref.cloudId,
|
|
31
|
+
resourceClient = _ref.resourceClient,
|
|
32
|
+
_ref$actions = _ref.actions,
|
|
33
|
+
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
34
|
+
_ref$position = _ref.position,
|
|
35
|
+
position = _ref$position === void 0 ? 'bottom-start' : _ref$position,
|
|
36
|
+
children = _ref.children,
|
|
37
|
+
testId = _ref.testId,
|
|
38
|
+
addFlag = _ref.addFlag,
|
|
39
|
+
onReportingLinesClick = _ref.onReportingLinesClick,
|
|
40
|
+
ariaLabel = _ref.ariaLabel,
|
|
41
|
+
ariaLabelledBy = _ref.ariaLabelledBy,
|
|
42
|
+
prepopulatedData = _ref.prepopulatedData,
|
|
43
|
+
disabledAriaAttributes = _ref.disabledAriaAttributes,
|
|
44
|
+
onVisibilityChange = _ref.onVisibilityChange;
|
|
45
|
+
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
46
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
47
|
+
var _useIntl = useIntl(),
|
|
48
|
+
formatMessage = _useIntl.formatMessage;
|
|
49
|
+
var isMounted = useRef(false);
|
|
50
|
+
var showDelay = trigger === 'click' ? 0 : DELAY_MS_SHOW;
|
|
51
|
+
var hideDelay = trigger === 'click' ? 0 : DELAY_MS_HIDE;
|
|
52
|
+
var showTimer = useRef(0);
|
|
53
|
+
var hideTimer = useRef(0);
|
|
54
|
+
var _useState = useState(false),
|
|
55
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
56
|
+
visible = _useState2[0],
|
|
57
|
+
setVisible = _useState2[1];
|
|
58
|
+
var _useState3 = useState(undefined),
|
|
59
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
60
|
+
isLoading = _useState4[0],
|
|
61
|
+
setIsLoading = _useState4[1];
|
|
62
|
+
var _useState5 = useState(false),
|
|
63
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
64
|
+
hasError = _useState6[0],
|
|
65
|
+
setHasError = _useState6[1];
|
|
66
|
+
var _useState7 = useState(null),
|
|
67
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
68
|
+
error = _useState8[0],
|
|
69
|
+
setError = _useState8[1];
|
|
70
|
+
var _useState9 = useState(null),
|
|
71
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
72
|
+
data = _useState10[0],
|
|
73
|
+
setData = _useState10[1];
|
|
74
|
+
var _useState11 = useState(undefined),
|
|
75
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
76
|
+
reportingLinesData = _useState12[0],
|
|
77
|
+
setReportingLinesData = _useState12[1];
|
|
78
|
+
var _useState13 = useState(false),
|
|
79
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
80
|
+
shouldShowGiveKudos = _useState14[0],
|
|
81
|
+
setShouldShowGiveKudos = _useState14[1];
|
|
82
|
+
var _useState15 = useState(undefined),
|
|
83
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
84
|
+
teamCentralBaseUrl = _useState16[0],
|
|
85
|
+
setTeamCentralBaseUrl = _useState16[1];
|
|
86
|
+
var _useState17 = useState(false),
|
|
87
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
88
|
+
kudosDrawerOpen = _useState18[0],
|
|
89
|
+
setKudosDrawerOpen = _useState18[1];
|
|
90
|
+
var _useState19 = useState(false),
|
|
91
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
92
|
+
isTriggeredUsingKeyboard = _useState20[0],
|
|
93
|
+
setTriggeredUsingKeyboard = _useState20[1];
|
|
94
|
+
var triggerRef = useRef(null);
|
|
95
|
+
useEffect(function () {
|
|
96
|
+
isMounted.current = true;
|
|
97
|
+
return function () {
|
|
98
|
+
isMounted.current = false;
|
|
99
|
+
clearTimeout(showTimer.current);
|
|
100
|
+
clearTimeout(hideTimer.current);
|
|
101
|
+
};
|
|
102
|
+
}, []);
|
|
103
|
+
useEffect(function () {
|
|
104
|
+
// Reset state when the userId changes
|
|
105
|
+
setIsLoading(undefined);
|
|
106
|
+
setHasError(false);
|
|
107
|
+
setError(null);
|
|
108
|
+
setData(null);
|
|
109
|
+
setReportingLinesData(undefined);
|
|
110
|
+
setShouldShowGiveKudos(false);
|
|
111
|
+
setTeamCentralBaseUrl(undefined);
|
|
112
|
+
}, [userId]);
|
|
113
|
+
var fireAnalytics = useCallback(function (payload) {
|
|
114
|
+
// Don't fire any analytics if the component is unmounted
|
|
115
|
+
if (!isMounted.current) {
|
|
116
|
+
return;
|
|
37
117
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
if (_this.props.createAnalyticsEvent) {
|
|
50
|
-
fireEvent(_this.props.createAnalyticsEvent, payload);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
_defineProperty(_assertThisInitialized(_this), "hideProfilecard", function () {
|
|
54
|
-
clearTimeout(_this.showTimer);
|
|
55
|
-
clearTimeout(_this.hideTimer);
|
|
56
|
-
_this.hideTimer = window.setTimeout(function () {
|
|
57
|
-
_this.setState({
|
|
58
|
-
visible: false
|
|
59
|
-
});
|
|
60
|
-
}, _this.hideDelay);
|
|
61
|
-
});
|
|
62
|
-
_defineProperty(_assertThisInitialized(_this), "showProfilecard", function () {
|
|
63
|
-
clearTimeout(_this.hideTimer);
|
|
64
|
-
clearTimeout(_this.showTimer);
|
|
65
|
-
_this.showTimer = window.setTimeout(function () {
|
|
66
|
-
if (!_this.state.visible) {
|
|
67
|
-
_this.clientFetchProfile();
|
|
68
|
-
_this.setState({
|
|
69
|
-
visible: true
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}, _this.showDelay);
|
|
73
|
-
});
|
|
74
|
-
_defineProperty(_assertThisInitialized(_this), "onClick", function (event) {
|
|
75
|
-
// If the user clicks on the trigger then we don't want that click event to
|
|
76
|
-
// propagate out to parent containers. For example when clicking a mention
|
|
77
|
-
// lozenge in an inline-edit.
|
|
78
|
-
event.stopPropagation();
|
|
79
|
-
_this.showProfilecard();
|
|
80
|
-
if (!_this.state.visible) {
|
|
81
|
-
_this.fireAnalytics(cardTriggered('user', 'click'));
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
_defineProperty(_assertThisInitialized(_this), "onMouseEnter", function () {
|
|
85
|
-
_this.showProfilecard();
|
|
86
|
-
if (!_this.state.visible) {
|
|
87
|
-
_this.fireAnalytics(cardTriggered('user', 'hover'));
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
_defineProperty(_assertThisInitialized(_this), "onKeyPress", function (event) {
|
|
91
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
92
|
-
event.preventDefault();
|
|
93
|
-
_this.showProfilecard();
|
|
94
|
-
if (!_this.state.visible) {
|
|
95
|
-
_this.fireAnalytics(cardTriggered('user', 'click'));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
_defineProperty(_assertThisInitialized(_this), "onFocus", function () {
|
|
100
|
-
_this.showProfilecard();
|
|
101
|
-
});
|
|
102
|
-
_defineProperty(_assertThisInitialized(_this), "containerListeners", _this.props.trigger === 'hover' ? {
|
|
103
|
-
onMouseEnter: _this.onMouseEnter,
|
|
104
|
-
onMouseLeave: _this.hideProfilecard,
|
|
105
|
-
onBlur: _this.hideProfilecard,
|
|
106
|
-
onKeyPress: _this.onKeyPress
|
|
107
|
-
} : {
|
|
108
|
-
onClick: _this.onClick,
|
|
109
|
-
onKeyPress: _this.onKeyPress
|
|
110
|
-
});
|
|
111
|
-
_defineProperty(_assertThisInitialized(_this), "layerListeners", {
|
|
112
|
-
handleClickOutside: _this.hideProfilecard,
|
|
113
|
-
handleEscapeKeydown: _this.hideProfilecard
|
|
114
|
-
});
|
|
115
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
116
|
-
visible: false,
|
|
117
|
-
isLoading: undefined,
|
|
118
|
-
hasError: false,
|
|
119
|
-
error: null,
|
|
120
|
-
data: null,
|
|
121
|
-
reportingLinesData: undefined,
|
|
122
|
-
shouldShowGiveKudos: false,
|
|
123
|
-
teamCentralBaseUrl: undefined,
|
|
124
|
-
kudosDrawerOpen: false
|
|
125
|
-
});
|
|
126
|
-
_defineProperty(_assertThisInitialized(_this), "clientFetchProfile", function () {
|
|
127
|
-
var _this$props = _this.props,
|
|
128
|
-
cloudId = _this$props.cloudId,
|
|
129
|
-
userId = _this$props.userId;
|
|
130
|
-
var isLoading = _this.state.isLoading;
|
|
131
|
-
if (isLoading === true) {
|
|
132
|
-
// don't fetch data when fetching is in process
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
_this.setState({
|
|
136
|
-
teamCentralBaseUrl: _this.props.resourceClient.getTeamCentralBaseUrl()
|
|
137
|
-
});
|
|
138
|
-
_this.setState({
|
|
139
|
-
isLoading: true,
|
|
140
|
-
hasError: false,
|
|
141
|
-
data: null
|
|
142
|
-
}, function () {
|
|
143
|
-
var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId || '', userId, _this.fireAnalytics), _this.props.resourceClient.getReportingLines(userId), _this.props.resourceClient.shouldShowGiveKudos()]);
|
|
144
|
-
requests.then(function (res) {
|
|
145
|
-
var _this2;
|
|
146
|
-
return (_this2 = _this).handleClientSuccess.apply(_this2, _toConsumableArray(res));
|
|
147
|
-
}, function (err) {
|
|
148
|
-
return _this.handleClientError(err);
|
|
149
|
-
}).catch(function (err) {
|
|
150
|
-
return _this.handleClientError(err);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
_defineProperty(_assertThisInitialized(_this), "openKudosDrawer", function () {
|
|
155
|
-
_this.hideProfilecard();
|
|
156
|
-
_this.setState({
|
|
157
|
-
kudosDrawerOpen: true
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
_defineProperty(_assertThisInitialized(_this), "closeKudosDrawer", function () {
|
|
161
|
-
_this.setState({
|
|
162
|
-
kudosDrawerOpen: false
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
_defineProperty(_assertThisInitialized(_this), "renderCard", function () {
|
|
166
|
-
var isLoading = _this.state.isLoading;
|
|
167
|
-
if (isLoading === true || isLoading === undefined) {
|
|
168
|
-
return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(UserLoadingState, {
|
|
169
|
-
fireAnalytics: _this.fireAnalytics
|
|
170
|
-
}));
|
|
171
|
-
} else {
|
|
172
|
-
return _this.renderProfileCard();
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
return _this;
|
|
176
|
-
}
|
|
177
|
-
_createClass(ProfilecardTrigger, [{
|
|
178
|
-
key: "componentDidMount",
|
|
179
|
-
value: function componentDidMount() {
|
|
180
|
-
this._isMounted = true;
|
|
118
|
+
fireEvent(createAnalyticsEvent, payload);
|
|
119
|
+
}, [createAnalyticsEvent]);
|
|
120
|
+
var hideProfilecard = useCallback(function () {
|
|
121
|
+
clearTimeout(showTimer.current);
|
|
122
|
+
clearTimeout(hideTimer.current);
|
|
123
|
+
if (!isTriggeredUsingKeyboard) {
|
|
124
|
+
hideTimer.current = window.setTimeout(function () {
|
|
125
|
+
setVisible(false);
|
|
126
|
+
onVisibilityChange && onVisibilityChange(false);
|
|
127
|
+
}, hideDelay);
|
|
181
128
|
}
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
userId = _this$props2.userId,
|
|
187
|
-
cloudId = _this$props2.cloudId,
|
|
188
|
-
resourceClient = _this$props2.resourceClient;
|
|
189
|
-
var visible = this.state.visible;
|
|
190
|
-
|
|
191
|
-
// just re-fetching data when the card opens
|
|
192
|
-
if (visible && (userId !== prevProps.userId || cloudId !== prevProps.cloudId || resourceClient !== prevProps.resourceClient)) {
|
|
193
|
-
this.setState({
|
|
194
|
-
isLoading: undefined
|
|
195
|
-
}, this.clientFetchProfile);
|
|
196
|
-
}
|
|
129
|
+
}, [hideDelay, isTriggeredUsingKeyboard, onVisibilityChange]);
|
|
130
|
+
var handleKeyboardClose = useCallback(function (event) {
|
|
131
|
+
if (event.key && event.key !== 'Escape') {
|
|
132
|
+
return;
|
|
197
133
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
value: function componentWillUnmount() {
|
|
201
|
-
this._isMounted = false;
|
|
202
|
-
clearTimeout(this.showTimer);
|
|
203
|
-
clearTimeout(this.hideTimer);
|
|
134
|
+
if (triggerRef.current) {
|
|
135
|
+
triggerRef.current.focus();
|
|
204
136
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
isLoading: false,
|
|
213
|
-
hasError: false,
|
|
214
|
-
data: profileData,
|
|
215
|
-
reportingLinesData: reportingLinesData,
|
|
216
|
-
shouldShowGiveKudos: shouldShowGiveKudos
|
|
217
|
-
});
|
|
137
|
+
setTriggeredUsingKeyboard(false);
|
|
138
|
+
setVisible(false);
|
|
139
|
+
onVisibilityChange && onVisibilityChange(false);
|
|
140
|
+
}, [setTriggeredUsingKeyboard, setVisible, onVisibilityChange]);
|
|
141
|
+
var handleClientSuccess = useCallback(function (profileData, reportingLinesData, shouldShowGiveKudos) {
|
|
142
|
+
if (!isMounted.current) {
|
|
143
|
+
return;
|
|
218
144
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
145
|
+
setIsLoading(false);
|
|
146
|
+
setHasError(false);
|
|
147
|
+
setData(profileData);
|
|
148
|
+
setReportingLinesData(reportingLinesData);
|
|
149
|
+
setShouldShowGiveKudos(shouldShowGiveKudos);
|
|
150
|
+
}, [setHasError, setIsLoading, setData, setReportingLinesData, setShouldShowGiveKudos]);
|
|
151
|
+
var handleClientError = useCallback(function (err) {
|
|
152
|
+
if (!isMounted.current) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
setIsLoading(false);
|
|
156
|
+
setHasError(true);
|
|
157
|
+
setError(err);
|
|
158
|
+
}, [setHasError, setIsLoading, setError]);
|
|
159
|
+
var clientFetchProfile = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
160
|
+
var requests, responses;
|
|
161
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
162
|
+
while (1) switch (_context.prev = _context.next) {
|
|
163
|
+
case 0:
|
|
164
|
+
if (!(isLoading === true)) {
|
|
165
|
+
_context.next = 2;
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
return _context.abrupt("return");
|
|
169
|
+
case 2:
|
|
170
|
+
setTeamCentralBaseUrl(resourceClient.getTeamCentralBaseUrl());
|
|
171
|
+
setIsLoading(true);
|
|
172
|
+
setHasError(false);
|
|
173
|
+
setError(null);
|
|
174
|
+
setData(null);
|
|
175
|
+
_context.prev = 7;
|
|
176
|
+
requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos()]);
|
|
177
|
+
_context.next = 11;
|
|
178
|
+
return requests;
|
|
179
|
+
case 11:
|
|
180
|
+
responses = _context.sent;
|
|
181
|
+
handleClientSuccess.apply(void 0, _toConsumableArray(responses));
|
|
182
|
+
_context.next = 18;
|
|
183
|
+
break;
|
|
184
|
+
case 15:
|
|
185
|
+
_context.prev = 15;
|
|
186
|
+
_context.t0 = _context["catch"](7);
|
|
187
|
+
handleClientError(_context.t0);
|
|
188
|
+
case 18:
|
|
189
|
+
case "end":
|
|
190
|
+
return _context.stop();
|
|
191
|
+
}
|
|
192
|
+
}, _callee, null, [[7, 15]]);
|
|
193
|
+
})), [cloudId, fireAnalytics, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
|
|
194
|
+
var showProfilecard = useCallback(function () {
|
|
195
|
+
clearTimeout(hideTimer.current);
|
|
196
|
+
clearTimeout(showTimer.current);
|
|
197
|
+
showTimer.current = window.setTimeout(function () {
|
|
198
|
+
if (!visible) {
|
|
199
|
+
void clientFetchProfile();
|
|
200
|
+
setVisible(true);
|
|
201
|
+
onVisibilityChange && onVisibilityChange(true);
|
|
224
202
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
203
|
+
}, showDelay);
|
|
204
|
+
}, [showDelay, visible, clientFetchProfile, onVisibilityChange]);
|
|
205
|
+
var onClick = useCallback(function (event) {
|
|
206
|
+
// If the user clicks on the trigger then we don't want that click event to
|
|
207
|
+
// propagate out to parent containers. For example when clicking a mention
|
|
208
|
+
// lozenge in an inline-edit.
|
|
209
|
+
event.stopPropagation();
|
|
210
|
+
showProfilecard();
|
|
211
|
+
if (!visible) {
|
|
212
|
+
fireAnalytics(cardTriggered('user', 'click'));
|
|
230
213
|
}
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
214
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
215
|
+
var onMouseEnter = useCallback(function () {
|
|
216
|
+
showProfilecard();
|
|
217
|
+
if (!visible) {
|
|
218
|
+
fireAnalytics(cardTriggered('user', 'hover'));
|
|
219
|
+
}
|
|
220
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
221
|
+
var onKeyPress = useCallback(function (event) {
|
|
222
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
setTriggeredUsingKeyboard(true);
|
|
225
|
+
showProfilecard();
|
|
226
|
+
if (!visible) {
|
|
227
|
+
fireAnalytics(cardTriggered('user', 'click'));
|
|
228
|
+
}
|
|
235
229
|
}
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
230
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
231
|
+
var onFocus = useCallback(function () {
|
|
232
|
+
showProfilecard();
|
|
233
|
+
}, [showProfilecard]);
|
|
234
|
+
var containerListeners = useMemo(function () {
|
|
235
|
+
return trigger === 'hover' ? {
|
|
236
|
+
onMouseEnter: onMouseEnter,
|
|
237
|
+
onMouseLeave: hideProfilecard,
|
|
238
|
+
onBlur: hideProfilecard,
|
|
239
|
+
onKeyPress: onKeyPress
|
|
240
|
+
} : {
|
|
241
|
+
onClick: onClick,
|
|
242
|
+
onKeyPress: onKeyPress
|
|
243
|
+
};
|
|
244
|
+
}, [hideProfilecard, onClick, onKeyPress, onMouseEnter, trigger]);
|
|
245
|
+
var filterActions = useCallback(function () {
|
|
246
|
+
return filterActionsInner(actions, data);
|
|
247
|
+
}, [actions, data]);
|
|
248
|
+
var openKudosDrawer = function openKudosDrawer() {
|
|
249
|
+
hideProfilecard();
|
|
250
|
+
setKudosDrawerOpen(true);
|
|
251
|
+
};
|
|
252
|
+
var closeKudosDrawer = function closeKudosDrawer() {
|
|
253
|
+
setKudosDrawerOpen(false);
|
|
254
|
+
};
|
|
255
|
+
var showLoading = isLoading === true || isLoading === undefined;
|
|
256
|
+
var wrapperProps = useMemo(function () {
|
|
257
|
+
return trigger === 'hover' ? {
|
|
258
|
+
onMouseEnter: onMouseEnter,
|
|
259
|
+
onMouseLeave: hideProfilecard,
|
|
260
|
+
onFocus: onFocus
|
|
261
|
+
} : {};
|
|
262
|
+
}, [hideProfilecard, onFocus, onMouseEnter, trigger]);
|
|
263
|
+
var profilecardProps = _objectSpread(_objectSpread({
|
|
264
|
+
userId: userId,
|
|
265
|
+
fullName: prepopulatedData === null || prepopulatedData === void 0 ? void 0 : prepopulatedData.fullName,
|
|
266
|
+
isCurrentUser: data === null || data === void 0 ? void 0 : data.isCurrentUser,
|
|
267
|
+
clientFetchProfile: clientFetchProfile
|
|
268
|
+
}, data), {}, {
|
|
269
|
+
reportingLines: reportingLinesData,
|
|
270
|
+
onReportingLinesClick: onReportingLinesClick,
|
|
271
|
+
isKudosEnabled: shouldShowGiveKudos,
|
|
272
|
+
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
273
|
+
cloudId: cloudId,
|
|
274
|
+
openKudosDrawer: openKudosDrawer,
|
|
275
|
+
isTriggeredUsingKeyboard: isTriggeredUsingKeyboard,
|
|
276
|
+
disabledAriaAttributes: disabledAriaAttributes
|
|
277
|
+
});
|
|
278
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Popup, {
|
|
279
|
+
isOpen: !!visible,
|
|
280
|
+
onClose: function onClose(event) {
|
|
281
|
+
hideProfilecard();
|
|
282
|
+
handleKeyboardClose(event);
|
|
283
|
+
},
|
|
284
|
+
placement: position,
|
|
285
|
+
content: function content() {
|
|
286
|
+
return /*#__PURE__*/React.createElement("div", wrapperProps, showLoading ? /*#__PURE__*/React.createElement(LoadingView, {
|
|
287
|
+
fireAnalytics: fireAnalytics
|
|
288
|
+
}) : visible && /*#__PURE__*/React.createElement(Suspense, {
|
|
258
289
|
fallback: null
|
|
259
|
-
}, /*#__PURE__*/React.createElement(ProfileCardLazy, _extends({},
|
|
260
|
-
actions:
|
|
261
|
-
hasError:
|
|
262
|
-
errorType:
|
|
290
|
+
}, /*#__PURE__*/React.createElement(ProfileCardLazy, _extends({}, profilecardProps, {
|
|
291
|
+
actions: filterActions(),
|
|
292
|
+
hasError: hasError,
|
|
293
|
+
errorType: error,
|
|
263
294
|
withoutElevation: true
|
|
264
295
|
}))));
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
var
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}]);
|
|
317
|
-
return ProfilecardTrigger;
|
|
318
|
-
}(React.PureComponent);
|
|
319
|
-
_defineProperty(ProfilecardTrigger, "defaultProps", {
|
|
320
|
-
actions: [],
|
|
321
|
-
trigger: 'hover',
|
|
322
|
-
position: 'bottom-start'
|
|
323
|
-
});
|
|
324
|
-
var ProfilecardTriggerLegacy = withAnalyticsEvents()(ProfilecardTrigger);
|
|
325
|
-
export default function ProfilecardTriggerSwitch(props) {
|
|
326
|
-
return fg('platform.profile-card-trigger-next') ? /*#__PURE__*/React.createElement(ProfilecardTriggerNext, _extends({}, props, {
|
|
327
|
-
onVisibilityChange: function onVisibilityChange(isVisible) {
|
|
328
|
-
if (props.onVisibilityChange) {
|
|
329
|
-
props.onVisibilityChange(isVisible);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
})) : /*#__PURE__*/React.createElement(ProfilecardTriggerLegacy, props);
|
|
333
|
-
}
|
|
296
|
+
},
|
|
297
|
+
trigger: function trigger(triggerProps) {
|
|
298
|
+
var callbackRef = triggerProps.ref,
|
|
299
|
+
innerProps = _objectWithoutProperties(triggerProps, _excluded);
|
|
300
|
+
var ref = function ref(element) {
|
|
301
|
+
triggerRef.current = element;
|
|
302
|
+
if (typeof callbackRef === 'function') {
|
|
303
|
+
callbackRef(element);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
var _ = innerProps['aria-expanded'],
|
|
307
|
+
__ = innerProps['aria-haspopup'],
|
|
308
|
+
restInnerProps = _objectWithoutProperties(innerProps, _excluded2);
|
|
309
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, disabledAriaAttributes ? restInnerProps : triggerProps, containerListeners, {
|
|
310
|
+
ref: ref,
|
|
311
|
+
"data-testid": testId,
|
|
312
|
+
"aria-labelledby": ariaLabelledBy
|
|
313
|
+
}, disabledAriaAttributes ? {} : {
|
|
314
|
+
role: 'button',
|
|
315
|
+
tabIndex: 0,
|
|
316
|
+
'aria-label': getLabelMessage(ariaLabel, profilecardProps.fullName, formatMessage)
|
|
317
|
+
}), children);
|
|
318
|
+
},
|
|
319
|
+
zIndex: layers.modal(),
|
|
320
|
+
shouldUseCaptureOnOutsideClick: true,
|
|
321
|
+
autoFocus: autoFocus !== null && autoFocus !== void 0 ? autoFocus : trigger === 'click'
|
|
322
|
+
}), shouldShowGiveKudos && /*#__PURE__*/React.createElement(Suspense, {
|
|
323
|
+
fallback: null
|
|
324
|
+
}, /*#__PURE__*/React.createElement(GiveKudosLauncherLazy, {
|
|
325
|
+
isOpen: kudosDrawerOpen,
|
|
326
|
+
recipient: {
|
|
327
|
+
type: KudosType.INDIVIDUAL,
|
|
328
|
+
recipientId: userId
|
|
329
|
+
},
|
|
330
|
+
analyticsSource: "profile-card",
|
|
331
|
+
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
332
|
+
cloudId: cloudId,
|
|
333
|
+
addFlag: addFlag,
|
|
334
|
+
onClose: closeKudosDrawer
|
|
335
|
+
})));
|
|
336
|
+
}
|
|
337
|
+
var LoadingView = function LoadingView(_ref3) {
|
|
338
|
+
var fireAnalytics = _ref3.fireAnalytics;
|
|
339
|
+
return /*#__PURE__*/React.createElement(CardWrapper, {
|
|
340
|
+
"data-testId": "profilecard.profilecardtrigger.loading"
|
|
341
|
+
}, /*#__PURE__*/React.createElement(UserLoadingState, {
|
|
342
|
+
fireAnalytics: fireAnalytics
|
|
343
|
+
}));
|
|
344
|
+
};
|
|
@@ -38,7 +38,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
|
|
|
38
38
|
actionSubjectId: actionSubjectId,
|
|
39
39
|
attributes: _objectSpread(_objectSpread({
|
|
40
40
|
packageName: "@atlaskit/profilecard",
|
|
41
|
-
packageVersion: "19.17.
|
|
41
|
+
packageVersion: "19.17.1"
|
|
42
42
|
}, attributes), {}, {
|
|
43
43
|
firedAt: Math.round(getPageTime())
|
|
44
44
|
})
|