@atlaskit/profilecard 19.7.14 → 19.8.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 +16 -0
- package/afm-cc/tsconfig.json +3 -0
- package/dist/cjs/client/getTeamFromAGG.js +1 -1
- package/dist/cjs/components/User/ProfileCard.js +5 -2
- package/dist/cjs/components/User/ProfileCardTrigger.js +7 -2
- package/dist/cjs/components/User/ProfileCardTriggerNext.js +324 -0
- package/dist/cjs/styled/Card.js +2 -2
- package/dist/cjs/util/analytics.js +1 -1
- package/dist/es2019/client/getTeamFromAGG.js +1 -1
- package/dist/es2019/components/User/ProfileCard.js +5 -2
- package/dist/es2019/components/User/ProfileCardTrigger.js +6 -1
- package/dist/es2019/components/User/ProfileCardTriggerNext.js +247 -0
- package/dist/es2019/styled/Card.js +2 -2
- package/dist/es2019/util/analytics.js +1 -1
- package/dist/esm/client/getTeamFromAGG.js +1 -1
- package/dist/esm/components/User/ProfileCard.js +5 -2
- package/dist/esm/components/User/ProfileCardTrigger.js +6 -1
- package/dist/esm/components/User/ProfileCardTriggerNext.js +314 -0
- package/dist/esm/styled/Card.js +2 -2
- package/dist/esm/util/analytics.js +1 -1
- package/dist/types/components/User/ProfileCardTrigger.d.ts +3 -4
- package/dist/types/components/User/ProfileCardTriggerNext.d.ts +3 -0
- package/dist/types/types.d.ts +1 -1
- package/dist/types-ts4.5/components/User/ProfileCardTrigger.d.ts +3 -4
- package/dist/types-ts4.5/components/User/ProfileCardTriggerNext.d.ts +3 -0
- package/dist/types-ts4.5/types.d.ts +1 -1
- package/package.json +9 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/profilecard
|
|
2
2
|
|
|
3
|
+
## 19.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#68345](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68345) [`c769c4488d20`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c769c4488d20) - Add aria label to trigger & add ProfilecardTriggerNext
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 19.7.15
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#67206](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67206) [`277421c217ae`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/277421c217ae) - PTC-8511 ENGHEALTH-5595 fix deprecated token
|
|
18
|
+
|
|
3
19
|
## 19.7.14
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -57,7 +57,7 @@ var addHeaders = exports.addHeaders = function addHeaders(headers) {
|
|
|
57
57
|
headers.append('X-ExperimentalApi', 'teams-beta');
|
|
58
58
|
headers.append('X-ExperimentalApi', 'team-members-beta');
|
|
59
59
|
headers.append('atl-client-name', "@atlaskit/profilecard");
|
|
60
|
-
headers.append('atl-client-version', "19.
|
|
60
|
+
headers.append('atl-client-version', "19.8.0");
|
|
61
61
|
return headers;
|
|
62
62
|
};
|
|
63
63
|
function getTeamFromAGG(_x, _x2, _x3) {
|
|
@@ -162,7 +162,8 @@ var Actions = function Actions(_ref) {
|
|
|
162
162
|
}, regularActions.map(function (action, index) {
|
|
163
163
|
var isKudos = action.id === GIVE_KUDOS_ACTION_ID;
|
|
164
164
|
var button = /*#__PURE__*/_react.default.createElement(_focusRing.default, {
|
|
165
|
-
isInset: true
|
|
165
|
+
isInset: true,
|
|
166
|
+
key: "profile-card-action-focus-ring_".concat(action.id || index)
|
|
166
167
|
}, /*#__PURE__*/_react.default.createElement(_customThemeButton.default, {
|
|
167
168
|
appearance: "default",
|
|
168
169
|
key: action.id || index,
|
|
@@ -175,7 +176,9 @@ var Actions = function Actions(_ref) {
|
|
|
175
176
|
href: action.link
|
|
176
177
|
}, action.label, isKudos && /*#__PURE__*/_react.default.createElement(_Card.AnimationWrapper, null, /*#__PURE__*/_react.default.createElement(_Card.KudosBlobAnimation, null))));
|
|
177
178
|
if (isKudos) {
|
|
178
|
-
return /*#__PURE__*/_react.default.createElement(_Card.AnimatedKudosButton,
|
|
179
|
+
return /*#__PURE__*/_react.default.createElement(_Card.AnimatedKudosButton, {
|
|
180
|
+
key: "profile-card-action-kudos_".concat(action.id || index)
|
|
181
|
+
}, button);
|
|
179
182
|
}
|
|
180
183
|
return button;
|
|
181
184
|
}), overflowActions && /*#__PURE__*/_react.default.createElement(_OverflowProfileCardButtons.OverflowProfileCardButtons, {
|
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default =
|
|
8
|
+
exports.default = ProfilecardTriggerSwitch;
|
|
9
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
@@ -19,6 +19,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
19
19
|
var _react = _interopRequireWildcard(require("react"));
|
|
20
20
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
21
21
|
var _giveKudos = require("@atlaskit/give-kudos");
|
|
22
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
22
23
|
var _popup = _interopRequireDefault(require("@atlaskit/popup"));
|
|
23
24
|
var _constants = require("@atlaskit/theme/constants");
|
|
24
25
|
var _filterActions2 = _interopRequireDefault(require("../../internal/filterActions"));
|
|
@@ -26,6 +27,7 @@ var _Card = require("../../styled/Card");
|
|
|
26
27
|
var _analytics = require("../../util/analytics");
|
|
27
28
|
var _config = require("../../util/config");
|
|
28
29
|
var _lazyProfileCard = require("./lazyProfileCard");
|
|
30
|
+
var _ProfileCardTriggerNext = _interopRequireDefault(require("./ProfileCardTriggerNext"));
|
|
29
31
|
var _UserLoadingState = _interopRequireDefault(require("./UserLoadingState"));
|
|
30
32
|
var _excluded = ["ref"];
|
|
31
33
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -325,4 +327,7 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
325
327
|
trigger: 'hover',
|
|
326
328
|
position: 'bottom-start'
|
|
327
329
|
});
|
|
328
|
-
var
|
|
330
|
+
var ProfilecardTriggerLegacy = (0, _analyticsNext.withAnalyticsEvents)()(ProfilecardTrigger);
|
|
331
|
+
function ProfilecardTriggerSwitch(props) {
|
|
332
|
+
return (0, _platformFeatureFlags.getBooleanFF)('platform.profile-card-trigger-next') ? /*#__PURE__*/_react.default.createElement(_ProfileCardTriggerNext.default, props) : /*#__PURE__*/_react.default.createElement(ProfilecardTriggerLegacy, props);
|
|
333
|
+
}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = ProfilecardTriggerNext;
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
14
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
var _reactIntlNext = require("react-intl-next");
|
|
18
|
+
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
19
|
+
var _giveKudos = require("@atlaskit/give-kudos");
|
|
20
|
+
var _popup = _interopRequireDefault(require("@atlaskit/popup"));
|
|
21
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
22
|
+
var _filterActions = _interopRequireDefault(require("../../internal/filterActions"));
|
|
23
|
+
var _Card = require("../../styled/Card");
|
|
24
|
+
var _analytics = require("../../util/analytics");
|
|
25
|
+
var _config = require("../../util/config");
|
|
26
|
+
var _lazyProfileCard = require("./lazyProfileCard");
|
|
27
|
+
var _UserLoadingState = _interopRequireDefault(require("./UserLoadingState"));
|
|
28
|
+
var _excluded = ["ref"];
|
|
29
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
30
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
+
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; }
|
|
32
|
+
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) { (0, _defineProperty2.default)(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; }
|
|
33
|
+
function ProfilecardTriggerNext(_ref) {
|
|
34
|
+
var _ref$trigger = _ref.trigger,
|
|
35
|
+
trigger = _ref$trigger === void 0 ? 'hover' : _ref$trigger,
|
|
36
|
+
userId = _ref.userId,
|
|
37
|
+
cloudId = _ref.cloudId,
|
|
38
|
+
resourceClient = _ref.resourceClient,
|
|
39
|
+
_ref$actions = _ref.actions,
|
|
40
|
+
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
41
|
+
_ref$position = _ref.position,
|
|
42
|
+
position = _ref$position === void 0 ? 'bottom-start' : _ref$position,
|
|
43
|
+
children = _ref.children,
|
|
44
|
+
testId = _ref.testId,
|
|
45
|
+
addFlag = _ref.addFlag,
|
|
46
|
+
onReportingLinesClick = _ref.onReportingLinesClick;
|
|
47
|
+
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
48
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
49
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
50
|
+
formatMessage = _useIntl.formatMessage;
|
|
51
|
+
var _useState = (0, _react.useState)(false),
|
|
52
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
53
|
+
isMounted = _useState2[0],
|
|
54
|
+
setIsMounted = _useState2[1];
|
|
55
|
+
var showDelay = trigger === 'click' ? 0 : _config.DELAY_MS_SHOW;
|
|
56
|
+
var hideDelay = trigger === 'click' ? 0 : _config.DELAY_MS_HIDE;
|
|
57
|
+
var _useState3 = (0, _react.useState)(0),
|
|
58
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
59
|
+
showTimer = _useState4[0],
|
|
60
|
+
setShowTimer = _useState4[1];
|
|
61
|
+
var _useState5 = (0, _react.useState)(0),
|
|
62
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
63
|
+
hideTimer = _useState6[0],
|
|
64
|
+
setHideTimer = _useState6[1];
|
|
65
|
+
var _useState7 = (0, _react.useState)(false),
|
|
66
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
67
|
+
visible = _useState8[0],
|
|
68
|
+
setVisible = _useState8[1];
|
|
69
|
+
var _useState9 = (0, _react.useState)(undefined),
|
|
70
|
+
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
71
|
+
isLoading = _useState10[0],
|
|
72
|
+
setIsLoading = _useState10[1];
|
|
73
|
+
var _useState11 = (0, _react.useState)(false),
|
|
74
|
+
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
75
|
+
hasError = _useState12[0],
|
|
76
|
+
setHasError = _useState12[1];
|
|
77
|
+
var _useState13 = (0, _react.useState)(null),
|
|
78
|
+
_useState14 = (0, _slicedToArray2.default)(_useState13, 2),
|
|
79
|
+
error = _useState14[0],
|
|
80
|
+
setError = _useState14[1];
|
|
81
|
+
var _useState15 = (0, _react.useState)(null),
|
|
82
|
+
_useState16 = (0, _slicedToArray2.default)(_useState15, 2),
|
|
83
|
+
data = _useState16[0],
|
|
84
|
+
setData = _useState16[1];
|
|
85
|
+
var _useState17 = (0, _react.useState)(undefined),
|
|
86
|
+
_useState18 = (0, _slicedToArray2.default)(_useState17, 2),
|
|
87
|
+
reportingLinesData = _useState18[0],
|
|
88
|
+
setReportingLinesData = _useState18[1];
|
|
89
|
+
var _useState19 = (0, _react.useState)(false),
|
|
90
|
+
_useState20 = (0, _slicedToArray2.default)(_useState19, 2),
|
|
91
|
+
shouldShowGiveKudos = _useState20[0],
|
|
92
|
+
setShouldShowGiveKudos = _useState20[1];
|
|
93
|
+
var _useState21 = (0, _react.useState)(undefined),
|
|
94
|
+
_useState22 = (0, _slicedToArray2.default)(_useState21, 2),
|
|
95
|
+
teamCentralBaseUrl = _useState22[0],
|
|
96
|
+
setTeamCentralBaseUrl = _useState22[1];
|
|
97
|
+
var _useState23 = (0, _react.useState)(false),
|
|
98
|
+
_useState24 = (0, _slicedToArray2.default)(_useState23, 2),
|
|
99
|
+
kudosDrawerOpen = _useState24[0],
|
|
100
|
+
setKudosDrawerOpen = _useState24[1];
|
|
101
|
+
(0, _react.useEffect)(function () {
|
|
102
|
+
setIsMounted(true);
|
|
103
|
+
return function () {
|
|
104
|
+
setIsMounted(false);
|
|
105
|
+
clearTimeout(showTimer);
|
|
106
|
+
clearTimeout(hideTimer);
|
|
107
|
+
};
|
|
108
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
109
|
+
}, []);
|
|
110
|
+
(0, _react.useEffect)(function () {
|
|
111
|
+
// Reset state when the userId changes
|
|
112
|
+
setIsLoading(undefined);
|
|
113
|
+
setHasError(false);
|
|
114
|
+
setError(null);
|
|
115
|
+
setData(null);
|
|
116
|
+
setReportingLinesData(undefined);
|
|
117
|
+
setShouldShowGiveKudos(false);
|
|
118
|
+
setTeamCentralBaseUrl(undefined);
|
|
119
|
+
}, [userId]);
|
|
120
|
+
var fireAnalytics = (0, _react.useCallback)(function (payload) {
|
|
121
|
+
// Don't fire any analytics if the component is unmounted
|
|
122
|
+
if (!isMounted) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
(0, _analytics.fireEvent)(createAnalyticsEvent, payload);
|
|
126
|
+
}, [createAnalyticsEvent, isMounted]);
|
|
127
|
+
var hideProfilecard = (0, _react.useCallback)(function () {
|
|
128
|
+
clearTimeout(showTimer);
|
|
129
|
+
clearTimeout(hideTimer);
|
|
130
|
+
setHideTimer(window.setTimeout(function () {
|
|
131
|
+
setVisible(false);
|
|
132
|
+
}, hideDelay));
|
|
133
|
+
}, [hideDelay, hideTimer, showTimer]);
|
|
134
|
+
var handleClientSuccess = (0, _react.useCallback)(function (profileData, reportingLinesData, shouldShowGiveKudos) {
|
|
135
|
+
if (!isMounted) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
setIsLoading(false);
|
|
139
|
+
setHasError(false);
|
|
140
|
+
setData(profileData);
|
|
141
|
+
setReportingLinesData(reportingLinesData);
|
|
142
|
+
setShouldShowGiveKudos(shouldShowGiveKudos);
|
|
143
|
+
}, [isMounted, setHasError, setIsLoading, setData, setReportingLinesData, setShouldShowGiveKudos]);
|
|
144
|
+
var handleClientError = (0, _react.useCallback)(function (err) {
|
|
145
|
+
if (!isMounted) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
setIsLoading(false);
|
|
149
|
+
setHasError(true);
|
|
150
|
+
setError(err);
|
|
151
|
+
}, [isMounted, setHasError, setIsLoading, setError]);
|
|
152
|
+
var clientFetchProfile = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
153
|
+
var requests, responses;
|
|
154
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
155
|
+
while (1) switch (_context.prev = _context.next) {
|
|
156
|
+
case 0:
|
|
157
|
+
if (!(isLoading === true)) {
|
|
158
|
+
_context.next = 2;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
return _context.abrupt("return");
|
|
162
|
+
case 2:
|
|
163
|
+
setTeamCentralBaseUrl(resourceClient.getTeamCentralBaseUrl());
|
|
164
|
+
setIsLoading(true);
|
|
165
|
+
setHasError(false);
|
|
166
|
+
setError(null);
|
|
167
|
+
setData(null);
|
|
168
|
+
_context.prev = 7;
|
|
169
|
+
requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos()]);
|
|
170
|
+
_context.next = 11;
|
|
171
|
+
return requests;
|
|
172
|
+
case 11:
|
|
173
|
+
responses = _context.sent;
|
|
174
|
+
handleClientSuccess.apply(void 0, (0, _toConsumableArray2.default)(responses));
|
|
175
|
+
_context.next = 18;
|
|
176
|
+
break;
|
|
177
|
+
case 15:
|
|
178
|
+
_context.prev = 15;
|
|
179
|
+
_context.t0 = _context["catch"](7);
|
|
180
|
+
handleClientError(_context.t0);
|
|
181
|
+
case 18:
|
|
182
|
+
case "end":
|
|
183
|
+
return _context.stop();
|
|
184
|
+
}
|
|
185
|
+
}, _callee, null, [[7, 15]]);
|
|
186
|
+
})), [cloudId, fireAnalytics, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
|
|
187
|
+
var showProfilecard = (0, _react.useCallback)(function () {
|
|
188
|
+
clearTimeout(hideTimer);
|
|
189
|
+
clearTimeout(showTimer);
|
|
190
|
+
setShowTimer(window.setTimeout(function () {
|
|
191
|
+
if (!visible) {
|
|
192
|
+
void clientFetchProfile();
|
|
193
|
+
setVisible(true);
|
|
194
|
+
}
|
|
195
|
+
}, showDelay));
|
|
196
|
+
}, [hideTimer, showDelay, showTimer, visible, clientFetchProfile]);
|
|
197
|
+
var onClick = (0, _react.useCallback)(function (event) {
|
|
198
|
+
// If the user clicks on the trigger then we don't want that click event to
|
|
199
|
+
// propagate out to parent containers. For example when clicking a mention
|
|
200
|
+
// lozenge in an inline-edit.
|
|
201
|
+
event.stopPropagation();
|
|
202
|
+
showProfilecard();
|
|
203
|
+
if (!visible) {
|
|
204
|
+
fireAnalytics((0, _analytics.cardTriggered)('user', 'click'));
|
|
205
|
+
}
|
|
206
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
207
|
+
var onMouseEnter = (0, _react.useCallback)(function () {
|
|
208
|
+
showProfilecard();
|
|
209
|
+
if (!visible) {
|
|
210
|
+
fireAnalytics((0, _analytics.cardTriggered)('user', 'hover'));
|
|
211
|
+
}
|
|
212
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
213
|
+
var onKeyPress = (0, _react.useCallback)(function (event) {
|
|
214
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
215
|
+
event.preventDefault();
|
|
216
|
+
showProfilecard();
|
|
217
|
+
if (!visible) {
|
|
218
|
+
fireAnalytics((0, _analytics.cardTriggered)('user', 'click'));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
222
|
+
var onFocus = (0, _react.useCallback)(function () {
|
|
223
|
+
showProfilecard();
|
|
224
|
+
}, [showProfilecard]);
|
|
225
|
+
var containerListeners = (0, _react.useMemo)(function () {
|
|
226
|
+
return trigger === 'hover' ? {
|
|
227
|
+
onMouseEnter: onMouseEnter,
|
|
228
|
+
onMouseLeave: hideProfilecard,
|
|
229
|
+
onBlur: hideProfilecard,
|
|
230
|
+
onKeyPress: onKeyPress
|
|
231
|
+
} : {
|
|
232
|
+
onClick: onClick,
|
|
233
|
+
onKeyPress: onKeyPress
|
|
234
|
+
};
|
|
235
|
+
}, [hideProfilecard, onClick, onKeyPress, onMouseEnter, trigger]);
|
|
236
|
+
var filterActions = (0, _react.useCallback)(function () {
|
|
237
|
+
return (0, _filterActions.default)(actions, data);
|
|
238
|
+
}, [actions, data]);
|
|
239
|
+
var openKudosDrawer = function openKudosDrawer() {
|
|
240
|
+
hideProfilecard();
|
|
241
|
+
setKudosDrawerOpen(true);
|
|
242
|
+
};
|
|
243
|
+
var closeKudosDrawer = function closeKudosDrawer() {
|
|
244
|
+
setKudosDrawerOpen(false);
|
|
245
|
+
};
|
|
246
|
+
var showLoading = isLoading === true || isLoading === undefined;
|
|
247
|
+
var wrapperProps = (0, _react.useMemo)(function () {
|
|
248
|
+
return trigger === 'hover' ? {
|
|
249
|
+
onMouseEnter: onMouseEnter,
|
|
250
|
+
onMouseLeave: hideProfilecard,
|
|
251
|
+
onFocus: onFocus
|
|
252
|
+
} : {};
|
|
253
|
+
}, [hideProfilecard, onFocus, onMouseEnter, trigger]);
|
|
254
|
+
var profilecardProps = _objectSpread(_objectSpread({
|
|
255
|
+
userId: userId,
|
|
256
|
+
isCurrentUser: data === null || data === void 0 ? void 0 : data.isCurrentUser,
|
|
257
|
+
clientFetchProfile: clientFetchProfile
|
|
258
|
+
}, data), {}, {
|
|
259
|
+
reportingLines: reportingLinesData,
|
|
260
|
+
onReportingLinesClick: onReportingLinesClick,
|
|
261
|
+
isKudosEnabled: shouldShowGiveKudos,
|
|
262
|
+
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
263
|
+
cloudId: cloudId,
|
|
264
|
+
openKudosDrawer: openKudosDrawer
|
|
265
|
+
});
|
|
266
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_popup.default, {
|
|
267
|
+
isOpen: !!visible,
|
|
268
|
+
onClose: hideProfilecard,
|
|
269
|
+
placement: position,
|
|
270
|
+
content: function content() {
|
|
271
|
+
return showLoading ? /*#__PURE__*/_react.default.createElement(LoadingView, {
|
|
272
|
+
fireAnalytics: fireAnalytics
|
|
273
|
+
}) : /*#__PURE__*/_react.default.createElement("div", wrapperProps, visible && /*#__PURE__*/_react.default.createElement(_react.Suspense, {
|
|
274
|
+
fallback: null
|
|
275
|
+
}, /*#__PURE__*/_react.default.createElement(_lazyProfileCard.ProfileCardLazy, (0, _extends2.default)({}, profilecardProps, {
|
|
276
|
+
actions: filterActions(),
|
|
277
|
+
hasError: hasError,
|
|
278
|
+
errorType: error,
|
|
279
|
+
withoutElevation: true
|
|
280
|
+
}))));
|
|
281
|
+
},
|
|
282
|
+
trigger: function trigger(triggerProps) {
|
|
283
|
+
var ref = triggerProps.ref,
|
|
284
|
+
innerProps = (0, _objectWithoutProperties2.default)(triggerProps, _excluded);
|
|
285
|
+
return /*#__PURE__*/_react.default.createElement("span", (0, _extends2.default)({}, innerProps, containerListeners, {
|
|
286
|
+
ref: ref,
|
|
287
|
+
"data-testid": testId,
|
|
288
|
+
role: "button",
|
|
289
|
+
tabIndex: 0,
|
|
290
|
+
"aria-label": formatMessage({
|
|
291
|
+
id: 'profilecard.user.trigger.aria-label',
|
|
292
|
+
defaultMessage: 'More information about {fullName}',
|
|
293
|
+
description: 'Label for profile card trigger'
|
|
294
|
+
}, {
|
|
295
|
+
fullName: profilecardProps.fullName
|
|
296
|
+
})
|
|
297
|
+
}), children);
|
|
298
|
+
},
|
|
299
|
+
zIndex: _constants.layers.modal(),
|
|
300
|
+
shouldUseCaptureOnOutsideClick: true,
|
|
301
|
+
autoFocus: trigger === 'click'
|
|
302
|
+
}), shouldShowGiveKudos && /*#__PURE__*/_react.default.createElement(_react.Suspense, {
|
|
303
|
+
fallback: null
|
|
304
|
+
}, /*#__PURE__*/_react.default.createElement(_giveKudos.GiveKudosLauncherLazy, {
|
|
305
|
+
isOpen: kudosDrawerOpen,
|
|
306
|
+
recipient: {
|
|
307
|
+
type: _giveKudos.KudosType.INDIVIDUAL,
|
|
308
|
+
recipientId: userId
|
|
309
|
+
},
|
|
310
|
+
analyticsSource: "profile-card",
|
|
311
|
+
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
312
|
+
cloudId: cloudId,
|
|
313
|
+
addFlag: addFlag,
|
|
314
|
+
onClose: closeKudosDrawer
|
|
315
|
+
})));
|
|
316
|
+
}
|
|
317
|
+
var LoadingView = function LoadingView(_ref3) {
|
|
318
|
+
var fireAnalytics = _ref3.fireAnalytics;
|
|
319
|
+
return /*#__PURE__*/_react.default.createElement(_Card.CardWrapper, {
|
|
320
|
+
"data-testId": "profilecard.profilecardtrigger.loading"
|
|
321
|
+
}, /*#__PURE__*/_react.default.createElement(_UserLoadingState.default, {
|
|
322
|
+
fireAnalytics: fireAnalytics
|
|
323
|
+
}));
|
|
324
|
+
};
|
package/dist/cjs/styled/Card.js
CHANGED
|
@@ -35,7 +35,7 @@ var CardContent = exports.CardContent = _styled.default.div(_templateObject10 ||
|
|
|
35
35
|
|
|
36
36
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
37
37
|
var DetailsGroup = exports.DetailsGroup = _styled.default.div(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n margin-left: ", "px;\n width: ", "px;\n"])), (0, _constants.gridSize)() * 14.5, (0, _constants.gridSize)() * 24.5);
|
|
38
|
-
var DisabledInfo = exports.DisabledInfo = _styled.default.div(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2.default)(["\n font-size: ", "px;\n color: ", ";\n margin: ", " 0 0 0;\n line-height:
|
|
38
|
+
var DisabledInfo = exports.DisabledInfo = _styled.default.div(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2.default)(["\n font-size: ", "px;\n color: ", ";\n margin: ", " 0 0 0;\n line-height: 16px;\n"])), _constants.fontSizeSmall, _constants2.labelTextColor, "var(--ds-space-150, 12px)");
|
|
39
39
|
var FullNameLabel = exports.FullNameLabel = _styled.default.h2(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2.default)(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n font-size: 18px;\n font-weight: 400;\n letter-spacing: normal;\n color: ", ";\n margin: ", ";\n line-height: ", "em;\n :first-child {\n margin: ", ";\n }\n"])), function (props) {
|
|
40
40
|
return props.isDisabledAccount ? _constants2.headerTextColorInactive : _constants2.headerTextColor;
|
|
41
41
|
}, function (props) {
|
|
@@ -57,6 +57,6 @@ var CardContainer = exports.CardContainer = _styled.default.div(_templateObject1
|
|
|
57
57
|
}, function (props) {
|
|
58
58
|
return props.withoutElevation ? '' : "".concat((0, _constants.borderRadius)(), "px");
|
|
59
59
|
});
|
|
60
|
-
var DetailsLabel = exports.DetailsLabel = _styled.default.div(_templateObject20 || (_templateObject20 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n align-items: center;\n line-height:
|
|
60
|
+
var DetailsLabel = exports.DetailsLabel = _styled.default.div(_templateObject20 || (_templateObject20 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n align-items: center;\n line-height: 24px;\n font-size: ", "px;\n margin: ", " 0 0 0;\n white-space: nowrap;\n\n & + & {\n margin-top: ", ";\n }\n"])), (0, _constants.gridSize)() * 1.5, "var(--ds-space-200, 16px)", "var(--ds-space-025, 2px)");
|
|
61
61
|
var DetailsLabelIcon = exports.DetailsLabelIcon = _styled.default.div(_templateObject21 || (_templateObject21 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-shrink: 0;\n color: ", ";\n width: ", ";\n height: ", ";\n padding: ", ";\n vertical-align: top;\n\n svg {\n width: 100%;\n height: 100%;\n }\n"])), _constants2.labelIconColor, "var(--ds-space-200, 16px)", "var(--ds-space-200, 16px)", "var(--ds-space-050, 4px)");
|
|
62
62
|
var DetailsLabelText = exports.DetailsLabelText = _styled.default.span(_templateObject22 || (_templateObject22 = (0, _taggedTemplateLiteral2.default)(["\n overflow: hidden;\n text-overflow: ellipsis;\n color: ", ";\n padding-left: ", ";\n"])), _constants2.labelTextColor, "var(--ds-space-050, 4px)");
|
|
@@ -44,7 +44,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
|
|
|
44
44
|
actionSubjectId: actionSubjectId,
|
|
45
45
|
attributes: _objectSpread(_objectSpread({
|
|
46
46
|
packageName: "@atlaskit/profilecard",
|
|
47
|
-
packageVersion: "19.
|
|
47
|
+
packageVersion: "19.8.0"
|
|
48
48
|
}, attributes), {}, {
|
|
49
49
|
firedAt: Math.round((0, _performance.getPageTime)())
|
|
50
50
|
})
|
|
@@ -67,7 +67,7 @@ export const addHeaders = headers => {
|
|
|
67
67
|
headers.append('X-ExperimentalApi', 'teams-beta');
|
|
68
68
|
headers.append('X-ExperimentalApi', 'team-members-beta');
|
|
69
69
|
headers.append('atl-client-name', "@atlaskit/profilecard");
|
|
70
|
-
headers.append('atl-client-version', "19.
|
|
70
|
+
headers.append('atl-client-version', "19.8.0");
|
|
71
71
|
return headers;
|
|
72
72
|
};
|
|
73
73
|
export async function getTeamFromAGG(url, teamId, siteId) {
|
|
@@ -148,7 +148,8 @@ const Actions = ({
|
|
|
148
148
|
}, regularActions.map((action, index) => {
|
|
149
149
|
const isKudos = action.id === GIVE_KUDOS_ACTION_ID;
|
|
150
150
|
const button = /*#__PURE__*/React.createElement(FocusRing, {
|
|
151
|
-
isInset: true
|
|
151
|
+
isInset: true,
|
|
152
|
+
key: `profile-card-action-focus-ring_${action.id || index}`
|
|
152
153
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
153
154
|
appearance: "default",
|
|
154
155
|
key: action.id || index,
|
|
@@ -156,7 +157,9 @@ const Actions = ({
|
|
|
156
157
|
href: action.link
|
|
157
158
|
}, action.label, isKudos && /*#__PURE__*/React.createElement(AnimationWrapper, null, /*#__PURE__*/React.createElement(KudosBlobAnimation, null))));
|
|
158
159
|
if (isKudos) {
|
|
159
|
-
return /*#__PURE__*/React.createElement(AnimatedKudosButton,
|
|
160
|
+
return /*#__PURE__*/React.createElement(AnimatedKudosButton, {
|
|
161
|
+
key: `profile-card-action-kudos_${action.id || index}`
|
|
162
|
+
}, button);
|
|
160
163
|
}
|
|
161
164
|
return button;
|
|
162
165
|
}), overflowActions && /*#__PURE__*/React.createElement(OverflowProfileCardButtons, {
|
|
@@ -3,6 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
import React, { Suspense } from 'react';
|
|
4
4
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
5
5
|
import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import Popup from '@atlaskit/popup';
|
|
7
8
|
import { layers } from '@atlaskit/theme/constants';
|
|
8
9
|
import filterActions from '../../internal/filterActions';
|
|
@@ -10,6 +11,7 @@ import { CardWrapper } from '../../styled/Card';
|
|
|
10
11
|
import { cardTriggered, fireEvent } from '../../util/analytics';
|
|
11
12
|
import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
|
|
12
13
|
import { ProfileCardLazy } from './lazyProfileCard';
|
|
14
|
+
import ProfilecardTriggerNext from './ProfileCardTriggerNext';
|
|
13
15
|
import UserLoadingState from './UserLoadingState';
|
|
14
16
|
class ProfilecardTrigger extends React.PureComponent {
|
|
15
17
|
constructor(...args) {
|
|
@@ -276,4 +278,7 @@ _defineProperty(ProfilecardTrigger, "defaultProps", {
|
|
|
276
278
|
trigger: 'hover',
|
|
277
279
|
position: 'bottom-start'
|
|
278
280
|
});
|
|
279
|
-
|
|
281
|
+
const ProfilecardTriggerLegacy = withAnalyticsEvents()(ProfilecardTrigger);
|
|
282
|
+
export default function ProfilecardTriggerSwitch(props) {
|
|
283
|
+
return getBooleanFF('platform.profile-card-trigger-next') ? /*#__PURE__*/React.createElement(ProfilecardTriggerNext, props) : /*#__PURE__*/React.createElement(ProfilecardTriggerLegacy, props);
|
|
284
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { Suspense, useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl-next';
|
|
4
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
5
|
+
import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
|
|
6
|
+
import Popup from '@atlaskit/popup';
|
|
7
|
+
import { layers } from '@atlaskit/theme/constants';
|
|
8
|
+
import filterActionsInner from '../../internal/filterActions';
|
|
9
|
+
import { CardWrapper } from '../../styled/Card';
|
|
10
|
+
import { cardTriggered, fireEvent } from '../../util/analytics';
|
|
11
|
+
import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
|
|
12
|
+
import { ProfileCardLazy } from './lazyProfileCard';
|
|
13
|
+
import UserLoadingState from './UserLoadingState';
|
|
14
|
+
export default function ProfilecardTriggerNext({
|
|
15
|
+
trigger = 'hover',
|
|
16
|
+
userId,
|
|
17
|
+
cloudId,
|
|
18
|
+
resourceClient,
|
|
19
|
+
actions = [],
|
|
20
|
+
position = 'bottom-start',
|
|
21
|
+
children,
|
|
22
|
+
testId,
|
|
23
|
+
addFlag,
|
|
24
|
+
onReportingLinesClick
|
|
25
|
+
}) {
|
|
26
|
+
const {
|
|
27
|
+
createAnalyticsEvent
|
|
28
|
+
} = useAnalyticsEvents();
|
|
29
|
+
const {
|
|
30
|
+
formatMessage
|
|
31
|
+
} = useIntl();
|
|
32
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
33
|
+
const showDelay = trigger === 'click' ? 0 : DELAY_MS_SHOW;
|
|
34
|
+
const hideDelay = trigger === 'click' ? 0 : DELAY_MS_HIDE;
|
|
35
|
+
const [showTimer, setShowTimer] = useState(0);
|
|
36
|
+
const [hideTimer, setHideTimer] = useState(0);
|
|
37
|
+
const [visible, setVisible] = useState(false);
|
|
38
|
+
const [isLoading, setIsLoading] = useState(undefined);
|
|
39
|
+
const [hasError, setHasError] = useState(false);
|
|
40
|
+
const [error, setError] = useState(null);
|
|
41
|
+
const [data, setData] = useState(null);
|
|
42
|
+
const [reportingLinesData, setReportingLinesData] = useState(undefined);
|
|
43
|
+
const [shouldShowGiveKudos, setShouldShowGiveKudos] = useState(false);
|
|
44
|
+
const [teamCentralBaseUrl, setTeamCentralBaseUrl] = useState(undefined);
|
|
45
|
+
const [kudosDrawerOpen, setKudosDrawerOpen] = useState(false);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
setIsMounted(true);
|
|
48
|
+
return () => {
|
|
49
|
+
setIsMounted(false);
|
|
50
|
+
clearTimeout(showTimer);
|
|
51
|
+
clearTimeout(hideTimer);
|
|
52
|
+
};
|
|
53
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
+
}, []);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
// Reset state when the userId changes
|
|
57
|
+
setIsLoading(undefined);
|
|
58
|
+
setHasError(false);
|
|
59
|
+
setError(null);
|
|
60
|
+
setData(null);
|
|
61
|
+
setReportingLinesData(undefined);
|
|
62
|
+
setShouldShowGiveKudos(false);
|
|
63
|
+
setTeamCentralBaseUrl(undefined);
|
|
64
|
+
}, [userId]);
|
|
65
|
+
const fireAnalytics = useCallback(payload => {
|
|
66
|
+
// Don't fire any analytics if the component is unmounted
|
|
67
|
+
if (!isMounted) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
fireEvent(createAnalyticsEvent, payload);
|
|
71
|
+
}, [createAnalyticsEvent, isMounted]);
|
|
72
|
+
const hideProfilecard = useCallback(() => {
|
|
73
|
+
clearTimeout(showTimer);
|
|
74
|
+
clearTimeout(hideTimer);
|
|
75
|
+
setHideTimer(window.setTimeout(() => {
|
|
76
|
+
setVisible(false);
|
|
77
|
+
}, hideDelay));
|
|
78
|
+
}, [hideDelay, hideTimer, showTimer]);
|
|
79
|
+
const handleClientSuccess = useCallback((profileData, reportingLinesData, shouldShowGiveKudos) => {
|
|
80
|
+
if (!isMounted) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
setIsLoading(false);
|
|
84
|
+
setHasError(false);
|
|
85
|
+
setData(profileData);
|
|
86
|
+
setReportingLinesData(reportingLinesData);
|
|
87
|
+
setShouldShowGiveKudos(shouldShowGiveKudos);
|
|
88
|
+
}, [isMounted, setHasError, setIsLoading, setData, setReportingLinesData, setShouldShowGiveKudos]);
|
|
89
|
+
const handleClientError = useCallback(err => {
|
|
90
|
+
if (!isMounted) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
setIsLoading(false);
|
|
94
|
+
setHasError(true);
|
|
95
|
+
setError(err);
|
|
96
|
+
}, [isMounted, setHasError, setIsLoading, setError]);
|
|
97
|
+
const clientFetchProfile = useCallback(async () => {
|
|
98
|
+
if (isLoading === true) {
|
|
99
|
+
// don't fetch data when fetching is in process
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
setTeamCentralBaseUrl(resourceClient.getTeamCentralBaseUrl());
|
|
103
|
+
setIsLoading(true);
|
|
104
|
+
setHasError(false);
|
|
105
|
+
setError(null);
|
|
106
|
+
setData(null);
|
|
107
|
+
try {
|
|
108
|
+
const requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos()]);
|
|
109
|
+
const responses = await requests;
|
|
110
|
+
handleClientSuccess(...responses);
|
|
111
|
+
} catch (err) {
|
|
112
|
+
handleClientError(err);
|
|
113
|
+
}
|
|
114
|
+
}, [cloudId, fireAnalytics, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
|
|
115
|
+
const showProfilecard = useCallback(() => {
|
|
116
|
+
clearTimeout(hideTimer);
|
|
117
|
+
clearTimeout(showTimer);
|
|
118
|
+
setShowTimer(window.setTimeout(() => {
|
|
119
|
+
if (!visible) {
|
|
120
|
+
void clientFetchProfile();
|
|
121
|
+
setVisible(true);
|
|
122
|
+
}
|
|
123
|
+
}, showDelay));
|
|
124
|
+
}, [hideTimer, showDelay, showTimer, visible, clientFetchProfile]);
|
|
125
|
+
const onClick = useCallback(event => {
|
|
126
|
+
// If the user clicks on the trigger then we don't want that click event to
|
|
127
|
+
// propagate out to parent containers. For example when clicking a mention
|
|
128
|
+
// lozenge in an inline-edit.
|
|
129
|
+
event.stopPropagation();
|
|
130
|
+
showProfilecard();
|
|
131
|
+
if (!visible) {
|
|
132
|
+
fireAnalytics(cardTriggered('user', 'click'));
|
|
133
|
+
}
|
|
134
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
135
|
+
const onMouseEnter = useCallback(() => {
|
|
136
|
+
showProfilecard();
|
|
137
|
+
if (!visible) {
|
|
138
|
+
fireAnalytics(cardTriggered('user', 'hover'));
|
|
139
|
+
}
|
|
140
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
141
|
+
const onKeyPress = useCallback(event => {
|
|
142
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
showProfilecard();
|
|
145
|
+
if (!visible) {
|
|
146
|
+
fireAnalytics(cardTriggered('user', 'click'));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
150
|
+
const onFocus = useCallback(() => {
|
|
151
|
+
showProfilecard();
|
|
152
|
+
}, [showProfilecard]);
|
|
153
|
+
const containerListeners = useMemo(() => trigger === 'hover' ? {
|
|
154
|
+
onMouseEnter: onMouseEnter,
|
|
155
|
+
onMouseLeave: hideProfilecard,
|
|
156
|
+
onBlur: hideProfilecard,
|
|
157
|
+
onKeyPress: onKeyPress
|
|
158
|
+
} : {
|
|
159
|
+
onClick: onClick,
|
|
160
|
+
onKeyPress: onKeyPress
|
|
161
|
+
}, [hideProfilecard, onClick, onKeyPress, onMouseEnter, trigger]);
|
|
162
|
+
const filterActions = useCallback(() => {
|
|
163
|
+
return filterActionsInner(actions, data);
|
|
164
|
+
}, [actions, data]);
|
|
165
|
+
const openKudosDrawer = () => {
|
|
166
|
+
hideProfilecard();
|
|
167
|
+
setKudosDrawerOpen(true);
|
|
168
|
+
};
|
|
169
|
+
const closeKudosDrawer = () => {
|
|
170
|
+
setKudosDrawerOpen(false);
|
|
171
|
+
};
|
|
172
|
+
const showLoading = isLoading === true || isLoading === undefined;
|
|
173
|
+
const wrapperProps = useMemo(() => trigger === 'hover' ? {
|
|
174
|
+
onMouseEnter: onMouseEnter,
|
|
175
|
+
onMouseLeave: hideProfilecard,
|
|
176
|
+
onFocus: onFocus
|
|
177
|
+
} : {}, [hideProfilecard, onFocus, onMouseEnter, trigger]);
|
|
178
|
+
const profilecardProps = {
|
|
179
|
+
userId: userId,
|
|
180
|
+
isCurrentUser: data === null || data === void 0 ? void 0 : data.isCurrentUser,
|
|
181
|
+
clientFetchProfile: clientFetchProfile,
|
|
182
|
+
...data,
|
|
183
|
+
reportingLines: reportingLinesData,
|
|
184
|
+
onReportingLinesClick: onReportingLinesClick,
|
|
185
|
+
isKudosEnabled: shouldShowGiveKudos,
|
|
186
|
+
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
187
|
+
cloudId: cloudId,
|
|
188
|
+
openKudosDrawer: openKudosDrawer
|
|
189
|
+
};
|
|
190
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Popup, {
|
|
191
|
+
isOpen: !!visible,
|
|
192
|
+
onClose: hideProfilecard,
|
|
193
|
+
placement: position,
|
|
194
|
+
content: () => showLoading ? /*#__PURE__*/React.createElement(LoadingView, {
|
|
195
|
+
fireAnalytics: fireAnalytics
|
|
196
|
+
}) : /*#__PURE__*/React.createElement("div", wrapperProps, visible && /*#__PURE__*/React.createElement(Suspense, {
|
|
197
|
+
fallback: null
|
|
198
|
+
}, /*#__PURE__*/React.createElement(ProfileCardLazy, _extends({}, profilecardProps, {
|
|
199
|
+
actions: filterActions(),
|
|
200
|
+
hasError: hasError,
|
|
201
|
+
errorType: error,
|
|
202
|
+
withoutElevation: true
|
|
203
|
+
})))),
|
|
204
|
+
trigger: triggerProps => {
|
|
205
|
+
const {
|
|
206
|
+
ref,
|
|
207
|
+
...innerProps
|
|
208
|
+
} = triggerProps;
|
|
209
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, innerProps, containerListeners, {
|
|
210
|
+
ref: ref,
|
|
211
|
+
"data-testid": testId,
|
|
212
|
+
role: "button",
|
|
213
|
+
tabIndex: 0,
|
|
214
|
+
"aria-label": formatMessage({
|
|
215
|
+
id: 'profilecard.user.trigger.aria-label',
|
|
216
|
+
defaultMessage: 'More information about {fullName}',
|
|
217
|
+
description: 'Label for profile card trigger'
|
|
218
|
+
}, {
|
|
219
|
+
fullName: profilecardProps.fullName
|
|
220
|
+
})
|
|
221
|
+
}), children);
|
|
222
|
+
},
|
|
223
|
+
zIndex: layers.modal(),
|
|
224
|
+
shouldUseCaptureOnOutsideClick: true,
|
|
225
|
+
autoFocus: trigger === 'click'
|
|
226
|
+
}), shouldShowGiveKudos && /*#__PURE__*/React.createElement(Suspense, {
|
|
227
|
+
fallback: null
|
|
228
|
+
}, /*#__PURE__*/React.createElement(GiveKudosLauncherLazy, {
|
|
229
|
+
isOpen: kudosDrawerOpen,
|
|
230
|
+
recipient: {
|
|
231
|
+
type: KudosType.INDIVIDUAL,
|
|
232
|
+
recipientId: userId
|
|
233
|
+
},
|
|
234
|
+
analyticsSource: "profile-card",
|
|
235
|
+
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
236
|
+
cloudId: cloudId,
|
|
237
|
+
addFlag: addFlag,
|
|
238
|
+
onClose: closeKudosDrawer
|
|
239
|
+
})));
|
|
240
|
+
}
|
|
241
|
+
const LoadingView = ({
|
|
242
|
+
fireAnalytics
|
|
243
|
+
}) => /*#__PURE__*/React.createElement(CardWrapper, {
|
|
244
|
+
"data-testId": "profilecard.profilecardtrigger.loading"
|
|
245
|
+
}, /*#__PURE__*/React.createElement(UserLoadingState, {
|
|
246
|
+
fireAnalytics: fireAnalytics
|
|
247
|
+
}));
|
|
@@ -127,7 +127,7 @@ export const DisabledInfo = styled.div`
|
|
|
127
127
|
font-size: ${fontSizeSmall}px;
|
|
128
128
|
color: ${labelTextColor};
|
|
129
129
|
margin: ${"var(--ds-space-150, 12px)"} 0 0 0;
|
|
130
|
-
line-height:
|
|
130
|
+
line-height: 16px;
|
|
131
131
|
`;
|
|
132
132
|
export const FullNameLabel = styled.h2`
|
|
133
133
|
overflow: hidden;
|
|
@@ -215,7 +215,7 @@ export const CardContainer = styled.div`
|
|
|
215
215
|
export const DetailsLabel = styled.div`
|
|
216
216
|
display: flex;
|
|
217
217
|
align-items: center;
|
|
218
|
-
line-height:
|
|
218
|
+
line-height: 24px;
|
|
219
219
|
font-size: ${gridSize() * 1.5}px;
|
|
220
220
|
margin: ${"var(--ds-space-200, 16px)"} 0 0 0;
|
|
221
221
|
white-space: nowrap;
|
|
@@ -31,7 +31,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
|
|
|
31
31
|
actionSubjectId,
|
|
32
32
|
attributes: {
|
|
33
33
|
packageName: "@atlaskit/profilecard",
|
|
34
|
-
packageVersion: "19.
|
|
34
|
+
packageVersion: "19.8.0",
|
|
35
35
|
...attributes,
|
|
36
36
|
firedAt: Math.round(getPageTime())
|
|
37
37
|
}
|
|
@@ -48,7 +48,7 @@ export var addHeaders = function addHeaders(headers) {
|
|
|
48
48
|
headers.append('X-ExperimentalApi', 'teams-beta');
|
|
49
49
|
headers.append('X-ExperimentalApi', 'team-members-beta');
|
|
50
50
|
headers.append('atl-client-name', "@atlaskit/profilecard");
|
|
51
|
-
headers.append('atl-client-version', "19.
|
|
51
|
+
headers.append('atl-client-version', "19.8.0");
|
|
52
52
|
return headers;
|
|
53
53
|
};
|
|
54
54
|
export function getTeamFromAGG(_x, _x2, _x3) {
|
|
@@ -152,7 +152,8 @@ var Actions = function Actions(_ref) {
|
|
|
152
152
|
}, regularActions.map(function (action, index) {
|
|
153
153
|
var isKudos = action.id === GIVE_KUDOS_ACTION_ID;
|
|
154
154
|
var button = /*#__PURE__*/React.createElement(FocusRing, {
|
|
155
|
-
isInset: true
|
|
155
|
+
isInset: true,
|
|
156
|
+
key: "profile-card-action-focus-ring_".concat(action.id || index)
|
|
156
157
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
157
158
|
appearance: "default",
|
|
158
159
|
key: action.id || index,
|
|
@@ -165,7 +166,9 @@ var Actions = function Actions(_ref) {
|
|
|
165
166
|
href: action.link
|
|
166
167
|
}, action.label, isKudos && /*#__PURE__*/React.createElement(AnimationWrapper, null, /*#__PURE__*/React.createElement(KudosBlobAnimation, null))));
|
|
167
168
|
if (isKudos) {
|
|
168
|
-
return /*#__PURE__*/React.createElement(AnimatedKudosButton,
|
|
169
|
+
return /*#__PURE__*/React.createElement(AnimatedKudosButton, {
|
|
170
|
+
key: "profile-card-action-kudos_".concat(action.id || index)
|
|
171
|
+
}, button);
|
|
169
172
|
}
|
|
170
173
|
return button;
|
|
171
174
|
}), overflowActions && /*#__PURE__*/React.createElement(OverflowProfileCardButtons, {
|
|
@@ -16,6 +16,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
16
16
|
import React, { Suspense } from 'react';
|
|
17
17
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
18
18
|
import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
|
|
19
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
19
20
|
import Popup from '@atlaskit/popup';
|
|
20
21
|
import { layers } from '@atlaskit/theme/constants';
|
|
21
22
|
import _filterActions from '../../internal/filterActions';
|
|
@@ -23,6 +24,7 @@ import { CardWrapper } from '../../styled/Card';
|
|
|
23
24
|
import { cardTriggered, fireEvent } from '../../util/analytics';
|
|
24
25
|
import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
|
|
25
26
|
import { ProfileCardLazy } from './lazyProfileCard';
|
|
27
|
+
import ProfilecardTriggerNext from './ProfileCardTriggerNext';
|
|
26
28
|
import UserLoadingState from './UserLoadingState';
|
|
27
29
|
var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
28
30
|
_inherits(ProfilecardTrigger, _React$PureComponent);
|
|
@@ -315,4 +317,7 @@ _defineProperty(ProfilecardTrigger, "defaultProps", {
|
|
|
315
317
|
trigger: 'hover',
|
|
316
318
|
position: 'bottom-start'
|
|
317
319
|
});
|
|
318
|
-
|
|
320
|
+
var ProfilecardTriggerLegacy = withAnalyticsEvents()(ProfilecardTrigger);
|
|
321
|
+
export default function ProfilecardTriggerSwitch(props) {
|
|
322
|
+
return getBooleanFF('platform.profile-card-trigger-next') ? /*#__PURE__*/React.createElement(ProfilecardTriggerNext, props) : /*#__PURE__*/React.createElement(ProfilecardTriggerLegacy, props);
|
|
323
|
+
}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
|
+
import React, { Suspense, useCallback, useEffect, useMemo, useState } from 'react';
|
|
12
|
+
import { useIntl } from 'react-intl-next';
|
|
13
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
14
|
+
import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
|
|
15
|
+
import Popup from '@atlaskit/popup';
|
|
16
|
+
import { layers } from '@atlaskit/theme/constants';
|
|
17
|
+
import filterActionsInner from '../../internal/filterActions';
|
|
18
|
+
import { CardWrapper } from '../../styled/Card';
|
|
19
|
+
import { cardTriggered, fireEvent } from '../../util/analytics';
|
|
20
|
+
import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
|
|
21
|
+
import { ProfileCardLazy } from './lazyProfileCard';
|
|
22
|
+
import UserLoadingState from './UserLoadingState';
|
|
23
|
+
export default function ProfilecardTriggerNext(_ref) {
|
|
24
|
+
var _ref$trigger = _ref.trigger,
|
|
25
|
+
trigger = _ref$trigger === void 0 ? 'hover' : _ref$trigger,
|
|
26
|
+
userId = _ref.userId,
|
|
27
|
+
cloudId = _ref.cloudId,
|
|
28
|
+
resourceClient = _ref.resourceClient,
|
|
29
|
+
_ref$actions = _ref.actions,
|
|
30
|
+
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
31
|
+
_ref$position = _ref.position,
|
|
32
|
+
position = _ref$position === void 0 ? 'bottom-start' : _ref$position,
|
|
33
|
+
children = _ref.children,
|
|
34
|
+
testId = _ref.testId,
|
|
35
|
+
addFlag = _ref.addFlag,
|
|
36
|
+
onReportingLinesClick = _ref.onReportingLinesClick;
|
|
37
|
+
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
38
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
39
|
+
var _useIntl = useIntl(),
|
|
40
|
+
formatMessage = _useIntl.formatMessage;
|
|
41
|
+
var _useState = useState(false),
|
|
42
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
43
|
+
isMounted = _useState2[0],
|
|
44
|
+
setIsMounted = _useState2[1];
|
|
45
|
+
var showDelay = trigger === 'click' ? 0 : DELAY_MS_SHOW;
|
|
46
|
+
var hideDelay = trigger === 'click' ? 0 : DELAY_MS_HIDE;
|
|
47
|
+
var _useState3 = useState(0),
|
|
48
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
49
|
+
showTimer = _useState4[0],
|
|
50
|
+
setShowTimer = _useState4[1];
|
|
51
|
+
var _useState5 = useState(0),
|
|
52
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
53
|
+
hideTimer = _useState6[0],
|
|
54
|
+
setHideTimer = _useState6[1];
|
|
55
|
+
var _useState7 = useState(false),
|
|
56
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
57
|
+
visible = _useState8[0],
|
|
58
|
+
setVisible = _useState8[1];
|
|
59
|
+
var _useState9 = useState(undefined),
|
|
60
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
61
|
+
isLoading = _useState10[0],
|
|
62
|
+
setIsLoading = _useState10[1];
|
|
63
|
+
var _useState11 = useState(false),
|
|
64
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
65
|
+
hasError = _useState12[0],
|
|
66
|
+
setHasError = _useState12[1];
|
|
67
|
+
var _useState13 = useState(null),
|
|
68
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
69
|
+
error = _useState14[0],
|
|
70
|
+
setError = _useState14[1];
|
|
71
|
+
var _useState15 = useState(null),
|
|
72
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
73
|
+
data = _useState16[0],
|
|
74
|
+
setData = _useState16[1];
|
|
75
|
+
var _useState17 = useState(undefined),
|
|
76
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
77
|
+
reportingLinesData = _useState18[0],
|
|
78
|
+
setReportingLinesData = _useState18[1];
|
|
79
|
+
var _useState19 = useState(false),
|
|
80
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
81
|
+
shouldShowGiveKudos = _useState20[0],
|
|
82
|
+
setShouldShowGiveKudos = _useState20[1];
|
|
83
|
+
var _useState21 = useState(undefined),
|
|
84
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
85
|
+
teamCentralBaseUrl = _useState22[0],
|
|
86
|
+
setTeamCentralBaseUrl = _useState22[1];
|
|
87
|
+
var _useState23 = useState(false),
|
|
88
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
89
|
+
kudosDrawerOpen = _useState24[0],
|
|
90
|
+
setKudosDrawerOpen = _useState24[1];
|
|
91
|
+
useEffect(function () {
|
|
92
|
+
setIsMounted(true);
|
|
93
|
+
return function () {
|
|
94
|
+
setIsMounted(false);
|
|
95
|
+
clearTimeout(showTimer);
|
|
96
|
+
clearTimeout(hideTimer);
|
|
97
|
+
};
|
|
98
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
99
|
+
}, []);
|
|
100
|
+
useEffect(function () {
|
|
101
|
+
// Reset state when the userId changes
|
|
102
|
+
setIsLoading(undefined);
|
|
103
|
+
setHasError(false);
|
|
104
|
+
setError(null);
|
|
105
|
+
setData(null);
|
|
106
|
+
setReportingLinesData(undefined);
|
|
107
|
+
setShouldShowGiveKudos(false);
|
|
108
|
+
setTeamCentralBaseUrl(undefined);
|
|
109
|
+
}, [userId]);
|
|
110
|
+
var fireAnalytics = useCallback(function (payload) {
|
|
111
|
+
// Don't fire any analytics if the component is unmounted
|
|
112
|
+
if (!isMounted) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
fireEvent(createAnalyticsEvent, payload);
|
|
116
|
+
}, [createAnalyticsEvent, isMounted]);
|
|
117
|
+
var hideProfilecard = useCallback(function () {
|
|
118
|
+
clearTimeout(showTimer);
|
|
119
|
+
clearTimeout(hideTimer);
|
|
120
|
+
setHideTimer(window.setTimeout(function () {
|
|
121
|
+
setVisible(false);
|
|
122
|
+
}, hideDelay));
|
|
123
|
+
}, [hideDelay, hideTimer, showTimer]);
|
|
124
|
+
var handleClientSuccess = useCallback(function (profileData, reportingLinesData, shouldShowGiveKudos) {
|
|
125
|
+
if (!isMounted) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
setIsLoading(false);
|
|
129
|
+
setHasError(false);
|
|
130
|
+
setData(profileData);
|
|
131
|
+
setReportingLinesData(reportingLinesData);
|
|
132
|
+
setShouldShowGiveKudos(shouldShowGiveKudos);
|
|
133
|
+
}, [isMounted, setHasError, setIsLoading, setData, setReportingLinesData, setShouldShowGiveKudos]);
|
|
134
|
+
var handleClientError = useCallback(function (err) {
|
|
135
|
+
if (!isMounted) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
setIsLoading(false);
|
|
139
|
+
setHasError(true);
|
|
140
|
+
setError(err);
|
|
141
|
+
}, [isMounted, setHasError, setIsLoading, setError]);
|
|
142
|
+
var clientFetchProfile = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
143
|
+
var requests, responses;
|
|
144
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
145
|
+
while (1) switch (_context.prev = _context.next) {
|
|
146
|
+
case 0:
|
|
147
|
+
if (!(isLoading === true)) {
|
|
148
|
+
_context.next = 2;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
return _context.abrupt("return");
|
|
152
|
+
case 2:
|
|
153
|
+
setTeamCentralBaseUrl(resourceClient.getTeamCentralBaseUrl());
|
|
154
|
+
setIsLoading(true);
|
|
155
|
+
setHasError(false);
|
|
156
|
+
setError(null);
|
|
157
|
+
setData(null);
|
|
158
|
+
_context.prev = 7;
|
|
159
|
+
requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos()]);
|
|
160
|
+
_context.next = 11;
|
|
161
|
+
return requests;
|
|
162
|
+
case 11:
|
|
163
|
+
responses = _context.sent;
|
|
164
|
+
handleClientSuccess.apply(void 0, _toConsumableArray(responses));
|
|
165
|
+
_context.next = 18;
|
|
166
|
+
break;
|
|
167
|
+
case 15:
|
|
168
|
+
_context.prev = 15;
|
|
169
|
+
_context.t0 = _context["catch"](7);
|
|
170
|
+
handleClientError(_context.t0);
|
|
171
|
+
case 18:
|
|
172
|
+
case "end":
|
|
173
|
+
return _context.stop();
|
|
174
|
+
}
|
|
175
|
+
}, _callee, null, [[7, 15]]);
|
|
176
|
+
})), [cloudId, fireAnalytics, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
|
|
177
|
+
var showProfilecard = useCallback(function () {
|
|
178
|
+
clearTimeout(hideTimer);
|
|
179
|
+
clearTimeout(showTimer);
|
|
180
|
+
setShowTimer(window.setTimeout(function () {
|
|
181
|
+
if (!visible) {
|
|
182
|
+
void clientFetchProfile();
|
|
183
|
+
setVisible(true);
|
|
184
|
+
}
|
|
185
|
+
}, showDelay));
|
|
186
|
+
}, [hideTimer, showDelay, showTimer, visible, clientFetchProfile]);
|
|
187
|
+
var onClick = useCallback(function (event) {
|
|
188
|
+
// If the user clicks on the trigger then we don't want that click event to
|
|
189
|
+
// propagate out to parent containers. For example when clicking a mention
|
|
190
|
+
// lozenge in an inline-edit.
|
|
191
|
+
event.stopPropagation();
|
|
192
|
+
showProfilecard();
|
|
193
|
+
if (!visible) {
|
|
194
|
+
fireAnalytics(cardTriggered('user', 'click'));
|
|
195
|
+
}
|
|
196
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
197
|
+
var onMouseEnter = useCallback(function () {
|
|
198
|
+
showProfilecard();
|
|
199
|
+
if (!visible) {
|
|
200
|
+
fireAnalytics(cardTriggered('user', 'hover'));
|
|
201
|
+
}
|
|
202
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
203
|
+
var onKeyPress = useCallback(function (event) {
|
|
204
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
205
|
+
event.preventDefault();
|
|
206
|
+
showProfilecard();
|
|
207
|
+
if (!visible) {
|
|
208
|
+
fireAnalytics(cardTriggered('user', 'click'));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
212
|
+
var onFocus = useCallback(function () {
|
|
213
|
+
showProfilecard();
|
|
214
|
+
}, [showProfilecard]);
|
|
215
|
+
var containerListeners = useMemo(function () {
|
|
216
|
+
return trigger === 'hover' ? {
|
|
217
|
+
onMouseEnter: onMouseEnter,
|
|
218
|
+
onMouseLeave: hideProfilecard,
|
|
219
|
+
onBlur: hideProfilecard,
|
|
220
|
+
onKeyPress: onKeyPress
|
|
221
|
+
} : {
|
|
222
|
+
onClick: onClick,
|
|
223
|
+
onKeyPress: onKeyPress
|
|
224
|
+
};
|
|
225
|
+
}, [hideProfilecard, onClick, onKeyPress, onMouseEnter, trigger]);
|
|
226
|
+
var filterActions = useCallback(function () {
|
|
227
|
+
return filterActionsInner(actions, data);
|
|
228
|
+
}, [actions, data]);
|
|
229
|
+
var openKudosDrawer = function openKudosDrawer() {
|
|
230
|
+
hideProfilecard();
|
|
231
|
+
setKudosDrawerOpen(true);
|
|
232
|
+
};
|
|
233
|
+
var closeKudosDrawer = function closeKudosDrawer() {
|
|
234
|
+
setKudosDrawerOpen(false);
|
|
235
|
+
};
|
|
236
|
+
var showLoading = isLoading === true || isLoading === undefined;
|
|
237
|
+
var wrapperProps = useMemo(function () {
|
|
238
|
+
return trigger === 'hover' ? {
|
|
239
|
+
onMouseEnter: onMouseEnter,
|
|
240
|
+
onMouseLeave: hideProfilecard,
|
|
241
|
+
onFocus: onFocus
|
|
242
|
+
} : {};
|
|
243
|
+
}, [hideProfilecard, onFocus, onMouseEnter, trigger]);
|
|
244
|
+
var profilecardProps = _objectSpread(_objectSpread({
|
|
245
|
+
userId: userId,
|
|
246
|
+
isCurrentUser: data === null || data === void 0 ? void 0 : data.isCurrentUser,
|
|
247
|
+
clientFetchProfile: clientFetchProfile
|
|
248
|
+
}, data), {}, {
|
|
249
|
+
reportingLines: reportingLinesData,
|
|
250
|
+
onReportingLinesClick: onReportingLinesClick,
|
|
251
|
+
isKudosEnabled: shouldShowGiveKudos,
|
|
252
|
+
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
253
|
+
cloudId: cloudId,
|
|
254
|
+
openKudosDrawer: openKudosDrawer
|
|
255
|
+
});
|
|
256
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Popup, {
|
|
257
|
+
isOpen: !!visible,
|
|
258
|
+
onClose: hideProfilecard,
|
|
259
|
+
placement: position,
|
|
260
|
+
content: function content() {
|
|
261
|
+
return showLoading ? /*#__PURE__*/React.createElement(LoadingView, {
|
|
262
|
+
fireAnalytics: fireAnalytics
|
|
263
|
+
}) : /*#__PURE__*/React.createElement("div", wrapperProps, visible && /*#__PURE__*/React.createElement(Suspense, {
|
|
264
|
+
fallback: null
|
|
265
|
+
}, /*#__PURE__*/React.createElement(ProfileCardLazy, _extends({}, profilecardProps, {
|
|
266
|
+
actions: filterActions(),
|
|
267
|
+
hasError: hasError,
|
|
268
|
+
errorType: error,
|
|
269
|
+
withoutElevation: true
|
|
270
|
+
}))));
|
|
271
|
+
},
|
|
272
|
+
trigger: function trigger(triggerProps) {
|
|
273
|
+
var ref = triggerProps.ref,
|
|
274
|
+
innerProps = _objectWithoutProperties(triggerProps, _excluded);
|
|
275
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, innerProps, containerListeners, {
|
|
276
|
+
ref: ref,
|
|
277
|
+
"data-testid": testId,
|
|
278
|
+
role: "button",
|
|
279
|
+
tabIndex: 0,
|
|
280
|
+
"aria-label": formatMessage({
|
|
281
|
+
id: 'profilecard.user.trigger.aria-label',
|
|
282
|
+
defaultMessage: 'More information about {fullName}',
|
|
283
|
+
description: 'Label for profile card trigger'
|
|
284
|
+
}, {
|
|
285
|
+
fullName: profilecardProps.fullName
|
|
286
|
+
})
|
|
287
|
+
}), children);
|
|
288
|
+
},
|
|
289
|
+
zIndex: layers.modal(),
|
|
290
|
+
shouldUseCaptureOnOutsideClick: true,
|
|
291
|
+
autoFocus: trigger === 'click'
|
|
292
|
+
}), shouldShowGiveKudos && /*#__PURE__*/React.createElement(Suspense, {
|
|
293
|
+
fallback: null
|
|
294
|
+
}, /*#__PURE__*/React.createElement(GiveKudosLauncherLazy, {
|
|
295
|
+
isOpen: kudosDrawerOpen,
|
|
296
|
+
recipient: {
|
|
297
|
+
type: KudosType.INDIVIDUAL,
|
|
298
|
+
recipientId: userId
|
|
299
|
+
},
|
|
300
|
+
analyticsSource: "profile-card",
|
|
301
|
+
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
302
|
+
cloudId: cloudId,
|
|
303
|
+
addFlag: addFlag,
|
|
304
|
+
onClose: closeKudosDrawer
|
|
305
|
+
})));
|
|
306
|
+
}
|
|
307
|
+
var LoadingView = function LoadingView(_ref3) {
|
|
308
|
+
var fireAnalytics = _ref3.fireAnalytics;
|
|
309
|
+
return /*#__PURE__*/React.createElement(CardWrapper, {
|
|
310
|
+
"data-testId": "profilecard.profilecardtrigger.loading"
|
|
311
|
+
}, /*#__PURE__*/React.createElement(UserLoadingState, {
|
|
312
|
+
fireAnalytics: fireAnalytics
|
|
313
|
+
}));
|
|
314
|
+
};
|
package/dist/esm/styled/Card.js
CHANGED
|
@@ -28,7 +28,7 @@ export var CardContent = styled.div(_templateObject10 || (_templateObject10 = _t
|
|
|
28
28
|
|
|
29
29
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
30
30
|
export var DetailsGroup = styled.div(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n margin-left: ", "px;\n width: ", "px;\n"])), gridSize() * 14.5, gridSize() * 24.5);
|
|
31
|
-
export var DisabledInfo = styled.div(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n font-size: ", "px;\n color: ", ";\n margin: ", " 0 0 0;\n line-height:
|
|
31
|
+
export var DisabledInfo = styled.div(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n font-size: ", "px;\n color: ", ";\n margin: ", " 0 0 0;\n line-height: 16px;\n"])), fontSizeSmall, labelTextColor, "var(--ds-space-150, 12px)");
|
|
32
32
|
export var FullNameLabel = styled.h2(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n font-size: 18px;\n font-weight: 400;\n letter-spacing: normal;\n color: ", ";\n margin: ", ";\n line-height: ", "em;\n :first-child {\n margin: ", ";\n }\n"])), function (props) {
|
|
33
33
|
return props.isDisabledAccount ? headerTextColorInactive : headerTextColor;
|
|
34
34
|
}, function (props) {
|
|
@@ -50,6 +50,6 @@ export var CardContainer = styled.div(_templateObject19 || (_templateObject19 =
|
|
|
50
50
|
}, function (props) {
|
|
51
51
|
return props.withoutElevation ? '' : "".concat(borderRadius(), "px");
|
|
52
52
|
});
|
|
53
|
-
export var DetailsLabel = styled.div(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n line-height:
|
|
53
|
+
export var DetailsLabel = styled.div(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n line-height: 24px;\n font-size: ", "px;\n margin: ", " 0 0 0;\n white-space: nowrap;\n\n & + & {\n margin-top: ", ";\n }\n"])), gridSize() * 1.5, "var(--ds-space-200, 16px)", "var(--ds-space-025, 2px)");
|
|
54
54
|
export var DetailsLabelIcon = styled.div(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["\n display: flex;\n flex-shrink: 0;\n color: ", ";\n width: ", ";\n height: ", ";\n padding: ", ";\n vertical-align: top;\n\n svg {\n width: 100%;\n height: 100%;\n }\n"])), labelIconColor, "var(--ds-space-200, 16px)", "var(--ds-space-200, 16px)", "var(--ds-space-050, 4px)");
|
|
55
55
|
export var DetailsLabelText = styled.span(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n color: ", ";\n padding-left: ", ";\n"])), labelTextColor, "var(--ds-space-050, 4px)");
|
|
@@ -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.
|
|
41
|
+
packageVersion: "19.8.0"
|
|
42
42
|
}, attributes), {}, {
|
|
43
43
|
firedAt: Math.round(getPageTime())
|
|
44
44
|
})
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export default _default;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ProfileCardTriggerProps } from '../../types';
|
|
3
|
+
export default function ProfilecardTriggerSwitch(props: ProfileCardTriggerProps): JSX.Element;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ProfileCardTriggerProps } from '../../types';
|
|
3
|
+
export default function ProfilecardTriggerNext({ trigger, userId, cloudId, resourceClient, actions, position, children, testId, addFlag, onReportingLinesClick, }: ProfileCardTriggerProps): JSX.Element;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -108,7 +108,7 @@ export interface ProfileCardTriggerProps {
|
|
|
108
108
|
onReportingLinesClick?: (user: ReportingLinesUser) => void;
|
|
109
109
|
position?: ProfilecardTriggerPosition;
|
|
110
110
|
trigger?: TriggerType;
|
|
111
|
-
children
|
|
111
|
+
children: React.ReactNode;
|
|
112
112
|
testId?: string;
|
|
113
113
|
addFlag?: (flag: any) => void;
|
|
114
114
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export default _default;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ProfileCardTriggerProps } from '../../types';
|
|
3
|
+
export default function ProfilecardTriggerSwitch(props: ProfileCardTriggerProps): JSX.Element;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ProfileCardTriggerProps } from '../../types';
|
|
3
|
+
export default function ProfilecardTriggerNext({ trigger, userId, cloudId, resourceClient, actions, position, children, testId, addFlag, onReportingLinesClick, }: ProfileCardTriggerProps): JSX.Element;
|
|
@@ -108,7 +108,7 @@ export interface ProfileCardTriggerProps {
|
|
|
108
108
|
onReportingLinesClick?: (user: ReportingLinesUser) => void;
|
|
109
109
|
position?: ProfilecardTriggerPosition;
|
|
110
110
|
trigger?: TriggerType;
|
|
111
|
-
children
|
|
111
|
+
children: React.ReactNode;
|
|
112
112
|
testId?: string;
|
|
113
113
|
addFlag?: (flag: any) => void;
|
|
114
114
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/profilecard",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.8.0",
|
|
4
4
|
"description": "A React component to display a card with user information.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
7
7
|
},
|
|
8
|
-
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
8
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
9
9
|
"author": "Atlassian Pty Ltd",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"main": "dist/cjs/index.js",
|
|
@@ -63,10 +63,11 @@
|
|
|
63
63
|
"@atlaskit/icon": "^22.0.0",
|
|
64
64
|
"@atlaskit/lozenge": "^11.6.0",
|
|
65
65
|
"@atlaskit/menu": "^2.1.0",
|
|
66
|
+
"@atlaskit/platform-feature-flags": "^0.2.4",
|
|
66
67
|
"@atlaskit/popup": "^1.11.0",
|
|
67
68
|
"@atlaskit/spinner": "^16.0.0",
|
|
68
69
|
"@atlaskit/theme": "^12.6.0",
|
|
69
|
-
"@atlaskit/tokens": "^1.
|
|
70
|
+
"@atlaskit/tokens": "^1.35.0",
|
|
70
71
|
"@atlaskit/tooltip": "^18.1.0",
|
|
71
72
|
"@babel/runtime": "^7.0.0",
|
|
72
73
|
"@emotion/react": "^11.7.1",
|
|
@@ -108,5 +109,10 @@
|
|
|
108
109
|
]
|
|
109
110
|
}
|
|
110
111
|
},
|
|
112
|
+
"platform-feature-flags": {
|
|
113
|
+
"platform.profile-card-trigger-next": {
|
|
114
|
+
"type": "boolean"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
111
117
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|
|
112
118
|
}
|