@atlaskit/smart-card 21.3.0 → 22.1.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 +56 -0
- package/dist/cjs/extractors/block/index.js +6 -7
- package/dist/cjs/extractors/common/actions/extractPreviewAction.js +16 -19
- package/dist/cjs/state/actions/index.js +54 -10
- package/dist/cjs/state/analytics/types.js +5 -0
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +429 -109
- package/dist/cjs/state/hooks-external/useSmartLinkActions.js +5 -3
- package/dist/cjs/utils/analytics/analytics.js +241 -74
- package/dist/cjs/utils/analytics/index.js +32 -5
- package/dist/cjs/utils/mocks.js +28 -2
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/actions/PreviewAction.js +2 -2
- package/dist/cjs/view/BlockCard/index.js +6 -5
- package/dist/cjs/view/CardWithUrl/component.js +27 -5
- package/dist/cjs/view/CardWithUrl/loader.js +6 -1
- package/dist/cjs/view/EmbedCard/index.js +3 -2
- package/dist/cjs/view/EmbedModal/components/analytics/index.js +100 -0
- package/dist/cjs/view/EmbedModal/components/analytics/types.js +5 -0
- package/dist/cjs/view/EmbedModal/components/size-experiment/index.js +5 -10
- package/dist/cjs/view/EmbedModal/index.js +54 -15
- package/dist/cjs/view/EmbedModal/types.js +9 -1
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +11 -3
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +15 -4
- package/dist/cjs/view/HoverCard/index.js +6 -1
- package/dist/cjs/view/InlineCard/IconAndTitleLayout/styled.js +2 -2
- package/dist/cjs/view/common/Modal.js +29 -4
- package/dist/cjs/view/common/ModalHeader.js +3 -2
- package/dist/es2019/extractors/block/index.js +6 -7
- package/dist/es2019/extractors/common/actions/extractPreviewAction.js +16 -10
- package/dist/es2019/state/actions/index.js +54 -10
- package/dist/es2019/state/analytics/types.js +1 -0
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +424 -41
- package/dist/es2019/state/hooks-external/useSmartLinkActions.js +5 -3
- package/dist/es2019/utils/analytics/analytics.js +254 -79
- package/dist/es2019/utils/analytics/index.js +32 -4
- package/dist/es2019/utils/mocks.js +26 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/actions/PreviewAction.js +3 -3
- package/dist/es2019/view/BlockCard/index.js +5 -4
- package/dist/es2019/view/CardWithUrl/component.js +27 -5
- package/dist/es2019/view/CardWithUrl/loader.js +6 -1
- package/dist/es2019/view/EmbedCard/index.js +3 -2
- package/dist/es2019/view/EmbedModal/components/analytics/index.js +80 -0
- package/dist/es2019/view/EmbedModal/components/analytics/types.js +1 -0
- package/dist/es2019/view/EmbedModal/components/size-experiment/index.js +5 -9
- package/dist/es2019/view/EmbedModal/index.js +46 -13
- package/dist/es2019/view/EmbedModal/types.js +6 -1
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +11 -3
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +15 -4
- package/dist/es2019/view/HoverCard/index.js +6 -1
- package/dist/es2019/view/InlineCard/IconAndTitleLayout/styled.js +0 -2
- package/dist/es2019/view/common/Modal.js +27 -6
- package/dist/es2019/view/common/ModalHeader.js +3 -2
- package/dist/esm/extractors/block/index.js +6 -7
- package/dist/esm/extractors/common/actions/extractPreviewAction.js +17 -19
- package/dist/esm/state/actions/index.js +54 -10
- package/dist/esm/state/analytics/types.js +1 -0
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +428 -111
- package/dist/esm/state/hooks-external/useSmartLinkActions.js +5 -3
- package/dist/esm/utils/analytics/analytics.js +241 -74
- package/dist/esm/utils/analytics/index.js +31 -4
- package/dist/esm/utils/mocks.js +25 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/actions/PreviewAction.js +3 -3
- package/dist/esm/view/BlockCard/index.js +5 -4
- package/dist/esm/view/CardWithUrl/component.js +27 -5
- package/dist/esm/view/CardWithUrl/loader.js +6 -1
- package/dist/esm/view/EmbedCard/index.js +3 -2
- package/dist/esm/view/EmbedModal/components/analytics/index.js +82 -0
- package/dist/esm/view/EmbedModal/components/analytics/types.js +1 -0
- package/dist/esm/view/EmbedModal/components/size-experiment/index.js +5 -10
- package/dist/esm/view/EmbedModal/index.js +52 -15
- package/dist/esm/view/EmbedModal/types.js +6 -1
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +11 -3
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +15 -4
- package/dist/esm/view/HoverCard/index.js +6 -1
- package/dist/esm/view/InlineCard/IconAndTitleLayout/styled.js +2 -2
- package/dist/esm/view/common/Modal.js +28 -6
- package/dist/esm/view/common/ModalHeader.js +3 -2
- package/dist/types/extractors/block/types.d.ts +4 -2
- package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +7 -5
- package/dist/types/state/analytics/types.d.ts +9 -0
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +41 -24
- package/dist/types/state/hooks/useSmartLink.d.ts +26 -18
- package/dist/types/state/hooks-external/useSmartLinkActions.d.ts +6 -2
- package/dist/types/utils/analytics/analytics.d.ts +19 -21
- package/dist/types/utils/analytics/index.d.ts +2 -2
- package/dist/types/utils/analytics/types.d.ts +91 -0
- package/dist/types/utils/mocks.d.ts +48 -0
- package/dist/types/utils/types.d.ts +3 -1
- package/dist/types/view/BlockCard/actions/PreviewAction.d.ts +4 -0
- package/dist/types/view/BlockCard/index.d.ts +2 -2
- package/dist/types/view/BlockCard/types.d.ts +4 -4
- package/dist/types/view/Card/index.d.ts +1 -1
- package/dist/types/view/EmbedCard/types.d.ts +2 -2
- package/dist/types/view/EmbedModal/components/analytics/index.d.ts +5 -0
- package/dist/types/view/EmbedModal/components/analytics/types.d.ts +6 -0
- package/dist/types/view/EmbedModal/components/size-experiment/index.d.ts +4 -3
- package/dist/types/view/EmbedModal/index.d.ts +3 -1
- package/dist/types/view/EmbedModal/types.d.ts +14 -4
- package/dist/types/view/common/Modal.d.ts +6 -8
- package/package.json +17 -17
- package/report.api.md +302 -107
|
@@ -5,7 +5,6 @@ import { extractBlockProps } from '../../extractors/block';
|
|
|
5
5
|
import { getEmptyJsonLd, getUnauthorizedJsonLd } from '../../utils/jsonld';
|
|
6
6
|
import { extractRequestAccessContext } from '../../extractors/common/context';
|
|
7
7
|
import { CardLinkView } from '../LinkView';
|
|
8
|
-
export { default as PreviewAction } from './actions/PreviewAction';
|
|
9
8
|
import { AuthorizeAction } from './actions/AuthorizeAction';
|
|
10
9
|
import { ForbiddenAction } from './actions/ForbiddenAction';
|
|
11
10
|
import { ResolvedView as BlockCardResolvedView } from './views/ResolvedView';
|
|
@@ -15,6 +14,7 @@ import { UnauthorizedView as BlockCardUnauthorisedView } from './views/Unauthori
|
|
|
15
14
|
import { ForbiddenView as BlockCardForbiddenView } from './views/ForbiddenView';
|
|
16
15
|
import { ErroredView as BlockCardErroredView } from './views/ErroredView';
|
|
17
16
|
import { useFeatureFlag } from '@atlaskit/link-provider';
|
|
17
|
+
export { default as PreviewAction } from './actions/PreviewAction';
|
|
18
18
|
export { ForbiddenAction, AuthorizeAction, BlockCardResolvedView, BlockCardResolvingView, BlockCardUnauthorisedView, BlockCardForbiddenView, BlockCardErroredView, BlockCardNotFoundView };
|
|
19
19
|
export var BlockCard = function BlockCard(_ref) {
|
|
20
20
|
var _details$meta, _forbiddenViewProps$c;
|
|
@@ -27,7 +27,6 @@ export var BlockCard = function BlockCard(_ref) {
|
|
|
27
27
|
handleAuthorize = _ref.handleAuthorize,
|
|
28
28
|
handleErrorRetry = _ref.handleErrorRetry,
|
|
29
29
|
handleFrameClick = _ref.handleFrameClick,
|
|
30
|
-
handleAnalytics = _ref.handleAnalytics,
|
|
31
30
|
handleInvoke = _ref.handleInvoke,
|
|
32
31
|
renderers = _ref.renderers,
|
|
33
32
|
isSelected = _ref.isSelected,
|
|
@@ -35,7 +34,8 @@ export var BlockCard = function BlockCard(_ref) {
|
|
|
35
34
|
onError = _ref.onError,
|
|
36
35
|
testId = _ref.testId,
|
|
37
36
|
showActions = _ref.showActions,
|
|
38
|
-
platform = _ref.platform
|
|
37
|
+
platform = _ref.platform,
|
|
38
|
+
analytics = _ref.analytics;
|
|
39
39
|
// Actions do not have access to the react tree, so we need to obtain
|
|
40
40
|
// feature flags here where we still can access SmartLinkContext context
|
|
41
41
|
// and pass the flags down to the extractor. See PreviewAction.tsx for details.
|
|
@@ -46,8 +46,9 @@ export var BlockCard = function BlockCard(_ref) {
|
|
|
46
46
|
var data = details && details.data || getEmptyJsonLd();
|
|
47
47
|
var meta = details && details.meta;
|
|
48
48
|
var extractorOpts = {
|
|
49
|
+
analytics: analytics,
|
|
50
|
+
origin: 'smartLinkCard',
|
|
49
51
|
featureFlags: featureFlags,
|
|
50
|
-
handleAnalytics: handleAnalytics,
|
|
51
52
|
handleInvoke: handleInvoke,
|
|
52
53
|
extensionKey: getExtensionKey(details)
|
|
53
54
|
};
|
|
@@ -63,7 +63,16 @@ export function CardWithUrlContent(_ref) {
|
|
|
63
63
|
}, [state.details, url]);
|
|
64
64
|
var handleClickWrapper = useCallback(function (event) {
|
|
65
65
|
var isModifierKeyPressed = isSpecialEvent(event);
|
|
66
|
-
analytics.ui.cardClickedEvent(
|
|
66
|
+
analytics.ui.cardClickedEvent({
|
|
67
|
+
id: id,
|
|
68
|
+
display: isFlexibleUi ? 'flexible' : appearance,
|
|
69
|
+
status: state.status,
|
|
70
|
+
definitionId: definitionId,
|
|
71
|
+
extensionKey: extensionKey,
|
|
72
|
+
isModifierKeyPressed: isModifierKeyPressed,
|
|
73
|
+
destinationProduct: product,
|
|
74
|
+
destinationSubproduct: subproduct
|
|
75
|
+
});
|
|
67
76
|
|
|
68
77
|
if (onClick) {
|
|
69
78
|
onClick(event);
|
|
@@ -87,7 +96,14 @@ export function CardWithUrlContent(_ref) {
|
|
|
87
96
|
|
|
88
97
|
if (state.status !== 'pending') {
|
|
89
98
|
measure.create(id, state.status);
|
|
90
|
-
analytics.operational.instrument(
|
|
99
|
+
analytics.operational.instrument({
|
|
100
|
+
id: id,
|
|
101
|
+
status: state.status,
|
|
102
|
+
definitionId: definitionId,
|
|
103
|
+
extensionKey: extensionKey,
|
|
104
|
+
resourceType: resourceType,
|
|
105
|
+
error: state.error
|
|
106
|
+
});
|
|
91
107
|
}
|
|
92
108
|
}, [id, appearance, state.status, state.error, definitionId, extensionKey, resourceType, analytics.operational]); // NB: once the smart-card has rendered into an end state, we capture
|
|
93
109
|
// this as a successful render. These can be one of:
|
|
@@ -96,7 +112,13 @@ export function CardWithUrlContent(_ref) {
|
|
|
96
112
|
|
|
97
113
|
useEffect(function () {
|
|
98
114
|
if (isFinalState(state.status)) {
|
|
99
|
-
analytics.ui.renderSuccessEvent(
|
|
115
|
+
analytics.ui.renderSuccessEvent({
|
|
116
|
+
display: appearance,
|
|
117
|
+
status: state.status,
|
|
118
|
+
id: id,
|
|
119
|
+
definitionId: definitionId,
|
|
120
|
+
extensionKey: extensionKey
|
|
121
|
+
});
|
|
100
122
|
}
|
|
101
123
|
}, [appearance, state.status, url, definitionId, extensionKey, analytics.ui, id]);
|
|
102
124
|
|
|
@@ -160,7 +182,7 @@ export function CardWithUrlContent(_ref) {
|
|
|
160
182
|
handleErrorRetry: handleRetry,
|
|
161
183
|
handleInvoke: handleInvoke,
|
|
162
184
|
handleFrameClick: handleClickWrapper,
|
|
163
|
-
|
|
185
|
+
analytics: analytics,
|
|
164
186
|
isSelected: isSelected,
|
|
165
187
|
onResolve: onResolve,
|
|
166
188
|
onError: onError,
|
|
@@ -178,7 +200,7 @@ export function CardWithUrlContent(_ref) {
|
|
|
178
200
|
handleErrorRetry: handleRetry,
|
|
179
201
|
handleFrameClick: handleClickWrapper,
|
|
180
202
|
handleInvoke: handleInvoke,
|
|
181
|
-
|
|
203
|
+
analytics: analytics,
|
|
182
204
|
isSelected: isSelected,
|
|
183
205
|
isFrameVisible: isFrameVisible,
|
|
184
206
|
platform: platform,
|
|
@@ -72,7 +72,12 @@ export function CardWithURLRenderer(props) {
|
|
|
72
72
|
var errorInfo = {
|
|
73
73
|
componentStack: componentStack
|
|
74
74
|
};
|
|
75
|
-
analytics.ui.renderFailedEvent(
|
|
75
|
+
analytics.ui.renderFailedEvent({
|
|
76
|
+
display: appearance,
|
|
77
|
+
id: id,
|
|
78
|
+
error: error,
|
|
79
|
+
errorInfo: errorInfo
|
|
80
|
+
});
|
|
76
81
|
}
|
|
77
82
|
}, [analytics.ui, appearance, id]);
|
|
78
83
|
|
|
@@ -23,7 +23,7 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef)
|
|
|
23
23
|
handleAuthorize = _ref.handleAuthorize,
|
|
24
24
|
handleErrorRetry = _ref.handleErrorRetry,
|
|
25
25
|
handleFrameClick = _ref.handleFrameClick,
|
|
26
|
-
|
|
26
|
+
analytics = _ref.analytics,
|
|
27
27
|
handleInvoke = _ref.handleInvoke,
|
|
28
28
|
showActions = _ref.showActions,
|
|
29
29
|
isSelected = _ref.isSelected,
|
|
@@ -77,7 +77,8 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef)
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
var resolvedBlockViewProps = extractBlockProps(data, meta, {
|
|
80
|
-
|
|
80
|
+
analytics: analytics,
|
|
81
|
+
origin: 'smartLinkEmbed',
|
|
81
82
|
handleInvoke: handleInvoke,
|
|
82
83
|
extensionKey: getExtensionKey(details)
|
|
83
84
|
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { EmbedModalSize } from '../../types';
|
|
4
|
+
|
|
5
|
+
var getResizeFrom = function getResizeFrom(size) {
|
|
6
|
+
return size === EmbedModalSize.Small ? EmbedModalSize.Large : EmbedModalSize.Small;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
var withAnalytics = function withAnalytics(Component) {
|
|
10
|
+
return function (props) {
|
|
11
|
+
var analytics = props.analytics,
|
|
12
|
+
onClose = props.onClose,
|
|
13
|
+
onOpen = props.onOpen,
|
|
14
|
+
onOpenFailed = props.onOpenFailed,
|
|
15
|
+
onResize = props.onResize,
|
|
16
|
+
origin = props.origin;
|
|
17
|
+
var handleOnOpen = useCallback(function (context) {
|
|
18
|
+
analytics.screen.modalViewedEvent({
|
|
19
|
+
name: 'embedPreviewModal',
|
|
20
|
+
attributes: {
|
|
21
|
+
origin: origin,
|
|
22
|
+
size: context.size
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
analytics.ui.renderSuccessEvent({
|
|
26
|
+
status: 'resolved',
|
|
27
|
+
display: 'preview'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (onOpen) {
|
|
31
|
+
onOpen(context);
|
|
32
|
+
}
|
|
33
|
+
}, [analytics.screen, analytics.ui, onOpen, origin]);
|
|
34
|
+
var handleOnOpenFailed = useCallback(function (error, errorInfo) {
|
|
35
|
+
analytics.ui.renderFailedEvent({
|
|
36
|
+
display: 'preview',
|
|
37
|
+
error: error,
|
|
38
|
+
errorInfo: errorInfo
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (onOpenFailed) {
|
|
42
|
+
onOpenFailed(error, errorInfo);
|
|
43
|
+
}
|
|
44
|
+
}, [analytics.ui, onOpenFailed]);
|
|
45
|
+
var handleOnClose = useCallback(function (context) {
|
|
46
|
+
analytics.ui.modalClosedEvent({
|
|
47
|
+
actionSubjectId: 'embedPreview',
|
|
48
|
+
attributes: {
|
|
49
|
+
origin: origin,
|
|
50
|
+
previewTime: context.duration,
|
|
51
|
+
size: context.size
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (onClose) {
|
|
56
|
+
onClose(context);
|
|
57
|
+
}
|
|
58
|
+
}, [analytics.ui, onClose, origin]);
|
|
59
|
+
var handleOnResize = useCallback(function (context) {
|
|
60
|
+
analytics.ui.buttonClickedEvent({
|
|
61
|
+
actionSubjectId: 'embedPreviewResize',
|
|
62
|
+
attributes: {
|
|
63
|
+
newSize: context.size,
|
|
64
|
+
origin: origin,
|
|
65
|
+
previousSize: getResizeFrom(context.size)
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (onResize) {
|
|
70
|
+
onResize(context);
|
|
71
|
+
}
|
|
72
|
+
}, [analytics.ui, onResize, origin]);
|
|
73
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
74
|
+
onClose: handleOnClose,
|
|
75
|
+
onOpen: handleOnOpen,
|
|
76
|
+
onOpenFailed: handleOnOpenFailed,
|
|
77
|
+
onResize: handleOnResize
|
|
78
|
+
}));
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default withAnalytics;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Modal from '../../../common/Modal';
|
|
4
|
-
import {
|
|
4
|
+
import { EmbedModalSize } from '../../types';
|
|
5
5
|
|
|
6
6
|
var withSizeExperiment = function withSizeExperiment(Component) {
|
|
7
7
|
return function (props) {
|
|
8
8
|
var _props$featureFlags = props.featureFlags,
|
|
9
|
-
featureFlags = _props$featureFlags === void 0 ? {} : _props$featureFlags
|
|
10
|
-
|
|
11
|
-
closeLabel = _props$closeLabel === void 0 ? 'Close Preview' : _props$closeLabel;
|
|
12
|
-
var embedModalSize = featureFlags.embedModalSize; // Experiment
|
|
9
|
+
featureFlags = _props$featureFlags === void 0 ? {} : _props$featureFlags;
|
|
10
|
+
var size = featureFlags.embedModalSize; // Experiment
|
|
13
11
|
|
|
14
|
-
if (
|
|
15
|
-
var size = embedModalSize === 'large' ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
|
|
12
|
+
if (size === EmbedModalSize.Large || size === EmbedModalSize.Small) {
|
|
16
13
|
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
17
14
|
size: size
|
|
18
15
|
}));
|
|
19
16
|
} // Control
|
|
20
17
|
|
|
21
18
|
|
|
22
|
-
return /*#__PURE__*/React.createElement(Modal,
|
|
23
|
-
closeLabel: closeLabel
|
|
24
|
-
}));
|
|
19
|
+
return /*#__PURE__*/React.createElement(Modal, props);
|
|
25
20
|
};
|
|
26
21
|
};
|
|
27
22
|
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
3
3
|
import ModalDialog, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
|
|
4
4
|
import LinkInfo from './components/link-info';
|
|
5
5
|
import { MAX_MODAL_SIZE, MIN_MODAL_SIZE } from './constants';
|
|
6
6
|
import EmbedContent from './components/embed-content';
|
|
7
|
+
import { EmbedModalSize } from './types';
|
|
7
8
|
import withErrorBoundary from './components/error-boundary';
|
|
8
9
|
import withSizeExperiment from './components/size-experiment';
|
|
10
|
+
import withAnalytics from './components/analytics';
|
|
11
|
+
|
|
12
|
+
var toSize = function toSize(width) {
|
|
13
|
+
return width === MAX_MODAL_SIZE ? EmbedModalSize.Large : EmbedModalSize.Small;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
var toWidth = function toWidth(size) {
|
|
17
|
+
return size === EmbedModalSize.Large ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
|
|
18
|
+
};
|
|
9
19
|
|
|
10
20
|
var EmbedModal = function EmbedModal(_ref) {
|
|
11
21
|
var downloadUrl = _ref.download,
|
|
@@ -16,49 +26,76 @@ var EmbedModal = function EmbedModal(_ref) {
|
|
|
16
26
|
onClose = _ref.onClose,
|
|
17
27
|
onDownloadActionClick = _ref.onDownloadActionClick,
|
|
18
28
|
onOpen = _ref.onOpen,
|
|
29
|
+
onResize = _ref.onResize,
|
|
19
30
|
onViewActionClick = _ref.onViewActionClick,
|
|
20
31
|
providerName = _ref.providerName,
|
|
21
32
|
showModal = _ref.showModal,
|
|
22
33
|
_ref$size = _ref.size,
|
|
23
|
-
|
|
34
|
+
size = _ref$size === void 0 ? EmbedModalSize.Small : _ref$size,
|
|
24
35
|
src = _ref.src,
|
|
25
36
|
_ref$testId = _ref.testId,
|
|
26
37
|
testId = _ref$testId === void 0 ? 'smart-embed-preview-modal' : _ref$testId,
|
|
27
38
|
title = _ref.title,
|
|
28
39
|
url = _ref.url;
|
|
40
|
+
var defaultWidth = toWidth(size);
|
|
29
41
|
|
|
30
42
|
var _useState = useState(showModal),
|
|
31
43
|
_useState2 = _slicedToArray(_useState, 2),
|
|
32
44
|
isOpen = _useState2[0],
|
|
33
45
|
setIsOpen = _useState2[1];
|
|
34
46
|
|
|
35
|
-
var _useState3 = useState(
|
|
47
|
+
var _useState3 = useState(defaultWidth),
|
|
36
48
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
37
|
-
|
|
38
|
-
|
|
49
|
+
width = _useState4[0],
|
|
50
|
+
setWidth = _useState4[1];
|
|
51
|
+
|
|
52
|
+
var openAt = useRef();
|
|
53
|
+
var handleOnOpenComplete = useCallback(function () {
|
|
54
|
+
openAt.current = Date.now();
|
|
39
55
|
|
|
56
|
+
if (onOpen) {
|
|
57
|
+
onOpen({
|
|
58
|
+
size: size
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, [onOpen, size]);
|
|
40
62
|
var handleOnClose = useCallback(function () {
|
|
41
63
|
return setIsOpen(false);
|
|
42
64
|
}, []);
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
65
|
+
var handleOnCloseComplete = useCallback(function () {
|
|
66
|
+
if (onClose) {
|
|
67
|
+
var duration = openAt.current ? Date.now() - openAt.current : undefined;
|
|
68
|
+
onClose({
|
|
69
|
+
duration: duration,
|
|
70
|
+
size: toSize(width)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}, [onClose, width]);
|
|
74
|
+
var handleOnResizeClick = useCallback(function () {
|
|
75
|
+
var newWidth = width === MIN_MODAL_SIZE ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
|
|
76
|
+
setWidth(newWidth);
|
|
77
|
+
|
|
78
|
+
if (onResize) {
|
|
79
|
+
onResize({
|
|
80
|
+
size: toSize(newWidth)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}, [onResize, width]);
|
|
47
84
|
return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(ModalDialog, {
|
|
48
85
|
height: "100%",
|
|
49
86
|
onClose: handleOnClose,
|
|
50
|
-
onCloseComplete:
|
|
51
|
-
onOpenComplete:
|
|
87
|
+
onCloseComplete: handleOnCloseComplete,
|
|
88
|
+
onOpenComplete: handleOnOpenComplete,
|
|
52
89
|
testId: testId,
|
|
53
|
-
width:
|
|
90
|
+
width: width
|
|
54
91
|
}, /*#__PURE__*/React.createElement(LinkInfo, {
|
|
55
92
|
downloadUrl: downloadUrl,
|
|
56
93
|
icon: icon,
|
|
57
94
|
providerName: providerName,
|
|
58
95
|
onViewButtonClick: onViewActionClick,
|
|
59
96
|
onDownloadButtonClick: onDownloadActionClick,
|
|
60
|
-
onResizeButtonClick:
|
|
61
|
-
size:
|
|
97
|
+
onResizeButtonClick: handleOnResizeClick,
|
|
98
|
+
size: width,
|
|
62
99
|
title: title,
|
|
63
100
|
testId: testId,
|
|
64
101
|
url: url
|
|
@@ -70,4 +107,4 @@ var EmbedModal = function EmbedModal(_ref) {
|
|
|
70
107
|
}))));
|
|
71
108
|
};
|
|
72
109
|
|
|
73
|
-
export default withSizeExperiment(withErrorBoundary(EmbedModal));
|
|
110
|
+
export default withSizeExperiment(withAnalytics(withErrorBoundary(EmbedModal)));
|
|
@@ -48,7 +48,11 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
48
48
|
//Check its previously open to avoid firing events when moving between the child and hover card components
|
|
49
49
|
if (isOpen === true && cardOpenTime.current) {
|
|
50
50
|
var hoverTime = Date.now() - cardOpenTime.current;
|
|
51
|
-
analytics.ui.hoverCardDismissedEvent(
|
|
51
|
+
analytics.ui.hoverCardDismissedEvent({
|
|
52
|
+
previewDisplay: 'card',
|
|
53
|
+
hoverTime: hoverTime,
|
|
54
|
+
previewInvokeMethod: 'mouse_hover'
|
|
55
|
+
});
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
setIsOpen(false);
|
|
@@ -73,7 +77,10 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
73
77
|
//Check if its previously closed to avoid firing events when moving between the child and hover card components
|
|
74
78
|
if (isOpen === false) {
|
|
75
79
|
cardOpenTime.current = Date.now();
|
|
76
|
-
analytics.ui.hoverCardViewedEvent(
|
|
80
|
+
analytics.ui.hoverCardViewedEvent({
|
|
81
|
+
previewDisplay: hoverDisplay,
|
|
82
|
+
previewInvokeMethod: invokeMethod
|
|
83
|
+
});
|
|
77
84
|
} //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
|
|
78
85
|
|
|
79
86
|
|
|
@@ -91,7 +98,8 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
91
98
|
var linkActions = useSmartLinkActions({
|
|
92
99
|
url: url,
|
|
93
100
|
appearance: SMART_CARD_ANALYTICS_DISPLAY,
|
|
94
|
-
analyticsHandler: analyticsHandler
|
|
101
|
+
analyticsHandler: analyticsHandler,
|
|
102
|
+
origin: 'smartLinkPreviewHoverCard'
|
|
95
103
|
});
|
|
96
104
|
var onActionClick = useCallback(function (actionId) {
|
|
97
105
|
if (actionId === 'preview-content') {
|
|
@@ -26,7 +26,9 @@ export var getOpenAction = function getOpenAction(url, analytics, onActionClick)
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
window.open(url, '_blank');
|
|
29
|
-
analytics.ui.hoverCardOpenLinkClickedEvent(
|
|
29
|
+
analytics.ui.hoverCardOpenLinkClickedEvent({
|
|
30
|
+
previewDisplay: 'card'
|
|
31
|
+
});
|
|
30
32
|
},
|
|
31
33
|
testId: 'hover-card-open-button'
|
|
32
34
|
};
|
|
@@ -68,15 +70,24 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
68
70
|
useEffect(function () {
|
|
69
71
|
// Since hover preview only render on resolved status,
|
|
70
72
|
// there is no need to check for statuses.
|
|
71
|
-
analytics.ui.renderSuccessEvent(
|
|
73
|
+
analytics.ui.renderSuccessEvent({
|
|
74
|
+
display: SMART_CARD_ANALYTICS_DISPLAY,
|
|
75
|
+
status: cardState.status
|
|
76
|
+
});
|
|
72
77
|
}, [analytics.ui, cardState.status]);
|
|
73
78
|
var extensionKey = useMemo(function () {
|
|
74
79
|
return getExtensionKey(cardState.details);
|
|
75
80
|
}, [cardState.details]);
|
|
76
81
|
var onClick = useCallback(function (event) {
|
|
77
82
|
var isModifierKeyPressed = isSpecialEvent(event);
|
|
78
|
-
analytics.ui.cardClickedEvent(
|
|
79
|
-
|
|
83
|
+
analytics.ui.cardClickedEvent({
|
|
84
|
+
id: id,
|
|
85
|
+
display: SMART_CARD_ANALYTICS_DISPLAY,
|
|
86
|
+
status: cardState.status,
|
|
87
|
+
isModifierKeyPressed: isModifierKeyPressed,
|
|
88
|
+
actionSubjectId: 'titleGoToLink'
|
|
89
|
+
});
|
|
90
|
+
}, [cardState.status, analytics.ui, id]);
|
|
80
91
|
var titleActions = useMemo(function () {
|
|
81
92
|
return [getOpenAction(url, analytics, onActionClick)];
|
|
82
93
|
}, [url, analytics, onActionClick]);
|
|
@@ -20,7 +20,12 @@ var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
|
|
|
20
20
|
}, [createAnalyticsEvent]);
|
|
21
21
|
var analytics = useSmartLinkAnalytics(url, analyticsHandler, id);
|
|
22
22
|
var onError = useCallback(function (error, info) {
|
|
23
|
-
analytics.ui.renderFailedEvent(
|
|
23
|
+
analytics.ui.renderFailedEvent({
|
|
24
|
+
display: SMART_CARD_ANALYTICS_DISPLAY,
|
|
25
|
+
id: id,
|
|
26
|
+
error: error,
|
|
27
|
+
errorInfo: info
|
|
28
|
+
});
|
|
24
29
|
}, [analytics.ui, id]);
|
|
25
30
|
return jsx(ErrorBoundary, {
|
|
26
31
|
fallback: children,
|
|
@@ -21,9 +21,9 @@ export var EmojiWrapper = styled.span(_templateObject2 || (_templateObject2 = _t
|
|
|
21
21
|
|
|
22
22
|
export var IconTitleWrapper = styled.span(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n white-space: pre-wrap;\n word-break: break-all;\n"]))); // TODO: Replace overrides with proper AtlasKit solution.
|
|
23
23
|
|
|
24
|
-
export var LozengeWrapper = styled.span(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: inline-block;\n vertical-align: 1px;\n & > span {\n margin-left: 4px;\n
|
|
24
|
+
export var LozengeWrapper = styled.span(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: inline-block;\n vertical-align: 1px;\n & > span {\n margin-left: 4px;\n }\n"]))); // TODO: Replace overrides with proper AtlasKit solution.
|
|
25
25
|
|
|
26
|
-
export var LozengeBlockWrapper = styled.span(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n & > span {\n margin-left: 4px;\n
|
|
26
|
+
export var LozengeBlockWrapper = styled.span(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n & > span {\n margin-left: 4px;\n }\n"])));
|
|
27
27
|
export var RightIconPositionWrapper = styled.span(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n margin-left: 2px;\n margin-right: 4px;\n position: relative;\n display: inline-block;\n"]))); // The following components are used to absolutely position icons in the vertical center.
|
|
28
28
|
// - IconPositionWrapper: the `relative` parent which has no height in itself.
|
|
29
29
|
// - IconEmptyWrapper: the child which forces `IconPositionWrapper` to have a height.
|
|
@@ -25,10 +25,12 @@ manually passed to your custom components.
|
|
|
25
25
|
|
|
26
26
|
For a complete guide on customization using the new compositional API, refer to the docs at
|
|
27
27
|
https://atlassian.design/components/modal-dialog/examples#customizing-modal-dialog. */
|
|
28
|
-
import React, { useState } from 'react';
|
|
29
|
-
import ModalDialog, {
|
|
28
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
29
|
+
import ModalDialog, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
|
|
30
30
|
import { Header } from './ModalHeader';
|
|
31
31
|
import { getIframeSandboxAttribute } from '../../utils';
|
|
32
|
+
import withAnalytics from '../EmbedModal/components/analytics';
|
|
33
|
+
import { EmbedModalSize } from '../EmbedModal/types';
|
|
32
34
|
var iframeStyles = {
|
|
33
35
|
width: "100%",
|
|
34
36
|
height: 'calc(100vh - 248px)'
|
|
@@ -72,7 +74,8 @@ var Modal = function Modal(_ref) {
|
|
|
72
74
|
providerName = _ref.providerName,
|
|
73
75
|
metadata = _ref.metadata,
|
|
74
76
|
icon = _ref.icon,
|
|
75
|
-
closeLabel = _ref.closeLabel,
|
|
77
|
+
_ref$closeLabel = _ref.closeLabel,
|
|
78
|
+
closeLabel = _ref$closeLabel === void 0 ? 'Close Preview' : _ref$closeLabel,
|
|
76
79
|
iframeName = _ref.iframeName,
|
|
77
80
|
title = _ref.title,
|
|
78
81
|
url = _ref.url,
|
|
@@ -88,16 +91,35 @@ var Modal = function Modal(_ref) {
|
|
|
88
91
|
isOpen = _useState2[0],
|
|
89
92
|
setIsOpen = _useState2[1];
|
|
90
93
|
|
|
94
|
+
var openAt = useRef();
|
|
95
|
+
var handleOnOpenComplete = useCallback(function () {
|
|
96
|
+
openAt.current = Date.now();
|
|
97
|
+
|
|
98
|
+
if (onOpen) {
|
|
99
|
+
onOpen({
|
|
100
|
+
size: EmbedModalSize.Small
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}, [onOpen]);
|
|
104
|
+
var handleOnCloseComplete = useCallback(function () {
|
|
105
|
+
if (onClose) {
|
|
106
|
+
var duration = openAt.current ? Date.now() - openAt.current : undefined;
|
|
107
|
+
onClose({
|
|
108
|
+
duration: duration,
|
|
109
|
+
size: EmbedModalSize.Small
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}, [onClose]);
|
|
91
113
|
var sandbox = getIframeSandboxAttribute(isTrusted);
|
|
92
114
|
return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(ModalDialog, {
|
|
93
115
|
height: "100%",
|
|
94
116
|
width: "large",
|
|
95
117
|
testId: testId,
|
|
96
|
-
onOpenComplete:
|
|
118
|
+
onOpenComplete: handleOnOpenComplete,
|
|
97
119
|
onClose: function onClose() {
|
|
98
120
|
setIsOpen(false);
|
|
99
121
|
},
|
|
100
|
-
onCloseComplete:
|
|
122
|
+
onCloseComplete: handleOnCloseComplete
|
|
101
123
|
}, /*#__PURE__*/React.createElement(Header, {
|
|
102
124
|
providerName: providerName,
|
|
103
125
|
icon: icon,
|
|
@@ -123,4 +145,4 @@ var Modal = function Modal(_ref) {
|
|
|
123
145
|
}))));
|
|
124
146
|
};
|
|
125
147
|
|
|
126
|
-
export default ModalWithErrorBoundary;
|
|
148
|
+
export default withAnalytics(ModalWithErrorBoundary);
|
|
@@ -75,7 +75,7 @@ export var Header = function Header(_ref) {
|
|
|
75
75
|
testId: "preview-view-action",
|
|
76
76
|
iconAfter: jsx(ShortcutIcon, {
|
|
77
77
|
size: "small",
|
|
78
|
-
label: "
|
|
78
|
+
label: ""
|
|
79
79
|
}),
|
|
80
80
|
onClick: onViewActionClick
|
|
81
81
|
}, providerName ? jsx(F, null, jsx(FormattedMessage, messages.viewIn), " ", providerName) : jsx(FormattedMessage, messages.viewOriginal)), jsx(Button, {
|
|
@@ -83,6 +83,7 @@ export var Header = function Header(_ref) {
|
|
|
83
83
|
iconBefore: jsx(EditorCloseIcon, {
|
|
84
84
|
label: label
|
|
85
85
|
}),
|
|
86
|
-
onClick: onClose
|
|
86
|
+
onClick: onClose,
|
|
87
|
+
testId: "preview-close-button"
|
|
87
88
|
}))));
|
|
88
89
|
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { LinkingPlatformFeatureFlags } from '@atlaskit/linking-common';
|
|
2
2
|
import { InvokeHandler } from '../../model/invoke-handler';
|
|
3
|
-
import {
|
|
3
|
+
import { AnalyticsFacade } from '../../state/analytics';
|
|
4
4
|
import { CardInnerAppearance } from '../../view/Card/types';
|
|
5
|
+
import { AnalyticsOrigin } from '../../utils/types';
|
|
5
6
|
export interface ExtractBlockOpts {
|
|
6
7
|
handleInvoke: InvokeHandler;
|
|
7
|
-
|
|
8
|
+
analytics: AnalyticsFacade;
|
|
9
|
+
origin?: AnalyticsOrigin;
|
|
8
10
|
extensionKey?: string;
|
|
9
11
|
featureFlags?: Partial<LinkingPlatformFeatureFlags>;
|
|
10
12
|
source?: CardInnerAppearance;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { JsonLd } from 'json-ld-types';
|
|
2
|
-
import {
|
|
3
|
-
import { InvokeHandler } from '../../../model/invoke-handler';
|
|
4
|
-
import { CardInnerAppearance } from '../../../view/Card/types';
|
|
5
|
-
import { AnalyticsHandler } from '../../../utils/types';
|
|
2
|
+
import { CardPlatform } from '../../../view/Card/types';
|
|
6
3
|
import { BlockCardResolvedViewProps } from '../../../view/BlockCard';
|
|
7
|
-
|
|
4
|
+
import { ExtractBlockOpts } from '../../block/types';
|
|
5
|
+
export declare const extractPreviewAction: ({ extensionKey, viewProps, jsonLd, handleInvoke, testId, platform, origin, source, featureFlags, analytics, }: ExtractBlockOpts & {
|
|
6
|
+
viewProps: BlockCardResolvedViewProps;
|
|
7
|
+
jsonLd: JsonLd.Data.BaseData;
|
|
8
|
+
platform?: JsonLd.Primitives.Platforms | undefined;
|
|
9
|
+
}) => import("../../../view/BlockCard/components/Action").ActionProps | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DestinationSubproduct, DestinationProduct } from '../../utils/analytics/types';
|
|
2
|
+
export interface CommonEventProps {
|
|
3
|
+
definitionId?: string;
|
|
4
|
+
extensionKey?: string;
|
|
5
|
+
resourceType?: string;
|
|
6
|
+
destinationSubproduct?: DestinationSubproduct | string;
|
|
7
|
+
destinationProduct?: DestinationProduct | string;
|
|
8
|
+
location?: string;
|
|
9
|
+
}
|