@atlaskit/smart-card 23.7.3 → 23.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 +6 -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 +11 -10
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +6 -4
- 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 +11 -10
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +8 -6
- 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 +11 -10
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +8 -6
- 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/views/unauthorised/types.d.ts +15 -4
- package/dist/types/view/HoverCard/types.d.ts +0 -2
- 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 { 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
|
});
|
|
@@ -9,14 +9,13 @@ import { useSmartLinkRenderers } from '../../../state/renderers';
|
|
|
9
9
|
import { useSmartCardState as useLinkState } from '../../../state/store';
|
|
10
10
|
import HoverCardContent from '../components/HoverCardContent';
|
|
11
11
|
import { HoverCardContainer, CARD_GAP_PX } from '../styled';
|
|
12
|
-
import {
|
|
12
|
+
import { CardDisplay } from '../../../constants';
|
|
13
13
|
export const hoverCardClassName = 'smart-links-hover-preview';
|
|
14
14
|
export const HoverCardComponent = ({
|
|
15
15
|
children,
|
|
16
16
|
url,
|
|
17
17
|
analyticsHandler,
|
|
18
|
-
analytics
|
|
19
|
-
onAuthorize
|
|
18
|
+
analytics
|
|
20
19
|
}) => {
|
|
21
20
|
const delay = 300;
|
|
22
21
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
@@ -28,6 +27,7 @@ export const HoverCardComponent = ({
|
|
|
28
27
|
const parentSpan = useRef(null);
|
|
29
28
|
const renderers = useSmartLinkRenderers();
|
|
30
29
|
const linkState = useLinkState(url);
|
|
30
|
+
const linkStatus = linkState.status;
|
|
31
31
|
const hoverDisplay = 'card';
|
|
32
32
|
const invokeMethod = 'mouse_hover';
|
|
33
33
|
const setMousePosition = useCallback(event => {
|
|
@@ -47,12 +47,13 @@ export const HoverCardComponent = ({
|
|
|
47
47
|
analytics.ui.hoverCardDismissedEvent({
|
|
48
48
|
previewDisplay: 'card',
|
|
49
49
|
hoverTime,
|
|
50
|
-
previewInvokeMethod: 'mouse_hover'
|
|
50
|
+
previewInvokeMethod: 'mouse_hover',
|
|
51
|
+
status: linkStatus
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
setIsOpen(false);
|
|
55
|
-
}, [analytics.ui, isOpen]);
|
|
56
|
+
}, [analytics.ui, isOpen, linkStatus]);
|
|
56
57
|
const initHideCard = useCallback(() => {
|
|
57
58
|
if (fadeInTimeoutId.current) {
|
|
58
59
|
clearTimeout(fadeInTimeoutId.current);
|
|
@@ -73,7 +74,8 @@ export const HoverCardComponent = ({
|
|
|
73
74
|
cardOpenTime.current = Date.now();
|
|
74
75
|
analytics.ui.hoverCardViewedEvent({
|
|
75
76
|
previewDisplay: hoverDisplay,
|
|
76
|
-
previewInvokeMethod: invokeMethod
|
|
77
|
+
previewInvokeMethod: invokeMethod,
|
|
78
|
+
status: linkStatus
|
|
77
79
|
});
|
|
78
80
|
} //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
|
|
79
81
|
|
|
@@ -88,10 +90,10 @@ export const HoverCardComponent = ({
|
|
|
88
90
|
|
|
89
91
|
setIsOpen(true);
|
|
90
92
|
}, delay);
|
|
91
|
-
}, [isOpen, setMousePosition, analytics.ui]);
|
|
93
|
+
}, [isOpen, setMousePosition, analytics.ui, linkStatus]);
|
|
92
94
|
const linkActions = useSmartLinkActions({
|
|
93
95
|
url,
|
|
94
|
-
appearance:
|
|
96
|
+
appearance: CardDisplay.HoverCardPreview,
|
|
95
97
|
analyticsHandler,
|
|
96
98
|
origin: 'smartLinkPreviewHoverCard'
|
|
97
99
|
});
|
|
@@ -125,8 +127,7 @@ export const HoverCardComponent = ({
|
|
|
125
127
|
onActionClick: onActionClick,
|
|
126
128
|
onResolve: update,
|
|
127
129
|
renderers: renderers,
|
|
128
|
-
url: url
|
|
129
|
-
onAuthorize: onAuthorize
|
|
130
|
+
url: url
|
|
130
131
|
})),
|
|
131
132
|
trigger: triggerProps => jsx("span", {
|
|
132
133
|
ref: parentSpan
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
2
2
|
import { extractType } from '@atlaskit/linking-common/extractors';
|
|
3
3
|
import React, { useCallback, useMemo } from 'react';
|
|
4
|
-
import { ActionName, SmartLinkPosition, SmartLinkSize } from '../../../constants';
|
|
4
|
+
import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
|
|
5
5
|
import { extractMetadata } from '../../../extractors/hover/extractMetadata';
|
|
6
6
|
import { getExtensionKey } from '../../../state/helpers';
|
|
7
7
|
import { isSpecialEvent } from '../../../utils';
|
|
8
8
|
import { flexibleUiOptions, titleBlockCss } from '../styled';
|
|
9
|
-
import { getSimulatedMetadata
|
|
9
|
+
import { getSimulatedMetadata } from '../utils';
|
|
10
10
|
import HoverCardLoadingView from './views/resolving';
|
|
11
11
|
import HoverCardUnauthorisedView from './views/unauthorised';
|
|
12
12
|
import HoverCardResolvedView from './views/resolved';
|
|
@@ -41,8 +41,7 @@ const HoverCardContent = ({
|
|
|
41
41
|
onActionClick,
|
|
42
42
|
onResolve,
|
|
43
43
|
renderers,
|
|
44
|
-
url
|
|
45
|
-
onAuthorize
|
|
44
|
+
url
|
|
46
45
|
}) => {
|
|
47
46
|
var _cardState$details;
|
|
48
47
|
|
|
@@ -51,7 +50,7 @@ const HoverCardContent = ({
|
|
|
51
50
|
const isModifierKeyPressed = isSpecialEvent(event);
|
|
52
51
|
analytics.ui.cardClickedEvent({
|
|
53
52
|
id,
|
|
54
|
-
display:
|
|
53
|
+
display: CardDisplay.HoverCardPreview,
|
|
55
54
|
status: cardState.status,
|
|
56
55
|
isModifierKeyPressed,
|
|
57
56
|
actionSubjectId: 'titleGoToLink'
|
|
@@ -91,8 +90,11 @@ const HoverCardContent = ({
|
|
|
91
90
|
|
|
92
91
|
if (cardState.status === 'unauthorized') {
|
|
93
92
|
return /*#__PURE__*/React.createElement(HoverCardUnauthorisedView, {
|
|
93
|
+
analytics: analytics,
|
|
94
|
+
extensionKey: extensionKey,
|
|
95
|
+
id: id,
|
|
94
96
|
flexibleCardProps: flexibleCardProps,
|
|
95
|
-
|
|
97
|
+
url: url
|
|
96
98
|
});
|
|
97
99
|
} // if metadataStatus is 'errored' simply render using data available (normal path)
|
|
98
100
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import { useFeatureFlag } from '@atlaskit/link-provider';
|
|
3
3
|
import { extractType } from '@atlaskit/linking-common/extractors';
|
|
4
|
-
import { ActionName, SmartLinkSize } from '../../../../../constants';
|
|
4
|
+
import { ActionName, CardDisplay, SmartLinkSize } from '../../../../../constants';
|
|
5
5
|
import { FooterBlock, MetadataBlock, SnippetBlock, TitleBlock } from '../../../../FlexibleCard/components/blocks';
|
|
6
6
|
import { footerBlockCss, hiddenSnippetStyles, metadataBlockCss } from './styled';
|
|
7
7
|
import FlexibleCard from '../../../../FlexibleCard';
|
|
8
8
|
import { useSmartCardActions } from '../../../../../state/actions';
|
|
9
|
-
import { getSimulatedMetadata, toActionableMetadata
|
|
9
|
+
import { getSimulatedMetadata, toActionableMetadata } from '../../../utils';
|
|
10
10
|
import SnippetOrPreview from '../../SnippetOrPreview';
|
|
11
11
|
import { extractMetadata } from '../../../../../extractors/hover/extractMetadata';
|
|
12
12
|
export const toFooterActions = (cardActions, onActionClick) => cardActions.map(action => ({
|
|
@@ -44,7 +44,7 @@ const HoverCardResolvedView = ({
|
|
|
44
44
|
// Since this hover view is only rendered on resolved status,
|
|
45
45
|
// there is no need to check for statuses.
|
|
46
46
|
analytics.ui.renderSuccessEvent({
|
|
47
|
-
display:
|
|
47
|
+
display: CardDisplay.HoverCardPreview,
|
|
48
48
|
status: cardState.status
|
|
49
49
|
});
|
|
50
50
|
}, [analytics.ui, cardState.status]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { useMemo } from 'react';
|
|
2
|
+
import React, { useCallback, useMemo } from 'react';
|
|
3
3
|
import { FormattedMessage } from 'react-intl-next';
|
|
4
4
|
import FlexibleCard from '../../../../FlexibleCard';
|
|
5
5
|
import { messages } from '../../../../../messages';
|
|
@@ -9,12 +9,16 @@ import { connectButtonStyles, mainTextStyles, titleBlockStyles } from './styled'
|
|
|
9
9
|
import UnauthorisedViewContent from '../../../../common/UnauthorisedViewContent';
|
|
10
10
|
import ActionGroup from '../../../../FlexibleCard/components/blocks/action-group';
|
|
11
11
|
import { LinkIcon } from '../../../../FlexibleCard/components/elements';
|
|
12
|
-
import { ActionName } from '../../../../../constants';
|
|
12
|
+
import { ActionName, CardDisplay } from '../../../../../constants';
|
|
13
|
+
import { useSmartCardActions } from '../../../../../state/actions';
|
|
13
14
|
|
|
14
15
|
const HoverCardUnauthorisedView = ({
|
|
16
|
+
analytics,
|
|
17
|
+
extensionKey,
|
|
18
|
+
id = '',
|
|
15
19
|
flexibleCardProps,
|
|
16
20
|
testId = 'hover-card-unauthorised-view',
|
|
17
|
-
|
|
21
|
+
url
|
|
18
22
|
}) => {
|
|
19
23
|
var _cardState$details, _extractProvider;
|
|
20
24
|
|
|
@@ -23,15 +27,26 @@ const HoverCardUnauthorisedView = ({
|
|
|
23
27
|
} = flexibleCardProps;
|
|
24
28
|
const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
25
29
|
const providerName = (_extractProvider = extractProvider(data)) === null || _extractProvider === void 0 ? void 0 : _extractProvider.text;
|
|
26
|
-
const
|
|
30
|
+
const {
|
|
31
|
+
authorize
|
|
32
|
+
} = useSmartCardActions(id, url, analytics);
|
|
33
|
+
const handleAuthorize = useCallback(() => {
|
|
34
|
+
if (authorize) {
|
|
35
|
+
analytics.track.appAccountAuthStarted({
|
|
36
|
+
extensionKey
|
|
37
|
+
});
|
|
38
|
+
authorize(CardDisplay.HoverCardPreview);
|
|
39
|
+
}
|
|
40
|
+
}, [authorize, extensionKey, analytics.track]);
|
|
41
|
+
const actions = useMemo(() => [{
|
|
27
42
|
name: ActionName.CustomAction,
|
|
28
43
|
content: /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_unauthorised_account_action, {
|
|
29
44
|
values: {
|
|
30
45
|
context: providerName
|
|
31
46
|
}
|
|
32
47
|
})),
|
|
33
|
-
onClick:
|
|
34
|
-
}]
|
|
48
|
+
onClick: handleAuthorize
|
|
49
|
+
}], [handleAuthorize, providerName]);
|
|
35
50
|
return /*#__PURE__*/React.createElement(FlexibleCard, _extends({}, flexibleCardProps, {
|
|
36
51
|
testId: testId
|
|
37
52
|
}), /*#__PURE__*/React.createElement(CustomBlock, {
|
|
@@ -45,7 +60,8 @@ const HoverCardUnauthorisedView = ({
|
|
|
45
60
|
overrideCss: mainTextStyles,
|
|
46
61
|
testId: `${testId}-content`
|
|
47
62
|
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
|
|
48
|
-
providerName: providerName
|
|
63
|
+
providerName: providerName,
|
|
64
|
+
analytics: analytics
|
|
49
65
|
}))), /*#__PURE__*/React.createElement(CustomBlock, {
|
|
50
66
|
overrideCss: connectButtonStyles,
|
|
51
67
|
testId: `${testId}-button`
|
|
@@ -8,7 +8,7 @@ import { ErrorBoundary } from 'react-error-boundary';
|
|
|
8
8
|
import { useSmartLinkAnalytics } from '../../state/analytics';
|
|
9
9
|
import { fireSmartLinkEvent } from '../../utils/analytics';
|
|
10
10
|
import { HoverCardComponent } from './components/HoverCardComponent';
|
|
11
|
-
import {
|
|
11
|
+
import { CardDisplay } from '../../constants';
|
|
12
12
|
|
|
13
13
|
const HoverCardWithErrorBoundary = props => {
|
|
14
14
|
const {
|
|
@@ -23,7 +23,7 @@ const HoverCardWithErrorBoundary = props => {
|
|
|
23
23
|
const analytics = useSmartLinkAnalytics(url, analyticsHandler, id);
|
|
24
24
|
const onError = useCallback((error, info) => {
|
|
25
25
|
analytics.ui.renderFailedEvent({
|
|
26
|
-
display:
|
|
26
|
+
display: CardDisplay.HoverCardPreview,
|
|
27
27
|
id,
|
|
28
28
|
error,
|
|
29
29
|
errorInfo: info
|
|
@@ -39,5 +39,8 @@ const HoverCardWithErrorBoundary = props => {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
export const HoverCard = withAnalyticsContext({
|
|
42
|
-
source: 'smartLinkPreviewHoverCard'
|
|
42
|
+
source: 'smartLinkPreviewHoverCard',
|
|
43
|
+
attributes: {
|
|
44
|
+
display: CardDisplay.HoverCardPreview
|
|
45
|
+
}
|
|
43
46
|
})(withAnalyticsEvents()(HoverCardWithErrorBoundary));
|
|
@@ -73,7 +73,8 @@ export class InlineCardUnauthorizedView extends React.Component {
|
|
|
73
73
|
if (showAuthTooltip) {
|
|
74
74
|
return /*#__PURE__*/React.createElement(HoverCard, {
|
|
75
75
|
url: url,
|
|
76
|
-
onAuthorize: this.props.onAuthorise
|
|
76
|
+
onAuthorize: this.props.onAuthorise,
|
|
77
|
+
id: this.props.id
|
|
77
78
|
}, inlineCardUnauthenticatedView);
|
|
78
79
|
}
|
|
79
80
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
3
|
import { FormattedMessage } from 'react-intl-next';
|
|
4
4
|
import { messages } from '../../messages';
|
|
5
5
|
import { CONTENT_URL_SECURITY_AND_PERMISSIONS } from '../../constants';
|
|
@@ -10,15 +10,22 @@ import { CONTENT_URL_SECURITY_AND_PERMISSIONS } from '../../constants';
|
|
|
10
10
|
*/
|
|
11
11
|
const UnauthorisedViewContent = ({
|
|
12
12
|
providerName,
|
|
13
|
-
testId = 'unauthorised-view-content'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
13
|
+
testId = 'unauthorised-view-content',
|
|
14
|
+
analytics
|
|
15
|
+
}) => {
|
|
16
|
+
const handleLearnMoreClick = useCallback(() => {
|
|
17
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.learnMoreClickedEvent();
|
|
18
|
+
}, [analytics === null || analytics === void 0 ? void 0 : analytics.ui]);
|
|
19
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, providerName ? /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_unauthorised_account_description, {
|
|
20
|
+
values: {
|
|
21
|
+
context: providerName
|
|
22
|
+
}
|
|
23
|
+
})) : /*#__PURE__*/React.createElement(FormattedMessage, messages.connect_unauthorised_account_description_no_provider), ' ', /*#__PURE__*/React.createElement("a", {
|
|
24
|
+
href: CONTENT_URL_SECURITY_AND_PERMISSIONS,
|
|
25
|
+
target: "_blank",
|
|
26
|
+
"data-testid": `${testId}-learn-more`,
|
|
27
|
+
onClick: handleLearnMoreClick
|
|
28
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, messages.learn_more_about_smart_links)));
|
|
29
|
+
};
|
|
23
30
|
|
|
24
31
|
export default UnauthorisedViewContent;
|
package/dist/esm/constants.js
CHANGED
|
@@ -230,4 +230,15 @@ export var MediaPlacement;
|
|
|
230
230
|
(function (MediaPlacement) {
|
|
231
231
|
MediaPlacement["Left"] = "left";
|
|
232
232
|
MediaPlacement["Right"] = "right";
|
|
233
|
-
})(MediaPlacement || (MediaPlacement = {}));
|
|
233
|
+
})(MediaPlacement || (MediaPlacement = {}));
|
|
234
|
+
|
|
235
|
+
export var CardDisplay;
|
|
236
|
+
|
|
237
|
+
(function (CardDisplay) {
|
|
238
|
+
CardDisplay["Inline"] = "inline";
|
|
239
|
+
CardDisplay["Block"] = "block";
|
|
240
|
+
CardDisplay["Embed"] = "embed";
|
|
241
|
+
CardDisplay["EmbedPreview"] = "embedPreview";
|
|
242
|
+
CardDisplay["Flexible"] = "flexible";
|
|
243
|
+
CardDisplay["HoverCardPreview"] = "hoverCardPreview";
|
|
244
|
+
})(CardDisplay || (CardDisplay = {}));
|
|
@@ -7,6 +7,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
7
7
|
import { extractDownloadUrl } from '../detail';
|
|
8
8
|
import { extractPreview, extractProvider } from '@atlaskit/linking-common/extractors';
|
|
9
9
|
import { PreviewAction } from '../../../view/BlockCard';
|
|
10
|
+
import { CardDisplay } from '../../../constants';
|
|
10
11
|
|
|
11
12
|
var getMetadataFromJsonLd = function getMetadataFromJsonLd(jsonLd, platform) {
|
|
12
13
|
var download = extractDownloadUrl(jsonLd);
|
|
@@ -40,7 +41,7 @@ var getInvokeOpts = function getInvokeOpts(key, action, source) {
|
|
|
40
41
|
// the actions on the preview state are invoked from the
|
|
41
42
|
// preview card. Hence, we have a `source` for distinguishing
|
|
42
43
|
// between the two.
|
|
43
|
-
source: source ||
|
|
44
|
+
source: source || CardDisplay.EmbedPreview,
|
|
44
45
|
action: {
|
|
45
46
|
type: action,
|
|
46
47
|
promise: function promise() {
|