@atlaskit/smart-card 32.2.2 → 32.4.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 +20 -0
- package/dist/cjs/state/hooks-external/useSmartLinkActions.js +17 -48
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +1 -0
- package/dist/cjs/view/EmbedCard/index.js +33 -4
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/state/hooks-external/useSmartLinkActions.js +17 -43
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +1 -0
- package/dist/es2019/view/EmbedCard/index.js +35 -5
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/state/hooks-external/useSmartLinkActions.js +17 -48
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/CardWithUrl/component.js +1 -0
- package/dist/esm/view/EmbedCard/index.js +33 -4
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/state/hooks-external/useSmartLinkActions.d.ts +3 -3
- package/dist/types/view/EmbedCard/types.d.ts +2 -0
- package/dist/types-ts4.5/state/hooks-external/useSmartLinkActions.d.ts +3 -3
- package/dist/types-ts4.5/view/EmbedCard/types.d.ts +2 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 32.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#170865](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/170865)
|
|
8
|
+
[`774efa325781c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/774efa325781c) -
|
|
9
|
+
[ux] Removes the legacy block card views from the embed card for the resolving and fallback states
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 32.3.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [#171274](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/171274)
|
|
20
|
+
[`3088957fbbf43`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3088957fbbf43) -
|
|
21
|
+
Clean up smart-card-use-refactored-usesmartlinkactions feature gate
|
|
22
|
+
|
|
3
23
|
## 32.2.2
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -7,14 +7,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.useSmartLinkActions = useSmartLinkActions;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
10
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
10
|
var _extractDownloadActionProps = require("../../extractors/action/extractDownloadActionProps");
|
|
12
11
|
var _extractPreviewActionProps = require("../../extractors/action/extractPreviewActionProps");
|
|
13
12
|
var _extractViewActionProps = require("../../extractors/action/extractViewActionProps");
|
|
14
|
-
var _block = require("../../extractors/block");
|
|
15
13
|
var _messages = require("../../messages");
|
|
16
14
|
var _toAction = require("../../utils/actions/to-action");
|
|
17
|
-
var _actions = require("../actions");
|
|
18
15
|
var _analytics = require("../analytics");
|
|
19
16
|
var _helpers = require("../helpers");
|
|
20
17
|
var _useInvokeClientAction = _interopRequireDefault(require("../hooks/use-invoke-client-action"));
|
|
@@ -22,8 +19,6 @@ var _store = require("../store");
|
|
|
22
19
|
function useSmartLinkActions(_ref) {
|
|
23
20
|
var url = _ref.url,
|
|
24
21
|
appearance = _ref.appearance,
|
|
25
|
-
_ref$platform = _ref.platform,
|
|
26
|
-
platform = _ref$platform === void 0 ? 'web' : _ref$platform,
|
|
27
22
|
origin = _ref.origin,
|
|
28
23
|
actionOptions = _ref.actionOptions;
|
|
29
24
|
var id = (0, _react.useMemo)(function () {
|
|
@@ -31,59 +26,33 @@ function useSmartLinkActions(_ref) {
|
|
|
31
26
|
}, []);
|
|
32
27
|
var linkState = (0, _store.useSmartCardState)(url);
|
|
33
28
|
var linkAnalytics = (0, _analytics.useSmartLinkAnalytics)(url, id);
|
|
34
|
-
var linkActions = (0, _actions.useSmartCardActions)(id, url, linkAnalytics);
|
|
35
29
|
var invokeClientAction = (0, _useInvokeClientAction.default)({
|
|
36
30
|
analytics: linkAnalytics
|
|
37
31
|
});
|
|
38
|
-
if ((0, _platformFeatureFlags.fg)('smart-card-use-refactored-usesmartlinkactions')) {
|
|
39
|
-
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
40
|
-
var opts = {
|
|
41
|
-
response: linkState.details,
|
|
42
|
-
handleInvoke: invokeClientAction,
|
|
43
|
-
analytics: linkAnalytics,
|
|
44
|
-
origin: origin,
|
|
45
|
-
extensionKey: (0, _helpers.getExtensionKey)(linkState.details),
|
|
46
|
-
source: appearance,
|
|
47
|
-
actionOptions: actionOptions
|
|
48
|
-
};
|
|
49
|
-
var actions = [];
|
|
50
|
-
var downloadActionProps = (0, _extractDownloadActionProps.extractDownloadActionProps)(opts);
|
|
51
|
-
if (downloadActionProps) {
|
|
52
|
-
actions.push((0, _toAction.toAction)(downloadActionProps, invokeClientAction, _messages.messages.download, 'download-content'));
|
|
53
|
-
}
|
|
54
|
-
var viewActionProps = (0, _extractViewActionProps.extractViewActionProps)(opts);
|
|
55
|
-
if (viewActionProps) {
|
|
56
|
-
actions.push((0, _toAction.toAction)(viewActionProps, invokeClientAction, _messages.messages.view, 'view-content'));
|
|
57
|
-
}
|
|
58
|
-
var previewActionProps = (0, _extractPreviewActionProps.extractPreviewActionProps)(opts);
|
|
59
|
-
if (previewActionProps) {
|
|
60
|
-
actions.push((0, _toAction.toAction)(previewActionProps, invokeClientAction, _messages.messages.preview_improved, 'preview-content'));
|
|
61
|
-
}
|
|
62
|
-
return actions;
|
|
63
|
-
}
|
|
64
|
-
return [];
|
|
65
|
-
}
|
|
66
32
|
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
},
|
|
33
|
+
var opts = {
|
|
34
|
+
response: linkState.details,
|
|
35
|
+
handleInvoke: invokeClientAction,
|
|
71
36
|
analytics: linkAnalytics,
|
|
72
37
|
origin: origin,
|
|
73
38
|
extensionKey: (0, _helpers.getExtensionKey)(linkState.details),
|
|
74
39
|
source: appearance,
|
|
75
40
|
actionOptions: actionOptions
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
41
|
+
};
|
|
42
|
+
var actions = [];
|
|
43
|
+
var downloadActionProps = (0, _extractDownloadActionProps.extractDownloadActionProps)(opts);
|
|
44
|
+
if (downloadActionProps) {
|
|
45
|
+
actions.push((0, _toAction.toAction)(downloadActionProps, invokeClientAction, _messages.messages.download, 'download-content'));
|
|
46
|
+
}
|
|
47
|
+
var viewActionProps = (0, _extractViewActionProps.extractViewActionProps)(opts);
|
|
48
|
+
if (viewActionProps) {
|
|
49
|
+
actions.push((0, _toAction.toAction)(viewActionProps, invokeClientAction, _messages.messages.view, 'view-content'));
|
|
50
|
+
}
|
|
51
|
+
var previewActionProps = (0, _extractPreviewActionProps.extractPreviewActionProps)(opts);
|
|
52
|
+
if (previewActionProps) {
|
|
53
|
+
actions.push((0, _toAction.toAction)(previewActionProps, invokeClientAction, _messages.messages.preview_improved, 'preview-content'));
|
|
86
54
|
}
|
|
55
|
+
return actions;
|
|
87
56
|
}
|
|
88
57
|
return [];
|
|
89
58
|
}
|
|
@@ -17,7 +17,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
|
|
|
17
17
|
var context = exports.context = {
|
|
18
18
|
componentName: 'smart-cards',
|
|
19
19
|
packageName: "@atlaskit/smart-card",
|
|
20
|
-
packageVersion: "32.
|
|
20
|
+
packageVersion: "32.4.0"
|
|
21
21
|
};
|
|
22
22
|
var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
23
23
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -255,6 +255,7 @@ function Component(_ref) {
|
|
|
255
255
|
return /*#__PURE__*/_react.default.createElement(_EmbedCard.EmbedCard, {
|
|
256
256
|
id: id,
|
|
257
257
|
url: url,
|
|
258
|
+
renderers: renderers,
|
|
258
259
|
cardState: state,
|
|
259
260
|
iframeUrlType: embedIframeUrlType,
|
|
260
261
|
handleAuthorize: services.length && handleAuthorize || undefined,
|
|
@@ -8,6 +8,7 @@ exports.EmbedCard = void 0;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var _block = require("../../extractors/block");
|
|
12
13
|
var _extractAccessContext = require("../../extractors/common/context/extractAccessContext");
|
|
13
14
|
var _embed = require("../../extractors/embed");
|
|
@@ -15,6 +16,7 @@ var _inline = require("../../extractors/inline");
|
|
|
15
16
|
var _helpers = require("../../state/helpers");
|
|
16
17
|
var _jsonld = require("../../utils/jsonld");
|
|
17
18
|
var _BlockCard = require("../BlockCard");
|
|
19
|
+
var _FlexibleResolvedView = _interopRequireDefault(require("../BlockCard/views/flexible/FlexibleResolvedView"));
|
|
18
20
|
var _ResolvedView = require("../InlineCard/ResolvedView");
|
|
19
21
|
var _ErroredView = require("./views/ErroredView");
|
|
20
22
|
var _forbiddenView = _interopRequireDefault(require("./views/forbidden-view"));
|
|
@@ -24,9 +26,7 @@ var _unauthorizedView = _interopRequireDefault(require("./views/unauthorized-vie
|
|
|
24
26
|
var EmbedCard = exports.EmbedCard = /*#__PURE__*/_react.default.forwardRef(function (_ref, iframeRef) {
|
|
25
27
|
var _details$meta, _forbiddenViewProps$c, _forbiddenViewProps$c2, _notFoundViewProps$co, _notFoundViewProps$co2;
|
|
26
28
|
var url = _ref.url,
|
|
27
|
-
|
|
28
|
-
status = _ref$cardState.status,
|
|
29
|
-
details = _ref$cardState.details,
|
|
29
|
+
cardState = _ref.cardState,
|
|
30
30
|
handleAuthorize = _ref.handleAuthorize,
|
|
31
31
|
handleErrorRetry = _ref.handleErrorRetry,
|
|
32
32
|
handleFrameClick = _ref.handleFrameClick,
|
|
@@ -42,9 +42,12 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/_react.default.forwardRef(funct
|
|
|
42
42
|
onIframeDwell = _ref.onIframeDwell,
|
|
43
43
|
onIframeFocus = _ref.onIframeFocus,
|
|
44
44
|
iframeUrlType = _ref.iframeUrlType,
|
|
45
|
-
actionOptions = _ref.actionOptions
|
|
45
|
+
actionOptions = _ref.actionOptions,
|
|
46
|
+
renderers = _ref.renderers;
|
|
46
47
|
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
47
48
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
49
|
+
var status = cardState.status,
|
|
50
|
+
details = cardState.details;
|
|
48
51
|
var data = details && details.data || (0, _jsonld.getEmptyJsonLd)();
|
|
49
52
|
var meta = details && details.meta;
|
|
50
53
|
var extensionKey = (0, _helpers.getExtensionKey)(details);
|
|
@@ -52,6 +55,19 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/_react.default.forwardRef(funct
|
|
|
52
55
|
switch (status) {
|
|
53
56
|
case 'pending':
|
|
54
57
|
case 'resolving':
|
|
58
|
+
if ((0, _platformFeatureFlags.fg)('smart-card-remove-block-card-from-embed')) {
|
|
59
|
+
return /*#__PURE__*/_react.default.createElement(_FlexibleResolvedView.default, {
|
|
60
|
+
url: url,
|
|
61
|
+
cardState: cardState,
|
|
62
|
+
onClick: handleFrameClick,
|
|
63
|
+
onError: onError,
|
|
64
|
+
onResolve: onResolve,
|
|
65
|
+
renderers: renderers,
|
|
66
|
+
actionOptions: actionOptions,
|
|
67
|
+
analytics: analytics,
|
|
68
|
+
testId: testId
|
|
69
|
+
});
|
|
70
|
+
}
|
|
55
71
|
return /*#__PURE__*/_react.default.createElement(_BlockCard.BlockCardResolvingView, {
|
|
56
72
|
testId: "embed-card-resolving-view",
|
|
57
73
|
inheritDimensions: inheritDimensions,
|
|
@@ -87,6 +103,19 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/_react.default.forwardRef(funct
|
|
|
87
103
|
onClick: handleFrameClick
|
|
88
104
|
}));
|
|
89
105
|
}
|
|
106
|
+
if ((0, _platformFeatureFlags.fg)('smart-card-remove-block-card-from-embed')) {
|
|
107
|
+
return /*#__PURE__*/_react.default.createElement(_FlexibleResolvedView.default, {
|
|
108
|
+
url: url,
|
|
109
|
+
cardState: cardState,
|
|
110
|
+
onClick: handleFrameClick,
|
|
111
|
+
onError: onError,
|
|
112
|
+
onResolve: onResolve,
|
|
113
|
+
renderers: renderers,
|
|
114
|
+
actionOptions: actionOptions,
|
|
115
|
+
analytics: analytics,
|
|
116
|
+
testId: testId
|
|
117
|
+
});
|
|
118
|
+
}
|
|
90
119
|
var resolvedBlockViewProps = (0, _block.extractBlockProps)(data, meta, {
|
|
91
120
|
analytics: analytics,
|
|
92
121
|
origin: 'smartLinkEmbed',
|
|
@@ -17,7 +17,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
|
|
|
17
17
|
_excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
|
|
18
18
|
var PACKAGE_DATA = {
|
|
19
19
|
packageName: "@atlaskit/smart-card",
|
|
20
|
-
packageVersion: "32.
|
|
20
|
+
packageVersion: "32.4.0",
|
|
21
21
|
componentName: 'linkUrl'
|
|
22
22
|
};
|
|
23
23
|
var Link = (0, _click.withLinkClickedEvent)('a');
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import uuid from 'uuid';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { extractDownloadActionProps } from '../../extractors/action/extractDownloadActionProps';
|
|
5
4
|
import { extractPreviewActionProps } from '../../extractors/action/extractPreviewActionProps';
|
|
6
5
|
import { extractViewActionProps } from '../../extractors/action/extractViewActionProps';
|
|
7
|
-
import { extractBlockProps as extractCardProps } from '../../extractors/block';
|
|
8
6
|
import { messages } from '../../messages';
|
|
9
7
|
import { toAction } from '../../utils/actions/to-action';
|
|
10
|
-
import { useSmartCardActions as useLinkActions } from '../actions';
|
|
11
8
|
import { useSmartLinkAnalytics as useLinkAnalytics } from '../analytics';
|
|
12
9
|
import { getExtensionKey } from '../helpers';
|
|
13
10
|
import useInvokeClientAction from '../hooks/use-invoke-client-action';
|
|
@@ -15,62 +12,39 @@ import { useSmartCardState as useLinkState } from '../store';
|
|
|
15
12
|
export function useSmartLinkActions({
|
|
16
13
|
url,
|
|
17
14
|
appearance,
|
|
18
|
-
platform = 'web',
|
|
19
15
|
origin,
|
|
20
16
|
actionOptions
|
|
21
17
|
}) {
|
|
22
18
|
const id = useMemo(() => uuid(), []);
|
|
23
19
|
const linkState = useLinkState(url);
|
|
24
20
|
const linkAnalytics = useLinkAnalytics(url, id);
|
|
25
|
-
const linkActions = useLinkActions(id, url, linkAnalytics);
|
|
26
21
|
const invokeClientAction = useInvokeClientAction({
|
|
27
22
|
analytics: linkAnalytics
|
|
28
23
|
});
|
|
29
|
-
if (fg('smart-card-use-refactored-usesmartlinkactions')) {
|
|
30
|
-
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
31
|
-
const opts = {
|
|
32
|
-
response: linkState.details,
|
|
33
|
-
handleInvoke: invokeClientAction,
|
|
34
|
-
analytics: linkAnalytics,
|
|
35
|
-
origin,
|
|
36
|
-
extensionKey: getExtensionKey(linkState.details),
|
|
37
|
-
source: appearance,
|
|
38
|
-
actionOptions
|
|
39
|
-
};
|
|
40
|
-
const actions = [];
|
|
41
|
-
const downloadActionProps = extractDownloadActionProps(opts);
|
|
42
|
-
if (downloadActionProps) {
|
|
43
|
-
actions.push(toAction(downloadActionProps, invokeClientAction, messages.download, 'download-content'));
|
|
44
|
-
}
|
|
45
|
-
const viewActionProps = extractViewActionProps(opts);
|
|
46
|
-
if (viewActionProps) {
|
|
47
|
-
actions.push(toAction(viewActionProps, invokeClientAction, messages.view, 'view-content'));
|
|
48
|
-
}
|
|
49
|
-
const previewActionProps = extractPreviewActionProps(opts);
|
|
50
|
-
if (previewActionProps) {
|
|
51
|
-
actions.push(toAction(previewActionProps, invokeClientAction, messages.preview_improved, 'preview-content'));
|
|
52
|
-
}
|
|
53
|
-
return actions;
|
|
54
|
-
}
|
|
55
|
-
return [];
|
|
56
|
-
}
|
|
57
24
|
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
58
|
-
const
|
|
59
|
-
|
|
25
|
+
const opts = {
|
|
26
|
+
response: linkState.details,
|
|
27
|
+
handleInvoke: invokeClientAction,
|
|
60
28
|
analytics: linkAnalytics,
|
|
61
29
|
origin,
|
|
62
30
|
extensionKey: getExtensionKey(linkState.details),
|
|
63
31
|
source: appearance,
|
|
64
32
|
actionOptions
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
33
|
+
};
|
|
34
|
+
const actions = [];
|
|
35
|
+
const downloadActionProps = extractDownloadActionProps(opts);
|
|
36
|
+
if (downloadActionProps) {
|
|
37
|
+
actions.push(toAction(downloadActionProps, invokeClientAction, messages.download, 'download-content'));
|
|
38
|
+
}
|
|
39
|
+
const viewActionProps = extractViewActionProps(opts);
|
|
40
|
+
if (viewActionProps) {
|
|
41
|
+
actions.push(toAction(viewActionProps, invokeClientAction, messages.view, 'view-content'));
|
|
42
|
+
}
|
|
43
|
+
const previewActionProps = extractPreviewActionProps(opts);
|
|
44
|
+
if (previewActionProps) {
|
|
45
|
+
actions.push(toAction(previewActionProps, invokeClientAction, messages.preview_improved, 'preview-content'));
|
|
73
46
|
}
|
|
47
|
+
return actions;
|
|
74
48
|
}
|
|
75
49
|
return [];
|
|
76
50
|
}
|
|
@@ -4,7 +4,7 @@ export const ANALYTICS_CHANNEL = 'media';
|
|
|
4
4
|
export const context = {
|
|
5
5
|
componentName: 'smart-cards',
|
|
6
6
|
packageName: "@atlaskit/smart-card",
|
|
7
|
-
packageVersion: "32.
|
|
7
|
+
packageVersion: "32.4.0"
|
|
8
8
|
};
|
|
9
9
|
export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -243,6 +243,7 @@ function Component({
|
|
|
243
243
|
return /*#__PURE__*/React.createElement(EmbedCard, {
|
|
244
244
|
id: id,
|
|
245
245
|
url: url,
|
|
246
|
+
renderers: renderers,
|
|
246
247
|
cardState: state,
|
|
247
248
|
iframeUrlType: embedIframeUrlType,
|
|
248
249
|
handleAuthorize: services.length && handleAuthorize || undefined,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { extractBlockProps } from '../../extractors/block';
|
|
5
6
|
import { extractRequestAccessContextImproved } from '../../extractors/common/context/extractAccessContext';
|
|
6
7
|
import { extractEmbedProps } from '../../extractors/embed';
|
|
@@ -8,6 +9,7 @@ import { extractInlineProps } from '../../extractors/inline';
|
|
|
8
9
|
import { getExtensionKey, hasAuthScopeOverrides } from '../../state/helpers';
|
|
9
10
|
import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
|
|
10
11
|
import { BlockCardResolvedView, BlockCardResolvingView } from '../BlockCard';
|
|
12
|
+
import FlexibleResolvedView from '../BlockCard/views/flexible/FlexibleResolvedView';
|
|
11
13
|
import { InlineCardResolvedView } from '../InlineCard/ResolvedView';
|
|
12
14
|
import { EmbedCardErroredView } from './views/ErroredView';
|
|
13
15
|
import ForbiddenView from './views/forbidden-view';
|
|
@@ -16,10 +18,7 @@ import { EmbedCardResolvedView } from './views/ResolvedView';
|
|
|
16
18
|
import UnauthorizedView from './views/unauthorized-view';
|
|
17
19
|
export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
18
20
|
url,
|
|
19
|
-
cardState
|
|
20
|
-
status,
|
|
21
|
-
details
|
|
22
|
-
},
|
|
21
|
+
cardState,
|
|
23
22
|
handleAuthorize,
|
|
24
23
|
handleErrorRetry,
|
|
25
24
|
handleFrameClick,
|
|
@@ -35,12 +34,17 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
35
34
|
onIframeDwell,
|
|
36
35
|
onIframeFocus,
|
|
37
36
|
iframeUrlType,
|
|
38
|
-
actionOptions
|
|
37
|
+
actionOptions,
|
|
38
|
+
renderers
|
|
39
39
|
}, iframeRef) => {
|
|
40
40
|
var _details$meta, _forbiddenViewProps$c, _forbiddenViewProps$c2, _notFoundViewProps$co, _notFoundViewProps$co2;
|
|
41
41
|
const {
|
|
42
42
|
createAnalyticsEvent
|
|
43
43
|
} = useAnalyticsEvents();
|
|
44
|
+
const {
|
|
45
|
+
status,
|
|
46
|
+
details
|
|
47
|
+
} = cardState;
|
|
44
48
|
const data = details && details.data || getEmptyJsonLd();
|
|
45
49
|
const meta = details && details.meta;
|
|
46
50
|
const extensionKey = getExtensionKey(details);
|
|
@@ -48,6 +52,19 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
48
52
|
switch (status) {
|
|
49
53
|
case 'pending':
|
|
50
54
|
case 'resolving':
|
|
55
|
+
if (fg('smart-card-remove-block-card-from-embed')) {
|
|
56
|
+
return /*#__PURE__*/React.createElement(FlexibleResolvedView, {
|
|
57
|
+
url: url,
|
|
58
|
+
cardState: cardState,
|
|
59
|
+
onClick: handleFrameClick,
|
|
60
|
+
onError: onError,
|
|
61
|
+
onResolve: onResolve,
|
|
62
|
+
renderers: renderers,
|
|
63
|
+
actionOptions: actionOptions,
|
|
64
|
+
analytics: analytics,
|
|
65
|
+
testId: testId
|
|
66
|
+
});
|
|
67
|
+
}
|
|
51
68
|
return /*#__PURE__*/React.createElement(BlockCardResolvingView, {
|
|
52
69
|
testId: "embed-card-resolving-view",
|
|
53
70
|
inheritDimensions: inheritDimensions,
|
|
@@ -83,6 +100,19 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
83
100
|
onClick: handleFrameClick
|
|
84
101
|
}));
|
|
85
102
|
}
|
|
103
|
+
if (fg('smart-card-remove-block-card-from-embed')) {
|
|
104
|
+
return /*#__PURE__*/React.createElement(FlexibleResolvedView, {
|
|
105
|
+
url: url,
|
|
106
|
+
cardState: cardState,
|
|
107
|
+
onClick: handleFrameClick,
|
|
108
|
+
onError: onError,
|
|
109
|
+
onResolve: onResolve,
|
|
110
|
+
renderers: renderers,
|
|
111
|
+
actionOptions: actionOptions,
|
|
112
|
+
analytics: analytics,
|
|
113
|
+
testId: testId
|
|
114
|
+
});
|
|
115
|
+
}
|
|
86
116
|
const resolvedBlockViewProps = extractBlockProps(data, meta, {
|
|
87
117
|
analytics,
|
|
88
118
|
origin: 'smartLinkEmbed',
|
|
@@ -7,7 +7,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
7
7
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
8
8
|
const PACKAGE_DATA = {
|
|
9
9
|
packageName: "@atlaskit/smart-card",
|
|
10
|
-
packageVersion: "32.
|
|
10
|
+
packageVersion: "32.4.0",
|
|
11
11
|
componentName: 'linkUrl'
|
|
12
12
|
};
|
|
13
13
|
const Link = withLinkClickedEvent('a');
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import uuid from 'uuid';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { extractDownloadActionProps } from '../../extractors/action/extractDownloadActionProps';
|
|
5
4
|
import { extractPreviewActionProps } from '../../extractors/action/extractPreviewActionProps';
|
|
6
5
|
import { extractViewActionProps } from '../../extractors/action/extractViewActionProps';
|
|
7
|
-
import { extractBlockProps as extractCardProps } from '../../extractors/block';
|
|
8
6
|
import { messages } from '../../messages';
|
|
9
7
|
import { toAction } from '../../utils/actions/to-action';
|
|
10
|
-
import { useSmartCardActions as useLinkActions } from '../actions';
|
|
11
8
|
import { useSmartLinkAnalytics as useLinkAnalytics } from '../analytics';
|
|
12
9
|
import { getExtensionKey } from '../helpers';
|
|
13
10
|
import useInvokeClientAction from '../hooks/use-invoke-client-action';
|
|
@@ -15,8 +12,6 @@ import { useSmartCardState as useLinkState } from '../store';
|
|
|
15
12
|
export function useSmartLinkActions(_ref) {
|
|
16
13
|
var url = _ref.url,
|
|
17
14
|
appearance = _ref.appearance,
|
|
18
|
-
_ref$platform = _ref.platform,
|
|
19
|
-
platform = _ref$platform === void 0 ? 'web' : _ref$platform,
|
|
20
15
|
origin = _ref.origin,
|
|
21
16
|
actionOptions = _ref.actionOptions;
|
|
22
17
|
var id = useMemo(function () {
|
|
@@ -24,59 +19,33 @@ export function useSmartLinkActions(_ref) {
|
|
|
24
19
|
}, []);
|
|
25
20
|
var linkState = useLinkState(url);
|
|
26
21
|
var linkAnalytics = useLinkAnalytics(url, id);
|
|
27
|
-
var linkActions = useLinkActions(id, url, linkAnalytics);
|
|
28
22
|
var invokeClientAction = useInvokeClientAction({
|
|
29
23
|
analytics: linkAnalytics
|
|
30
24
|
});
|
|
31
|
-
if (fg('smart-card-use-refactored-usesmartlinkactions')) {
|
|
32
|
-
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
33
|
-
var opts = {
|
|
34
|
-
response: linkState.details,
|
|
35
|
-
handleInvoke: invokeClientAction,
|
|
36
|
-
analytics: linkAnalytics,
|
|
37
|
-
origin: origin,
|
|
38
|
-
extensionKey: getExtensionKey(linkState.details),
|
|
39
|
-
source: appearance,
|
|
40
|
-
actionOptions: actionOptions
|
|
41
|
-
};
|
|
42
|
-
var actions = [];
|
|
43
|
-
var downloadActionProps = extractDownloadActionProps(opts);
|
|
44
|
-
if (downloadActionProps) {
|
|
45
|
-
actions.push(toAction(downloadActionProps, invokeClientAction, messages.download, 'download-content'));
|
|
46
|
-
}
|
|
47
|
-
var viewActionProps = extractViewActionProps(opts);
|
|
48
|
-
if (viewActionProps) {
|
|
49
|
-
actions.push(toAction(viewActionProps, invokeClientAction, messages.view, 'view-content'));
|
|
50
|
-
}
|
|
51
|
-
var previewActionProps = extractPreviewActionProps(opts);
|
|
52
|
-
if (previewActionProps) {
|
|
53
|
-
actions.push(toAction(previewActionProps, invokeClientAction, messages.preview_improved, 'preview-content'));
|
|
54
|
-
}
|
|
55
|
-
return actions;
|
|
56
|
-
}
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
25
|
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
},
|
|
26
|
+
var opts = {
|
|
27
|
+
response: linkState.details,
|
|
28
|
+
handleInvoke: invokeClientAction,
|
|
64
29
|
analytics: linkAnalytics,
|
|
65
30
|
origin: origin,
|
|
66
31
|
extensionKey: getExtensionKey(linkState.details),
|
|
67
32
|
source: appearance,
|
|
68
33
|
actionOptions: actionOptions
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
34
|
+
};
|
|
35
|
+
var actions = [];
|
|
36
|
+
var downloadActionProps = extractDownloadActionProps(opts);
|
|
37
|
+
if (downloadActionProps) {
|
|
38
|
+
actions.push(toAction(downloadActionProps, invokeClientAction, messages.download, 'download-content'));
|
|
39
|
+
}
|
|
40
|
+
var viewActionProps = extractViewActionProps(opts);
|
|
41
|
+
if (viewActionProps) {
|
|
42
|
+
actions.push(toAction(viewActionProps, invokeClientAction, messages.view, 'view-content'));
|
|
43
|
+
}
|
|
44
|
+
var previewActionProps = extractPreviewActionProps(opts);
|
|
45
|
+
if (previewActionProps) {
|
|
46
|
+
actions.push(toAction(previewActionProps, invokeClientAction, messages.preview_improved, 'preview-content'));
|
|
79
47
|
}
|
|
48
|
+
return actions;
|
|
80
49
|
}
|
|
81
50
|
return [];
|
|
82
51
|
}
|
|
@@ -10,7 +10,7 @@ export var ANALYTICS_CHANNEL = 'media';
|
|
|
10
10
|
export var context = {
|
|
11
11
|
componentName: 'smart-cards',
|
|
12
12
|
packageName: "@atlaskit/smart-card",
|
|
13
|
-
packageVersion: "32.
|
|
13
|
+
packageVersion: "32.4.0"
|
|
14
14
|
};
|
|
15
15
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
16
16
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -245,6 +245,7 @@ function Component(_ref) {
|
|
|
245
245
|
return /*#__PURE__*/React.createElement(EmbedCard, {
|
|
246
246
|
id: id,
|
|
247
247
|
url: url,
|
|
248
|
+
renderers: renderers,
|
|
248
249
|
cardState: state,
|
|
249
250
|
iframeUrlType: embedIframeUrlType,
|
|
250
251
|
handleAuthorize: services.length && handleAuthorize || undefined,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { extractBlockProps } from '../../extractors/block';
|
|
5
6
|
import { extractRequestAccessContextImproved } from '../../extractors/common/context/extractAccessContext';
|
|
6
7
|
import { extractEmbedProps } from '../../extractors/embed';
|
|
@@ -8,6 +9,7 @@ import { extractInlineProps } from '../../extractors/inline';
|
|
|
8
9
|
import { getExtensionKey, hasAuthScopeOverrides } from '../../state/helpers';
|
|
9
10
|
import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
|
|
10
11
|
import { BlockCardResolvedView, BlockCardResolvingView } from '../BlockCard';
|
|
12
|
+
import FlexibleResolvedView from '../BlockCard/views/flexible/FlexibleResolvedView';
|
|
11
13
|
import { InlineCardResolvedView } from '../InlineCard/ResolvedView';
|
|
12
14
|
import { EmbedCardErroredView } from './views/ErroredView';
|
|
13
15
|
import ForbiddenView from './views/forbidden-view';
|
|
@@ -17,9 +19,7 @@ import UnauthorizedView from './views/unauthorized-view';
|
|
|
17
19
|
export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef) {
|
|
18
20
|
var _details$meta, _forbiddenViewProps$c, _forbiddenViewProps$c2, _notFoundViewProps$co, _notFoundViewProps$co2;
|
|
19
21
|
var url = _ref.url,
|
|
20
|
-
|
|
21
|
-
status = _ref$cardState.status,
|
|
22
|
-
details = _ref$cardState.details,
|
|
22
|
+
cardState = _ref.cardState,
|
|
23
23
|
handleAuthorize = _ref.handleAuthorize,
|
|
24
24
|
handleErrorRetry = _ref.handleErrorRetry,
|
|
25
25
|
handleFrameClick = _ref.handleFrameClick,
|
|
@@ -35,9 +35,12 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef)
|
|
|
35
35
|
onIframeDwell = _ref.onIframeDwell,
|
|
36
36
|
onIframeFocus = _ref.onIframeFocus,
|
|
37
37
|
iframeUrlType = _ref.iframeUrlType,
|
|
38
|
-
actionOptions = _ref.actionOptions
|
|
38
|
+
actionOptions = _ref.actionOptions,
|
|
39
|
+
renderers = _ref.renderers;
|
|
39
40
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
40
41
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
42
|
+
var status = cardState.status,
|
|
43
|
+
details = cardState.details;
|
|
41
44
|
var data = details && details.data || getEmptyJsonLd();
|
|
42
45
|
var meta = details && details.meta;
|
|
43
46
|
var extensionKey = getExtensionKey(details);
|
|
@@ -45,6 +48,19 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef)
|
|
|
45
48
|
switch (status) {
|
|
46
49
|
case 'pending':
|
|
47
50
|
case 'resolving':
|
|
51
|
+
if (fg('smart-card-remove-block-card-from-embed')) {
|
|
52
|
+
return /*#__PURE__*/React.createElement(FlexibleResolvedView, {
|
|
53
|
+
url: url,
|
|
54
|
+
cardState: cardState,
|
|
55
|
+
onClick: handleFrameClick,
|
|
56
|
+
onError: onError,
|
|
57
|
+
onResolve: onResolve,
|
|
58
|
+
renderers: renderers,
|
|
59
|
+
actionOptions: actionOptions,
|
|
60
|
+
analytics: analytics,
|
|
61
|
+
testId: testId
|
|
62
|
+
});
|
|
63
|
+
}
|
|
48
64
|
return /*#__PURE__*/React.createElement(BlockCardResolvingView, {
|
|
49
65
|
testId: "embed-card-resolving-view",
|
|
50
66
|
inheritDimensions: inheritDimensions,
|
|
@@ -80,6 +96,19 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef)
|
|
|
80
96
|
onClick: handleFrameClick
|
|
81
97
|
}));
|
|
82
98
|
}
|
|
99
|
+
if (fg('smart-card-remove-block-card-from-embed')) {
|
|
100
|
+
return /*#__PURE__*/React.createElement(FlexibleResolvedView, {
|
|
101
|
+
url: url,
|
|
102
|
+
cardState: cardState,
|
|
103
|
+
onClick: handleFrameClick,
|
|
104
|
+
onError: onError,
|
|
105
|
+
onResolve: onResolve,
|
|
106
|
+
renderers: renderers,
|
|
107
|
+
actionOptions: actionOptions,
|
|
108
|
+
analytics: analytics,
|
|
109
|
+
testId: testId
|
|
110
|
+
});
|
|
111
|
+
}
|
|
83
112
|
var resolvedBlockViewProps = extractBlockProps(data, meta, {
|
|
84
113
|
analytics: analytics,
|
|
85
114
|
origin: 'smartLinkEmbed',
|
|
@@ -10,7 +10,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
10
10
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
11
11
|
var PACKAGE_DATA = {
|
|
12
12
|
packageName: "@atlaskit/smart-card",
|
|
13
|
-
packageVersion: "32.
|
|
13
|
+
packageVersion: "32.4.0",
|
|
14
14
|
componentName: 'linkUrl'
|
|
15
15
|
};
|
|
16
16
|
var Link = withLinkClickedEvent('a');
|
|
@@ -45,8 +45,8 @@ export interface UseSmartLinkActionsOpts {
|
|
|
45
45
|
*/
|
|
46
46
|
actionOptions?: CardActionOptions;
|
|
47
47
|
}
|
|
48
|
-
export declare function useSmartLinkActions({ url, appearance,
|
|
48
|
+
export declare function useSmartLinkActions({ url, appearance, origin, actionOptions, }: UseSmartLinkActionsOpts): {
|
|
49
49
|
id: string;
|
|
50
|
-
text:
|
|
51
|
-
invoke: () => Promise<
|
|
50
|
+
text: JSX.Element;
|
|
51
|
+
invoke: () => Promise<void>;
|
|
52
52
|
}[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import { type CardProviderRenderers } from '@atlaskit/link-provider';
|
|
2
3
|
import { type RequestAccessMessageKey } from '../../messages';
|
|
3
4
|
import { type InvokeHandler } from '../../model/invoke-handler';
|
|
4
5
|
import { type AnalyticsFacade } from '../../state/analytics';
|
|
@@ -26,6 +27,7 @@ export type EmbedCardProps = {
|
|
|
26
27
|
onIframeDwell?: (dwellTime: number, dwellPercentVisible: number) => void;
|
|
27
28
|
onIframeFocus?: () => void;
|
|
28
29
|
iframeUrlType?: EmbedIframeUrlType;
|
|
30
|
+
renderers?: CardProviderRenderers;
|
|
29
31
|
};
|
|
30
32
|
export interface WithShowControlMethodProp {
|
|
31
33
|
showControls?: () => void;
|
|
@@ -45,8 +45,8 @@ export interface UseSmartLinkActionsOpts {
|
|
|
45
45
|
*/
|
|
46
46
|
actionOptions?: CardActionOptions;
|
|
47
47
|
}
|
|
48
|
-
export declare function useSmartLinkActions({ url, appearance,
|
|
48
|
+
export declare function useSmartLinkActions({ url, appearance, origin, actionOptions, }: UseSmartLinkActionsOpts): {
|
|
49
49
|
id: string;
|
|
50
|
-
text:
|
|
51
|
-
invoke: () => Promise<
|
|
50
|
+
text: JSX.Element;
|
|
51
|
+
invoke: () => Promise<void>;
|
|
52
52
|
}[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import { type CardProviderRenderers } from '@atlaskit/link-provider';
|
|
2
3
|
import { type RequestAccessMessageKey } from '../../messages';
|
|
3
4
|
import { type InvokeHandler } from '../../model/invoke-handler';
|
|
4
5
|
import { type AnalyticsFacade } from '../../state/analytics';
|
|
@@ -26,6 +27,7 @@ export type EmbedCardProps = {
|
|
|
26
27
|
onIframeDwell?: (dwellTime: number, dwellPercentVisible: number) => void;
|
|
27
28
|
onIframeFocus?: () => void;
|
|
28
29
|
iframeUrlType?: EmbedIframeUrlType;
|
|
30
|
+
renderers?: CardProviderRenderers;
|
|
29
31
|
};
|
|
30
32
|
export interface WithShowControlMethodProp {
|
|
31
33
|
showControls?: () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.4.0",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@atlaskit/dropdown-menu": "^12.23.0",
|
|
36
36
|
"@atlaskit/form": "^10.6.0",
|
|
37
37
|
"@atlaskit/frontend-utilities": "^2.7.0",
|
|
38
|
-
"@atlaskit/heading": "^
|
|
38
|
+
"@atlaskit/heading": "^4.0.0",
|
|
39
39
|
"@atlaskit/icon": "^22.28.0",
|
|
40
40
|
"@atlaskit/icon-file-type": "^6.7.0",
|
|
41
41
|
"@atlaskit/icon-object": "^6.8.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
55
55
|
"@atlaskit/popup": "^1.29.0",
|
|
56
56
|
"@atlaskit/primitives": "^13.3.0",
|
|
57
|
-
"@atlaskit/section-message": "^6.
|
|
57
|
+
"@atlaskit/section-message": "^6.8.0",
|
|
58
58
|
"@atlaskit/select": "^18.6.0",
|
|
59
59
|
"@atlaskit/spinner": "^16.3.0",
|
|
60
60
|
"@atlaskit/textarea": "^5.6.0",
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
"smart_links_for_plans_platform": {
|
|
175
175
|
"type": "boolean"
|
|
176
176
|
},
|
|
177
|
-
"smart-card-
|
|
177
|
+
"smart-card-remove-block-card-from-embed": {
|
|
178
178
|
"type": "boolean"
|
|
179
179
|
}
|
|
180
180
|
}
|