@atlaskit/profilecard 26.2.3 → 26.3.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.
@@ -1,407 +1,12 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import React, { Suspense } from 'react';
4
- import { FormattedMessage, injectIntl } from 'react-intl';
5
- import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
6
- import { fg } from '@atlaskit/platform-feature-flags';
7
- import Popup from '@atlaskit/popup';
8
- import { Box } from '@atlaskit/primitives/compiled';
9
- import { useAnalyticsEvents } from '@atlaskit/teams-app-internal-analytics';
10
- import { layers } from '@atlaskit/theme/constants';
11
- import filterActions from '../../internal/filterActions';
12
- import messages from '../../messages';
13
- import { PACKAGE_META_DATA } from '../../util/analytics';
14
- import { isBasicClick } from '../../util/click';
15
- import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
16
- import { getPageTime } from '../../util/performance';
17
- import { ErrorBoundary } from '../Error';
18
- import { TeamProfileCardLazy } from './lazyTeamProfileCard';
19
- import TeamLoadingState from './TeamLoadingState';
20
- export class TeamProfileCardTriggerInternal extends React.PureComponent {
21
- constructor(...args) {
22
- super(...args);
23
- _defineProperty(this, "_isMounted", false);
24
- _defineProperty(this, "showTimer", 0);
25
- _defineProperty(this, "hideTimer", 0);
26
- _defineProperty(this, "openedByHover", false);
27
- _defineProperty(this, "openTime", 0);
28
- _defineProperty(this, "fireAnalytics", (eventKey, ...attributes) => {
29
- // Don't fire any analytics if the component is unmounted
30
- if (!this._isMounted) {
31
- return;
32
- }
33
- if (this.props.fireEvent) {
34
- this.props.fireEvent(eventKey, ...attributes);
35
- }
36
- });
37
- _defineProperty(this, "fireAnalyticsWithDuration", (eventKey, generator) => {
38
- const duration = getPageTime() - this.openTime;
39
- const attributes = generator(duration);
40
- this.fireAnalytics(eventKey, attributes);
41
- });
42
- _defineProperty(this, "hideProfilecard", (delay = 0) => {
43
- clearTimeout(this.showTimer);
44
- clearTimeout(this.hideTimer);
45
- this.hideTimer = window.setTimeout(() => {
46
- this.setState({
47
- visible: false
48
- });
49
- }, delay);
50
- });
51
- _defineProperty(this, "showProfilecard", (delay = 0) => {
52
- clearTimeout(this.hideTimer);
53
- clearTimeout(this.showTimer);
54
- this.showTimer = window.setTimeout(() => {
55
- if (!this.state.visible) {
56
- this.clientFetchProfile();
57
- this.openTime = getPageTime();
58
- this.setState({
59
- visible: true
60
- });
61
- }
62
- }, delay);
63
- });
64
- _defineProperty(this, "onClick", event => {
65
- if (this.props.triggerLinkType === 'link') {
66
- // We want to prevent navigation occurring on basic click, but it's important that
67
- // cmd+click, ctrl+click, etc. still work as expected.
68
- if (isBasicClick(event)) {
69
- event.preventDefault();
70
- }
71
- }
72
- if (this.props.triggerLinkType === 'clickable-link') {
73
- if (this.props.viewProfileOnClick) {
74
- this.props.viewProfileOnClick(event);
75
- }
76
- }
77
- if (this.props.trigger !== 'hover') {
78
- this.openedByHover = false;
79
- this.showProfilecard(0);
80
- if (!this.state.visible) {
81
- this.fireAnalytics('ui.teamProfileCard.triggered', {
82
- method: 'click',
83
- ...PACKAGE_META_DATA,
84
- firedAt: Math.round(getPageTime()),
85
- teamId: this.props.teamId
86
- });
87
- }
88
- }
89
- });
90
- _defineProperty(this, "onMouseEnter", () => {
91
- if (this.props.trigger === 'click') {
92
- return;
93
- }
94
- if (!this.state.visible) {
95
- this.openedByHover = true;
96
- this.fireAnalytics('ui.teamProfileCard.triggered', {
97
- method: 'hover',
98
- ...PACKAGE_META_DATA,
99
- firedAt: Math.round(getPageTime()),
100
- teamId: this.props.teamId
101
- });
102
- }
103
- this.showProfilecard(DELAY_MS_SHOW);
104
- });
105
- _defineProperty(this, "onMouseLeave", () => {
106
- if (this.props.trigger === 'click') {
107
- return;
108
- }
109
- if (this.openedByHover) {
110
- this.hideProfilecard(DELAY_MS_HIDE);
111
- }
112
- });
113
- _defineProperty(this, "onKeyPress", event => {
114
- if (event.key === 'Enter' || event.key === ' ') {
115
- event.preventDefault();
116
- this.setState({
117
- isTriggeredByKeyboard: true
118
- });
119
- this.showProfilecard(0);
120
- if (!this.state.visible) {
121
- this.fireAnalytics('ui.teamProfileCard.triggered', {
122
- method: 'click',
123
- firedAt: Math.round(getPageTime()),
124
- teamId: this.props.teamId,
125
- ...PACKAGE_META_DATA
126
- });
127
- }
128
- }
129
- });
130
- _defineProperty(this, "onClose", () => {
131
- this.hideProfilecard();
132
- this.setState({
133
- isTriggeredByKeyboard: false
134
- });
135
- });
136
- _defineProperty(this, "openKudosDrawer", () => {
137
- this.hideProfilecard(DELAY_MS_HIDE);
138
- this.setState({
139
- kudosDrawerOpen: true
140
- });
141
- });
142
- _defineProperty(this, "closeKudosDrawer", () => {
143
- this.setState({
144
- kudosDrawerOpen: false
145
- });
146
- });
147
- _defineProperty(this, "kudosUrl", () => {
148
- const recipientId = this.props.teamId && `&recipientId=${this.props.teamId}` || '';
149
- const cloudId = this.props.cloudId && `&cloudId=${this.props.cloudId}` || '';
150
- return `${this.state.teamCentralBaseUrl}/kudos/give?type=team${recipientId}${cloudId}`;
151
- });
152
- _defineProperty(this, "stopPropagation", event => {
153
- // We need to stop propagation when users click on the card, so that it
154
- // doesn't trigger any special effects that occur when clicking the trigger.
155
- event.stopPropagation();
156
- });
157
- _defineProperty(this, "triggerListeners", {
158
- onClick: this.onClick,
159
- onMouseEnter: this.onMouseEnter,
160
- onMouseLeave: this.onMouseLeave
161
- });
162
- _defineProperty(this, "cardListeners", {
163
- onClick: this.stopPropagation,
164
- onMouseEnter: this.onMouseEnter,
165
- onMouseLeave: this.onMouseLeave
166
- });
167
- _defineProperty(this, "state", {
168
- visible: false,
169
- isLoading: undefined,
170
- hasError: false,
171
- error: null,
172
- data: null,
173
- shouldShowGiveKudos: false,
174
- teamCentralBaseUrl: undefined,
175
- kudosDrawerOpen: false,
176
- isTriggeredByKeyboard: false
177
- });
178
- _defineProperty(this, "clientFetchProfile", () => {
179
- const {
180
- orgId,
181
- teamId
182
- } = this.props;
183
- const {
184
- isLoading
185
- } = this.state;
186
- if (isLoading === true) {
187
- // don't fetch data when fetching is in process
188
- return;
189
- }
190
- this.setState({
191
- isLoading: true,
192
- data: null
193
- }, () => {
194
- const requests = Promise.all([this.props.resourceClient.getTeamProfile(teamId, orgId, this.fireAnalytics), this.props.resourceClient.shouldShowGiveKudos(), this.props.resourceClient.getTeamCentralBaseUrl({
195
- withOrgContext: true,
196
- withSiteContext: true
197
- })]);
198
- requests.then(res => this.handleClientSuccess(...res), err => this.handleClientError(err)).catch(err => this.handleClientError(err));
199
- });
200
- });
201
- _defineProperty(this, "onErrorBoundary", () => {
202
- this.fireAnalytics('ui.teamProfileCard.rendered.errorBoundary', {
203
- ...PACKAGE_META_DATA,
204
- firedAt: Math.round(getPageTime()),
205
- duration: 0
206
- });
207
- this.setState({
208
- renderError: true
209
- });
210
- });
211
- _defineProperty(this, "renderProfileCard", () => {
212
- const {
213
- generateUserLink,
214
- onUserClick,
215
- viewingUserId,
216
- viewProfileLink,
217
- viewProfileOnClick
218
- } = this.props;
219
- const {
220
- data,
221
- error,
222
- hasError,
223
- isLoading
224
- } = this.state;
225
- const newProps = {
226
- clientFetchProfile: this.clientFetchProfile,
227
- actions: this.filterActions(),
228
- analytics: this.fireAnalyticsWithDuration,
229
- team: data || undefined,
230
- generateUserLink,
231
- onUserClick,
232
- viewingUserId,
233
- viewProfileLink,
234
- viewProfileOnClick
235
- };
236
- return /*#__PURE__*/React.createElement("div", this.cardListeners, this.state.visible && /*#__PURE__*/React.createElement(Suspense, {
237
- fallback: /*#__PURE__*/React.createElement(TeamLoadingState, {
238
- analytics: this.fireAnalyticsWithDuration
239
- })
240
- }, /*#__PURE__*/React.createElement(TeamProfileCardLazy, _extends({}, newProps, {
241
- isLoading: isLoading,
242
- hasError: hasError,
243
- errorType: error,
244
- isTriggeredByKeyboard: this.state.isTriggeredByKeyboard
245
- }))));
246
- });
247
- _defineProperty(this, "renderKudosLauncher", () => {
248
- return this.state.shouldShowGiveKudos && /*#__PURE__*/React.createElement(Suspense, {
249
- fallback: null
250
- }, /*#__PURE__*/React.createElement(GiveKudosLauncherLazy, {
251
- isOpen: this.state.kudosDrawerOpen,
252
- recipient: {
253
- type: KudosType.TEAM,
254
- recipientId: this.props.teamId
255
- },
256
- analyticsSource: "team-profile-card",
257
- teamCentralBaseUrl: this.state.teamCentralBaseUrl,
258
- cloudId: this.props.cloudId || '',
259
- addFlag: this.props.addFlag,
260
- onClose: this.closeKudosDrawer
261
- }));
262
- });
263
- _defineProperty(this, "renderTrigger", triggerProps => {
264
- const {
265
- children,
266
- intl,
267
- triggerLinkType,
268
- viewProfileLink
269
- } = this.props;
270
- if (triggerLinkType === 'none') {
271
- return /*#__PURE__*/React.createElement(React.Fragment, null, this.renderKudosLauncher(), /*#__PURE__*/React.createElement(Box, _extends({
272
- as: "span",
273
- role: "button",
274
- testId: "team-profilecard-trigger-wrapper",
275
- tabIndex: 0,
276
- "aria-label": intl.formatMessage(messages.teamProfileCardAriaLabel),
277
- onKeyUp: this.onKeyPress
278
- }, triggerProps, this.triggerListeners), children));
279
- }
280
- return /*#__PURE__*/React.createElement(React.Fragment, null, this.renderKudosLauncher(), /*#__PURE__*/React.createElement("a", _extends({
281
- "data-testid": "team-profilecard-trigger-wrapper"
282
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
283
- ,
284
- style: {
285
- color: 'initial',
286
- textDecoration: 'none'
287
- },
288
- href: viewProfileLink
289
- }, triggerProps, {
290
- ref: triggerProps.ref
291
- }, this.triggerListeners), children));
292
- });
293
- }
294
- componentDidMount() {
295
- this._isMounted = true;
296
- }
297
- componentDidUpdate(prevProps) {
298
- const {
299
- orgId,
300
- teamId,
301
- resourceClient
302
- } = this.props;
303
- const {
304
- visible
305
- } = this.state;
306
-
307
- // just re-fetching data when the card opens
308
- if (visible && (teamId !== prevProps.teamId || orgId !== prevProps.orgId || resourceClient !== prevProps.resourceClient)) {
309
- this.setState({
310
- isLoading: undefined
311
- }, this.clientFetchProfile);
312
- }
313
- }
314
- componentWillUnmount() {
315
- this._isMounted = false;
316
- clearTimeout(this.showTimer);
317
- clearTimeout(this.hideTimer);
318
- }
319
- handleClientSuccess(team, shouldShowGiveKudos, teamCentralBaseUrl) {
320
- if (!this._isMounted) {
321
- return;
322
- }
323
- this.setState({
324
- isLoading: false,
325
- hasError: false,
326
- data: team,
327
- shouldShowGiveKudos,
328
- teamCentralBaseUrl
329
- });
330
- }
331
- handleClientError(err) {
332
- if (!this._isMounted) {
333
- return;
334
- }
335
- this.setState({
336
- isLoading: false,
337
- hasError: true,
338
- error: err
339
- });
340
- }
341
- filterActions() {
342
- const actions = filterActions(this.props.actions, this.state.data);
343
- if (this.state.shouldShowGiveKudos) {
344
- const kudosAction = {
345
- label: /*#__PURE__*/React.createElement(FormattedMessage, messages.giveKudosButton),
346
- id: 'give-kudos',
347
- callback: () => {
348
- this.openKudosDrawer();
349
- },
350
- link: this.kudosUrl()
351
- };
352
- return actions.concat([kudosAction]);
353
- }
354
- return actions;
355
- }
356
- renderPopup() {
357
- if (this.state.renderError) {
358
- return this.props.children;
359
- }
360
- return /*#__PURE__*/React.createElement(ErrorBoundary, {
361
- onError: this.onErrorBoundary
362
- }, /*#__PURE__*/React.createElement(Popup, {
363
- isOpen: !!this.state.visible,
364
- onClose: this.onClose,
365
- placement: this.props.position,
366
- content: this.renderProfileCard,
367
- trigger: triggerProps => this.renderTrigger(triggerProps),
368
- zIndex: layers.modal(),
369
- shouldFlip: true,
370
- autoFocus: this.props.trigger !== 'hover' && !this.openedByHover,
371
- shouldRenderToParent: this.props.shouldRenderToParent
372
- }));
373
- }
374
- render() {
375
- if (this.props.children) {
376
- return this.renderPopup();
377
- } else {
378
- throw new Error('Component "TeamProfileCardTrigger" must have "children" property');
379
- }
380
- }
381
- }
382
- _defineProperty(TeamProfileCardTriggerInternal, "defaultProps", {
383
- actions: [],
384
- trigger: 'hover',
385
- position: 'bottom-start',
386
- triggerLinkType: 'link',
387
- shouldRenderToParent: true
388
- });
389
- const TeamProfileCardTrigger = props => {
390
- const {
391
- fireEvent
392
- } = useAnalyticsEvents();
393
- if (fg('people-teams-deprecate-profilecard-teams')) {
394
- return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
395
- }
396
- return /*#__PURE__*/React.createElement(TeamProfileCardTriggerInternal, _extends({}, props, {
397
- fireEvent: fireEvent
398
- }));
399
- };
1
+ import React from 'react';
400
2
 
