@atlaskit/media-card 78.17.3 → 78.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/media-card
2
2
 
3
+ ## 78.18.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 78.18.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#97492](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97492)
14
+ [`5195c4fd974a3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5195c4fd974a3) -
15
+ Integrated warning modal dialog to prevent against abuse-classified file downloads.
16
+
17
+ Integrated with MediaViewerWithPortal replacing React Potal (behind feature flag)
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies
22
+
3
23
  ## 78.17.3
4
24
 
5
25
  ### Patch Changes
@@ -21,7 +21,7 @@ var _excluded = ["identifier"];
21
21
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
22
22
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
23
23
  var packageName = "@atlaskit/media-card";
24
- var packageVersion = "78.17.3";
24
+ var packageVersion = "78.18.1";
25
25
  var CardBase = exports.CardBase = function CardBase(_ref) {
26
26
  var identifier = _ref.identifier,
27
27
  otherProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
@@ -38,10 +38,19 @@ var _actions = require("./actions");
38
38
  var _performance = require("./performance");
39
39
  var _dateOverrideContext = require("../dateOverrideContext");
40
40
  var _reactIntlNext = require("react-intl-next");
41
+ var _abuseModal = require("@atlaskit/media-ui/abuseModal");
42
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
41
43
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
42
44
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
43
45
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
44
46
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
47
+ var MediaViewerComponent = function MediaViewerComponent(props) {
48
+ if ((0, _platformFeatureFlags.fg)('media_card_replace_react_portal_for_ds_portal')) {
49
+ return /*#__PURE__*/_react.default.createElement(_mediaViewer.MediaViewerWithPortal, props);
50
+ } else {
51
+ return /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement(_mediaViewer.MediaViewer, props), document.body);
52
+ }
53
+ };
45
54
  var FileCard = exports.FileCard = function FileCard(_ref) {
46
55
  var _ref$appearance = _ref.appearance,
47
56
  appearance = _ref$appearance === void 0 ? 'auto' : _ref$appearance,
@@ -78,6 +87,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
78
87
  includeHashForDuplicateFiles = _ref.includeHashForDuplicateFiles;
79
88
  var _useIntl = (0, _reactIntlNext.useIntl)(),
80
89
  formatMessage = _useIntl.formatMessage;
90
+ var openModalRef = /*#__PURE__*/(0, _react.createRef)();
81
91
  var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
82
92
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
83
93
  //----------------------------------------------------------------//
@@ -248,34 +258,55 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
248
258
  fileStatus: fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.status
249
259
  };
250
260
  }, [fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.status, metadata.id, metadata.mediaType, metadata.mimeType, metadata.size]);
261
+ var downloadFn = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
262
+ var _error;
263
+ return _regenerator.default.wrap(function _callee$(_context) {
264
+ while (1) switch (_context.prev = _context.next) {
265
+ case 0:
266
+ _context.prev = 0;
267
+ _context.next = 3;
268
+ return mediaClient.file.downloadBinary(identifier.id, metadata.name, identifier.collectionName, traceContext);
269
+ case 3:
270
+ (0, _cardAnalytics.fireDownloadSucceededEvent)(createAnalyticsEvent, fileAttributes, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
271
+ _context.next = 10;
272
+ break;
273
+ case 6:
274
+ _context.prev = 6;
275
+ _context.t0 = _context["catch"](0);
276
+ _error = new _errors.MediaCardError('download', _context.t0);
277
+ (0, _cardAnalytics.fireDownloadFailedEvent)(createAnalyticsEvent, fileAttributes, _error, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
278
+ case 10:
279
+ case "end":
280
+ return _context.stop();
281
+ }
282
+ }, _callee, null, [[0, 6]]);
283
+ })), [createAnalyticsEvent, fileAttributes, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext, identifier.collectionName, identifier.id, mediaClient.file, metadata.name, traceContext]);
251
284
  var computedActions = (0, _react.useMemo)(function () {
252
285
  if (finalStatus === 'failed-processing' || shouldEnableDownloadButton) {
253
286
  var handler = /*#__PURE__*/function () {
254
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
255
- var _error;
256
- return _regenerator.default.wrap(function _callee$(_context) {
257
- while (1) switch (_context.prev = _context.next) {
287
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
288
+ var _openModalRef$current;
289
+ return _regenerator.default.wrap(function _callee2$(_context2) {
290
+ while (1) switch (_context2.prev = _context2.next) {
258
291
  case 0:
259
- _context.prev = 0;
260
- _context.next = 3;
261
- return mediaClient.file.downloadBinary(identifier.id, metadata.name, identifier.collectionName, traceContext);
262
- case 3:
263
- (0, _cardAnalytics.fireDownloadSucceededEvent)(createAnalyticsEvent, fileAttributes, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
264
- _context.next = 10;
292
+ if (!(fileStateValue !== null && fileStateValue !== void 0 && fileStateValue.abuseClassification)) {
293
+ _context2.next = 4;
294
+ break;
295
+ }
296
+ (_openModalRef$current = openModalRef.current) === null || _openModalRef$current === void 0 || _openModalRef$current.call(openModalRef);
297
+ _context2.next = 6;
265
298
  break;
299
+ case 4:
300
+ _context2.next = 6;
301
+ return downloadFn();
266
302
  case 6:
267
- _context.prev = 6;
268
- _context.t0 = _context["catch"](0);
269
- _error = new _errors.MediaCardError('download', _context.t0);
270
- (0, _cardAnalytics.fireDownloadFailedEvent)(createAnalyticsEvent, fileAttributes, _error, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
271
- case 10:
272
303
  case "end":
273
- return _context.stop();
304
+ return _context2.stop();
274
305
  }
275
- }, _callee, null, [[0, 6]]);
306
+ }, _callee2);
276
307
  }));
277
308
  return function handler() {
278
- return _ref2.apply(this, arguments);
309
+ return _ref3.apply(this, arguments);
279
310
  };
280
311
  }();
281
312
  var downloadAction = (0, _actions.createDownloadAction)({
@@ -286,7 +317,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
286
317
  } else {
287
318
  return actions;
288
319
  }
289
- }, [actions, identifier.collectionName, identifier.id, mediaClient.file, mediaClient.config.enforceDataSecurityPolicy, metadata.name, shouldEnableDownloadButton, finalStatus, createAnalyticsEvent, fileAttributes, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext, traceContext, formatMessage]);
320
+ }, [actions, mediaClient.config.enforceDataSecurityPolicy, shouldEnableDownloadButton, finalStatus, formatMessage, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.abuseClassification, openModalRef, downloadFn]);
290
321
 
291
322
  //----------------------------------------------------------------//
292
323
  //---------------------- Analytics ------------------------------//
@@ -607,7 +638,11 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
607
638
 
608
639
  var inlinePlayerFallback = isPlayingFile ? renderCard(false, 'loading', false) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
609
640
  var collectionName = identifier.collectionName || '';
610
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isPlayingFile ? /*#__PURE__*/_react.default.createElement(_react.Suspense, {
641
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_abuseModal.AbuseModal, {
642
+ ref: openModalRef,
643
+ onConfirm: downloadFn,
644
+ shouldMount: !!(fileStateValue !== null && fileStateValue !== void 0 && fileStateValue.abuseClassification)
645
+ }), isPlayingFile ? /*#__PURE__*/_react.default.createElement(_react.Suspense, {
611
646
  fallback: inlinePlayerFallback
612
647
  }, /*#__PURE__*/_react.default.createElement(_inlinePlayerLazy.InlinePlayerLazy, {
613
648
  dimensions: cardDimensions,
@@ -626,7 +661,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
626
661
  testId: testId,
627
662
  cardPreview: preview,
628
663
  videoControlsWrapperRef: videoControlsWrapperRef
629
- })) : renderCard(), mediaViewerSelectedItem ? /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement(_mediaViewer.MediaViewer, {
664
+ })) : renderCard(), mediaViewerSelectedItem ? /*#__PURE__*/_react.default.createElement(MediaViewerComponent, {
630
665
  collectionName: collectionName,
631
666
  items: mediaViewerItems || [],
632
667
  mediaClientConfig: mediaClient.config,
@@ -637,5 +672,5 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
637
672
  contextId: contextId,
638
673
  featureFlags: featureFlags,
639
674
  viewerOptions: viewerOptions
640
- }), document.body) : null, getSsrScriptProps && /*#__PURE__*/_react.default.createElement("script", getSsrScriptProps()));
675
+ }) : null, getSsrScriptProps && /*#__PURE__*/_react.default.createElement("script", getSsrScriptProps()));
641
676
  };
@@ -87,7 +87,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
87
87
  }(_react.default.Component);
88
88
  (0, _defineProperty2.default)(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
89
89
  var packageName = "@atlaskit/media-card";
90
- var packageVersion = "78.17.3";
90
+ var packageVersion = "78.18.1";
91
91
 
92
92
  // @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
93
93
  var MediaCardAnalyticsErrorBoundary = (0, _mediaCommon.withMediaAnalyticsContext)({
@@ -117,7 +117,7 @@ var MediaInlineCardLoader = exports.default = /*#__PURE__*/function (_React$Pure
117
117
  ErrorBoundary = _this$state.ErrorBoundary;
118
118
  var analyticsContext = {
119
119
  packageVersion: "@atlaskit/media-card",
120
- packageName: "78.17.3",
120
+ packageName: "78.18.1",
121
121
  componentName: 'mediaInlineCard',
122
122
  component: 'mediaInlineCard'
123
123
  };
@@ -15,7 +15,7 @@ var _mediaClient = require("@atlaskit/media-client");
15
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
17
  var packageName = "@atlaskit/media-card";
18
- var packageVersion = "78.17.3";
18
+ var packageVersion = "78.18.1";
19
19
  var concurrentExperience;
20
20
  var getExperience = function getExperience(id) {
21
21
  if (!concurrentExperience) {
@@ -9,7 +9,7 @@ import { startResourceObserver, setAnalyticsContext } from '../utils/mediaPerfor
9
9
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
10
10
  import UFOLabel from '@atlaskit/react-ufo/label';
11
11
  const packageName = "@atlaskit/media-card";
12
- const packageVersion = "78.17.3";
12
+ const packageVersion = "78.18.1";
13
13
  export const CardBase = ({
14
14
  identifier,
15
15
  ...otherProps
@@ -2,8 +2,8 @@ import { useAnalyticsEvents } from '@atlaskit/analytics-next';
2
2
  import { globalMediaEventEmitter, RECENTS_COLLECTION, imageResizeModeToFileImageMode, isProcessedFileState, isErrorFileState } from '@atlaskit/media-client';
3
3
  import { MediaFileStateError, useFileState, useMediaClient } from '@atlaskit/media-client-react';
4
4
  import { getRandomHex, isMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
5
- import { MediaViewer } from '@atlaskit/media-viewer';
6
- import React, { Suspense, useEffect, useMemo, useRef, useState } from 'react';
5
+ import { MediaViewer, MediaViewerWithPortal } from '@atlaskit/media-viewer';
6
+ import React, { Suspense, useEffect, useMemo, useRef, useState, createRef, useCallback } from 'react';
7
7
  import ReactDOM from 'react-dom';
8
8
  import { useMergeRefs } from 'use-callback-ref';
9
9
  import { MediaCardError } from '../errors';
@@ -26,6 +26,15 @@ import { performanceNow } from './performance';
26
26
  import { useContext } from 'react';
27
27
  import { DateOverrideContext } from '../dateOverrideContext';
28
28
  import { useIntl } from 'react-intl-next';
29
+ import { AbuseModal } from '@atlaskit/media-ui/abuseModal';
30
+ import { fg } from '@atlaskit/platform-feature-flags';
31
+ const MediaViewerComponent = props => {
32
+ if (fg('media_card_replace_react_portal_for_ds_portal')) {
33
+ return /*#__PURE__*/React.createElement(MediaViewerWithPortal, props);
34
+ } else {
35
+ return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(MediaViewer, props), document.body);
36
+ }
37
+ };
29
38
  export const FileCard = ({
30
39
  appearance = 'auto',
31
40
  resizeMode = 'crop',
@@ -60,6 +69,7 @@ export const FileCard = ({
60
69
  const {
61
70
  formatMessage
62
71
  } = useIntl();
72
+ const openModalRef = /*#__PURE__*/createRef();
63
73
  const {
64
74
  createAnalyticsEvent
65
75
  } = useAnalyticsEvents();
@@ -203,15 +213,23 @@ export const FileCard = ({
203
213
  fileStatus: fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.status
204
214
  };
205
215
  }, [fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.status, metadata.id, metadata.mediaType, metadata.mimeType, metadata.size]);
216
+ const downloadFn = useCallback(async () => {
217
+ try {
218
+ await mediaClient.file.downloadBinary(identifier.id, metadata.name, identifier.collectionName, traceContext);
219
+ fireDownloadSucceededEvent(createAnalyticsEvent, fileAttributes, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
220
+ } catch (e) {
221
+ const error = new MediaCardError('download', e);
222
+ fireDownloadFailedEvent(createAnalyticsEvent, fileAttributes, error, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
223
+ }
224
+ }, [createAnalyticsEvent, fileAttributes, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext, identifier.collectionName, identifier.id, mediaClient.file, metadata.name, traceContext]);
206
225
  const computedActions = useMemo(() => {
207
226
  if (finalStatus === 'failed-processing' || shouldEnableDownloadButton) {
208
227
  const handler = async () => {
209
- try {
210
- await mediaClient.file.downloadBinary(identifier.id, metadata.name, identifier.collectionName, traceContext);
211
- fireDownloadSucceededEvent(createAnalyticsEvent, fileAttributes, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
212
- } catch (e) {
213
- const error = new MediaCardError('download', e);
214
- fireDownloadFailedEvent(createAnalyticsEvent, fileAttributes, error, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
228
+ if (!!(fileStateValue !== null && fileStateValue !== void 0 && fileStateValue.abuseClassification)) {
229
+ var _openModalRef$current;
230
+ (_openModalRef$current = openModalRef.current) === null || _openModalRef$current === void 0 ? void 0 : _openModalRef$current.call(openModalRef);
231
+ } else {
232
+ await downloadFn();
215
233
  }
216
234
  };
217
235
  const downloadAction = createDownloadAction({
@@ -222,7 +240,7 @@ export const FileCard = ({
222
240
  } else {
223
241
  return actions;
224
242
  }
225
- }, [actions, identifier.collectionName, identifier.id, mediaClient.file, mediaClient.config.enforceDataSecurityPolicy, metadata.name, shouldEnableDownloadButton, finalStatus, createAnalyticsEvent, fileAttributes, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext, traceContext, formatMessage]);
243
+ }, [actions, mediaClient.config.enforceDataSecurityPolicy, shouldEnableDownloadButton, finalStatus, formatMessage, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.abuseClassification, openModalRef, downloadFn]);
226
244
 
227
245
  //----------------------------------------------------------------//
228
246
  //---------------------- Analytics ------------------------------//
@@ -544,7 +562,11 @@ export const FileCard = ({
544
562
 
545
563
  const inlinePlayerFallback = isPlayingFile ? renderCard(false, 'loading', false) : /*#__PURE__*/React.createElement(React.Fragment, null);
546
564
  const collectionName = identifier.collectionName || '';
547
- return /*#__PURE__*/React.createElement(React.Fragment, null, isPlayingFile ? /*#__PURE__*/React.createElement(Suspense, {
565
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AbuseModal, {
566
+ ref: openModalRef,
567
+ onConfirm: downloadFn,
568
+ shouldMount: !!(fileStateValue !== null && fileStateValue !== void 0 && fileStateValue.abuseClassification)
569
+ }), isPlayingFile ? /*#__PURE__*/React.createElement(Suspense, {
548
570
  fallback: inlinePlayerFallback
549
571
  }, /*#__PURE__*/React.createElement(InlinePlayerLazy, {
550
572
  dimensions: cardDimensions,
@@ -563,7 +585,7 @@ export const FileCard = ({
563
585
  testId: testId,
564
586
  cardPreview: preview,
565
587
  videoControlsWrapperRef: videoControlsWrapperRef
566
- })) : renderCard(), mediaViewerSelectedItem ? /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(MediaViewer, {
588
+ })) : renderCard(), mediaViewerSelectedItem ? /*#__PURE__*/React.createElement(MediaViewerComponent, {
567
589
  collectionName: collectionName,
568
590
  items: mediaViewerItems || [],
569
591
  mediaClientConfig: mediaClient.config,
@@ -574,5 +596,5 @@ export const FileCard = ({
574
596
  contextId: contextId,
575
597
  featureFlags: featureFlags,
576
598
  viewerOptions: viewerOptions
577
- }), document.body) : null, getSsrScriptProps && /*#__PURE__*/React.createElement("script", getSsrScriptProps()));
599
+ }) : null, getSsrScriptProps && /*#__PURE__*/React.createElement("script", getSsrScriptProps()));
578
600
  };
@@ -66,7 +66,7 @@ class WrappedMediaCardAnalyticsErrorBoundary extends React.Component {
66
66
  }
67
67
  _defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
68
68
  const packageName = "@atlaskit/media-card";
69
- const packageVersion = "78.17.3";
69
+ const packageVersion = "78.18.1";
70
70
 
71
71
  // @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
72
72
  const MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
@@ -37,7 +37,7 @@ export default class MediaInlineCardLoader extends React.PureComponent {
37
37
  } = this.state;
38
38
  const analyticsContext = {
39
39
  packageVersion: "@atlaskit/media-card",
40
- packageName: "78.17.3",
40
+ packageName: "78.18.1",
41
41
  componentName: 'mediaInlineCard',
42
42
  component: 'mediaInlineCard'
43
43
  };
@@ -5,7 +5,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
5
5
  import { MediaCardError } from '../errors';
6
6
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
7
7
  const packageName = "@atlaskit/media-card";
8
- const packageVersion = "78.17.3";
8
+ const packageVersion = "78.18.1";
9
9
  let concurrentExperience;
10
10
  const getExperience = id => {
11
11
  if (!concurrentExperience) {
@@ -11,7 +11,7 @@ import { startResourceObserver, setAnalyticsContext } from '../utils/mediaPerfor
11
11
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
12
12
  import UFOLabel from '@atlaskit/react-ufo/label';
13
13
  var packageName = "@atlaskit/media-card";
14
- var packageVersion = "78.17.3";
14
+ var packageVersion = "78.18.1";
15
15
  export var CardBase = function CardBase(_ref) {
16
16
  var identifier = _ref.identifier,
17
17
  otherProps = _objectWithoutProperties(_ref, _excluded);
@@ -9,8 +9,8 @@ import { useAnalyticsEvents } from '@atlaskit/analytics-next';
9
9
  import { globalMediaEventEmitter, RECENTS_COLLECTION, imageResizeModeToFileImageMode, isProcessedFileState, isErrorFileState } from '@atlaskit/media-client';
10
10
  import { MediaFileStateError, useFileState, useMediaClient } from '@atlaskit/media-client-react';
11
11
  import { getRandomHex, isMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
12
- import { MediaViewer } from '@atlaskit/media-viewer';
13
- import React, { Suspense, useEffect, useMemo, useRef, useState } from 'react';
12
+ import { MediaViewer, MediaViewerWithPortal } from '@atlaskit/media-viewer';
13
+ import React, { Suspense, useEffect, useMemo, useRef, useState, createRef, useCallback } from 'react';
14
14
  import ReactDOM from 'react-dom';
15
15
  import { useMergeRefs } from 'use-callback-ref';
16
16
  import { MediaCardError } from '../errors';
@@ -33,6 +33,15 @@ import { performanceNow } from './performance';
33
33
  import { useContext } from 'react';
34
34
  import { DateOverrideContext } from '../dateOverrideContext';
35
35
  import { useIntl } from 'react-intl-next';
36
+ import { AbuseModal } from '@atlaskit/media-ui/abuseModal';
37
+ import { fg } from '@atlaskit/platform-feature-flags';
38
+ var MediaViewerComponent = function MediaViewerComponent(props) {
39
+ if (fg('media_card_replace_react_portal_for_ds_portal')) {
40
+ return /*#__PURE__*/React.createElement(MediaViewerWithPortal, props);
41
+ } else {
42
+ return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(MediaViewer, props), document.body);
43
+ }
44
+ };
36
45
  export var FileCard = function FileCard(_ref) {
37
46
  var _ref$appearance = _ref.appearance,
38
47
  appearance = _ref$appearance === void 0 ? 'auto' : _ref$appearance,
@@ -69,6 +78,7 @@ export var FileCard = function FileCard(_ref) {
69
78
  includeHashForDuplicateFiles = _ref.includeHashForDuplicateFiles;
70
79
  var _useIntl = useIntl(),
71
80
  formatMessage = _useIntl.formatMessage;
81
+ var openModalRef = /*#__PURE__*/createRef();
72
82
  var _useAnalyticsEvents = useAnalyticsEvents(),
73
83
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
74
84
  //----------------------------------------------------------------//
@@ -239,34 +249,55 @@ export var FileCard = function FileCard(_ref) {
239
249
  fileStatus: fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.status
240
250
  };
241
251
  }, [fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.status, metadata.id, metadata.mediaType, metadata.mimeType, metadata.size]);
252
+ var downloadFn = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
253
+ var _error;
254
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
255
+ while (1) switch (_context.prev = _context.next) {
256
+ case 0:
257
+ _context.prev = 0;
258
+ _context.next = 3;
259
+ return mediaClient.file.downloadBinary(identifier.id, metadata.name, identifier.collectionName, traceContext);
260
+ case 3:
261
+ fireDownloadSucceededEvent(createAnalyticsEvent, fileAttributes, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
262
+ _context.next = 10;
263
+ break;
264
+ case 6:
265
+ _context.prev = 6;
266
+ _context.t0 = _context["catch"](0);
267
+ _error = new MediaCardError('download', _context.t0);
268
+ fireDownloadFailedEvent(createAnalyticsEvent, fileAttributes, _error, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
269
+ case 10:
270
+ case "end":
271
+ return _context.stop();
272
+ }
273
+ }, _callee, null, [[0, 6]]);
274
+ })), [createAnalyticsEvent, fileAttributes, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext, identifier.collectionName, identifier.id, mediaClient.file, metadata.name, traceContext]);
242
275
  var computedActions = useMemo(function () {
243
276
  if (finalStatus === 'failed-processing' || shouldEnableDownloadButton) {
244
277
  var handler = /*#__PURE__*/function () {
245
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
246
- var _error;
247
- return _regeneratorRuntime.wrap(function _callee$(_context) {
248
- while (1) switch (_context.prev = _context.next) {
278
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
279
+ var _openModalRef$current;
280
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
281
+ while (1) switch (_context2.prev = _context2.next) {
249
282
  case 0:
250
- _context.prev = 0;
251
- _context.next = 3;
252
- return mediaClient.file.downloadBinary(identifier.id, metadata.name, identifier.collectionName, traceContext);
253
- case 3:
254
- fireDownloadSucceededEvent(createAnalyticsEvent, fileAttributes, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
255
- _context.next = 10;
283
+ if (!(fileStateValue !== null && fileStateValue !== void 0 && fileStateValue.abuseClassification)) {
284
+ _context2.next = 4;
285
+ break;
286
+ }
287
+ (_openModalRef$current = openModalRef.current) === null || _openModalRef$current === void 0 || _openModalRef$current.call(openModalRef);
288
+ _context2.next = 6;
256
289
  break;
290
+ case 4:
291
+ _context2.next = 6;
292
+ return downloadFn();
257
293
  case 6:
258
- _context.prev = 6;
259
- _context.t0 = _context["catch"](0);
260
- _error = new MediaCardError('download', _context.t0);
261
- fireDownloadFailedEvent(createAnalyticsEvent, fileAttributes, _error, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
262
- case 10:
263
294
  case "end":
264
- return _context.stop();
295
+ return _context2.stop();
265
296
  }
266
- }, _callee, null, [[0, 6]]);
297
+ }, _callee2);
267
298
  }));
268
299
  return function handler() {
269
- return _ref2.apply(this, arguments);
300
+ return _ref3.apply(this, arguments);
270
301
  };
271
302
  }();
272
303
  var downloadAction = createDownloadAction({
@@ -277,7 +308,7 @@ export var FileCard = function FileCard(_ref) {
277
308
  } else {
278
309
  return actions;
279
310
  }
280
- }, [actions, identifier.collectionName, identifier.id, mediaClient.file, mediaClient.config.enforceDataSecurityPolicy, metadata.name, shouldEnableDownloadButton, finalStatus, createAnalyticsEvent, fileAttributes, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext, traceContext, formatMessage]);
311
+ }, [actions, mediaClient.config.enforceDataSecurityPolicy, shouldEnableDownloadButton, finalStatus, formatMessage, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.abuseClassification, openModalRef, downloadFn]);
281
312
 
282
313
  //----------------------------------------------------------------//
283
314
  //---------------------- Analytics ------------------------------//
@@ -598,7 +629,11 @@ export var FileCard = function FileCard(_ref) {
598
629
 
599
630
  var inlinePlayerFallback = isPlayingFile ? renderCard(false, 'loading', false) : /*#__PURE__*/React.createElement(React.Fragment, null);
600
631
  var collectionName = identifier.collectionName || '';
601
- return /*#__PURE__*/React.createElement(React.Fragment, null, isPlayingFile ? /*#__PURE__*/React.createElement(Suspense, {
632
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AbuseModal, {
633
+ ref: openModalRef,
634
+ onConfirm: downloadFn,
635
+ shouldMount: !!(fileStateValue !== null && fileStateValue !== void 0 && fileStateValue.abuseClassification)
636
+ }), isPlayingFile ? /*#__PURE__*/React.createElement(Suspense, {
602
637
  fallback: inlinePlayerFallback
603
638
  }, /*#__PURE__*/React.createElement(InlinePlayerLazy, {
604
639
  dimensions: cardDimensions,
@@ -617,7 +652,7 @@ export var FileCard = function FileCard(_ref) {
617
652
  testId: testId,
618
653
  cardPreview: preview,
619
654
  videoControlsWrapperRef: videoControlsWrapperRef
620
- })) : renderCard(), mediaViewerSelectedItem ? /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(MediaViewer, {
655
+ })) : renderCard(), mediaViewerSelectedItem ? /*#__PURE__*/React.createElement(MediaViewerComponent, {
621
656
  collectionName: collectionName,
622
657
  items: mediaViewerItems || [],
623
658
  mediaClientConfig: mediaClient.config,
@@ -628,5 +663,5 @@ export var FileCard = function FileCard(_ref) {
628
663
  contextId: contextId,
629
664
  featureFlags: featureFlags,
630
665
  viewerOptions: viewerOptions
631
- }), document.body) : null, getSsrScriptProps && /*#__PURE__*/React.createElement("script", getSsrScriptProps()));
666
+ }) : null, getSsrScriptProps && /*#__PURE__*/React.createElement("script", getSsrScriptProps()));
632
667
  };
@@ -80,7 +80,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
80
80
  }(React.Component);
81
81
  _defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
82
82
  var packageName = "@atlaskit/media-card";
83
- var packageVersion = "78.17.3";
83
+ var packageVersion = "78.18.1";
84
84
 
85
85
  // @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
86
86
  var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
@@ -101,7 +101,7 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
101
101
  ErrorBoundary = _this$state.ErrorBoundary;
102
102
  var analyticsContext = {
103
103
  packageVersion: "@atlaskit/media-card",
104
- packageName: "78.17.3",
104
+ packageName: "78.18.1",
105
105
  componentName: 'mediaInlineCard',
106
106
  component: 'mediaInlineCard'
107
107
  };
@@ -8,7 +8,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
8
8
  import { MediaCardError } from '../errors';
9
9
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
10
10
  var packageName = "@atlaskit/media-card";
11
- var packageVersion = "78.17.3";
11
+ var packageVersion = "78.18.1";
12
12
  var concurrentExperience;
13
13
  var getExperience = function getExperience(id) {
14
14
  if (!concurrentExperience) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "78.17.3",
3
+ "version": "78.18.1",
4
4
  "description": "Includes all media card related components, CardView, CardViewSmall, Card...",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -36,21 +36,21 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@atlaskit/analytics-next": "^10.2.0",
39
- "@atlaskit/dropdown-menu": "^12.23.0",
39
+ "@atlaskit/dropdown-menu": "^12.24.0",
40
40
  "@atlaskit/editor-shared-styles": "^3.2.0",
41
- "@atlaskit/icon": "^23.1.0",
41
+ "@atlaskit/icon": "^23.3.0",
42
42
  "@atlaskit/media-client": "^29.0.0",
43
43
  "@atlaskit/media-client-react": "^2.5.0",
44
44
  "@atlaskit/media-common": "^11.7.0",
45
45
  "@atlaskit/media-file-preview": "^0.9.0",
46
- "@atlaskit/media-ui": "^27.2.0",
47
- "@atlaskit/media-viewer": "^49.5.0",
46
+ "@atlaskit/media-ui": "^27.3.0",
47
+ "@atlaskit/media-viewer": "^49.6.0",
48
48
  "@atlaskit/platform-feature-flags": "^0.3.0",
49
49
  "@atlaskit/primitives": "^13.3.0",
50
- "@atlaskit/react-ufo": "^2.8.0",
50
+ "@atlaskit/react-ufo": "^2.9.0",
51
51
  "@atlaskit/spinner": "^16.3.0",
52
52
  "@atlaskit/theme": "^14.0.0",
53
- "@atlaskit/tokens": "^2.5.0",
53
+ "@atlaskit/tokens": "^3.0.0",
54
54
  "@atlaskit/tooltip": "^19.0.0",
55
55
  "@atlaskit/ufo": "^0.3.0",
56
56
  "@atlaskit/visually-hidden": "^1.5.0",
@@ -76,8 +76,8 @@
76
76
  "@atlaskit/inline-message": "^13.0.0",
77
77
  "@atlaskit/media-core": "^34.4.0",
78
78
  "@atlaskit/media-picker": "^67.0.0",
79
- "@atlaskit/media-state": "^1.2.0",
80
- "@atlaskit/media-test-data": "^2.7.0",
79
+ "@atlaskit/media-state": "^1.3.0",
80
+ "@atlaskit/media-test-data": "^2.8.0",
81
81
  "@atlaskit/media-test-helpers": "^34.7.0",
82
82
  "@atlaskit/radio": "^7.0.0",
83
83
  "@atlaskit/range": "^8.0.0",
@@ -113,6 +113,9 @@
113
113
  },
114
114
  "platform_media_cdn_single_host": {
115
115
  "type": "boolean"
116
+ },
117
+ "media_card_replace_react_portal_for_ds_portal": {
118
+ "type": "boolean"
116
119
  }
117
120
  },
118
121
  "techstack": {