@atlaskit/smart-card 23.7.3 → 23.8.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 +12 -0
- package/dist/cjs/constants.js +14 -2
- package/dist/cjs/extractors/common/actions/extractPreviewAction.js +3 -1
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +41 -13
- package/dist/cjs/utils/analytics/analytics.js +128 -96
- package/dist/cjs/utils/analytics/index.js +12 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/components/flexible/footer/index.js +1 -1
- package/dist/cjs/view/BlockCard/index.js +4 -2
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleNotFoundView.js +1 -1
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +3 -3
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +17 -4
- package/dist/cjs/view/CardWithUrl/component.js +3 -1
- package/dist/cjs/view/EmbedCard/index.js +6 -2
- package/dist/cjs/view/EmbedCard/views/UnauthorisedView.js +21 -4
- package/dist/cjs/view/EmbedModal/components/analytics/index.js +4 -2
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +14 -24
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +61 -34
- package/dist/cjs/view/HoverCard/components/views/resolved/index.js +1 -1
- package/dist/cjs/view/HoverCard/components/views/unauthorised/index.js +26 -7
- package/dist/cjs/view/HoverCard/index.js +6 -3
- package/dist/cjs/view/HoverCard/utils.js +1 -4
- package/dist/cjs/view/InlineCard/UnauthorisedView/index.js +2 -1
- package/dist/cjs/view/InlineCard/index.js +2 -1
- package/dist/cjs/view/common/UnauthorisedViewContent.js +14 -3
- package/dist/es2019/constants.js +12 -1
- package/dist/es2019/extractors/common/actions/extractPreviewAction.js +2 -1
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +33 -8
- package/dist/es2019/utils/analytics/analytics.js +28 -4
- package/dist/es2019/utils/analytics/index.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/components/flexible/footer/index.js +1 -1
- package/dist/es2019/view/BlockCard/index.js +4 -2
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleNotFoundView.js +1 -1
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +4 -4
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +15 -3
- package/dist/es2019/view/CardWithUrl/component.js +2 -1
- package/dist/es2019/view/EmbedCard/index.js +6 -2
- package/dist/es2019/view/EmbedCard/views/UnauthorisedView.js +14 -3
- package/dist/es2019/view/EmbedModal/components/analytics/index.js +3 -2
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +14 -20
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +52 -30
- package/dist/es2019/view/HoverCard/components/views/resolved/index.js +3 -3
- package/dist/es2019/view/HoverCard/components/views/unauthorised/index.js +23 -7
- package/dist/es2019/view/HoverCard/index.js +6 -3
- package/dist/es2019/view/HoverCard/utils.js +0 -1
- package/dist/es2019/view/InlineCard/UnauthorisedView/index.js +2 -1
- package/dist/es2019/view/InlineCard/index.js +2 -1
- package/dist/es2019/view/common/UnauthorisedViewContent.js +18 -11
- package/dist/esm/constants.js +12 -1
- package/dist/esm/extractors/common/actions/extractPreviewAction.js +2 -1
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +42 -14
- package/dist/esm/utils/analytics/analytics.js +118 -92
- package/dist/esm/utils/analytics/index.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/components/flexible/footer/index.js +1 -1
- package/dist/esm/view/BlockCard/index.js +4 -2
- package/dist/esm/view/BlockCard/views/flexible/FlexibleNotFoundView.js +1 -1
- package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +4 -4
- package/dist/esm/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +18 -5
- package/dist/esm/view/CardWithUrl/component.js +2 -1
- package/dist/esm/view/EmbedCard/index.js +6 -2
- package/dist/esm/view/EmbedCard/views/UnauthorisedView.js +15 -4
- package/dist/esm/view/EmbedModal/components/analytics/index.js +3 -2
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +14 -22
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +54 -30
- package/dist/esm/view/HoverCard/components/views/resolved/index.js +3 -3
- package/dist/esm/view/HoverCard/components/views/unauthorised/index.js +27 -9
- package/dist/esm/view/HoverCard/index.js +6 -3
- package/dist/esm/view/HoverCard/utils.js +0 -1
- package/dist/esm/view/InlineCard/UnauthorisedView/index.js +2 -1
- package/dist/esm/view/InlineCard/index.js +2 -1
- package/dist/esm/view/common/UnauthorisedViewContent.js +8 -3
- package/dist/types/constants.d.ts +8 -0
- package/dist/types/state/actions/index.d.ts +1 -2
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +17 -4
- package/dist/types/state/flexible-ui-context/index.d.ts +8 -4
- package/dist/types/state/hooks/useSmartLink.d.ts +5 -3
- package/dist/types/utils/analytics/analytics.d.ts +4 -2
- package/dist/types/utils/analytics/index.d.ts +1 -1
- package/dist/types/utils/analytics/types.d.ts +2 -0
- package/dist/types/utils/mocks.d.ts +4 -2
- package/dist/types/utils/types.d.ts +1 -1
- package/dist/types/view/BlockCard/components/flexible/footer/index.d.ts +1 -1
- package/dist/types/view/BlockCard/views/flexible/FlexibleUnauthorisedView.d.ts +1 -1
- package/dist/types/view/BlockCard/views/flexible/types.d.ts +17 -13
- package/dist/types/view/Card/types.d.ts +1 -1
- package/dist/types/view/EmbedCard/views/UnauthorisedView.d.ts +3 -0
- package/dist/types/view/HoverCard/components/HoverCardComponent.d.ts +0 -1
- package/dist/types/view/HoverCard/components/HoverCardContent.d.ts +1 -0
- package/dist/types/view/HoverCard/components/views/unauthorised/types.d.ts +15 -4
- package/dist/types/view/HoverCard/types.d.ts +3 -3
- package/dist/types/view/HoverCard/utils.d.ts +0 -1
- package/dist/types/view/InlineCard/UnauthorisedView/index.d.ts +2 -0
- package/dist/types/view/common/UnauthorisedViewContent.d.ts +7 -1
- package/package.json +5 -5
- package/report.api.md +15 -1
- package/tmp/api-report-tmp.d.ts +8 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { getUrl } from '@atlaskit/linking-common';
|
|
3
|
-
import { connectFailedEvent, connectSucceededEvent, context, instrumentEvent, invokeFailedEvent, invokeSucceededEvent, screenAuthPopupEvent, trackAppAccountConnected, uiActionClickedEvent, uiAuthAlternateAccountEvent, uiAuthEvent, uiCardClickedEvent, uiClosedAuthEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiHoverCardViewedEvent, uiRenderFailedEvent, uiRenderSuccessEvent } from '../../utils/analytics';
|
|
3
|
+
import { connectFailedEvent, connectSucceededEvent, context, instrumentEvent, invokeFailedEvent, invokeSucceededEvent, screenAuthPopupEvent, trackAppAccountAuthStarted, trackAppAccountConnected, uiActionClickedEvent, uiAuthAlternateAccountEvent, uiAuthEvent, uiCardClickedEvent, uiClosedAuthEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiHoverCardViewedEvent, uiLearnMoreLinkClickedEvent, uiRenderFailedEvent, uiRenderSuccessEvent } from '../../utils/analytics';
|
|
4
4
|
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
5
5
|
import { getDefinitionId, getExtensionKey, getProduct, getResourceType, getSubproduct } from '../helpers';
|
|
6
6
|
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
@@ -359,7 +359,8 @@ export const useSmartLinkAnalytics = (url, dispatchAnalytics, id, defaultLocatio
|
|
|
359
359
|
resourceType,
|
|
360
360
|
destinationProduct,
|
|
361
361
|
destinationSubproduct,
|
|
362
|
-
location
|
|
362
|
+
location,
|
|
363
|
+
status
|
|
363
364
|
}) => dispatchAnalytics(applyCommonAttributes(uiHoverCardViewedEvent({
|
|
364
365
|
id,
|
|
365
366
|
previewDisplay,
|
|
@@ -369,7 +370,8 @@ export const useSmartLinkAnalytics = (url, dispatchAnalytics, id, defaultLocatio
|
|
|
369
370
|
destinationProduct,
|
|
370
371
|
destinationSubproduct,
|
|
371
372
|
location,
|
|
372
|
-
previewInvokeMethod
|
|
373
|
+
previewInvokeMethod,
|
|
374
|
+
status
|
|
373
375
|
}), commonAttributes)),
|
|
374
376
|
|
|
375
377
|
/**
|
|
@@ -377,7 +379,7 @@ export const useSmartLinkAnalytics = (url, dispatchAnalytics, id, defaultLocatio
|
|
|
377
379
|
* @param hoverDisplay Whether the hover preview was displayed as a card or embed.
|
|
378
380
|
* @param hoverTime The duration that the user hovered over a Smart Link before the preview was dismissed.
|
|
379
381
|
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
380
|
-
* @param extensionKey The extensionKey of the Smart Link
|
|
382
|
+
* @param extensionKey The extensionKey of the Smart Link resolver invoked.
|
|
381
383
|
* @param previewInvokeMethod How the preview was triggered.
|
|
382
384
|
* @returns
|
|
383
385
|
*/
|
|
@@ -391,7 +393,8 @@ export const useSmartLinkAnalytics = (url, dispatchAnalytics, id, defaultLocatio
|
|
|
391
393
|
resourceType,
|
|
392
394
|
destinationProduct,
|
|
393
395
|
destinationSubproduct,
|
|
394
|
-
location
|
|
396
|
+
location,
|
|
397
|
+
status
|
|
395
398
|
}) => dispatchAnalytics(applyCommonAttributes(uiHoverCardDismissedEvent({
|
|
396
399
|
previewDisplay,
|
|
397
400
|
id,
|
|
@@ -402,8 +405,16 @@ export const useSmartLinkAnalytics = (url, dispatchAnalytics, id, defaultLocatio
|
|
|
402
405
|
destinationProduct,
|
|
403
406
|
destinationSubproduct,
|
|
404
407
|
location,
|
|
405
|
-
previewInvokeMethod
|
|
406
|
-
|
|
408
|
+
previewInvokeMethod,
|
|
409
|
+
status
|
|
410
|
+
}), commonAttributes)),
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Fires an event that signifies that a "Learn More" link was clicked on an unauthenticated card
|
|
414
|
+
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
415
|
+
* @param location The location where a link is displayed (jiraWebLinks, confluencePages etc)
|
|
416
|
+
*/
|
|
417
|
+
learnMoreClickedEvent: () => dispatchAnalytics(applyCommonAttributes(uiLearnMoreLinkClickedEvent(), commonAttributes))
|
|
407
418
|
}), [defaultId, commonAttributes, dispatchAnalytics]);
|
|
408
419
|
/** Contains all operational analytics events */
|
|
409
420
|
|
|
@@ -581,7 +592,7 @@ export const useSmartLinkAnalytics = (url, dispatchAnalytics, id, defaultLocatio
|
|
|
581
592
|
|
|
582
593
|
const track = useMemo(() => ({
|
|
583
594
|
/**
|
|
584
|
-
* This fires an event which represents a user
|
|
595
|
+
* This fires an event which represents a user connecting their account to view a Smart Link.
|
|
585
596
|
* @param definitionId The definitionId of the Smart Link resolver invoked.
|
|
586
597
|
* @param extensionKey The extensionKey of the Smart Link resovler invoked.
|
|
587
598
|
* @returns
|
|
@@ -600,6 +611,20 @@ export const useSmartLinkAnalytics = (url, dispatchAnalytics, id, defaultLocatio
|
|
|
600
611
|
destinationProduct,
|
|
601
612
|
destinationSubproduct,
|
|
602
613
|
location
|
|
614
|
+
}), commonAttributes)),
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* This fires an event which represents a user starting the Smart Link connect account process.
|
|
618
|
+
* @param location a location where the Smart Link auth action was initiated.
|
|
619
|
+
* @param extensionKey The extensionKey of the Smart Link resolver invoked.
|
|
620
|
+
* @returns
|
|
621
|
+
*/
|
|
622
|
+
appAccountAuthStarted: ({
|
|
623
|
+
extensionKey,
|
|
624
|
+
location
|
|
625
|
+
}) => dispatchAnalytics(applyCommonAttributes(trackAppAccountAuthStarted({ ...commonAttributes,
|
|
626
|
+
extensionKey,
|
|
627
|
+
location
|
|
603
628
|
}), commonAttributes))
|
|
604
629
|
}), [commonAttributes, dispatchAnalytics]);
|
|
605
630
|
/** Contains all screen analytics events */
|
|
@@ -203,6 +203,18 @@ export const trackAppAccountConnected = ({
|
|
|
203
203
|
location
|
|
204
204
|
}
|
|
205
205
|
});
|
|
206
|
+
export const trackAppAccountAuthStarted = ({
|
|
207
|
+
extensionKey,
|
|
208
|
+
location
|
|
209
|
+
}) => ({
|
|
210
|
+
action: 'authStarted',
|
|
211
|
+
actionSubject: 'applicationAccount',
|
|
212
|
+
eventType: 'track',
|
|
213
|
+
attributes: { ...context,
|
|
214
|
+
extensionKey,
|
|
215
|
+
location
|
|
216
|
+
}
|
|
217
|
+
});
|
|
206
218
|
export const uiAuthEvent = ({
|
|
207
219
|
definitionId,
|
|
208
220
|
extensionKey,
|
|
@@ -389,7 +401,8 @@ export const uiHoverCardViewedEvent = ({
|
|
|
389
401
|
destinationProduct,
|
|
390
402
|
destinationSubproduct,
|
|
391
403
|
location,
|
|
392
|
-
previewInvokeMethod
|
|
404
|
+
previewInvokeMethod,
|
|
405
|
+
status
|
|
393
406
|
}) => ({
|
|
394
407
|
action: 'viewed',
|
|
395
408
|
actionSubject: 'hoverCard',
|
|
@@ -402,7 +415,8 @@ export const uiHoverCardViewedEvent = ({
|
|
|
402
415
|
destinationProduct,
|
|
403
416
|
destinationSubproduct,
|
|
404
417
|
location,
|
|
405
|
-
previewInvokeMethod
|
|
418
|
+
previewInvokeMethod,
|
|
419
|
+
status
|
|
406
420
|
}
|
|
407
421
|
});
|
|
408
422
|
export const uiHoverCardDismissedEvent = ({
|
|
@@ -414,7 +428,8 @@ export const uiHoverCardDismissedEvent = ({
|
|
|
414
428
|
destinationProduct,
|
|
415
429
|
destinationSubproduct,
|
|
416
430
|
location,
|
|
417
|
-
previewInvokeMethod
|
|
431
|
+
previewInvokeMethod,
|
|
432
|
+
status
|
|
418
433
|
}) => ({
|
|
419
434
|
action: 'dismissed',
|
|
420
435
|
actionSubject: 'hoverCard',
|
|
@@ -428,7 +443,8 @@ export const uiHoverCardDismissedEvent = ({
|
|
|
428
443
|
destinationProduct,
|
|
429
444
|
destinationSubproduct,
|
|
430
445
|
location,
|
|
431
|
-
previewInvokeMethod
|
|
446
|
+
previewInvokeMethod,
|
|
447
|
+
status
|
|
432
448
|
}
|
|
433
449
|
});
|
|
434
450
|
export const uiHoverCardOpenLinkClickedEvent = ({
|
|
@@ -455,4 +471,12 @@ export const uiHoverCardOpenLinkClickedEvent = ({
|
|
|
455
471
|
location,
|
|
456
472
|
previewInvokeMethod
|
|
457
473
|
}
|
|
474
|
+
});
|
|
475
|
+
export const uiLearnMoreLinkClickedEvent = () => ({
|
|
476
|
+
action: 'clicked',
|
|
477
|
+
actionSubject: 'button',
|
|
478
|
+
actionSubjectId: 'learnMore',
|
|
479
|
+
eventType: 'ui',
|
|
480
|
+
attributes: { ...context
|
|
481
|
+
}
|
|
458
482
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getMeasure } from '../performance';
|
|
2
2
|
import { resolvedEvent, unresolvedEvent } from './analytics';
|
|
3
|
-
export { ANALYTICS_CHANNEL, context, fireSmartLinkEvent, resolvedEvent, unresolvedEvent, invokeSucceededEvent, invokeFailedEvent, connectSucceededEvent, connectFailedEvent, trackAppAccountConnected, uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, screenAuthPopupEvent, uiRenderSuccessEvent, uiRenderFailedEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent } from './analytics';
|
|
3
|
+
export { ANALYTICS_CHANNEL, context, fireSmartLinkEvent, resolvedEvent, unresolvedEvent, invokeSucceededEvent, invokeFailedEvent, connectSucceededEvent, connectFailedEvent, trackAppAccountAuthStarted, trackAppAccountConnected, uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, screenAuthPopupEvent, uiRenderSuccessEvent, uiRenderFailedEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, uiLearnMoreLinkClickedEvent } from './analytics';
|
|
4
4
|
export const instrumentEvent = ({
|
|
5
5
|
id,
|
|
6
6
|
status,
|
package/dist/es2019/version.json
CHANGED
|
@@ -22,7 +22,7 @@ const providerStyles = css`
|
|
|
22
22
|
}
|
|
23
23
|
`;
|
|
24
24
|
/**
|
|
25
|
-
* This
|
|
25
|
+
* This Component is a footer that is used in a Block Card with Flexible UI.
|
|
26
26
|
* It contains a provider icon if provider is present and an actions list if one is passed.
|
|
27
27
|
* To be shown as a part of Flexible UI, needs to be wrapped inside of a CustomBlock
|
|
28
28
|
*
|
|
@@ -55,11 +55,12 @@ export const BlockCard = ({
|
|
|
55
55
|
} = cardState;
|
|
56
56
|
const data = details && details.data || getEmptyJsonLd();
|
|
57
57
|
const meta = details && details.meta;
|
|
58
|
+
const extensionKey = getExtensionKey(details);
|
|
58
59
|
const extractorOpts = {
|
|
59
60
|
analytics,
|
|
60
61
|
origin: 'smartLinkCard',
|
|
61
62
|
handleInvoke,
|
|
62
|
-
extensionKey
|
|
63
|
+
extensionKey
|
|
63
64
|
};
|
|
64
65
|
|
|
65
66
|
if (enableFlexibleBlockCard) {
|
|
@@ -74,7 +75,8 @@ export const BlockCard = ({
|
|
|
74
75
|
onError,
|
|
75
76
|
renderers,
|
|
76
77
|
ui,
|
|
77
|
-
analytics
|
|
78
|
+
analytics,
|
|
79
|
+
extensionKey
|
|
78
80
|
};
|
|
79
81
|
|
|
80
82
|
switch (status) {
|
|
@@ -45,7 +45,7 @@ const FlexibleNotFoundView = ({
|
|
|
45
45
|
message: {
|
|
46
46
|
descriptor: messages.not_found_description
|
|
47
47
|
},
|
|
48
|
-
testId: testId
|
|
48
|
+
testId: `${testId}-message`
|
|
49
49
|
})), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
|
|
50
50
|
status: status
|
|
51
51
|
})));
|
|
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
|
|
|
2
2
|
import FlexibleCard from '../../../FlexibleCard';
|
|
3
3
|
import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
|
|
4
4
|
import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock } from '../../../FlexibleCard/components/blocks';
|
|
5
|
-
import { ActionName, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
|
|
5
|
+
import { ActionName, CardDisplay, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
|
|
6
6
|
import uuid from 'uuid';
|
|
7
7
|
/**
|
|
8
8
|
* This view represents a Block card that has an 'Resolved' status.
|
|
@@ -79,7 +79,7 @@ const FlexibleResolvedView = ({
|
|
|
79
79
|
analytics.operational.invokeSucceededEvent({
|
|
80
80
|
id: analyticsId,
|
|
81
81
|
actionType: 'preview',
|
|
82
|
-
display:
|
|
82
|
+
display: CardDisplay.Block
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
}, {
|
|
@@ -89,7 +89,7 @@ const FlexibleResolvedView = ({
|
|
|
89
89
|
analytics.operational.invokeSucceededEvent({
|
|
90
90
|
id: analyticsId,
|
|
91
91
|
actionType: 'view',
|
|
92
|
-
display:
|
|
92
|
+
display: CardDisplay.Block
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
}, {
|
|
@@ -99,7 +99,7 @@ const FlexibleResolvedView = ({
|
|
|
99
99
|
analytics.operational.invokeSucceededEvent({
|
|
100
100
|
id: analyticsId,
|
|
101
101
|
actionType: 'download',
|
|
102
|
-
display:
|
|
102
|
+
display: CardDisplay.Block
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
}]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
2
|
import FlexibleCard from '../../../FlexibleCard';
|
|
3
3
|
import { AuthorizeAction } from '../../actions/flexible/AuthorizeAction';
|
|
4
4
|
import BlockCardFooter from '../../components/flexible/footer';
|
|
@@ -22,7 +22,9 @@ const contentStyles = css`
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
const FlexibleUnauthorisedView = ({
|
|
25
|
+
analytics,
|
|
25
26
|
cardState,
|
|
27
|
+
extensionKey = '',
|
|
26
28
|
onAuthorize,
|
|
27
29
|
onClick,
|
|
28
30
|
onError,
|
|
@@ -34,7 +36,15 @@ const FlexibleUnauthorisedView = ({
|
|
|
34
36
|
|
|
35
37
|
const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
36
38
|
const providerName = (_extractProvider = extractProvider(data)) === null || _extractProvider === void 0 ? void 0 : _extractProvider.text;
|
|
37
|
-
const
|
|
39
|
+
const handleAuthorize = useCallback(() => {
|
|
40
|
+
if (onAuthorize) {
|
|
41
|
+
analytics.track.appAccountAuthStarted({
|
|
42
|
+
extensionKey
|
|
43
|
+
});
|
|
44
|
+
onAuthorize();
|
|
45
|
+
}
|
|
46
|
+
}, [onAuthorize, extensionKey, analytics.track]);
|
|
47
|
+
const actions = useMemo(() => onAuthorize ? [AuthorizeAction(handleAuthorize, providerName)] : [], [handleAuthorize, onAuthorize, providerName]);
|
|
38
48
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
39
49
|
appearance: "block",
|
|
40
50
|
cardState: cardState,
|
|
@@ -50,7 +60,9 @@ const FlexibleUnauthorisedView = ({
|
|
|
50
60
|
overrideCss: contentStyles,
|
|
51
61
|
testId: `${testId}-content`
|
|
52
62
|
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
|
|
53
|
-
providerName: providerName
|
|
63
|
+
providerName: providerName,
|
|
64
|
+
analytics: analytics,
|
|
65
|
+
testId: testId
|
|
54
66
|
}))), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
|
|
55
67
|
actions: actions,
|
|
56
68
|
status: SmartLinkStatus.Unauthorized,
|
|
@@ -10,6 +10,7 @@ import { EmbedCard } from '../EmbedCard';
|
|
|
10
10
|
import { isFlexibleUiCard } from '../../utils/flexible';
|
|
11
11
|
import FlexibleCard from '../FlexibleCard';
|
|
12
12
|
import { APIError } from '../..';
|
|
13
|
+
import { CardDisplay } from '../../constants';
|
|
13
14
|
export function CardWithUrlContent({
|
|
14
15
|
id,
|
|
15
16
|
url,
|
|
@@ -66,7 +67,7 @@ export function CardWithUrlContent({
|
|
|
66
67
|
const isModifierKeyPressed = isSpecialEvent(event);
|
|
67
68
|
analytics.ui.cardClickedEvent({
|
|
68
69
|
id,
|
|
69
|
-
display: isFlexibleUi ?
|
|
70
|
+
display: isFlexibleUi ? CardDisplay.Flexible : appearance,
|
|
70
71
|
status: state.status,
|
|
71
72
|
definitionId,
|
|
72
73
|
extensionKey,
|
|
@@ -37,6 +37,7 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
37
37
|
|
|
38
38
|
const data = details && details.data || getEmptyJsonLd();
|
|
39
39
|
const meta = details && details.meta;
|
|
40
|
+
const extensionKey = getExtensionKey(details);
|
|
40
41
|
|
|
41
42
|
switch (status) {
|
|
42
43
|
case 'pending':
|
|
@@ -82,7 +83,7 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
82
83
|
analytics,
|
|
83
84
|
origin: 'smartLinkEmbed',
|
|
84
85
|
handleInvoke,
|
|
85
|
-
extensionKey
|
|
86
|
+
extensionKey
|
|
86
87
|
});
|
|
87
88
|
return /*#__PURE__*/React.createElement(BlockCardResolvedView, _extends({}, resolvedBlockViewProps, {
|
|
88
89
|
isSelected: isSelected,
|
|
@@ -105,7 +106,10 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
105
106
|
isSelected: isSelected,
|
|
106
107
|
onAuthorise: handleAuthorize,
|
|
107
108
|
inheritDimensions: inheritDimensions,
|
|
108
|
-
onClick: handleFrameClick
|
|
109
|
+
onClick: handleFrameClick,
|
|
110
|
+
analytics: analytics,
|
|
111
|
+
extensionKey: extensionKey,
|
|
112
|
+
testId: testId
|
|
109
113
|
}));
|
|
110
114
|
|
|
111
115
|
case 'forbidden':
|
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
2
|
import { EmbedCardUnresolvedView } from './UnresolvedView';
|
|
3
3
|
import { UnauthorisedImage } from '../constants';
|
|
4
4
|
import { ExpandedFrame } from '../components/ExpandedFrame';
|
|
5
5
|
import { ImageIcon } from '../components/ImageIcon';
|
|
6
6
|
import UnauthorisedViewContent from '../../common/UnauthorisedViewContent';
|
|
7
7
|
export const EmbedCardUnauthorisedView = ({
|
|
8
|
+
analytics,
|
|
8
9
|
link,
|
|
9
10
|
context,
|
|
10
11
|
isSelected,
|
|
11
12
|
testId = 'embed-card-unauthorized-view',
|
|
12
13
|
onAuthorise,
|
|
13
14
|
inheritDimensions,
|
|
14
|
-
onClick
|
|
15
|
+
onClick,
|
|
16
|
+
extensionKey
|
|
15
17
|
}) => {
|
|
16
18
|
var _context$image;
|
|
17
19
|
|
|
18
20
|
const icon = context && context.icon && /*#__PURE__*/React.createElement(ImageIcon, {
|
|
19
21
|
src: typeof context.icon === 'string' ? context.icon : undefined
|
|
20
22
|
});
|
|
23
|
+
const handleOnAuthorizeClick = useCallback(() => {
|
|
24
|
+
if (onAuthorise) {
|
|
25
|
+
analytics.track.appAccountAuthStarted({
|
|
26
|
+
extensionKey: extensionKey
|
|
27
|
+
});
|
|
28
|
+
onAuthorise();
|
|
29
|
+
}
|
|
30
|
+
}, [onAuthorise, analytics.track, extensionKey]);
|
|
21
31
|
return /*#__PURE__*/React.createElement(ExpandedFrame, {
|
|
22
32
|
href: link,
|
|
23
33
|
icon: icon,
|
|
@@ -38,9 +48,10 @@ export const EmbedCardUnauthorisedView = ({
|
|
|
38
48
|
text: 'connect_unauthorised_account_action',
|
|
39
49
|
testId: 'connect-account'
|
|
40
50
|
},
|
|
41
|
-
onClick:
|
|
51
|
+
onClick: handleOnAuthorizeClick,
|
|
42
52
|
testId: testId
|
|
43
53
|
}, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
|
|
54
|
+
analytics: analytics,
|
|
44
55
|
providerName: context === null || context === void 0 ? void 0 : context.text,
|
|
45
56
|
testId: testId
|
|
46
57
|
})));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useCallback } from 'react';
|
|
3
3
|
import { EmbedModalSize } from '../../types';
|
|
4
|
+
import { CardDisplay } from '../../../../constants';
|
|
4
5
|
|
|
5
6
|
const getResizeFrom = size => size === EmbedModalSize.Small ? EmbedModalSize.Large : EmbedModalSize.Small;
|
|
6
7
|
|
|
@@ -23,7 +24,7 @@ const withAnalytics = Component => props => {
|
|
|
23
24
|
});
|
|
24
25
|
analytics.ui.renderSuccessEvent({
|
|
25
26
|
status: 'resolved',
|
|
26
|
-
display:
|
|
27
|
+
display: CardDisplay.EmbedPreview
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
if (onOpen) {
|
|
@@ -32,7 +33,7 @@ const withAnalytics = Component => props => {
|
|
|
32
33
|
}, [analytics.screen, analytics.ui, onOpen, origin]);
|
|
33
34
|
const handleOnOpenFailed = useCallback((error, errorInfo) => {
|
|
34
35
|
analytics.ui.renderFailedEvent({
|
|
35
|
-
display:
|
|
36
|
+
display: CardDisplay.EmbedPreview,
|
|
36
37
|
error,
|
|
37
38
|
errorInfo
|
|
38
39
|
});
|
|
@@ -8,15 +8,13 @@ import { useSmartLinkActions } from '../../../state/hooks-external/useSmartLinkA
|
|
|
8
8
|
import { useSmartLinkRenderers } from '../../../state/renderers';
|
|
9
9
|
import { useSmartCardState as useLinkState } from '../../../state/store';
|
|
10
10
|
import HoverCardContent from '../components/HoverCardContent';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
export const hoverCardClassName = 'smart-links-hover-preview';
|
|
11
|
+
import { CARD_GAP_PX } from '../styled';
|
|
12
|
+
import { CardDisplay } from '../../../constants';
|
|
14
13
|
export const HoverCardComponent = ({
|
|
15
14
|
children,
|
|
16
15
|
url,
|
|
17
16
|
analyticsHandler,
|
|
18
|
-
analytics
|
|
19
|
-
onAuthorize
|
|
17
|
+
analytics
|
|
20
18
|
}) => {
|
|
21
19
|
const delay = 300;
|
|
22
20
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
@@ -28,6 +26,7 @@ export const HoverCardComponent = ({
|
|
|
28
26
|
const parentSpan = useRef(null);
|
|
29
27
|
const renderers = useSmartLinkRenderers();
|
|
30
28
|
const linkState = useLinkState(url);
|
|
29
|
+
const linkStatus = linkState.status;
|
|
31
30
|
const hoverDisplay = 'card';
|
|
32
31
|
const invokeMethod = 'mouse_hover';
|
|
33
32
|
const setMousePosition = useCallback(event => {
|
|
@@ -47,12 +46,13 @@ export const HoverCardComponent = ({
|
|
|
47
46
|
analytics.ui.hoverCardDismissedEvent({
|
|
48
47
|
previewDisplay: 'card',
|
|
49
48
|
hoverTime,
|
|
50
|
-
previewInvokeMethod: 'mouse_hover'
|
|
49
|
+
previewInvokeMethod: 'mouse_hover',
|
|
50
|
+
status: linkStatus
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
setIsOpen(false);
|
|
55
|
-
}, [analytics.ui, isOpen]);
|
|
55
|
+
}, [analytics.ui, isOpen, linkStatus]);
|
|
56
56
|
const initHideCard = useCallback(() => {
|
|
57
57
|
if (fadeInTimeoutId.current) {
|
|
58
58
|
clearTimeout(fadeInTimeoutId.current);
|
|
@@ -73,7 +73,8 @@ export const HoverCardComponent = ({
|
|
|
73
73
|
cardOpenTime.current = Date.now();
|
|
74
74
|
analytics.ui.hoverCardViewedEvent({
|
|
75
75
|
previewDisplay: hoverDisplay,
|
|
76
|
-
previewInvokeMethod: invokeMethod
|
|
76
|
+
previewInvokeMethod: invokeMethod,
|
|
77
|
+
status: linkStatus
|
|
77
78
|
});
|
|
78
79
|
} //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
|
|
79
80
|
|
|
@@ -88,10 +89,10 @@ export const HoverCardComponent = ({
|
|
|
88
89
|
|
|
89
90
|
setIsOpen(true);
|
|
90
91
|
}, delay);
|
|
91
|
-
}, [isOpen, setMousePosition, analytics.ui]);
|
|
92
|
+
}, [isOpen, setMousePosition, analytics.ui, linkStatus]);
|
|
92
93
|
const linkActions = useSmartLinkActions({
|
|
93
94
|
url,
|
|
94
|
-
appearance:
|
|
95
|
+
appearance: CardDisplay.HoverCardPreview,
|
|
95
96
|
analyticsHandler,
|
|
96
97
|
origin: 'smartLinkPreviewHoverCard'
|
|
97
98
|
});
|
|
@@ -101,7 +102,6 @@ export const HoverCardComponent = ({
|
|
|
101
102
|
}
|
|
102
103
|
}, [hideCard]); // Stop hover preview content to propagate event to parent.
|
|
103
104
|
|
|
104
|
-
const onClick = useCallback(e => e.stopPropagation(), []);
|
|
105
105
|
return jsx(Popup, {
|
|
106
106
|
testId: "hover-card",
|
|
107
107
|
isOpen: isOpen,
|
|
@@ -111,23 +111,17 @@ export const HoverCardComponent = ({
|
|
|
111
111
|
autoFocus: false,
|
|
112
112
|
content: ({
|
|
113
113
|
update
|
|
114
|
-
}) => jsx(
|
|
114
|
+
}) => jsx(HoverCardContent, {
|
|
115
115
|
onMouseEnter: initShowCard,
|
|
116
116
|
onMouseLeave: initHideCard,
|
|
117
|
-
onClick: onClick,
|
|
118
|
-
css: HoverCardContainer // class name for trello to exclude click events
|
|
119
|
-
,
|
|
120
|
-
className: hoverCardClassName
|
|
121
|
-
}, jsx(HoverCardContent, {
|
|
122
117
|
analytics: analytics,
|
|
123
118
|
cardActions: linkActions,
|
|
124
119
|
cardState: linkState,
|
|
125
120
|
onActionClick: onActionClick,
|
|
126
121
|
onResolve: update,
|
|
127
122
|
renderers: renderers,
|
|
128
|
-
url: url
|
|
129
|
-
|
|
130
|
-
})),
|
|
123
|
+
url: url
|
|
124
|
+
}),
|
|
131
125
|
trigger: triggerProps => jsx("span", {
|
|
132
126
|
ref: parentSpan
|
|
133
127
|
}, jsx("span", _extends({}, triggerProps, {
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
1
3
|
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
2
4
|
import { extractType } from '@atlaskit/linking-common/extractors';
|
|
3
5
|
import React, { useCallback, useMemo } from 'react';
|
|
4
|
-
import { ActionName, SmartLinkPosition, SmartLinkSize } from '../../../constants';
|
|
6
|
+
import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
|
|
5
7
|
import { extractMetadata } from '../../../extractors/hover/extractMetadata';
|
|
6
8
|
import { getExtensionKey } from '../../../state/helpers';
|
|
7
9
|
import { isSpecialEvent } from '../../../utils';
|
|
8
|
-
import { flexibleUiOptions, titleBlockCss } from '../styled';
|
|
9
|
-
import { getSimulatedMetadata
|
|
10
|
+
import { HoverCardContainer, flexibleUiOptions, titleBlockCss } from '../styled';
|
|
11
|
+
import { getSimulatedMetadata } from '../utils';
|
|
10
12
|
import HoverCardLoadingView from './views/resolving';
|
|
11
13
|
import HoverCardUnauthorisedView from './views/unauthorised';
|
|
12
14
|
import HoverCardResolvedView from './views/resolved';
|
|
13
15
|
import { FormattedMessage } from 'react-intl-next';
|
|
14
16
|
import { messages } from '../../../messages';
|
|
17
|
+
export const hoverCardClassName = 'smart-links-hover-preview';
|
|
15
18
|
export const getOpenAction = (url, analytics, onActionClick) => ({
|
|
16
19
|
name: ActionName.CustomAction,
|
|
17
|
-
icon:
|
|
20
|
+
icon: jsx(ShortcutIcon, {
|
|
18
21
|
label: "open in new tab",
|
|
19
22
|
size: "medium"
|
|
20
23
|
}),
|
|
@@ -29,7 +32,7 @@ export const getOpenAction = (url, analytics, onActionClick) => ({
|
|
|
29
32
|
previewDisplay: 'card'
|
|
30
33
|
});
|
|
31
34
|
},
|
|
32
|
-
tooltipMessage:
|
|
35
|
+
tooltipMessage: jsx(FormattedMessage, messages.open_link_in_a_new_tab),
|
|
33
36
|
testId: 'hover-card-open-button'
|
|
34
37
|
});
|
|
35
38
|
|
|
@@ -42,7 +45,8 @@ const HoverCardContent = ({
|
|
|
42
45
|
onResolve,
|
|
43
46
|
renderers,
|
|
44
47
|
url,
|
|
45
|
-
|
|
48
|
+
onMouseEnter,
|
|
49
|
+
onMouseLeave
|
|
46
50
|
}) => {
|
|
47
51
|
var _cardState$details;
|
|
48
52
|
|
|
@@ -51,7 +55,7 @@ const HoverCardContent = ({
|
|
|
51
55
|
const isModifierKeyPressed = isSpecialEvent(event);
|
|
52
56
|
analytics.ui.cardClickedEvent({
|
|
53
57
|
id,
|
|
54
|
-
display:
|
|
58
|
+
display: CardDisplay.HoverCardPreview,
|
|
55
59
|
status: cardState.status,
|
|
56
60
|
isModifierKeyPressed,
|
|
57
61
|
actionSubjectId: 'titleGoToLink'
|
|
@@ -81,33 +85,51 @@ const HoverCardContent = ({
|
|
|
81
85
|
url: url,
|
|
82
86
|
children: {}
|
|
83
87
|
};
|
|
88
|
+
const onClickStopPropagation = useCallback(e => e.stopPropagation(), []);
|
|
84
89
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
const getCardView = cardState => {
|
|
91
|
+
if (cardState.metadataStatus === 'pending') {
|
|
92
|
+
return jsx(HoverCardLoadingView, {
|
|
93
|
+
flexibleCardProps: flexibleCardProps,
|
|
94
|
+
titleBlockProps: titleBlockProps
|
|
95
|
+
});
|
|
96
|
+
}
|
|
91
97
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
if (cardState.status === 'unauthorized') {
|
|
99
|
+
return jsx(HoverCardUnauthorisedView, {
|
|
100
|
+
analytics: analytics,
|
|
101
|
+
extensionKey: extensionKey,
|
|
102
|
+
id: id,
|
|
103
|
+
flexibleCardProps: flexibleCardProps,
|
|
104
|
+
url: url
|
|
105
|
+
});
|
|
106
|
+
}
|
|
98
107
|
|
|
108
|
+
if (cardState.status === 'resolved') {
|
|
109
|
+
return jsx(HoverCardResolvedView, {
|
|
110
|
+
id: id,
|
|
111
|
+
url: url,
|
|
112
|
+
extensionKey: extensionKey,
|
|
113
|
+
analytics: analytics,
|
|
114
|
+
cardActions: cardActions,
|
|
115
|
+
cardState: cardState,
|
|
116
|
+
flexibleCardProps: flexibleCardProps,
|
|
117
|
+
onActionClick: onActionClick,
|
|
118
|
+
titleBlockProps: titleBlockProps
|
|
119
|
+
});
|
|
120
|
+
}
|
|
99
121
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
});
|
|
122
|
+
return null;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const cardView = getCardView(cardState);
|
|
126
|
+
return cardView ? jsx("div", {
|
|
127
|
+
onMouseEnter: onMouseEnter,
|
|
128
|
+
onMouseLeave: onMouseLeave,
|
|
129
|
+
onClick: onClickStopPropagation,
|
|
130
|
+
className: hoverCardClassName,
|
|
131
|
+
css: HoverCardContainer
|
|
132
|
+
}, cardView) : null;
|
|
111
133
|
};
|
|
112
134
|
|
|
113
135
|
export default HoverCardContent;
|