401
3
  /**
4
+ * @private
402
5
  * @deprecated This component is deprecated and provides no functionality.
403
- * It now simply renders its children without any profile card behavior.
404
- * Please use `@atlassian/team-profilecard` instead for team profile card functionality.
6
+ * It simply renders its children without any profile card behavior.
7
+ * Use `@atlassian/team-profilecard` instead for team profile card functionality.
405
8
  */
406
- const _default_1 = injectIntl(TeamProfileCardTrigger);
407
- export default _default_1;
9
+ const TeamProfileCardTrigger = ({
10
+ children
11
+ }) => /*#__PURE__*/React.createElement(React.Fragment, null, children);
12
+ export default TeamProfileCardTrigger;
@@ -2,7 +2,7 @@ var _process$env$_PACKAGE, _process$env$_PACKAGE2;
2
2
  import { getPageTime } from './performance';
3
3
  export const PACKAGE_META_DATA = {
4
4
  packageName: (_process$env$_PACKAGE = "@atlaskit/profilecard") !== null && _process$env$_PACKAGE !== void 0 ? _process$env$_PACKAGE : '',
5
- packageVersion: (_process$env$_PACKAGE2 = "26.2.2") !== null && _process$env$_PACKAGE2 !== void 0 ? _process$env$_PACKAGE2 : ''
5
+ packageVersion: (_process$env$_PACKAGE2 = "26.2.4") !== null && _process$env$_PACKAGE2 !== void 0 ? _process$env$_PACKAGE2 : ''
6
6
  };
