@atlaskit/smart-card 23.6.2 → 23.6.4
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/extractors/common/actions/extractPreviewAction.js +2 -2
- package/dist/cjs/state/hooks-external/useSmartLinkActions.js +27 -5
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/actions/PreviewAction.js +3 -3
- package/dist/cjs/view/BlockCard/index.js +5 -2
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +40 -5
- package/dist/cjs/view/HoverCard/utils.js +3 -1
- package/dist/es2019/extractors/common/actions/extractPreviewAction.js +3 -1
- package/dist/es2019/state/hooks-external/useSmartLinkActions.js +25 -4
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/actions/PreviewAction.js +2 -1
- package/dist/es2019/view/BlockCard/index.js +4 -1
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +33 -5
- package/dist/es2019/view/HoverCard/utils.js +3 -1
- package/dist/esm/extractors/common/actions/extractPreviewAction.js +2 -2
- package/dist/esm/state/hooks-external/useSmartLinkActions.js +27 -6
- 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 -2
- package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +40 -6
- package/dist/esm/view/HoverCard/utils.js +3 -1
- package/dist/types/model/invoke-opts.d.ts +1 -1
- package/dist/types/state/hooks-external/useSmartLinkActions.d.ts +5 -1
- package/dist/types/view/BlockCard/components/Action.d.ts +1 -1
- package/dist/types/view/BlockCard/views/flexible/FlexibleResolvedView.d.ts +1 -1
- package/dist/types/view/BlockCard/views/flexible/types.d.ts +9 -0
- package/dist/types/view/Card/index.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 23.6.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e402b41fc94`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e402b41fc94) - [ux] This change removes the icons on flexible block card actions, and also adds analytics for each of the flexible block card actions to maintain parity with the older block card.
|
|
8
|
+
|
|
9
|
+
## 23.6.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`b3c2a297df4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b3c2a297df4) - Hover Preview: Actionable element experiment: Reload link after embed view modal is closed
|
|
14
|
+
|
|
3
15
|
## 23.6.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -100,8 +100,8 @@ var extractPreviewAction = function extractPreviewAction(_ref) {
|
|
|
100
100
|
|
|
101
101
|
previewActionProps.action.promise = previewAction.promise; // - Promise invoked on click of `Preview` on block card; trigger above promise.
|
|
102
102
|
|
|
103
|
-
previewAction.promise = function () {
|
|
104
|
-
return handleInvoke(previewActionProps);
|
|
103
|
+
previewAction.promise = function (opts) {
|
|
104
|
+
return handleInvoke(_objectSpread(_objectSpread({}, previewActionProps), opts));
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
return previewAction;
|
|
@@ -23,6 +23,8 @@ var _store = require("../store");
|
|
|
23
23
|
|
|
24
24
|
var _helpers = require("../helpers");
|
|
25
25
|
|
|
26
|
+
var _linkProvider = require("@atlaskit/link-provider");
|
|
27
|
+
|
|
26
28
|
function useSmartLinkActions(_ref) {
|
|
27
29
|
var url = _ref.url,
|
|
28
30
|
appearance = _ref.appearance,
|
|
@@ -41,16 +43,36 @@ function useSmartLinkActions(_ref) {
|
|
|
41
43
|
|
|
42
44
|
var linkState = (0, _store.useSmartCardState)(url);
|
|
43
45
|
var linkAnalytics = (0, _analytics.useSmartLinkAnalytics)(url, analyticsHandler, id);
|
|
44
|
-
var linkActions = (0, _actions.useSmartCardActions)(id, url, linkAnalytics);
|
|
46
|
+
var linkActions = (0, _actions.useSmartCardActions)(id, url, linkAnalytics); // Start: Smart ink Actions experiment
|
|
47
|
+
|
|
48
|
+
var enableActionableElement = (0, _linkProvider.useFeatureFlag)('enableActionableElement');
|
|
49
|
+
var reload = (0, _react.useCallback)(function () {
|
|
50
|
+
return linkActions.reload();
|
|
51
|
+
}, [linkActions]);
|
|
52
|
+
var handleInvoke = (0, _react.useCallback)(function (opts) {
|
|
53
|
+
var _opts$action;
|
|
54
|
+
|
|
55
|
+
if (enableActionableElement && opts.type === 'client' && opts.isReloadRequired && ((_opts$action = opts.action) === null || _opts$action === void 0 ? void 0 : _opts$action.type) === 'PreviewAction') {
|
|
56
|
+
// Reload when embed preview modal close
|
|
57
|
+
var promise = opts.action.promise;
|
|
58
|
+
|
|
59
|
+
opts.action.promise = function () {
|
|
60
|
+
return promise({
|
|
61
|
+
onClose: reload
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return linkActions.invoke(opts, appearance);
|
|
67
|
+
}, [appearance, enableActionableElement, linkActions, reload]); // End: Smart ink Actions experiment
|
|
68
|
+
|
|
45
69
|
(0, _react.useEffect)(function () {
|
|
46
70
|
if (!linkState.details) {
|
|
47
71
|
return;
|
|
48
72
|
}
|
|
49
73
|
|
|
50
74
|
var cardProperties = (0, _block.extractBlockProps)(linkState.details.data, linkState.details.meta, {
|
|
51
|
-
handleInvoke:
|
|
52
|
-
return linkActions.invoke(opts, appearance);
|
|
53
|
-
},
|
|
75
|
+
handleInvoke: handleInvoke,
|
|
54
76
|
analytics: linkAnalytics,
|
|
55
77
|
origin: origin,
|
|
56
78
|
extensionKey: (0, _helpers.getExtensionKey)(linkState.details),
|
|
@@ -69,6 +91,6 @@ function useSmartLinkActions(_ref) {
|
|
|
69
91
|
};
|
|
70
92
|
});
|
|
71
93
|
setActions(cardActions);
|
|
72
|
-
}, [linkState, linkActions, linkAnalytics, appearance, platform, origin]);
|
|
94
|
+
}, [linkState, linkActions, linkAnalytics, appearance, platform, origin, handleInvoke]);
|
|
73
95
|
return actions;
|
|
74
96
|
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -115,14 +115,14 @@ var _default = function _default(_ref2) {
|
|
|
115
115
|
return {
|
|
116
116
|
id: 'preview-content',
|
|
117
117
|
text: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.preview),
|
|
118
|
-
promise: function promise() {
|
|
119
|
-
return previewFunction(_objectSpread({
|
|
118
|
+
promise: function promise(props) {
|
|
119
|
+
return previewFunction(_objectSpread(_objectSpread({
|
|
120
120
|
popupMountPointId: 'twp-editor-preview-iframe',
|
|
121
121
|
providerName: 'Preview',
|
|
122
122
|
showModal: true,
|
|
123
123
|
iframeName: 'twp-editor-preview-iframe',
|
|
124
124
|
onClose: function onClose() {}
|
|
125
|
-
}, rest));
|
|
125
|
+
}, props), rest));
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
};
|
|
@@ -114,7 +114,8 @@ var flexibleBlockCardElevationStyle = (0, _react.css)(_templateObject || (_templ
|
|
|
114
114
|
var BlockCard = function BlockCard(_ref) {
|
|
115
115
|
var _details$meta, _forbiddenViewProps$c;
|
|
116
116
|
|
|
117
|
-
var
|
|
117
|
+
var id = _ref.id,
|
|
118
|
+
url = _ref.url,
|
|
118
119
|
cardState = _ref.cardState,
|
|
119
120
|
authFlow = _ref.authFlow,
|
|
120
121
|
handleAuthorize = _ref.handleAuthorize,
|
|
@@ -146,12 +147,14 @@ var BlockCard = function BlockCard(_ref) {
|
|
|
146
147
|
hideElevation: true
|
|
147
148
|
};
|
|
148
149
|
var flexibleProps = {
|
|
150
|
+
id: id,
|
|
149
151
|
cardState: cardState,
|
|
150
152
|
url: url,
|
|
151
153
|
testId: testId,
|
|
152
154
|
onError: onError,
|
|
153
155
|
renderers: renderers,
|
|
154
|
-
ui: ui
|
|
156
|
+
ui: ui,
|
|
157
|
+
analytics: analytics
|
|
155
158
|
};
|
|
156
159
|
|
|
157
160
|
switch (status) {
|
|
@@ -21,6 +21,8 @@ var _blocks = require("../../../FlexibleCard/components/blocks");
|
|
|
21
21
|
|
|
22
22
|
var _constants = require("../../../../constants");
|
|
23
23
|
|
|
24
|
+
var _uuid = _interopRequireDefault(require("uuid"));
|
|
25
|
+
|
|
24
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
27
|
|
|
26
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -31,13 +33,15 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
31
33
|
* @see FlexibleCardProps
|
|
32
34
|
*/
|
|
33
35
|
var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
|
|
34
|
-
var
|
|
36
|
+
var id = _ref.id,
|
|
37
|
+
cardState = _ref.cardState,
|
|
35
38
|
onClick = _ref.onClick,
|
|
36
39
|
onError = _ref.onError,
|
|
37
40
|
_ref$testId = _ref.testId,
|
|
38
41
|
testId = _ref$testId === void 0 ? 'smart-block-resolved-view' : _ref$testId,
|
|
39
42
|
ui = _ref.ui,
|
|
40
|
-
url = _ref.url
|
|
43
|
+
url = _ref.url,
|
|
44
|
+
analytics = _ref.analytics;
|
|
41
45
|
|
|
42
46
|
var _useState = (0, _react.useState)(false),
|
|
43
47
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -47,6 +51,13 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
|
|
|
47
51
|
(0, _react.useEffect)(function () {
|
|
48
52
|
setIsPreviewBlockErrored(false);
|
|
49
53
|
}, [url, cardState]);
|
|
54
|
+
|
|
55
|
+
var _useState3 = (0, _react.useState)(function () {
|
|
56
|
+
return id ? id : (0, _uuid.default)();
|
|
57
|
+
}),
|
|
58
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 1),
|
|
59
|
+
analyticsId = _useState4[0];
|
|
60
|
+
|
|
50
61
|
return /*#__PURE__*/_react.default.createElement(_FlexibleCard.default, {
|
|
51
62
|
appearance: "block",
|
|
52
63
|
cardState: cardState,
|
|
@@ -95,11 +106,35 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
|
|
|
95
106
|
}
|
|
96
107
|
}) : null, /*#__PURE__*/_react.default.createElement(_blocks.FooterBlock, {
|
|
97
108
|
actions: [{
|
|
98
|
-
name: _constants.ActionName.PreviewAction
|
|
109
|
+
name: _constants.ActionName.PreviewAction,
|
|
110
|
+
hideIcon: true,
|
|
111
|
+
onClick: function onClick() {
|
|
112
|
+
analytics.operational.invokeSucceededEvent({
|
|
113
|
+
id: analyticsId,
|
|
114
|
+
actionType: 'preview',
|
|
115
|
+
display: 'block'
|
|
116
|
+
});
|
|
117
|
+
}
|
|
99
118
|
}, {
|
|
100
|
-
name: _constants.ActionName.ViewAction
|
|
119
|
+
name: _constants.ActionName.ViewAction,
|
|
120
|
+
hideIcon: true,
|
|
121
|
+
onClick: function onClick() {
|
|
122
|
+
analytics.operational.invokeSucceededEvent({
|
|
123
|
+
id: analyticsId,
|
|
124
|
+
actionType: 'view',
|
|
125
|
+
display: 'block'
|
|
126
|
+
});
|
|
127
|
+
}
|
|
101
128
|
}, {
|
|
102
|
-
name: _constants.ActionName.DownloadAction
|
|
129
|
+
name: _constants.ActionName.DownloadAction,
|
|
130
|
+
hideIcon: true,
|
|
131
|
+
onClick: function onClick() {
|
|
132
|
+
analytics.operational.invokeSucceededEvent({
|
|
133
|
+
id: analyticsId,
|
|
134
|
+
actionType: 'download',
|
|
135
|
+
display: 'block'
|
|
136
|
+
});
|
|
137
|
+
}
|
|
103
138
|
}]
|
|
104
139
|
}));
|
|
105
140
|
};
|
|
@@ -121,7 +121,9 @@ var toActionableMetadata = function toActionableMetadata(onActionClick, extensio
|
|
|
121
121
|
onActionClick(previewAction.id);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
return previewAction.invoke(
|
|
124
|
+
return previewAction.invoke({
|
|
125
|
+
isReloadRequired: true
|
|
126
|
+
});
|
|
125
127
|
}
|
|
126
128
|
}) : elementItem;
|
|
127
129
|
});
|
|
@@ -76,7 +76,9 @@ export const extractPreviewAction = ({
|
|
|
76
76
|
|
|
77
77
|
previewActionProps.action.promise = previewAction.promise; // - Promise invoked on click of `Preview` on block card; trigger above promise.
|
|
78
78
|
|
|
79
|
-
previewAction.promise =
|
|
79
|
+
previewAction.promise = opts => handleInvoke({ ...previewActionProps,
|
|
80
|
+
...opts
|
|
81
|
+
});
|
|
80
82
|
|
|
81
83
|
return previewAction;
|
|
82
84
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import uuid from 'uuid';
|
|
3
3
|
import { extractBlockProps as extractCardProps } from '../../extractors/block';
|
|
4
4
|
import { useSmartCardActions as useLinkActions } from '../actions';
|
|
5
5
|
import { useSmartLinkAnalytics as useLinkAnalytics } from '../analytics';
|
|
6
6
|
import { useSmartCardState as useLinkState } from '../store';
|
|
7
7
|
import { getExtensionKey } from '../helpers';
|
|
8
|
+
import { useFeatureFlag } from '@atlaskit/link-provider';
|
|
8
9
|
export function useSmartLinkActions({
|
|
9
10
|
url,
|
|
10
11
|
appearance,
|
|
@@ -16,14 +17,34 @@ export function useSmartLinkActions({
|
|
|
16
17
|
const [actions, setActions] = useState([]);
|
|
17
18
|
const linkState = useLinkState(url);
|
|
18
19
|
const linkAnalytics = useLinkAnalytics(url, analyticsHandler, id);
|
|
19
|
-
const linkActions = useLinkActions(id, url, linkAnalytics);
|
|
20
|
+
const linkActions = useLinkActions(id, url, linkAnalytics); // Start: Smart ink Actions experiment
|
|
21
|
+
|
|
22
|
+
const enableActionableElement = useFeatureFlag('enableActionableElement');
|
|
23
|
+
const reload = useCallback(() => linkActions.reload(), [linkActions]);
|
|
24
|
+
const handleInvoke = useCallback(opts => {
|
|
25
|
+
var _opts$action;
|
|
26
|
+
|
|
27
|
+
if (enableActionableElement && opts.type === 'client' && opts.isReloadRequired && ((_opts$action = opts.action) === null || _opts$action === void 0 ? void 0 : _opts$action.type) === 'PreviewAction') {
|
|
28
|
+
// Reload when embed preview modal close
|
|
29
|
+
const {
|
|
30
|
+
promise
|
|
31
|
+
} = opts.action;
|
|
32
|
+
|
|
33
|
+
opts.action.promise = () => promise({
|
|
34
|
+
onClose: reload
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return linkActions.invoke(opts, appearance);
|
|
39
|
+
}, [appearance, enableActionableElement, linkActions, reload]); // End: Smart ink Actions experiment
|
|
40
|
+
|
|
20
41
|
useEffect(() => {
|
|
21
42
|
if (!linkState.details) {
|
|
22
43
|
return;
|
|
23
44
|
}
|
|
24
45
|
|
|
25
46
|
const cardProperties = extractCardProps(linkState.details.data, linkState.details.meta, {
|
|
26
|
-
handleInvoke
|
|
47
|
+
handleInvoke,
|
|
27
48
|
analytics: linkAnalytics,
|
|
28
49
|
origin,
|
|
29
50
|
extensionKey: getExtensionKey(linkState.details),
|
|
@@ -40,6 +61,6 @@ export function useSmartLinkActions({
|
|
|
40
61
|
invoke: action.promise
|
|
41
62
|
}));
|
|
42
63
|
setActions(cardActions);
|
|
43
|
-
}, [linkState, linkActions, linkAnalytics, appearance, platform, origin]);
|
|
64
|
+
}, [linkState, linkActions, linkAnalytics, appearance, platform, origin, handleInvoke]);
|
|
44
65
|
return actions;
|
|
45
66
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -55,12 +55,13 @@ export default (({
|
|
|
55
55
|
}) => ({
|
|
56
56
|
id: 'preview-content',
|
|
57
57
|
text: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview),
|
|
58
|
-
promise:
|
|
58
|
+
promise: props => previewFunction({
|
|
59
59
|
popupMountPointId: 'twp-editor-preview-iframe',
|
|
60
60
|
providerName: 'Preview',
|
|
61
61
|
showModal: true,
|
|
62
62
|
iframeName: 'twp-editor-preview-iframe',
|
|
63
63
|
onClose: () => {},
|
|
64
|
+
...props,
|
|
64
65
|
...rest
|
|
65
66
|
})
|
|
66
67
|
}));
|
|
@@ -29,6 +29,7 @@ const flexibleBlockCardElevationStyle = css`
|
|
|
29
29
|
margin: 2px;
|
|
30
30
|
`;
|
|
31
31
|
export const BlockCard = ({
|
|
32
|
+
id,
|
|
32
33
|
url,
|
|
33
34
|
cardState,
|
|
34
35
|
authFlow,
|
|
@@ -66,12 +67,14 @@ export const BlockCard = ({
|
|
|
66
67
|
hideElevation: true
|
|
67
68
|
};
|
|
68
69
|
const flexibleProps = {
|
|
70
|
+
id,
|
|
69
71
|
cardState,
|
|
70
72
|
url,
|
|
71
73
|
testId,
|
|
72
74
|
onError,
|
|
73
75
|
renderers,
|
|
74
|
-
ui
|
|
76
|
+
ui,
|
|
77
|
+
analytics
|
|
75
78
|
};
|
|
76
79
|
|
|
77
80
|
switch (status) {
|
|
@@ -3,24 +3,28 @@ 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
5
|
import { ActionName, 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.
|
|
9
9
|
* @see SmartLinkStatus
|
|
10
10
|
* @see FlexibleCardProps
|
|
11
11
|
*/
|
|
12
|
+
|
|
12
13
|
const FlexibleResolvedView = ({
|
|
14
|
+
id,
|
|
13
15
|
cardState,
|
|
14
16
|
onClick,
|
|
15
17
|
onError,
|
|
16
18
|
testId = 'smart-block-resolved-view',
|
|
17
19
|
ui,
|
|
18
|
-
url
|
|
20
|
+
url,
|
|
21
|
+
analytics
|
|
19
22
|
}) => {
|
|
20
23
|
const [isPreviewBlockErrored, setIsPreviewBlockErrored] = useState(false);
|
|
21
24
|
useEffect(() => {
|
|
22
25
|
setIsPreviewBlockErrored(false);
|
|
23
26
|
}, [url, cardState]);
|
|
27
|
+
const [analyticsId] = useState(() => id ? id : uuid());
|
|
24
28
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
25
29
|
appearance: "block",
|
|
26
30
|
cardState: cardState,
|
|
@@ -69,11 +73,35 @@ const FlexibleResolvedView = ({
|
|
|
69
73
|
}
|
|
70
74
|
}) : null, /*#__PURE__*/React.createElement(FooterBlock, {
|
|
71
75
|
actions: [{
|
|
72
|
-
name: ActionName.PreviewAction
|
|
76
|
+
name: ActionName.PreviewAction,
|
|
77
|
+
hideIcon: true,
|
|
78
|
+
onClick: () => {
|
|
79
|
+
analytics.operational.invokeSucceededEvent({
|
|
80
|
+
id: analyticsId,
|
|
81
|
+
actionType: 'preview',
|
|
82
|
+
display: 'block'
|
|
83
|
+
});
|
|
84
|
+
}
|
|
73
85
|
}, {
|
|
74
|
-
name: ActionName.ViewAction
|
|
86
|
+
name: ActionName.ViewAction,
|
|
87
|
+
hideIcon: true,
|
|
88
|
+
onClick: () => {
|
|
89
|
+
analytics.operational.invokeSucceededEvent({
|
|
90
|
+
id: analyticsId,
|
|
91
|
+
actionType: 'view',
|
|
92
|
+
display: 'block'
|
|
93
|
+
});
|
|
94
|
+
}
|
|
75
95
|
}, {
|
|
76
|
-
name: ActionName.DownloadAction
|
|
96
|
+
name: ActionName.DownloadAction,
|
|
97
|
+
hideIcon: true,
|
|
98
|
+
onClick: () => {
|
|
99
|
+
analytics.operational.invokeSucceededEvent({
|
|
100
|
+
id: analyticsId,
|
|
101
|
+
actionType: 'download',
|
|
102
|
+
display: 'block'
|
|
103
|
+
});
|
|
104
|
+
}
|
|
77
105
|
}]
|
|
78
106
|
}));
|
|
79
107
|
};
|
|
@@ -89,8 +89,8 @@ export var extractPreviewAction = function extractPreviewAction(_ref) {
|
|
|
89
89
|
|
|
90
90
|
previewActionProps.action.promise = previewAction.promise; // - Promise invoked on click of `Preview` on block card; trigger above promise.
|
|
91
91
|
|
|
92
|
-
previewAction.promise = function () {
|
|
93
|
-
return handleInvoke(previewActionProps);
|
|
92
|
+
previewAction.promise = function (opts) {
|
|
93
|
+
return handleInvoke(_objectSpread(_objectSpread({}, previewActionProps), opts));
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
return previewAction;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import uuid from 'uuid';
|
|
4
4
|
import { extractBlockProps as extractCardProps } from '../../extractors/block';
|
|
5
5
|
import { useSmartCardActions as useLinkActions } from '../actions';
|
|
6
6
|
import { useSmartLinkAnalytics as useLinkAnalytics } from '../analytics';
|
|
7
7
|
import { useSmartCardState as useLinkState } from '../store';
|
|
8
8
|
import { getExtensionKey } from '../helpers';
|
|
9
|
+
import { useFeatureFlag } from '@atlaskit/link-provider';
|
|
9
10
|
export function useSmartLinkActions(_ref) {
|
|
10
11
|
var url = _ref.url,
|
|
11
12
|
appearance = _ref.appearance,
|
|
@@ -24,16 +25,36 @@ export function useSmartLinkActions(_ref) {
|
|
|
24
25
|
|
|
25
26
|
var linkState = useLinkState(url);
|
|
26
27
|
var linkAnalytics = useLinkAnalytics(url, analyticsHandler, id);
|
|
27
|
-
var linkActions = useLinkActions(id, url, linkAnalytics);
|
|
28
|
+
var linkActions = useLinkActions(id, url, linkAnalytics); // Start: Smart ink Actions experiment
|
|
29
|
+
|
|
30
|
+
var enableActionableElement = useFeatureFlag('enableActionableElement');
|
|
31
|
+
var reload = useCallback(function () {
|
|
32
|
+
return linkActions.reload();
|
|
33
|
+
}, [linkActions]);
|
|
34
|
+
var handleInvoke = useCallback(function (opts) {
|
|
35
|
+
var _opts$action;
|
|
36
|
+
|
|
37
|
+
if (enableActionableElement && opts.type === 'client' && opts.isReloadRequired && ((_opts$action = opts.action) === null || _opts$action === void 0 ? void 0 : _opts$action.type) === 'PreviewAction') {
|
|
38
|
+
// Reload when embed preview modal close
|
|
39
|
+
var promise = opts.action.promise;
|
|
40
|
+
|
|
41
|
+
opts.action.promise = function () {
|
|
42
|
+
return promise({
|
|
43
|
+
onClose: reload
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return linkActions.invoke(opts, appearance);
|
|
49
|
+
}, [appearance, enableActionableElement, linkActions, reload]); // End: Smart ink Actions experiment
|
|
50
|
+
|
|
28
51
|
useEffect(function () {
|
|
29
52
|
if (!linkState.details) {
|
|
30
53
|
return;
|
|
31
54
|
}
|
|
32
55
|
|
|
33
56
|
var cardProperties = extractCardProps(linkState.details.data, linkState.details.meta, {
|
|
34
|
-
handleInvoke:
|
|
35
|
-
return linkActions.invoke(opts, appearance);
|
|
36
|
-
},
|
|
57
|
+
handleInvoke: handleInvoke,
|
|
37
58
|
analytics: linkAnalytics,
|
|
38
59
|
origin: origin,
|
|
39
60
|
extensionKey: getExtensionKey(linkState.details),
|
|
@@ -52,6 +73,6 @@ export function useSmartLinkActions(_ref) {
|
|
|
52
73
|
};
|
|
53
74
|
});
|
|
54
75
|
setActions(cardActions);
|
|
55
|
-
}, [linkState, linkActions, linkAnalytics, appearance, platform, origin]);
|
|
76
|
+
}, [linkState, linkActions, linkAnalytics, appearance, platform, origin, handleInvoke]);
|
|
56
77
|
return actions;
|
|
57
78
|
}
|
package/dist/esm/version.json
CHANGED
|
@@ -88,14 +88,14 @@ export default (function (_ref2) {
|
|
|
88
88
|
return {
|
|
89
89
|
id: 'preview-content',
|
|
90
90
|
text: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview),
|
|
91
|
-
promise: function promise() {
|
|
92
|
-
return previewFunction(_objectSpread({
|
|
91
|
+
promise: function promise(props) {
|
|
92
|
+
return previewFunction(_objectSpread(_objectSpread({
|
|
93
93
|
popupMountPointId: 'twp-editor-preview-iframe',
|
|
94
94
|
providerName: 'Preview',
|
|
95
95
|
showModal: true,
|
|
96
96
|
iframeName: 'twp-editor-preview-iframe',
|
|
97
97
|
onClose: function onClose() {}
|
|
98
|
-
}, rest));
|
|
98
|
+
}, props), rest));
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
});
|
|
@@ -30,7 +30,8 @@ var flexibleBlockCardElevationStyle = css(_templateObject || (_templateObject =
|
|
|
30
30
|
export var BlockCard = function BlockCard(_ref) {
|
|
31
31
|
var _details$meta, _forbiddenViewProps$c;
|
|
32
32
|
|
|
33
|
-
var
|
|
33
|
+
var id = _ref.id,
|
|
34
|
+
url = _ref.url,
|
|
34
35
|
cardState = _ref.cardState,
|
|
35
36
|
authFlow = _ref.authFlow,
|
|
36
37
|
handleAuthorize = _ref.handleAuthorize,
|
|
@@ -62,12 +63,14 @@ export var BlockCard = function BlockCard(_ref) {
|
|
|
62
63
|
hideElevation: true
|
|
63
64
|
};
|
|
64
65
|
var flexibleProps = {
|
|
66
|
+
id: id,
|
|
65
67
|
cardState: cardState,
|
|
66
68
|
url: url,
|
|
67
69
|
testId: testId,
|
|
68
70
|
onError: onError,
|
|
69
71
|
renderers: renderers,
|
|
70
|
-
ui: ui
|
|
72
|
+
ui: ui,
|
|
73
|
+
analytics: analytics
|
|
71
74
|
};
|
|
72
75
|
|
|
73
76
|
switch (status) {
|
|
@@ -4,20 +4,23 @@ import FlexibleCard from '../../../FlexibleCard';
|
|
|
4
4
|
import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
|
|
5
5
|
import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock } from '../../../FlexibleCard/components/blocks';
|
|
6
6
|
import { ActionName, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
|
|
7
|
-
|
|
7
|
+
import uuid from 'uuid';
|
|
8
8
|
/**
|
|
9
9
|
* This view represents a Block card that has an 'Resolved' status.
|
|
10
10
|
* @see SmartLinkStatus
|
|
11
11
|
* @see FlexibleCardProps
|
|
12
12
|
*/
|
|
13
|
+
|
|
13
14
|
var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
|
|
14
|
-
var
|
|
15
|
+
var id = _ref.id,
|
|
16
|
+
cardState = _ref.cardState,
|
|
15
17
|
onClick = _ref.onClick,
|
|
16
18
|
onError = _ref.onError,
|
|
17
19
|
_ref$testId = _ref.testId,
|
|
18
20
|
testId = _ref$testId === void 0 ? 'smart-block-resolved-view' : _ref$testId,
|
|
19
21
|
ui = _ref.ui,
|
|
20
|
-
url = _ref.url
|
|
22
|
+
url = _ref.url,
|
|
23
|
+
analytics = _ref.analytics;
|
|
21
24
|
|
|
22
25
|
var _useState = useState(false),
|
|
23
26
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -27,6 +30,13 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
|
|
|
27
30
|
useEffect(function () {
|
|
28
31
|
setIsPreviewBlockErrored(false);
|
|
29
32
|
}, [url, cardState]);
|
|
33
|
+
|
|
34
|
+
var _useState3 = useState(function () {
|
|
35
|
+
return id ? id : uuid();
|
|
36
|
+
}),
|
|
37
|
+
_useState4 = _slicedToArray(_useState3, 1),
|
|
38
|
+
analyticsId = _useState4[0];
|
|
39
|
+
|
|
30
40
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
31
41
|
appearance: "block",
|
|
32
42
|
cardState: cardState,
|
|
@@ -75,11 +85,35 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
|
|
|
75
85
|
}
|
|
76
86
|
}) : null, /*#__PURE__*/React.createElement(FooterBlock, {
|
|
77
87
|
actions: [{
|
|
78
|
-
name: ActionName.PreviewAction
|
|
88
|
+
name: ActionName.PreviewAction,
|
|
89
|
+
hideIcon: true,
|
|
90
|
+
onClick: function onClick() {
|
|
91
|
+
analytics.operational.invokeSucceededEvent({
|
|
92
|
+
id: analyticsId,
|
|
93
|
+
actionType: 'preview',
|
|
94
|
+
display: 'block'
|
|
95
|
+
});
|
|
96
|
+
}
|
|
79
97
|
}, {
|
|
80
|
-
name: ActionName.ViewAction
|
|
98
|
+
name: ActionName.ViewAction,
|
|
99
|
+
hideIcon: true,
|
|
100
|
+
onClick: function onClick() {
|
|
101
|
+
analytics.operational.invokeSucceededEvent({
|
|
102
|
+
id: analyticsId,
|
|
103
|
+
actionType: 'view',
|
|
104
|
+
display: 'block'
|
|
105
|
+
});
|
|
106
|
+
}
|
|
81
107
|
}, {
|
|
82
|
-
name: ActionName.DownloadAction
|
|
108
|
+
name: ActionName.DownloadAction,
|
|
109
|
+
hideIcon: true,
|
|
110
|
+
onClick: function onClick() {
|
|
111
|
+
analytics.operational.invokeSucceededEvent({
|
|
112
|
+
id: analyticsId,
|
|
113
|
+
actionType: 'download',
|
|
114
|
+
display: 'block'
|
|
115
|
+
});
|
|
116
|
+
}
|
|
83
117
|
}]
|
|
84
118
|
}));
|
|
85
119
|
};
|
|
@@ -106,7 +106,9 @@ export var toActionableMetadata = function toActionableMetadata(onActionClick, e
|
|
|
106
106
|
onActionClick(previewAction.id);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
return previewAction.invoke(
|
|
109
|
+
return previewAction.invoke({
|
|
110
|
+
isReloadRequired: true
|
|
111
|
+
});
|
|
110
112
|
}
|
|
111
113
|
}) : elementItem;
|
|
112
114
|
});
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import { JsonLd } from 'json-ld-types';
|
|
3
3
|
import type { AnalyticsHandler, AnalyticsOrigin } from '../../utils/types';
|
|
4
4
|
import type { CardInnerAppearance } from '../../view/Card/types';
|
|
5
|
+
declare type ExperimentInvokeOpts = {
|
|
6
|
+
isReloadRequired?: boolean;
|
|
7
|
+
};
|
|
5
8
|
export interface LinkAction {
|
|
6
9
|
/**
|
|
7
10
|
* Unique ID for the action.
|
|
@@ -18,7 +21,7 @@ export interface LinkAction {
|
|
|
18
21
|
* Promise to invoke on triggering this action.
|
|
19
22
|
* @example Clicking on `Delete` leading to deletion of content.
|
|
20
23
|
*/
|
|
21
|
-
invoke: () => Promise<any>;
|
|
24
|
+
invoke: (opts?: ExperimentInvokeOpts) => Promise<any>;
|
|
22
25
|
}
|
|
23
26
|
export interface UseSmartLinkActionsOpts {
|
|
24
27
|
/**
|
|
@@ -47,3 +50,4 @@ export interface UseSmartLinkActionsOpts {
|
|
|
47
50
|
origin?: AnalyticsOrigin;
|
|
48
51
|
}
|
|
49
52
|
export declare function useSmartLinkActions({ url, appearance, analyticsHandler, platform, origin, }: UseSmartLinkActionsOpts): LinkAction[];
|
|
53
|
+
export {};
|
|
@@ -5,7 +5,7 @@ import { Appearance } from '@atlaskit/button/types';
|
|
|
5
5
|
export interface ActionProps {
|
|
6
6
|
id: string;
|
|
7
7
|
text: React.ReactNode;
|
|
8
|
-
promise: () => Promise<any>;
|
|
8
|
+
promise: <T>(opts?: T) => Promise<any>;
|
|
9
9
|
buttonAppearance?: Appearance;
|
|
10
10
|
}
|
|
11
11
|
export declare type ActionState = 'init' | 'loading' | 'success' | 'failure';
|
|
@@ -5,5 +5,5 @@ import { FlexibleBlockCardProps } from './types';
|
|
|
5
5
|
* @see SmartLinkStatus
|
|
6
6
|
* @see FlexibleCardProps
|
|
7
7
|
*/
|
|
8
|
-
declare const FlexibleResolvedView: ({ cardState, onClick, onError, testId, ui, url, }: FlexibleBlockCardProps) => JSX.Element;
|
|
8
|
+
declare const FlexibleResolvedView: ({ id, cardState, onClick, onError, testId, ui, url, analytics, }: FlexibleBlockCardProps) => JSX.Element;
|
|
9
9
|
export default FlexibleResolvedView;
|
|
@@ -4,6 +4,7 @@ import { OnErrorCallback } from '../../../types';
|
|
|
4
4
|
import { FlexibleUiOptions } from '../../../FlexibleCard/types';
|
|
5
5
|
import { OnResolveCallback } from '../../../Card/types';
|
|
6
6
|
import { CardProviderRenderers } from '@atlaskit/link-provider';
|
|
7
|
+
import { AnalyticsFacade } from '../../../../state/analytics';
|
|
7
8
|
export declare type FlexibleBlockCardProps = {
|
|
8
9
|
/**
|
|
9
10
|
* Determines the status and data of the Smart Link.
|
|
@@ -49,6 +50,14 @@ export declare type FlexibleBlockCardProps = {
|
|
|
49
50
|
* @see FlexibleUiOptions
|
|
50
51
|
*/
|
|
51
52
|
ui?: FlexibleUiOptions;
|
|
53
|
+
/**
|
|
54
|
+
* A unique id for this Smart Link instance, used for analytics.
|
|
55
|
+
*/
|
|
56
|
+
id?: string;
|
|
57
|
+
/**
|
|
58
|
+
* An AnalyticsFacade object used for calling analytics.
|
|
59
|
+
*/
|
|
60
|
+
analytics: AnalyticsFacade;
|
|
52
61
|
/**
|
|
53
62
|
* Determines the URL of the Smart Link.
|
|
54
63
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CardAppearance, CardPlatform, CardProps } from './types';
|
|
3
3
|
import { WrappedComponentProps } from 'react-intl-next';
|
|
4
|
-
export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "ui" | "showActions" | "onResolve" | "platform" | "
|
|
4
|
+
export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "ui" | "showActions" | "onResolve" | "platform" | "showHoverPreview" | "isFrameVisible" | "embedIframeRef" | "inlinePreloaderStyle" | "importer" | "container" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
|
|
5
5
|
export type { CardAppearance, CardProps, CardPlatform };
|