@atlaskit/smart-card 26.26.1 → 26.26.2

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/extractors/common/actions/extractPreviewAction.js +1 -6
  3. package/dist/cjs/utils/analytics/analytics.js +1 -1
  4. package/dist/cjs/view/EmbedModal/components/link-info/index.js +7 -13
  5. package/dist/cjs/view/EmbedModal/components/link-info/link-info-button/index.js +0 -1
  6. package/dist/cjs/view/EmbedModal/index.js +64 -10
  7. package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +1 -0
  8. package/dist/cjs/view/LinkUrl/index.js +1 -1
  9. package/dist/es2019/extractors/common/actions/extractPreviewAction.js +1 -6
  10. package/dist/es2019/utils/analytics/analytics.js +1 -1
  11. package/dist/es2019/view/EmbedModal/components/link-info/index.js +6 -12
  12. package/dist/es2019/view/EmbedModal/components/link-info/link-info-button/index.js +0 -1
  13. package/dist/es2019/view/EmbedModal/index.js +30 -10
  14. package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +1 -0
  15. package/dist/es2019/view/LinkUrl/index.js +1 -1
  16. package/dist/esm/extractors/common/actions/extractPreviewAction.js +1 -6
  17. package/dist/esm/utils/analytics/analytics.js +1 -1
  18. package/dist/esm/view/EmbedModal/components/link-info/index.js +7 -13
  19. package/dist/esm/view/EmbedModal/components/link-info/link-info-button/index.js +0 -1
  20. package/dist/esm/view/EmbedModal/index.js +64 -10
  21. package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +1 -0
  22. package/dist/esm/view/LinkUrl/index.js +1 -1
  23. package/dist/types/view/BlockCard/actions/PreviewAction.d.ts +1 -0
  24. package/dist/types/view/EmbedModal/components/analytics/types.d.ts +1 -0
  25. package/dist/types/view/EmbedModal/components/link-info/types.d.ts +0 -2
  26. package/dist/types/view/EmbedModal/index.d.ts +0 -2
  27. package/dist/types/view/EmbedModal/types.d.ts +0 -2
  28. package/dist/types-ts4.5/view/BlockCard/actions/PreviewAction.d.ts +1 -0
  29. package/dist/types-ts4.5/view/EmbedModal/components/analytics/types.d.ts +1 -0
  30. package/dist/types-ts4.5/view/EmbedModal/components/link-info/types.d.ts +0 -2
  31. package/dist/types-ts4.5/view/EmbedModal/index.d.ts +0 -2
  32. package/dist/types-ts4.5/view/EmbedModal/types.d.ts +0 -2
  33. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 26.26.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`da7fcd582e2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/da7fcd582e2) - Fixed embed modal go to url and download button inconsitent behaviour when triggered from hover preview and block card
8
+
3
9
  ## 26.26.1
4
10
 
5
11
  ### Patch Changes
@@ -75,14 +75,9 @@ var extractPreviewAction = function extractPreviewAction(_ref) {
75
75
  var key = extensionKey;
76
76
  var previewAction = (0, _BlockCard.PreviewAction)(_objectSpread(_objectSpread({}, metadata), {}, {
77
77
  analytics: analytics,
78
+ extensionKey: extensionKey,
78
79
  origin: origin,
79
80
  testId: testId,
80
- onDownloadActionClick: function onDownloadActionClick() {
81
- handleInvoke(getInvokeOpts(key, 'DownloadAction'));
82
- },
83
- onViewActionClick: function onViewActionClick() {
84
- handleInvoke(getInvokeOpts(key, 'ViewAction'));
85
- },
86
81
  isSupportTheming: (0, _extractIsSupportTheming.extractIsSupportTheming)(meta)
87
82
  }));
88
83
  // Setup props to go through proper Redux 'invocation' flow
@@ -23,7 +23,7 @@ exports.ANALYTICS_CHANNEL = ANALYTICS_CHANNEL;
23
23
  var context = {
24
24
  componentName: 'smart-cards',
25
25
  packageName: "@atlaskit/smart-card",
26
- packageVersion: "26.26.1"
26
+ packageVersion: "26.26.2"
27
27
  };
28
28
  exports.context = context;
29
29
  var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
@@ -25,47 +25,41 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
25
25
  /** @jsx jsx */
26
26
 
27
27
  var LinkInfo = function LinkInfo(_ref) {
28
- var downloadUrl = _ref.downloadUrl,
29
- icon = _ref.icon,
28
+ var icon = _ref.icon,
30
29
  providerName = _ref.providerName,
31
30
  onDownloadButtonClick = _ref.onDownloadButtonClick,
32
31
  onResizeButtonClick = _ref.onResizeButtonClick,
33
32
  onViewButtonClick = _ref.onViewButtonClick,
34
33
  size = _ref.size,
35
34
  testId = _ref.testId,
36
- title = _ref.title,
37
- url = _ref.url;
35
+ title = _ref.title;
38
36
  var _useModal = (0, _modalDialog.useModal)(),
39
37
  onClose = _useModal.onClose;
40
38
  var downloadButton = (0, _react2.useMemo)(function () {
41
- if (downloadUrl) {
39
+ if (onDownloadButtonClick) {
42
40
  return (0, _react.jsx)(_linkInfoButton.default, {
43
41
  content: (0, _react.jsx)(_reactIntlNext.FormattedMessage, _messages.messages.download),
44
- href: downloadUrl,
45
42
  icon: (0, _react.jsx)(_download.default, {
46
43
  label: _messages.messages.download.defaultMessage
47
44
  }),
48
45
  onClick: onDownloadButtonClick,
49
- testId: "".concat(testId, "-download"),
50
- target: "_blank"
46
+ testId: "".concat(testId, "-download")
51
47
  });
52
48
  }
53
- }, [downloadUrl, onDownloadButtonClick, testId]);
49
+ }, [onDownloadButtonClick, testId]);
54
50
  var urlButton = (0, _react2.useMemo)(function () {
55
- if (url) {
51
+ if (onViewButtonClick) {
56
52
  var content = providerName ? (0, _react.jsx)(_react2.default.Fragment, null, (0, _react.jsx)(_reactIntlNext.FormattedMessage, _messages.messages.viewIn), " ", providerName) : (0, _react.jsx)(_reactIntlNext.FormattedMessage, _messages.messages.viewOriginal);
57
53
  return (0, _react.jsx)(_linkInfoButton.default, {
58
54
  content: content,
59
- href: url,
60
55
  icon: (0, _react.jsx)(_shortcut.default, {
61
56
  label: _messages.messages.viewOriginal.defaultMessage
62
57
  }),
63
58
  onClick: onViewButtonClick,
64
- target: "_blank",
65
59
  testId: "".concat(testId, "-url")
66
60
  });
67
61
  }
68
- }, [onViewButtonClick, providerName, testId, url]);
62
+ }, [onViewButtonClick, providerName, testId]);
69
63
  var sizeButton = (0, _react2.useMemo)(function () {
70
64
  var isFullScreen = size === _constants.MAX_MODAL_SIZE;
71
65
  var message = isFullScreen ? _messages.messages.preview_min_size : _messages.messages.preview_max_size;
@@ -20,7 +20,6 @@ var LinkInfoButton = function LinkInfoButton(_ref) {
20
20
  return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
21
21
  content: content,
22
22
  hideTooltipOnClick: true,
23
- position: "top",
24
23
  tag: "span",
25
24
  testId: "".concat(testId, "-tooltip")
26
25
  }, /*#__PURE__*/_react.default.createElement(_customThemeButton.default, {
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
9
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
12
  var _react = _interopRequireWildcard(require("react"));
11
13
  var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
@@ -16,6 +18,9 @@ var _types = require("./types");
16
18
  var _errorBoundary = _interopRequireDefault(require("./components/error-boundary"));
17
19
  var _analytics = _interopRequireDefault(require("./components/analytics"));
18
20
  var _tokens = require("@atlaskit/tokens");
21
+ var _useInvokeClientAction = _interopRequireDefault(require("../../state/hooks/use-invoke-client-action"));
22
+ var _constants2 = require("../../constants");
23
+ var _utils = require("../../utils");
19
24
  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); }
20
25
  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; }
21
26
  var toSize = function toSize(width) {
@@ -25,16 +30,17 @@ var toWidth = function toWidth(size) {
25
30
  return size === _types.EmbedModalSize.Large ? _constants.MAX_MODAL_SIZE : _constants.MIN_MODAL_SIZE;
26
31
  };
27
32
  var EmbedModal = function EmbedModal(_ref) {
28
- var downloadUrl = _ref.download,
33
+ var analytics = _ref.analytics,
34
+ download = _ref.download,
35
+ extensionKey = _ref.extensionKey,
29
36
  icon = _ref.icon,
30
37
  iframeName = _ref.iframeName,
38
+ isSupportTheming = _ref.isSupportTheming,
31
39
  _ref$isTrusted = _ref.isTrusted,
32
40
  isTrusted = _ref$isTrusted === void 0 ? false : _ref$isTrusted,
33
41
  onClose = _ref.onClose,
34
- onDownloadActionClick = _ref.onDownloadActionClick,
35
42
  onOpen = _ref.onOpen,
36
43
  onResize = _ref.onResize,
37
- onViewActionClick = _ref.onViewActionClick,
38
44
  providerName = _ref.providerName,
39
45
  showModal = _ref.showModal,
40
46
  _ref$size = _ref.size,
@@ -43,8 +49,7 @@ var EmbedModal = function EmbedModal(_ref) {
43
49
  _ref$testId = _ref.testId,
44
50
  testId = _ref$testId === void 0 ? 'smart-embed-preview-modal' : _ref$testId,
45
51
  title = _ref.title,
46
- url = _ref.url,
47
- isSupportTheming = _ref.isSupportTheming;
52
+ url = _ref.url;
48
53
  var defaultWidth = toWidth(size);
49
54
  var _useState = (0, _react.useState)(showModal),
50
55
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -55,6 +60,9 @@ var EmbedModal = function EmbedModal(_ref) {
55
60
  width = _useState4[0],
56
61
  setWidth = _useState4[1];
57
62
  var openAt = (0, _react.useRef)();
63
+ var invoke = (0, _useInvokeClientAction.default)({
64
+ analytics: analytics
65
+ });
58
66
  var handleOnOpenComplete = (0, _react.useCallback)(function () {
59
67
  openAt.current = Date.now();
60
68
  if (onOpen) {
@@ -87,6 +95,54 @@ var EmbedModal = function EmbedModal(_ref) {
87
95
  var _useThemeObserver = (0, _tokens.useThemeObserver)(),
88
96
  colorMode = _useThemeObserver.colorMode;
89
97
  var previewUrl = src;
98
+ var handleOnViewActionClick = (0, _react.useCallback)(function () {
99
+ invoke({
100
+ actionType: _constants2.ActionName.ViewAction,
101
+ actionFn: function () {
102
+ var _actionFn = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
103
+ return _regenerator.default.wrap(function _callee$(_context) {
104
+ while (1) switch (_context.prev = _context.next) {
105
+ case 0:
106
+ return _context.abrupt("return", (0, _utils.openUrl)(url));
107
+ case 1:
108
+ case "end":
109
+ return _context.stop();
110
+ }
111
+ }, _callee);
112
+ }));
113
+ function actionFn() {
114
+ return _actionFn.apply(this, arguments);
115
+ }
116
+ return actionFn;
117
+ }(),
118
+ display: _constants2.CardDisplay.EmbedPreview,
119
+ extensionKey: extensionKey
120
+ });
121
+ }, [extensionKey, invoke, url]);
122
+ var handleOnDownloadActionClick = (0, _react.useCallback)(function () {
123
+ invoke({
124
+ actionType: _constants2.ActionName.DownloadAction,
125
+ actionFn: function () {
126
+ var _actionFn2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
127
+ return _regenerator.default.wrap(function _callee2$(_context2) {
128
+ while (1) switch (_context2.prev = _context2.next) {
129
+ case 0:
130
+ return _context2.abrupt("return", (0, _utils.downloadUrl)(download));
131
+ case 1:
132
+ case "end":
133
+ return _context2.stop();
134
+ }
135
+ }, _callee2);
136
+ }));
137
+ function actionFn() {
138
+ return _actionFn2.apply(this, arguments);
139
+ }
140
+ return actionFn;
141
+ }(),
142
+ display: _constants2.CardDisplay.EmbedPreview,
143
+ extensionKey: extensionKey
144
+ });
145
+ }, [download, extensionKey, invoke]);
90
146
  if (previewUrl && isSupportTheming && colorMode) {
91
147
  previewUrl = "".concat(previewUrl).concat(previewUrl.includes('?') ? '&' : '?', "themeMode=").concat(colorMode);
92
148
  }
@@ -98,16 +154,14 @@ var EmbedModal = function EmbedModal(_ref) {
98
154
  testId: testId,
99
155
  width: width
100
156
  }, /*#__PURE__*/_react.default.createElement(_linkInfo.default, {
101
- downloadUrl: downloadUrl,
102
157
  icon: icon,
103
158
  providerName: providerName,
104
- onViewButtonClick: onViewActionClick,
105
- onDownloadButtonClick: onDownloadActionClick,
159
+ onViewButtonClick: url ? handleOnViewActionClick : undefined,
160
+ onDownloadButtonClick: download ? handleOnDownloadActionClick : undefined,
106
161
  onResizeButtonClick: handleOnResizeClick,
107
162
  size: width,
108
163
  title: title,
109
- testId: testId,
110
- url: url
164
+ testId: testId
111
165
  }), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalBody, null, /*#__PURE__*/_react.default.createElement(_embedContent.default, {
112
166
  isTrusted: isTrusted,
113
167
  name: iframeName,
@@ -43,6 +43,7 @@ var PreviewAction = function PreviewAction(props) {
43
43
  case 0:
44
44
  return _context.abrupt("return", (0, _utils.openEmbedModalWithFlexibleUiIcon)({
45
45
  download: downloadUrl,
46
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey,
46
47
  title: title,
47
48
  providerName: providerName,
48
49
  isSupportTheming: isSupportTheming,
@@ -18,7 +18,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
18
18
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
19
19
  var PACKAGE_DATA = {
20
20
  packageName: "@atlaskit/smart-card",
21
- packageVersion: "26.26.1",
21
+ packageVersion: "26.26.2",
22
22
  componentName: 'linkUrl'
23
23
  };
24
24
  var Link = (0, _click.withLinkClickedEvent)('a');
@@ -62,14 +62,9 @@ export const extractPreviewAction = ({
62
62
  const previewAction = PreviewAction({
63
63
  ...metadata,
64
64
  analytics,
65
+ extensionKey,
65
66
  origin,
66
67
  testId,
67
- onDownloadActionClick: () => {
68
- handleInvoke(getInvokeOpts(key, 'DownloadAction'));
69
- },
70
- onViewActionClick: () => {
71
- handleInvoke(getInvokeOpts(key, 'ViewAction'));
72
- },
73
68
  isSupportTheming: extractIsSupportTheming(meta)
74
69
  });
75
70
  // Setup props to go through proper Redux 'invocation' flow
@@ -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: "26.26.1"
7
+ packageVersion: "26.26.2"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -14,7 +14,6 @@ import { MAX_MODAL_SIZE } from '../../constants';
14
14
  import LinkInfoButton from './link-info-button';
15
15
  import { actionCss, containerStyles, iconCss, titleCss } from './styled';
16
16
  const LinkInfo = ({
17
- downloadUrl,
18
17
  icon,
19
18
  providerName,
20
19
  onDownloadButtonClick,
@@ -22,41 +21,36 @@ const LinkInfo = ({
22
21
  onViewButtonClick,
23
22
  size,
24
23
  testId,
25
- title,
26
- url
24
+ title
27
25
  }) => {
28
26
  const {
29
27
  onClose
30
28
  } = useModal();
31
29
  const downloadButton = useMemo(() => {
32
- if (downloadUrl) {
30
+ if (onDownloadButtonClick) {
33
31
  return jsx(LinkInfoButton, {
34
32
  content: jsx(FormattedMessage, messages.download),
35
- href: downloadUrl,
36
33
  icon: jsx(DownloadIcon, {
37
34
  label: messages.download.defaultMessage
38
35
  }),
39
36
  onClick: onDownloadButtonClick,
40
- testId: `${testId}-download`,
41
- target: "_blank"
37
+ testId: `${testId}-download`
42
38
  });
43
39
  }
44
- }, [downloadUrl, onDownloadButtonClick, testId]);
40
+ }, [onDownloadButtonClick, testId]);
45
41
  const urlButton = useMemo(() => {
46
- if (url) {
42
+ if (onViewButtonClick) {
47
43
  const content = providerName ? jsx(React.Fragment, null, jsx(FormattedMessage, messages.viewIn), " ", providerName) : jsx(FormattedMessage, messages.viewOriginal);
48
44
  return jsx(LinkInfoButton, {
49
45
  content: content,
50
- href: url,
51
46
  icon: jsx(ShortcutIcon, {
52
47
  label: messages.viewOriginal.defaultMessage
53
48
  }),
54
49
  onClick: onViewButtonClick,
55
- target: "_blank",
56
50
  testId: `${testId}-url`
57
51
  });
58
52
  }
59
- }, [onViewButtonClick, providerName, testId, url]);
53
+ }, [onViewButtonClick, providerName, testId]);
60
54
  const sizeButton = useMemo(() => {
61
55
  const isFullScreen = size === MAX_MODAL_SIZE;
62
56
  const message = isFullScreen ? messages.preview_min_size : messages.preview_max_size;
@@ -14,7 +14,6 @@ const LinkInfoButton = ({
14
14
  return /*#__PURE__*/React.createElement(Tooltip, {
15
15
  content: content,
16
16
  hideTooltipOnClick: true,
17
- position: "top",
18
17
  tag: "span",
19
18
  testId: `${testId}-tooltip`
20
19
  }, /*#__PURE__*/React.createElement(Button, {
@@ -7,31 +7,37 @@ import { EmbedModalSize } from './types';
7
7
  import withErrorBoundary from './components/error-boundary';
8
8
  import withAnalytics from './components/analytics';
9
9
  import { useThemeObserver } from '@atlaskit/tokens';
10
+ import useInvokeClientAction from '../../state/hooks/use-invoke-client-action';
11
+ import { ActionName, CardDisplay } from '../../constants';
12
+ import { downloadUrl, openUrl } from '../../utils';
10
13
  const toSize = width => width === MAX_MODAL_SIZE ? EmbedModalSize.Large : EmbedModalSize.Small;
11
14
  const toWidth = size => size === EmbedModalSize.Large ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
12
15
  const EmbedModal = ({
13
- download: downloadUrl,
16
+ analytics,
17
+ download,
18
+ extensionKey,
14
19
  icon,
15
20
  iframeName,
21
+ isSupportTheming,
16
22
  isTrusted = false,
17
23
  onClose,
18
- onDownloadActionClick,
19
24
  onOpen,
20
25
  onResize,
21
- onViewActionClick,
22
26
  providerName,
23
27
  showModal,
24
28
  size = EmbedModalSize.Large,
25
29
  src,
26
30
  testId = 'smart-embed-preview-modal',
27
31
  title,
28
- url,
29
- isSupportTheming
32
+ url
30
33
  }) => {
31
34
  const defaultWidth = toWidth(size);
32
35
  const [isOpen, setIsOpen] = useState(showModal);
33
36
  const [width, setWidth] = useState(defaultWidth);
34
37
  const openAt = useRef();
38
+ const invoke = useInvokeClientAction({
39
+ analytics
40
+ });
35
41
  const handleOnOpenComplete = useCallback(() => {
36
42
  openAt.current = Date.now();
37
43
  if (onOpen) {
@@ -63,6 +69,22 @@ const EmbedModal = ({
63
69
  colorMode
64
70
  } = useThemeObserver();
65
71
  let previewUrl = src;
72
+ const handleOnViewActionClick = useCallback(() => {
73
+ invoke({
74
+ actionType: ActionName.ViewAction,
75
+ actionFn: async () => openUrl(url),
76
+ display: CardDisplay.EmbedPreview,
77
+ extensionKey
78
+ });
79
+ }, [extensionKey, invoke, url]);
80
+ const handleOnDownloadActionClick = useCallback(() => {
81
+ invoke({
82
+ actionType: ActionName.DownloadAction,
83
+ actionFn: async () => downloadUrl(download),
84
+ display: CardDisplay.EmbedPreview,
85
+ extensionKey
86
+ });
87
+ }, [download, extensionKey, invoke]);
66
88
  if (previewUrl && isSupportTheming && colorMode) {
67
89
  previewUrl = `${previewUrl}${previewUrl.includes('?') ? '&' : '?'}themeMode=${colorMode}`;
68
90
  }
@@ -74,16 +96,14 @@ const EmbedModal = ({
74
96
  testId: testId,
75
97
  width: width
76
98
  }, /*#__PURE__*/React.createElement(LinkInfo, {
77
- downloadUrl: downloadUrl,
78
99
  icon: icon,
79
100
  providerName: providerName,
80
- onViewButtonClick: onViewActionClick,
81
- onDownloadButtonClick: onDownloadActionClick,
101
+ onViewButtonClick: url ? handleOnViewActionClick : undefined,
102
+ onDownloadButtonClick: download ? handleOnDownloadActionClick : undefined,
82
103
  onResizeButtonClick: handleOnResizeClick,
83
104
  size: width,
84
105
  title: title,
85
- testId: testId,
86
- url: url
106
+ testId: testId
87
107
  }), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(EmbedContent, {
88
108
  isTrusted: isTrusted,
89
109
  name: iframeName,
@@ -28,6 +28,7 @@ const PreviewAction = props => {
28
28
  if (src && url) {
29
29
  const actionFn = async () => openEmbedModalWithFlexibleUiIcon({
30
30
  download: downloadUrl,
31
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey,
31
32
  title,
32
33
  providerName,
33
34
  isSupportTheming,
@@ -8,7 +8,7 @@ import LinkWarningModal from './LinkWarningModal';
8
8
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
9
  const PACKAGE_DATA = {
10
10
  packageName: "@atlaskit/smart-card",
11
- packageVersion: "26.26.1",
11
+ packageVersion: "26.26.2",
12
12
  componentName: 'linkUrl'
13
13
  };
14
14
  const Link = withLinkClickedEvent('a');
@@ -68,14 +68,9 @@ export var extractPreviewAction = function extractPreviewAction(_ref) {
68
68
  var key = extensionKey;
69
69
  var previewAction = PreviewAction(_objectSpread(_objectSpread({}, metadata), {}, {
70
70
  analytics: analytics,
71
+ extensionKey: extensionKey,
71
72
  origin: origin,
72
73
  testId: testId,
73
- onDownloadActionClick: function onDownloadActionClick() {
74
- handleInvoke(getInvokeOpts(key, 'DownloadAction'));
75
- },
76
- onViewActionClick: function onViewActionClick() {
77
- handleInvoke(getInvokeOpts(key, 'ViewAction'));
78
- },
79
74
  isSupportTheming: extractIsSupportTheming(meta)
80
75
  }));
81
76
  // Setup props to go through proper Redux 'invocation' flow
@@ -15,7 +15,7 @@ export var ANALYTICS_CHANNEL = 'media';
15
15
  export var context = {
16
16
  componentName: 'smart-cards',
17
17
  packageName: "@atlaskit/smart-card",
18
- packageVersion: "26.26.1"
18
+ packageVersion: "26.26.2"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -14,47 +14,41 @@ import { MAX_MODAL_SIZE } from '../../constants';
14
14
  import LinkInfoButton from './link-info-button';
15
15
  import { actionCss, containerStyles, iconCss, titleCss } from './styled';
16
16
  var LinkInfo = function LinkInfo(_ref) {
17
- var downloadUrl = _ref.downloadUrl,
18
- icon = _ref.icon,
17
+ var icon = _ref.icon,
19
18
  providerName = _ref.providerName,
20
19
  onDownloadButtonClick = _ref.onDownloadButtonClick,
21
20
  onResizeButtonClick = _ref.onResizeButtonClick,
22
21
  onViewButtonClick = _ref.onViewButtonClick,
23
22
  size = _ref.size,
24
23
  testId = _ref.testId,
25
- title = _ref.title,
26
- url = _ref.url;
24
+ title = _ref.title;
27
25
  var _useModal = useModal(),
28
26
  onClose = _useModal.onClose;
29
27
  var downloadButton = useMemo(function () {
30
- if (downloadUrl) {
28
+ if (onDownloadButtonClick) {
31
29
  return jsx(LinkInfoButton, {
32
30
  content: jsx(FormattedMessage, messages.download),
33
- href: downloadUrl,
34
31
  icon: jsx(DownloadIcon, {
35
32
  label: messages.download.defaultMessage
36
33
  }),
37
34
  onClick: onDownloadButtonClick,
38
- testId: "".concat(testId, "-download"),
39
- target: "_blank"
35
+ testId: "".concat(testId, "-download")
40
36
  });
41
37
  }
42
- }, [downloadUrl, onDownloadButtonClick, testId]);
38
+ }, [onDownloadButtonClick, testId]);
43
39
  var urlButton = useMemo(function () {
44
- if (url) {
40
+ if (onViewButtonClick) {
45
41
  var content = providerName ? jsx(React.Fragment, null, jsx(FormattedMessage, messages.viewIn), " ", providerName) : jsx(FormattedMessage, messages.viewOriginal);
46
42
  return jsx(LinkInfoButton, {
47
43
  content: content,
48
- href: url,
49
44
  icon: jsx(ShortcutIcon, {
50
45
  label: messages.viewOriginal.defaultMessage
51
46
  }),
52
47
  onClick: onViewButtonClick,
53
- target: "_blank",
54
48
  testId: "".concat(testId, "-url")
55
49
  });
56
50
  }
57
- }, [onViewButtonClick, providerName, testId, url]);
51
+ }, [onViewButtonClick, providerName, testId]);
58
52
  var sizeButton = useMemo(function () {
59
53
  var isFullScreen = size === MAX_MODAL_SIZE;
60
54
  var message = isFullScreen ? messages.preview_min_size : messages.preview_max_size;
@@ -13,7 +13,6 @@ var LinkInfoButton = function LinkInfoButton(_ref) {
13
13
  return /*#__PURE__*/React.createElement(Tooltip, {
14
14
  content: content,
15
15
  hideTooltipOnClick: true,
16
- position: "top",
17
16
  tag: "span",
18
17
  testId: "".concat(testId, "-tooltip")
19
18
  }, /*#__PURE__*/React.createElement(Button, {
@@ -1,4 +1,6 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
4
  import React, { useCallback, useRef, useState } from 'react';
3
5
  import ModalDialog, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
4
6
  import LinkInfo from './components/link-info';
@@ -8,6 +10,9 @@ import { EmbedModalSize } from './types';
8
10
  import withErrorBoundary from './components/error-boundary';
9
11
  import withAnalytics from './components/analytics';
10
12
  import { useThemeObserver } from '@atlaskit/tokens';
13
+ import useInvokeClientAction from '../../state/hooks/use-invoke-client-action';
14
+ import { ActionName, CardDisplay } from '../../constants';
15
+ import { downloadUrl, openUrl } from '../../utils';
11
16
  var toSize = function toSize(width) {
12
17
  return width === MAX_MODAL_SIZE ? EmbedModalSize.Large : EmbedModalSize.Small;
13
18
  };
@@ -15,16 +20,17 @@ var toWidth = function toWidth(size) {
15
20
  return size === EmbedModalSize.Large ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
16
21
  };
17
22
  var EmbedModal = function EmbedModal(_ref) {
18
- var downloadUrl = _ref.download,
23
+ var analytics = _ref.analytics,
24
+ download = _ref.download,
25
+ extensionKey = _ref.extensionKey,
19
26
  icon = _ref.icon,
20
27
  iframeName = _ref.iframeName,
28
+ isSupportTheming = _ref.isSupportTheming,
21
29
  _ref$isTrusted = _ref.isTrusted,
22
30
  isTrusted = _ref$isTrusted === void 0 ? false : _ref$isTrusted,
23
31
  onClose = _ref.onClose,
24
- onDownloadActionClick = _ref.onDownloadActionClick,
25
32
  onOpen = _ref.onOpen,
26
33
  onResize = _ref.onResize,
27
- onViewActionClick = _ref.onViewActionClick,
28
34
  providerName = _ref.providerName,
29
35
  showModal = _ref.showModal,
30
36
  _ref$size = _ref.size,
@@ -33,8 +39,7 @@ var EmbedModal = function EmbedModal(_ref) {
33
39
  _ref$testId = _ref.testId,
34
40
  testId = _ref$testId === void 0 ? 'smart-embed-preview-modal' : _ref$testId,
35
41
  title = _ref.title,
36
- url = _ref.url,
37
- isSupportTheming = _ref.isSupportTheming;
42
+ url = _ref.url;
38
43
  var defaultWidth = toWidth(size);
39
44
  var _useState = useState(showModal),
40
45
  _useState2 = _slicedToArray(_useState, 2),
@@ -45,6 +50,9 @@ var EmbedModal = function EmbedModal(_ref) {
45
50
  width = _useState4[0],
46
51
  setWidth = _useState4[1];
47
52
  var openAt = useRef();
53
+ var invoke = useInvokeClientAction({
54
+ analytics: analytics
55
+ });
48
56
  var handleOnOpenComplete = useCallback(function () {
49
57
  openAt.current = Date.now();
50
58
  if (onOpen) {
@@ -77,6 +85,54 @@ var EmbedModal = function EmbedModal(_ref) {
77
85
  var _useThemeObserver = useThemeObserver(),
78
86
  colorMode = _useThemeObserver.colorMode;
79
87
  var previewUrl = src;
88
+ var handleOnViewActionClick = useCallback(function () {
89
+ invoke({
90
+ actionType: ActionName.ViewAction,
91
+ actionFn: function () {
92
+ var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
93
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
94
+ while (1) switch (_context.prev = _context.next) {
95
+ case 0:
96
+ return _context.abrupt("return", openUrl(url));
97
+ case 1:
98
+ case "end":
99
+ return _context.stop();
100
+ }
101
+ }, _callee);
102
+ }));
103
+ function actionFn() {
104
+ return _actionFn.apply(this, arguments);
105
+ }
106
+ return actionFn;
107
+ }(),
108
+ display: CardDisplay.EmbedPreview,
109
+ extensionKey: extensionKey
110
+ });
111
+ }, [extensionKey, invoke, url]);
112
+ var handleOnDownloadActionClick = useCallback(function () {
113
+ invoke({
114
+ actionType: ActionName.DownloadAction,
115
+ actionFn: function () {
116
+ var _actionFn2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
117
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
118
+ while (1) switch (_context2.prev = _context2.next) {
119
+ case 0:
120
+ return _context2.abrupt("return", downloadUrl(download));
121
+ case 1:
122
+ case "end":
123
+ return _context2.stop();
124
+ }
125
+ }, _callee2);
126
+ }));
127
+ function actionFn() {
128
+ return _actionFn2.apply(this, arguments);
129
+ }
130
+ return actionFn;
131
+ }(),
132
+ display: CardDisplay.EmbedPreview,
133
+ extensionKey: extensionKey
134
+ });
135
+ }, [download, extensionKey, invoke]);
80
136
  if (previewUrl && isSupportTheming && colorMode) {
81
137
  previewUrl = "".concat(previewUrl).concat(previewUrl.includes('?') ? '&' : '?', "themeMode=").concat(colorMode);
82
138
  }
@@ -88,16 +144,14 @@ var EmbedModal = function EmbedModal(_ref) {
88
144
  testId: testId,
89
145
  width: width
90
146
  }, /*#__PURE__*/React.createElement(LinkInfo, {
91
- downloadUrl: downloadUrl,
92
147
  icon: icon,
93
148
  providerName: providerName,
94
- onViewButtonClick: onViewActionClick,
95
- onDownloadButtonClick: onDownloadActionClick,
149
+ onViewButtonClick: url ? handleOnViewActionClick : undefined,
150
+ onDownloadButtonClick: download ? handleOnDownloadActionClick : undefined,
96
151
  onResizeButtonClick: handleOnResizeClick,
97
152
  size: width,
98
153
  title: title,
99
- testId: testId,
100
- url: url
154
+ testId: testId
101
155
  }), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(EmbedContent, {
102
156
  isTrusted: isTrusted,
103
157
  name: iframeName,
@@ -36,6 +36,7 @@ var PreviewAction = function PreviewAction(props) {
36
36
  case 0:
37
37
  return _context.abrupt("return", openEmbedModalWithFlexibleUiIcon({
38
38
  download: downloadUrl,
39
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey,
39
40
  title: title,
40
41
  providerName: providerName,
41
42
  isSupportTheming: isSupportTheming,
@@ -11,7 +11,7 @@ import LinkWarningModal from './LinkWarningModal';
11
11
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
12
12
  var PACKAGE_DATA = {
13
13
  packageName: "@atlaskit/smart-card",
14
- packageVersion: "26.26.1",
14
+ packageVersion: "26.26.2",
15
15
  componentName: 'linkUrl'
16
16
  };
17
17
  var Link = withLinkClickedEvent('a');
@@ -21,6 +21,7 @@ type PreviewInfo = {
21
21
  analytics: AnalyticsFacade;
22
22
  origin?: AnalyticsOrigin;
23
23
  isSupportTheming?: boolean;
24
+ extensionKey?: string;
24
25
  };
25
26
  declare const _default: ({ details, ...rest }: PreviewInfo) => ActionProps;
26
27
  export default _default;
@@ -2,5 +2,6 @@ import { AnalyticsFacade } from '../../../../state/analytics';
2
2
  import { AnalyticsOrigin } from '../../../../utils/types';
3
3
  export type WithAnalytics = {
4
4
  analytics?: AnalyticsFacade;
5
+ extensionKey?: string;
5
6
  origin?: AnalyticsOrigin;
6
7
  };
@@ -1,6 +1,5 @@
1
1
  import { IconProps } from '../../../common/Icon';
2
2
  export type LinkInfoProps = {
3
- downloadUrl?: string;
4
3
  icon?: IconProps;
5
4
  providerName?: string;
6
5
  onDownloadButtonClick?: () => void;
@@ -9,5 +8,4 @@ export type LinkInfoProps = {
9
8
  size?: string;
10
9
  testId?: string;
11
10
  title?: string;
12
- url?: string;
13
11
  };
@@ -7,11 +7,9 @@ declare const _default: React.FC<{
7
7
  isTrusted?: boolean | undefined;
8
8
  isSupportTheming?: boolean | undefined;
9
9
  onClose: (context: import("./types").EmbedModalContext) => void;
10
- onDownloadActionClick?: (() => void) | undefined;
11
10
  onOpen?: ((context: import("./types").EmbedModalContext) => void) | undefined;
12
11
  onOpenFailed?: ((error: Error, errorInfo: React.ErrorInfo) => void) | undefined;
13
12
  onResize?: ((context: import("./types").EmbedModalContext) => void) | undefined;
14
- onViewActionClick?: (() => void) | undefined;
15
13
  providerName?: string | undefined;
16
14
  showModal?: boolean | undefined;
17
15
  size?: EmbedModalSize | undefined;
@@ -16,11 +16,9 @@ export type EmbedModalProps = {
16
16
  isTrusted?: boolean;
17
17
  isSupportTheming?: boolean;
18
18
  onClose: (context: EmbedModalContext) => void;
19
- onDownloadActionClick?: () => void;
20
19
  onOpen?: (context: EmbedModalContext) => void;
21
20
  onOpenFailed?: (error: Error, errorInfo: ErrorInfo) => void;
22
21
  onResize?: (context: EmbedModalContext) => void;
23
- onViewActionClick?: () => void;
24
22
  providerName?: string;
25
23
  showModal?: boolean;
26
24
  size?: EmbedModalSize;
@@ -21,6 +21,7 @@ type PreviewInfo = {
21
21
  analytics: AnalyticsFacade;
22
22
  origin?: AnalyticsOrigin;
23
23
  isSupportTheming?: boolean;
24
+ extensionKey?: string;
24
25
  };
25
26
  declare const _default: ({ details, ...rest }: PreviewInfo) => ActionProps;
26
27
  export default _default;
@@ -2,5 +2,6 @@ import { AnalyticsFacade } from '../../../../state/analytics';
2
2
  import { AnalyticsOrigin } from '../../../../utils/types';
3
3
  export type WithAnalytics = {
4
4
  analytics?: AnalyticsFacade;
5
+ extensionKey?: string;
5
6
  origin?: AnalyticsOrigin;
6
7
  };
@@ -1,6 +1,5 @@
1
1
  import { IconProps } from '../../../common/Icon';
2
2
  export type LinkInfoProps = {
3
- downloadUrl?: string;
4
3
  icon?: IconProps;
5
4
  providerName?: string;
6
5
  onDownloadButtonClick?: () => void;
@@ -9,5 +8,4 @@ export type LinkInfoProps = {
9
8
  size?: string;
10
9
  testId?: string;
11
10
  title?: string;
12
- url?: string;
13
11
  };
@@ -7,11 +7,9 @@ declare const _default: React.FC<{
7
7
  isTrusted?: boolean | undefined;
8
8
  isSupportTheming?: boolean | undefined;
9
9
  onClose: (context: import("./types").EmbedModalContext) => void;
10
- onDownloadActionClick?: (() => void) | undefined;
11
10
  onOpen?: ((context: import("./types").EmbedModalContext) => void) | undefined;
12
11
  onOpenFailed?: ((error: Error, errorInfo: React.ErrorInfo) => void) | undefined;
13
12
  onResize?: ((context: import("./types").EmbedModalContext) => void) | undefined;
14
- onViewActionClick?: (() => void) | undefined;
15
13
  providerName?: string | undefined;
16
14
  showModal?: boolean | undefined;
17
15
  size?: EmbedModalSize | undefined;
@@ -16,11 +16,9 @@ export type EmbedModalProps = {
16
16
  isTrusted?: boolean;
17
17
  isSupportTheming?: boolean;
18
18
  onClose: (context: EmbedModalContext) => void;
19
- onDownloadActionClick?: () => void;
20
19
  onOpen?: (context: EmbedModalContext) => void;
21
20
  onOpenFailed?: (error: Error, errorInfo: ErrorInfo) => void;
22
21
  onResize?: (context: EmbedModalContext) => void;
23
- onViewActionClick?: () => void;
24
22
  providerName?: string;
25
23
  showModal?: boolean;
26
24
  size?: EmbedModalSize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.26.1",
3
+ "version": "26.26.2",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"