7
7
  const TEAM_SUBJECT = 'teamProfileCard';
8
8
  const USER_SUBJECT = 'profilecard';
@@ -19,7 +19,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
19
19
  actionSubjectId,
20
20
  attributes: {
21
21
  packageName: "@atlaskit/profilecard",
22
- packageVersion: "26.2.2",
22
+ packageVersion: "26.2.4",
23
23
  ...attributes,
24
24
  firedAt: Math.round(getPageTime())
25
25
  }
@@ -4,7 +4,7 @@ import { AGGQuery } from './graphqlUtils';
4
4
  var ORG_ID_FROM_CLOUD_ID_QUERY = "query OrgIdFromCloudId($cloudId: ID!) {\n\ttenantContexts(cloudIds: [$cloudId]) {\n\t\torgId\n\t}\n}";
5
5
  var addHeaders = function addHeaders(headers) {
6
6
  headers.append('atl-client-name', "@atlaskit/profilecard");
7
- headers.append('atl-client-version', "26.2.2");
7
+ headers.append('atl-client-version', "26.2.4");
8
8
  return headers;
9
9
  };
10
10
  export function getOrgIdForCloudIdFromAGG(_x, _x2) {
@@ -59,7 +59,7 @@ export var addHeaders = function addHeaders(headers) {
59
59
  headers.append('X-ExperimentalApi', 'teams-beta');
60
60
  headers.append('X-ExperimentalApi', 'team-members-beta');
61
61
  headers.append('atl-client-name', "@atlaskit/profilecard");
62
- headers.append('atl-client-version', "26.2.2");
62
+ headers.append('atl-client-version', "26.2.4");
63
63
  return headers;
64
64
  };
65
65
  export function getTeamFromAGG(_x, _x2, _x3) {