@atlaskit/profilecard 19.16.3 → 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 +16 -0
- package/afm-post-office/tsconfig.json +78 -0
- package/dist/cjs/client/getTeamFromAGG.js +1 -1
- package/dist/cjs/components/Icon/IconLabel.js +7 -6
- package/dist/cjs/components/Team/TeamProfileCard.js +5 -3
- package/dist/cjs/components/User/OverflowProfileCardButtons.js +4 -2
- 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/Icon/IconLabel.js +6 -5
- package/dist/es2019/components/Team/TeamProfileCard.js +4 -2
- package/dist/es2019/components/User/OverflowProfileCardButtons.js +3 -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/Icon/IconLabel.js +6 -5
- package/dist/esm/components/Team/TeamProfileCard.js +4 -2
- package/dist/esm/components/User/OverflowProfileCardButtons.js +3 -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 +7 -10
- 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
|
@@ -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.17.1"
|
|
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.17.1");
|
|
71
71
|
return headers;
|
|
72
72
|
};
|
|
73
73
|
export async function getTeamFromAGG(url, teamId, siteId) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import IconRecent from '@atlaskit/icon/core/migration/clock--recent';
|
|
4
|
+
import IconEmail from '@atlaskit/icon/core/migration/email';
|
|
5
|
+
import IconLocation from '@atlaskit/icon/core/migration/location';
|
|
6
|
+
import OfficeBuildingIcon from '@atlaskit/icon/core/migration/office-building';
|
|
7
7
|
import { DetailsLabel, DetailsLabelIcon, DetailsLabelText } from '../../styled/Card';
|
|
8
8
|
const icons = {
|
|
9
9
|
location: IconLocation,
|
|
@@ -21,7 +21,8 @@ export default class IconLabel extends React.PureComponent {
|
|
|
21
21
|
const IconElement = this.props.icon && icons[this.props.icon];
|
|
22
22
|
const displayIcon = IconElement ? /*#__PURE__*/React.createElement(IconElement, {
|
|
23
23
|
label: `${this.props.icon}`,
|
|
24
|
-
|
|
24
|
+
LEGACY_size: "small",
|
|
25
|
+
color: "currentColor"
|
|
25
26
|
}) : null;
|
|
26
27
|
return /*#__PURE__*/React.createElement(DetailsLabel, null, /*#__PURE__*/React.createElement(DetailsLabelIcon, null, displayIcon), /*#__PURE__*/React.createElement(DetailsLabelText, null, this.props.children));
|
|
27
28
|
}
|
|
@@ -5,7 +5,7 @@ import AvatarGroup from '@atlaskit/avatar-group';
|
|
|
5
5
|
import LoadingButton from '@atlaskit/button/loading-button';
|
|
6
6
|
import Button from '@atlaskit/button/standard-button';
|
|
7
7
|
import FocusRing from '@atlaskit/focus-ring';
|
|
8
|
-
import MoreIcon from '@atlaskit/icon/
|
|
8
|
+
import MoreIcon from '@atlaskit/icon/core/migration/show-more-horizontal--more';
|
|
9
9
|
import { LinkItem, MenuGroup } from '@atlaskit/menu';
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
11
|
import Popup from '@atlaskit/popup';
|
|
@@ -152,7 +152,9 @@ const ExtraActions = ({
|
|
|
152
152
|
isSelected: isOpen,
|
|
153
153
|
onClick: () => onMoreClick(!isOpen),
|
|
154
154
|
iconAfter: /*#__PURE__*/React.createElement(MoreIcon, {
|
|
155
|
-
|
|
155
|
+
spacing: "spacious",
|
|
156
|
+
label: "actions",
|
|
157
|
+
color: "currentColor"
|
|
156
158
|
})
|
|
157
159
|
})),
|
|
158
160
|
zIndex: layers.modal(),
|
|
@@ -3,7 +3,7 @@ import React, { useCallback, useState } from 'react';
|
|
|
3
3
|
import { useIntl } from 'react-intl-next';
|
|
4
4
|
import Button from '@atlaskit/button/custom-theme-button';
|
|
5
5
|
import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
6
|
-
import MoreIcon from '@atlaskit/icon/
|
|
6
|
+
import MoreIcon from '@atlaskit/icon/core/migration/show-more-horizontal--more';
|
|
7
7
|
import messages from '../../messages';
|
|
8
8
|
import { OverflowActionButtonsWrapper } from '../../styled/Card';
|
|
9
9
|
import { moreActionsClicked } from '../../util/analytics';
|
|
@@ -45,6 +45,8 @@ export const OverflowProfileCardButtons = props => {
|
|
|
45
45
|
}, providedProps, {
|
|
46
46
|
ref: triggerRef,
|
|
47
47
|
iconBefore: /*#__PURE__*/React.createElement(MoreIcon, {
|
|
48
|
+
color: "currentColor",
|
|
49
|
+
spacing: "spacious",
|
|
48
50
|
label: intl.formatMessage(messages.profileCardMoreIconLabel)
|
|
49
51
|
})
|
|
50
52
|
}))
|
|
@@ -1,293 +1,284 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import React, { Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl-next';
|
|
4
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
5
5
|
import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
|
|
6
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
6
|
import Popup from '@atlaskit/popup';
|
|
8
7
|
import { layers } from '@atlaskit/theme/constants';
|
|
9
|
-
import
|
|
8
|
+
import filterActionsInner from '../../internal/filterActions';
|
|
9
|
+
import getLabelMessage from '../../internal/getLabelMessage';
|
|
10
10
|
import { CardWrapper } from '../../styled/Card';
|
|
11
11
|
import { cardTriggered, fireEvent } from '../../util/analytics';
|
|
12
12
|
import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
|
|
13
13
|
import { ProfileCardLazy } from './lazyProfileCard';
|
|
14
|
-
import ProfilecardTriggerNext from './ProfileCardTriggerNext';
|
|
15
14
|
import UserLoadingState from './UserLoadingState';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
onKeyPress: this.onKeyPress
|
|
90
|
-
});
|
|
91
|
-
_defineProperty(this, "layerListeners", {
|
|
92
|
-
handleClickOutside: this.hideProfilecard,
|
|
93
|
-
handleEscapeKeydown: this.hideProfilecard
|
|
94
|
-
});
|
|
95
|
-
_defineProperty(this, "state", {
|
|
96
|
-
visible: false,
|
|
97
|
-
isLoading: undefined,
|
|
98
|
-
hasError: false,
|
|
99
|
-
error: null,
|
|
100
|
-
data: null,
|
|
101
|
-
reportingLinesData: undefined,
|
|
102
|
-
shouldShowGiveKudos: false,
|
|
103
|
-
teamCentralBaseUrl: undefined,
|
|
104
|
-
kudosDrawerOpen: false
|
|
105
|
-
});
|
|
106
|
-
_defineProperty(this, "clientFetchProfile", () => {
|
|
107
|
-
const {
|
|
108
|
-
cloudId,
|
|
109
|
-
userId
|
|
110
|
-
} = this.props;
|
|
111
|
-
const {
|
|
112
|
-
isLoading
|
|
113
|
-
} = this.state;
|
|
114
|
-
if (isLoading === true) {
|
|
115
|
-
// don't fetch data when fetching is in process
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
this.setState({
|
|
119
|
-
teamCentralBaseUrl: this.props.resourceClient.getTeamCentralBaseUrl()
|
|
120
|
-
});
|
|
121
|
-
this.setState({
|
|
122
|
-
isLoading: true,
|
|
123
|
-
hasError: false,
|
|
124
|
-
data: null
|
|
125
|
-
}, () => {
|
|
126
|
-
const requests = Promise.all([this.props.resourceClient.getProfile(cloudId || '', userId, this.fireAnalytics), this.props.resourceClient.getReportingLines(userId), this.props.resourceClient.shouldShowGiveKudos()]);
|
|
127
|
-
requests.then(res => this.handleClientSuccess(...res), err => this.handleClientError(err)).catch(err => this.handleClientError(err));
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
_defineProperty(this, "openKudosDrawer", () => {
|
|
131
|
-
this.hideProfilecard();
|
|
132
|
-
this.setState({
|
|
133
|
-
kudosDrawerOpen: true
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
_defineProperty(this, "closeKudosDrawer", () => {
|
|
137
|
-
this.setState({
|
|
138
|
-
kudosDrawerOpen: false
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
_defineProperty(this, "renderCard", () => {
|
|
142
|
-
const {
|
|
143
|
-
isLoading
|
|
144
|
-
} = this.state;
|
|
145
|
-
if (isLoading === true || isLoading === undefined) {
|
|
146
|
-
return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(UserLoadingState, {
|
|
147
|
-
fireAnalytics: this.fireAnalytics
|
|
148
|
-
}));
|
|
149
|
-
} else {
|
|
150
|
-
return this.renderProfileCard();
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
componentDidMount() {
|
|
155
|
-
this._isMounted = true;
|
|
156
|
-
}
|
|
157
|
-
componentDidUpdate(prevProps) {
|
|
158
|
-
const {
|
|
159
|
-
userId,
|
|
160
|
-
cloudId,
|
|
161
|
-
resourceClient
|
|
162
|
-
} = this.props;
|
|
163
|
-
const {
|
|
164
|
-
visible
|
|
165
|
-
} = this.state;
|
|
166
|
-
|
|
167
|
-
// just re-fetching data when the card opens
|
|
168
|
-
if (visible && (userId !== prevProps.userId || cloudId !== prevProps.cloudId || resourceClient !== prevProps.resourceClient)) {
|
|
169
|
-
this.setState({
|
|
170
|
-
isLoading: undefined
|
|
171
|
-
}, this.clientFetchProfile);
|
|
15
|
+
export default function ProfilecardTriggerNext({
|
|
16
|
+
autoFocus,
|
|
17
|
+
trigger = 'hover',
|
|
18
|
+
userId,
|
|
19
|
+
cloudId,
|
|
20
|
+
resourceClient,
|
|
21
|
+
actions = [],
|
|
22
|
+
position = 'bottom-start',
|
|
23
|
+
children,
|
|
24
|
+
testId,
|
|
25
|
+
addFlag,
|
|
26
|
+
onReportingLinesClick,
|
|
27
|
+
ariaLabel,
|
|
28
|
+
ariaLabelledBy,
|
|
29
|
+
prepopulatedData,
|
|
30
|
+
disabledAriaAttributes,
|
|
31
|
+
onVisibilityChange
|
|
32
|
+
}) {
|
|
33
|
+
const {
|
|
34
|
+
createAnalyticsEvent
|
|
35
|
+
} = useAnalyticsEvents();
|
|
36
|
+
const {
|
|
37
|
+
formatMessage
|
|
38
|
+
} = useIntl();
|
|
39
|
+
const isMounted = useRef(false);
|
|
40
|
+
const showDelay = trigger === 'click' ? 0 : DELAY_MS_SHOW;
|
|
41
|
+
const hideDelay = trigger === 'click' ? 0 : DELAY_MS_HIDE;
|
|
42
|
+
const showTimer = useRef(0);
|
|
43
|
+
const hideTimer = useRef(0);
|
|
44
|
+
const [visible, setVisible] = useState(false);
|
|
45
|
+
const [isLoading, setIsLoading] = useState(undefined);
|
|
46
|
+
const [hasError, setHasError] = useState(false);
|
|
47
|
+
const [error, setError] = useState(null);
|
|
48
|
+
const [data, setData] = useState(null);
|
|
49
|
+
const [reportingLinesData, setReportingLinesData] = useState(undefined);
|
|
50
|
+
const [shouldShowGiveKudos, setShouldShowGiveKudos] = useState(false);
|
|
51
|
+
const [teamCentralBaseUrl, setTeamCentralBaseUrl] = useState(undefined);
|
|
52
|
+
const [kudosDrawerOpen, setKudosDrawerOpen] = useState(false);
|
|
53
|
+
const [isTriggeredUsingKeyboard, setTriggeredUsingKeyboard] = useState(false);
|
|
54
|
+
const triggerRef = useRef(null);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
isMounted.current = true;
|
|
57
|
+
return () => {
|
|
58
|
+
isMounted.current = false;
|
|
59
|
+
clearTimeout(showTimer.current);
|
|
60
|
+
clearTimeout(hideTimer.current);
|
|
61
|
+
};
|
|
62
|
+
}, []);
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
// Reset state when the userId changes
|
|
65
|
+
setIsLoading(undefined);
|
|
66
|
+
setHasError(false);
|
|
67
|
+
setError(null);
|
|
68
|
+
setData(null);
|
|
69
|
+
setReportingLinesData(undefined);
|
|
70
|
+
setShouldShowGiveKudos(false);
|
|
71
|
+
setTeamCentralBaseUrl(undefined);
|
|
72
|
+
}, [userId]);
|
|
73
|
+
const fireAnalytics = useCallback(payload => {
|
|
74
|
+
// Don't fire any analytics if the component is unmounted
|
|
75
|
+
if (!isMounted.current) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
fireEvent(createAnalyticsEvent, payload);
|
|
79
|
+
}, [createAnalyticsEvent]);
|
|
80
|
+
const hideProfilecard = useCallback(() => {
|
|
81
|
+
clearTimeout(showTimer.current);
|
|
82
|
+
clearTimeout(hideTimer.current);
|
|
83
|
+
if (!isTriggeredUsingKeyboard) {
|
|
84
|
+
hideTimer.current = window.setTimeout(() => {
|
|
85
|
+
setVisible(false);
|
|
86
|
+
onVisibilityChange && onVisibilityChange(false);
|
|
87
|
+
}, hideDelay);
|
|
172
88
|
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
clearTimeout(this.showTimer);
|
|
177
|
-
clearTimeout(this.hideTimer);
|
|
178
|
-
}
|
|
179
|
-
handleClientSuccess(profileData, reportingLinesData, shouldShowGiveKudos) {
|
|
180
|
-
if (!this._isMounted) {
|
|
89
|
+
}, [hideDelay, isTriggeredUsingKeyboard, onVisibilityChange]);
|
|
90
|
+
const handleKeyboardClose = useCallback(event => {
|
|
91
|
+
if (event.key && event.key !== 'Escape') {
|
|
181
92
|
return;
|
|
182
93
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (!this._isMounted) {
|
|
94
|
+
if (triggerRef.current) {
|
|
95
|
+
triggerRef.current.focus();
|
|
96
|
+
}
|
|
97
|
+
setTriggeredUsingKeyboard(false);
|
|
98
|
+
setVisible(false);
|
|
99
|
+
onVisibilityChange && onVisibilityChange(false);
|
|
100
|
+
}, [setTriggeredUsingKeyboard, setVisible, onVisibilityChange]);
|
|
101
|
+
const handleClientSuccess = useCallback((profileData, reportingLinesData, shouldShowGiveKudos) => {
|
|
102
|
+
if (!isMounted.current) {
|
|
193
103
|
return;
|
|
194
104
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
renderProfileCard() {
|
|
205
|
-
var _this$state$data;
|
|
206
|
-
const newProps = {
|
|
207
|
-
userId: this.props.userId,
|
|
208
|
-
isCurrentUser: (_this$state$data = this.state.data) === null || _this$state$data === void 0 ? void 0 : _this$state$data.isCurrentUser,
|
|
209
|
-
clientFetchProfile: this.clientFetchProfile,
|
|
210
|
-
...this.state.data,
|
|
211
|
-
reportingLines: this.state.reportingLinesData,
|
|
212
|
-
onReportingLinesClick: this.props.onReportingLinesClick,
|
|
213
|
-
isKudosEnabled: this.state.shouldShowGiveKudos,
|
|
214
|
-
teamCentralBaseUrl: this.state.teamCentralBaseUrl,
|
|
215
|
-
cloudId: this.props.cloudId,
|
|
216
|
-
openKudosDrawer: this.openKudosDrawer
|
|
217
|
-
};
|
|
218
|
-
const wrapperProps = this.props.trigger === 'hover' ? {
|
|
219
|
-
onMouseEnter: this.onMouseEnter,
|
|
220
|
-
onMouseLeave: this.hideProfilecard,
|
|
221
|
-
onFocus: this.onFocus
|
|
222
|
-
} : {};
|
|
223
|
-
return /*#__PURE__*/React.createElement("div", wrapperProps, this.state.visible && /*#__PURE__*/React.createElement(Suspense, {
|
|
224
|
-
fallback: null
|
|
225
|
-
}, /*#__PURE__*/React.createElement(ProfileCardLazy, _extends({}, newProps, {
|
|
226
|
-
actions: this.filterActions(),
|
|
227
|
-
hasError: this.state.hasError,
|
|
228
|
-
errorType: this.state.error,
|
|
229
|
-
withoutElevation: true
|
|
230
|
-
}))));
|
|
231
|
-
}
|
|
232
|
-
renderWithTrigger() {
|
|
233
|
-
var _this$props$autoFocus, _this$props$offset;
|
|
234
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Popup, {
|
|
235
|
-
isOpen: !!this.state.visible,
|
|
236
|
-
onClose: this.hideProfilecard,
|
|
237
|
-
placement: this.props.position,
|
|
238
|
-
content: this.renderCard,
|
|
239
|
-
trigger: triggerProps => {
|
|
240
|
-
const {
|
|
241
|
-
ref,
|
|
242
|
-
...innerProps
|
|
243
|
-
} = triggerProps;
|
|
244
|
-
return /*#__PURE__*/React.createElement("span", _extends({}, innerProps, this.containerListeners, {
|
|
245
|
-
ref: ref,
|
|
246
|
-
"data-testid": this.props.testId,
|
|
247
|
-
role: "button",
|
|
248
|
-
tabIndex: 0
|
|
249
|
-
}), this.props.children);
|
|
250
|
-
},
|
|
251
|
-
zIndex: layers.modal(),
|
|
252
|
-
shouldUseCaptureOnOutsideClick: true,
|
|
253
|
-
autoFocus: (_this$props$autoFocus = this.props.autoFocus) !== null && _this$props$autoFocus !== void 0 ? _this$props$autoFocus : this.props.trigger === 'click',
|
|
254
|
-
offset: (_this$props$offset = this.props.offset) !== null && _this$props$offset !== void 0 ? _this$props$offset : [0, 8],
|
|
255
|
-
shouldRenderToParent: fg('enable_appropriate_reading_order_in_profile_card')
|
|
256
|
-
}), this.state.shouldShowGiveKudos && /*#__PURE__*/React.createElement(Suspense, {
|
|
257
|
-
fallback: null
|
|
258
|
-
}, /*#__PURE__*/React.createElement(GiveKudosLauncherLazy, {
|
|
259
|
-
isOpen: this.state.kudosDrawerOpen,
|
|
260
|
-
recipient: {
|
|
261
|
-
type: KudosType.INDIVIDUAL,
|
|
262
|
-
recipientId: this.props.userId
|
|
263
|
-
},
|
|
264
|
-
analyticsSource: "profile-card",
|
|
265
|
-
teamCentralBaseUrl: this.state.teamCentralBaseUrl,
|
|
266
|
-
cloudId: this.props.cloudId,
|
|
267
|
-
addFlag: this.props.addFlag,
|
|
268
|
-
onClose: this.closeKudosDrawer
|
|
269
|
-
})));
|
|
270
|
-
}
|
|
271
|
-
render() {
|
|
272
|
-
if (this.props.children) {
|
|
273
|
-
return this.renderWithTrigger();
|
|
274
|
-
} else {
|
|
275
|
-
throw new Error('Component "ProfileCardTrigger" must have "children" property');
|
|
105
|
+
setIsLoading(false);
|
|
106
|
+
setHasError(false);
|
|
107
|
+
setData(profileData);
|
|
108
|
+
setReportingLinesData(reportingLinesData);
|
|
109
|
+
setShouldShowGiveKudos(shouldShowGiveKudos);
|
|
110
|
+
}, [setHasError, setIsLoading, setData, setReportingLinesData, setShouldShowGiveKudos]);
|
|
111
|
+
const handleClientError = useCallback(err => {
|
|
112
|
+
if (!isMounted.current) {
|
|
113
|
+
return;
|
|
276
114
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
115
|
+
setIsLoading(false);
|
|
116
|
+
setHasError(true);
|
|
117
|
+
setError(err);
|
|
118
|
+
}, [setHasError, setIsLoading, setError]);
|
|
119
|
+
const clientFetchProfile = useCallback(async () => {
|
|
120
|
+
if (isLoading === true) {
|
|
121
|
+
// don't fetch data when fetching is in process
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
setTeamCentralBaseUrl(resourceClient.getTeamCentralBaseUrl());
|
|
125
|
+
setIsLoading(true);
|
|
126
|
+
setHasError(false);
|
|
127
|
+
setError(null);
|
|
128
|
+
setData(null);
|
|
129
|
+
try {
|
|
130
|
+
const requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos()]);
|
|
131
|
+
const responses = await requests;
|
|
132
|
+
handleClientSuccess(...responses);
|
|
133
|
+
} catch (err) {
|
|
134
|
+
handleClientError(err);
|
|
135
|
+
}
|
|
136
|
+
}, [cloudId, fireAnalytics, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
|
|
137
|
+
const showProfilecard = useCallback(() => {
|
|
138
|
+
clearTimeout(hideTimer.current);
|
|
139
|
+
clearTimeout(showTimer.current);
|
|
140
|
+
showTimer.current = window.setTimeout(() => {
|
|
141
|
+
if (!visible) {
|
|
142
|
+
void clientFetchProfile();
|
|
143
|
+
setVisible(true);
|
|
144
|
+
onVisibilityChange && onVisibilityChange(true);
|
|
290
145
|
}
|
|
146
|
+
}, showDelay);
|
|
147
|
+
}, [showDelay, visible, clientFetchProfile, onVisibilityChange]);
|
|
148
|
+
const onClick = useCallback(event => {
|
|
149
|
+
// If the user clicks on the trigger then we don't want that click event to
|
|
150
|
+
// propagate out to parent containers. For example when clicking a mention
|
|
151
|
+
// lozenge in an inline-edit.
|
|
152
|
+
event.stopPropagation();
|
|
153
|
+
showProfilecard();
|
|
154
|
+
if (!visible) {
|
|
155
|
+
fireAnalytics(cardTriggered('user', 'click'));
|
|
156
|
+
}
|
|
157
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
158
|
+
const onMouseEnter = useCallback(() => {
|
|
159
|
+
showProfilecard();
|
|
160
|
+
if (!visible) {
|
|
161
|
+
fireAnalytics(cardTriggered('user', 'hover'));
|
|
291
162
|
}
|
|
292
|
-
}
|
|
293
|
-
|
|
163
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
164
|
+
const onKeyPress = useCallback(event => {
|
|
165
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
setTriggeredUsingKeyboard(true);
|
|
168
|
+
showProfilecard();
|
|
169
|
+
if (!visible) {
|
|
170
|
+
fireAnalytics(cardTriggered('user', 'click'));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}, [fireAnalytics, showProfilecard, visible]);
|
|
174
|
+
const onFocus = useCallback(() => {
|
|
175
|
+
showProfilecard();
|
|
176
|
+
}, [showProfilecard]);
|
|
177
|
+
const containerListeners = useMemo(() => trigger === 'hover' ? {
|
|
178
|
+
onMouseEnter: onMouseEnter,
|
|
179
|
+
onMouseLeave: hideProfilecard,
|
|
180
|
+
onBlur: hideProfilecard,
|
|
181
|
+
onKeyPress: onKeyPress
|
|
182
|
+
} : {
|
|
183
|
+
onClick: onClick,
|
|
184
|
+
onKeyPress: onKeyPress
|
|
185
|
+
}, [hideProfilecard, onClick, onKeyPress, onMouseEnter, trigger]);
|
|
186
|
+
const filterActions = useCallback(() => {
|
|
187
|
+
return filterActionsInner(actions, data);
|
|
188
|
+
}, [actions, data]);
|
|
189
|
+
const openKudosDrawer = () => {
|
|
190
|
+
hideProfilecard();
|
|
191
|
+
setKudosDrawerOpen(true);
|
|
192
|
+
};
|
|
193
|
+
const closeKudosDrawer = () => {
|
|
194
|
+
setKudosDrawerOpen(false);
|
|
195
|
+
};
|
|
196
|
+
const showLoading = isLoading === true || isLoading === undefined;
|
|
197
|
+
const wrapperProps = useMemo(() => trigger === 'hover' ? {
|
|
198
|
+
onMouseEnter: onMouseEnter,
|
|
199
|
+
onMouseLeave: hideProfilecard,
|
|
200
|
+
onFocus: onFocus
|
|
201
|
+
} : {}, [hideProfilecard, onFocus, onMouseEnter, trigger]);
|
|
202
|
+
const profilecardProps = {
|
|
203
|
+
userId: userId,
|
|
204
|
+
fullName: prepopulatedData === null || prepopulatedData === void 0 ? void 0 : prepopulatedData.fullName,
|
|
205
|
+
isCurrentUser: data === null || data === void 0 ? void 0 : data.isCurrentUser,
|
|
206
|
+
clientFetchProfile: clientFetchProfile,
|
|
207
|
+
...data,
|
|
208
|
+
reportingLines: reportingLinesData,
|
|
209
|
+
onReportingLinesClick: onReportingLinesClick,
|
|
210
|
+
isKudosEnabled: shouldShowGiveKudos,
|
|
211
|
+
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
212
|
+
cloudId: cloudId,
|
|
213
|
+
openKudosDrawer: openKudosDrawer,
|
|
214
|
+
isTriggeredUsingKeyboard: isTriggeredUsingKeyboard,
|
|
215
|
+
disabledAriaAttributes: disabledAriaAttributes
|
|
216
|
+
};
|
|
217
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Popup, {
|
|
218
|
+
isOpen: !!visible,
|
|
219
|
+
onClose: event => {
|
|
220
|
+
hideProfilecard();
|
|
221
|
+
handleKeyboardClose(event);
|
|
222
|
+
},
|
|
223
|
+
placement: position,
|
|
224
|
+
content: () => /*#__PURE__*/React.createElement("div", wrapperProps, showLoading ? /*#__PURE__*/React.createElement(LoadingView, {
|
|
225
|
+
fireAnalytics: fireAnalytics
|
|
226
|
+
}) : visible && /*#__PURE__*/React.createElement(Suspense, {
|
|
227
|
+
fallback: null
|
|
228
|
+
}, /*#__PURE__*/React.createElement(ProfileCardLazy, _extends({}, profilecardProps, {
|
|
229
|
+
actions: filterActions(),
|
|
230
|
+
hasError: hasError,
|
|
231
|
+
errorType: error,
|
|
232
|
+
withoutElevation: true
|
|
233
|
+
})))),
|
|
234
|
+
trigger: triggerProps => {
|
|
235
|
+
const {
|
|
236
|
+
ref: callbackRef,
|
|
237
|
+
...innerProps
|
|
238
|
+
} = triggerProps;
|
|
239
|
+
const ref = element => {
|
|
240
|
+
triggerRef.current = element;
|
|
241
|
+
if (typeof callbackRef === 'function') {
|
|
242
|
+
callbackRef(element);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
const {
|
|
246
|
+
'aria-expanded': _,
|
|
247
|
+
'aria-haspopup': __,
|
|
248
|
+
...restInnerProps
|
|
249
|
+
} = innerProps;
|
|
250
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, disabledAriaAttributes ? restInnerProps : triggerProps, containerListeners, {
|
|
251
|
+
ref: ref,
|
|
252
|
+
"data-testid": testId,
|
|
253
|
+
"aria-labelledby": ariaLabelledBy
|
|
254
|
+
}, disabledAriaAttributes ? {} : {
|
|
255
|
+
role: 'button',
|
|
256
|
+
tabIndex: 0,
|
|
257
|
+
'aria-label': getLabelMessage(ariaLabel, profilecardProps.fullName, formatMessage)
|
|
258
|
+
}), children);
|
|
259
|
+
},
|
|
260
|
+
zIndex: layers.modal(),
|
|
261
|
+
shouldUseCaptureOnOutsideClick: true,
|
|
262
|
+
autoFocus: autoFocus !== null && autoFocus !== void 0 ? autoFocus : trigger === 'click'
|
|
263
|
+
}), shouldShowGiveKudos && /*#__PURE__*/React.createElement(Suspense, {
|
|
264
|
+
fallback: null
|
|
265
|
+
}, /*#__PURE__*/React.createElement(GiveKudosLauncherLazy, {
|
|
266
|
+
isOpen: kudosDrawerOpen,
|
|
267
|
+
recipient: {
|
|
268
|
+
type: KudosType.INDIVIDUAL,
|
|
269
|
+
recipientId: userId
|
|
270
|
+
},
|
|
271
|
+
analyticsSource: "profile-card",
|
|
272
|
+
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
273
|
+
cloudId: cloudId,
|
|
274
|
+
addFlag: addFlag,
|
|
275
|
+
onClose: closeKudosDrawer
|
|
276
|
+
})));
|
|
277
|
+
}
|
|
278
|
+
const LoadingView = ({
|
|
279
|
+
fireAnalytics
|
|
280
|
+
}) => /*#__PURE__*/React.createElement(CardWrapper, {
|
|
281
|
+
"data-testId": "profilecard.profilecardtrigger.loading"
|
|
282
|
+
}, /*#__PURE__*/React.createElement(UserLoadingState, {
|
|
283
|
+
fireAnalytics: fireAnalytics
|
|
284
|
+
}));
|
|
@@ -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.17.1",
|
|
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.17.1");
|
|
52
52
|
return headers;
|
|
53
53
|
};
|
|
54
54
|
export function getTeamFromAGG(_x, _x2, _x3) {
|