@atlaskit/media-viewer 52.5.3 → 52.5.5

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 (27) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/analytics/index.js +1 -1
  3. package/dist/cjs/analytics/ufoExperiences.js +1 -1
  4. package/dist/cjs/viewers/archiveSidebar/archive-sidebar-folder-entry.js +15 -6
  5. package/dist/cjs/viewers/archiveSidebar/archive-sidebar-renderer.js +2 -1
  6. package/dist/cjs/viewers/archiveSidebar/archive-sidebar.js +13 -7
  7. package/dist/cjs/viewers/archiveSidebar/archive.js +4 -0
  8. package/dist/cjs/viewers/doc/index.js +5 -1
  9. package/dist/es2019/analytics/index.js +1 -1
  10. package/dist/es2019/analytics/ufoExperiences.js +1 -1
  11. package/dist/es2019/viewers/archiveSidebar/archive-sidebar-folder-entry.js +11 -0
  12. package/dist/es2019/viewers/archiveSidebar/archive-sidebar-renderer.js +2 -1
  13. package/dist/es2019/viewers/archiveSidebar/archive-sidebar.js +13 -6
  14. package/dist/es2019/viewers/archiveSidebar/archive.js +4 -0
  15. package/dist/es2019/viewers/doc/index.js +4 -0
  16. package/dist/esm/analytics/index.js +1 -1
  17. package/dist/esm/analytics/ufoExperiences.js +1 -1
  18. package/dist/esm/viewers/archiveSidebar/archive-sidebar-folder-entry.js +15 -6
  19. package/dist/esm/viewers/archiveSidebar/archive-sidebar-renderer.js +2 -1
  20. package/dist/esm/viewers/archiveSidebar/archive-sidebar.js +13 -7
  21. package/dist/esm/viewers/archiveSidebar/archive.js +4 -0
  22. package/dist/esm/viewers/doc/index.js +5 -1
  23. package/dist/types/viewers/archiveSidebar/archive-sidebar-folder-entry.d.ts +1 -0
  24. package/dist/types/viewers/archiveSidebar/archive-sidebar.d.ts +1 -0
  25. package/dist/types-ts4.5/viewers/archiveSidebar/archive-sidebar-folder-entry.d.ts +1 -0
  26. package/dist/types-ts4.5/viewers/archiveSidebar/archive-sidebar.d.ts +1 -0
  27. package/package.json +6 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/media-viewer
2
2
 
3
+ ## 52.5.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`324d924df5712`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/324d924df5712) -
8
+ Emit media-viewed event for archive and document.
9
+
10
+ ## 52.5.4
11
+
12
+ ### Patch Changes
13
+
14
+ - [`5f53f075991b4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5f53f075991b4) -
15
+ Updated archive viewer to emit media-viewed event on child file download
16
+ - Updated dependencies
17
+
3
18
  ## 52.5.3
4
19
 
5
20
  ### Patch Changes
@@ -10,7 +10,7 @@ exports.packageVersion = exports.packageName = void 0;
10
10
  var _analytics = require("@atlaskit/media-common/analytics");
11
11
  var componentName = exports.component = exports.componentName = 'mediaViewer';
12
12
  var packageName = exports.packageName = "@atlaskit/media-viewer";
13
- var packageVersion = exports.packageVersion = "0.0.0-development";
13
+ var packageVersion = exports.packageVersion = "52.5.4";
14
14
  function getFileAttributes(fileState) {
15
15
  if (!fileState) {
16
16
  return {
@@ -13,7 +13,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
13
  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; }
14
14
  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; }
15
15
  var packageName = "@atlaskit/media-viewer";
16
- var packageVersion = "0.0.0-development";
16
+ var packageVersion = "52.5.4";
17
17
  var ufoExperience;
18
18
  var getExperience = function getExperience() {
19
19
  if (!ufoExperience) {
@@ -17,6 +17,8 @@ var _react = _interopRequireDefault(require("react"));
17
17
  var _ = _interopRequireDefault(require("@atlaskit/icon-file-type/glyph/folder/24"));
18
18
  var _mediaCommon = require("@atlaskit/media-common");
19
19
  var _mediaTypeIcon = require("@atlaskit/media-ui/media-type-icon");
20
+ var _mediaClient = require("@atlaskit/media-client");
21
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
22
  var _styleWrappers = require("./styleWrappers");
21
23
  var _utils = require("../../utils");
22
24
  var _customButtonItem = require("./custom-button-item");
@@ -91,21 +93,28 @@ var ArchiveSidebarFolderEntryBase = /*#__PURE__*/function (_React$Component) {
91
93
  });
92
94
  case 3:
93
95
  blob = _context.sent;
94
- name = _this.formatName(root, entry.name);
96
+ name = _this.formatName(root, entry.name); // Emit media-viewed event if feature flag is enabled
97
+ if (_this.props.fileId && (0, _platformFeatureFlags.fg)('download_event_for_jira_attachments')) {
98
+ _mediaClient.globalMediaEventEmitter.emit('media-viewed', {
99
+ fileId: _this.props.fileId,
100
+ viewingLevel: 'download',
101
+ childFileName: name
102
+ });
103
+ }
95
104
  (0, _mediaCommon.downloadUrl)(URL.createObjectURL(blob), {
96
105
  name: name
97
106
  });
98
- _context.next = 11;
107
+ _context.next = 12;
99
108
  break;
100
- case 8:
101
- _context.prev = 8;
109
+ case 9:
110
+ _context.prev = 9;
102
111
  _context.t0 = _context["catch"](0);
103
112
  _this.props.onError(_context.t0, entry);
104
- case 11:
113
+ case 12:
105
114
  case "end":
106
115
  return _context.stop();
107
116
  }
108
- }, _callee, null, [[0, 8]]);
117
+ }, _callee, null, [[0, 9]]);
109
118
  }));
110
119
  return function (_x, _x2) {
111
120
  return _ref.apply(this, arguments);
@@ -100,7 +100,8 @@ var ArchiveSidebarRenderer = exports.default = /*#__PURE__*/function (_Component
100
100
  mediaClient: mediaClient,
101
101
  isArchiveEntryLoading: isArchiveEntryLoading,
102
102
  onError: onError,
103
- shouldRenderAbuseModal: !(0, _mediaClient.isErrorFileState)(selectedFileState) && !!selectedFileState.abuseClassification
103
+ shouldRenderAbuseModal: !(0, _mediaClient.isErrorFileState)(selectedFileState) && !!selectedFileState.abuseClassification,
104
+ fileId: selectedFileState.id
104
105
  }));
105
106
  }
106
107
  }]);
@@ -48,6 +48,7 @@ var ArchiveSidebar = exports.ArchiveSidebar = /*#__PURE__*/function (_React$Comp
48
48
  case 5:
49
49
  archive = _context.sent;
50
50
  Object.values(archive.entries).forEach(function (zipEntry) {
51
+ // eslint-disable-next-line no-param-reassign
51
52
  zipEntry.name = _this.state.currentArchiveSidebarFolder.name + zipEntry.name;
52
53
  });
53
54
  return _context.abrupt("return", archive);
@@ -103,7 +104,7 @@ var ArchiveSidebar = exports.ArchiveSidebar = /*#__PURE__*/function (_React$Comp
103
104
  }());
104
105
  (0, _defineProperty2.default)(_this, "onFolderEntrySelected", /*#__PURE__*/function () {
105
106
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(folder, isArchive) {
106
- var _this$props, entries, mediaClient, folderName, archiveEntries, _this$props2, isArchiveEntryLoading, onError, shouldRenderAbuseModal, currentFolderName;
107
+ var _this$props, entries, mediaClient, folderName, archiveEntries, _this$props2, isArchiveEntryLoading, onError, shouldRenderAbuseModal, fileId, currentFolderName;
107
108
  return _regenerator.default.wrap(function _callee3$(_context3) {
108
109
  while (1) switch (_context3.prev = _context3.next) {
109
110
  case 0:
@@ -119,7 +120,7 @@ var ArchiveSidebar = exports.ArchiveSidebar = /*#__PURE__*/function (_React$Comp
119
120
  entries = _objectSpread(_objectSpread({}, entries), archiveEntries);
120
121
  folderName = (0, _utils.extractArchiveFolderName)(folder.name);
121
122
  case 7:
122
- _this$props2 = _this.props, isArchiveEntryLoading = _this$props2.isArchiveEntryLoading, onError = _this$props2.onError, shouldRenderAbuseModal = _this$props2.shouldRenderAbuseModal;
123
+ _this$props2 = _this.props, isArchiveEntryLoading = _this$props2.isArchiveEntryLoading, onError = _this$props2.onError, shouldRenderAbuseModal = _this$props2.shouldRenderAbuseModal, fileId = _this$props2.fileId;
123
124
  currentFolderName = folderName || folder.name;
124
125
  _this.setState({
125
126
  currentArchiveSidebarFolder: {
@@ -130,7 +131,8 @@ var ArchiveSidebar = exports.ArchiveSidebar = /*#__PURE__*/function (_React$Comp
130
131
  onEntrySelected: _this.onEntrySelected,
131
132
  mediaClient: mediaClient,
132
133
  onError: onError,
133
- shouldRenderAbuseModal: shouldRenderAbuseModal
134
+ shouldRenderAbuseModal: shouldRenderAbuseModal,
135
+ fileId: fileId
134
136
  }
135
137
  });
136
138
  case 10:
@@ -150,7 +152,8 @@ var ArchiveSidebar = exports.ArchiveSidebar = /*#__PURE__*/function (_React$Comp
150
152
  onHeaderClicked = _this$props3.onHeaderClicked,
151
153
  isArchiveEntryLoading = _this$props3.isArchiveEntryLoading,
152
154
  onError = _this$props3.onError,
153
- shouldRenderAbuseModal = _this$props3.shouldRenderAbuseModal;
155
+ shouldRenderAbuseModal = _this$props3.shouldRenderAbuseModal,
156
+ fileId = _this$props3.fileId;
154
157
  var folderParent = (0, _utils.getFolderParent)(_this.state.currentArchiveSidebarFolder.root);
155
158
  _this.setState({
156
159
  currentArchiveSidebarFolder: {
@@ -161,7 +164,8 @@ var ArchiveSidebar = exports.ArchiveSidebar = /*#__PURE__*/function (_React$Comp
161
164
  onEntrySelected: _this.onEntrySelected,
162
165
  mediaClient: mediaClient,
163
166
  onError: onError,
164
- shouldRenderAbuseModal: shouldRenderAbuseModal
167
+ shouldRenderAbuseModal: shouldRenderAbuseModal,
168
+ fileId: fileId
165
169
  }
166
170
  });
167
171
 
@@ -172,7 +176,8 @@ var ArchiveSidebar = exports.ArchiveSidebar = /*#__PURE__*/function (_React$Comp
172
176
  _entries = props.entries,
173
177
  _mediaClient = props.mediaClient,
174
178
  _onError = props.onError,
175
- _shouldRenderAbuseModal = props.shouldRenderAbuseModal;
179
+ _shouldRenderAbuseModal = props.shouldRenderAbuseModal,
180
+ _fileId = props.fileId;
176
181
  _this.state = {
177
182
  currentArchiveSidebarFolder: {
178
183
  isArchiveEntryLoading: _isArchiveEntryLoading,
@@ -183,7 +188,8 @@ var ArchiveSidebar = exports.ArchiveSidebar = /*#__PURE__*/function (_React$Comp
183
188
  hideHeader: true,
184
189
  mediaClient: _mediaClient,
185
190
  onError: _onError,
186
- shouldRenderAbuseModal: _shouldRenderAbuseModal
191
+ shouldRenderAbuseModal: _shouldRenderAbuseModal,
192
+ fileId: _fileId
187
193
  }
188
194
  };
189
195
  return _this;
@@ -39,6 +39,7 @@ var _codeViewerRenderer = require("../codeViewer/codeViewerRenderer");
39
39
  var _util = require("../codeViewer/util");
40
40
  var _itemViewer = require("../../item-viewer");
41
41
  var _nativePdfViewer = require("./nativePdfViewer");
42
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
42
43
  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; }
43
44
  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; }
44
45
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
@@ -182,6 +183,9 @@ var ArchiveViewerBase = exports.ArchiveViewerBase = /*#__PURE__*/function (_Base
182
183
  }))
183
184
  });
184
185
  _this.props.onSuccess();
186
+ if ((0, _platformFeatureFlags.fg)('download_event_for_jira_attachments')) {
187
+ _this.onMediaDisplayed();
188
+ }
185
189
  });
186
190
  return _this;
187
191
  }
@@ -18,6 +18,7 @@ var _domain = require("../../domain");
18
18
  var _baseViewer = require("../base-viewer");
19
19
  var _zoomLevel = require("../../domain/zoomLevel");
20
20
  var _docViewer = require("./doc-viewer");
21
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
22
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
22
23
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
23
24
  var DocViewer = exports.DocViewer = /*#__PURE__*/function (_BaseViewer) {
@@ -62,7 +63,10 @@ var DocViewer = exports.DocViewer = /*#__PURE__*/function (_BaseViewer) {
62
63
  this.setState({
63
64
  content: _domain.Outcome.successful(item.id)
64
65
  });
65
- case 2:
66
+ if ((0, _platformFeatureFlags.fg)('download_event_for_jira_attachments')) {
67
+ this.onMediaDisplayed();
68
+ }
69
+ case 3:
66
70
  case "end":
67
71
  return _context.stop();
68
72
  }
@@ -1,7 +1,7 @@
1
1
  import { ANALYTICS_MEDIA_CHANNEL, sanitiseAnalyticsPayload } from '@atlaskit/media-common/analytics';
2
2
  const componentName = 'mediaViewer';
3
3
  const packageName = "@atlaskit/media-viewer";
4
- const packageVersion = "0.0.0-development";
4
+ const packageVersion = "52.5.4";
5
5
  export { packageName, packageVersion, componentName, componentName as component };
6
6
  export function getFileAttributes(fileState) {
7
7
  if (!fileState) {
@@ -3,7 +3,7 @@ import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
3
3
  import { getFeatureFlagKeysAllProducts } from '@atlaskit/media-common';
4
4
  import { fg } from '@atlaskit/platform-feature-flags';
5
5
  const packageName = "@atlaskit/media-viewer";
6
- const packageVersion = "0.0.0-development";
6
+ const packageVersion = "52.5.4";
7
7
  let ufoExperience;
8
8
  const getExperience = () => {
9
9
  if (!ufoExperience) {
@@ -3,6 +3,8 @@ import React from 'react';
3
3
  import Folder24Icon from '@atlaskit/icon-file-type/glyph/folder/24';
4
4
  import { downloadUrl } from '@atlaskit/media-common';
5
5
  import { MediaTypeIcon } from '@atlaskit/media-ui/media-type-icon';
6
+ import { globalMediaEventEmitter } from '@atlaskit/media-client';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
6
8
  import { ArchiveSidebarFolderWrapper, ArchiveSidebarFileEntryWrapper, SidebarItemWrapper } from './styleWrappers';
7
9
  import { getMediaTypeFromFilename, isMacPrivateFile, rejectAfter } from '../../utils';
8
10
  import { CustomButtonItem } from './custom-button-item';
@@ -59,6 +61,15 @@ class ArchiveSidebarFolderEntryBase extends React.Component {
59
61
  try {
60
62
  const blob = await rejectAfter(() => entry.blob());
61
63
  const name = this.formatName(root, entry.name);
64
+
65
+ // Emit media-viewed event if feature flag is enabled
66
+ if (this.props.fileId && fg('download_event_for_jira_attachments')) {
67
+ globalMediaEventEmitter.emit('media-viewed', {
68
+ fileId: this.props.fileId,
69
+ viewingLevel: 'download',
70
+ childFileName: name
71
+ });
72
+ }
62
73
  downloadUrl(URL.createObjectURL(blob), {
63
74
  name
64
75
  });
@@ -58,7 +58,8 @@ export default class ArchiveSidebarRenderer extends Component {
58
58
  mediaClient: mediaClient,
59
59
  isArchiveEntryLoading: isArchiveEntryLoading,
60
60
  onError: onError,
61
- shouldRenderAbuseModal: !isErrorFileState(selectedFileState) && !!selectedFileState.abuseClassification
61
+ shouldRenderAbuseModal: !isErrorFileState(selectedFileState) && !!selectedFileState.abuseClassification,
62
+ fileId: selectedFileState.id
62
63
  }));
63
64
  }
64
65
  }
@@ -13,6 +13,7 @@ export class ArchiveSidebar extends React.Component {
13
13
  const blob = await rejectAfter(() => entry.blob());
14
14
  const archive = await rejectAfter(() => unzip(blob));
15
15
  Object.values(archive.entries).forEach(zipEntry => {
16
+ // eslint-disable-next-line no-param-reassign
16
17
  zipEntry.name = this.state.currentArchiveSidebarFolder.name + zipEntry.name;
17
18
  });
18
19
  return archive;
@@ -48,7 +49,8 @@ export class ArchiveSidebar extends React.Component {
48
49
  const {
49
50
  isArchiveEntryLoading,
50
51
  onError,
51
- shouldRenderAbuseModal
52
+ shouldRenderAbuseModal,
53
+ fileId
52
54
  } = this.props;
53
55
  const currentFolderName = folderName || folder.name;
54
56
  this.setState({
@@ -60,7 +62,8 @@ export class ArchiveSidebar extends React.Component {
60
62
  onEntrySelected: this.onEntrySelected,
61
63
  mediaClient,
62
64
  onError,
63
- shouldRenderAbuseModal
65
+ shouldRenderAbuseModal,
66
+ fileId
64
67
  }
65
68
  });
66
69
  });
@@ -71,7 +74,8 @@ export class ArchiveSidebar extends React.Component {
71
74
  onHeaderClicked,
72
75
  isArchiveEntryLoading,
73
76
  onError,
74
- shouldRenderAbuseModal
77
+ shouldRenderAbuseModal,
78
+ fileId
75
79
  } = this.props;
76
80
  const folderParent = getFolderParent(this.state.currentArchiveSidebarFolder.root);
77
81
  this.setState({
@@ -83,7 +87,8 @@ export class ArchiveSidebar extends React.Component {
83
87
  onEntrySelected: this.onEntrySelected,
84
88
  mediaClient,
85
89
  onError,
86
- shouldRenderAbuseModal
90
+ shouldRenderAbuseModal,
91
+ fileId
87
92
  }
88
93
  });
89
94
 
@@ -95,7 +100,8 @@ export class ArchiveSidebar extends React.Component {
95
100
  entries: _entries,
96
101
  mediaClient: _mediaClient,
97
102
  onError: _onError,
98
- shouldRenderAbuseModal: _shouldRenderAbuseModal
103
+ shouldRenderAbuseModal: _shouldRenderAbuseModal,
104
+ fileId: _fileId
99
105
  } = props;
100
106
  this.state = {
101
107
  currentArchiveSidebarFolder: {
@@ -107,7 +113,8 @@ export class ArchiveSidebar extends React.Component {
107
113
  hideHeader: true,
108
114
  mediaClient: _mediaClient,
109
115
  onError: _onError,
110
- shouldRenderAbuseModal: _shouldRenderAbuseModal
116
+ shouldRenderAbuseModal: _shouldRenderAbuseModal,
117
+ fileId: _fileId
111
118
  }
112
119
  };
113
120
  }
@@ -26,6 +26,7 @@ import { CodeViewRenderer } from '../codeViewer/codeViewerRenderer';
26
26
  import { DEFAULT_LANGUAGE } from '../codeViewer/util';
27
27
  import { MAX_FILE_SIZE_SUPPORTED_BY_CODEVIEWER } from '../../item-viewer';
28
28
  import { NativePdfViewer } from './nativePdfViewer';
29
+ import { fg } from '@atlaskit/platform-feature-flags';
29
30
  export const getArchiveEntriesFromFileState = async (fileState, mediaClient, collectionName) => {
30
31
  const url = await mediaClient.file.getFileBinaryURL(fileState.id, collectionName);
31
32
  const reader = new HTTPRangeReader(url);
@@ -105,6 +106,9 @@ export class ArchiveViewerBase extends BaseViewer {
105
106
  })
106
107
  });
107
108
  this.props.onSuccess();
109
+ if (fg('download_event_for_jira_attachments')) {
110
+ this.onMediaDisplayed();
111
+ }
108
112
  });
109
113
  }
110
114
  async init() {
@@ -4,6 +4,7 @@ import { Outcome } from '../../domain';
4
4
  import { BaseViewer } from '../base-viewer';
5
5
  import { ZoomLevel } from '../../domain/zoomLevel';
6
6
  import { DocViewer as DocViewerComponent } from './doc-viewer';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  export class DocViewer extends BaseViewer {
8
9
  constructor(...args) {
9
10
  super(...args);
@@ -30,6 +31,9 @@ export class DocViewer extends BaseViewer {
30
31
  this.setState({
31
32
  content: Outcome.successful(item.id)
32
33
  });
34
+ if (fg('download_event_for_jira_attachments')) {
35
+ this.onMediaDisplayed();
36
+ }
33
37
  }
34
38
  release() {
35
39
  if (!this.isObjectUrl) {
@@ -1,7 +1,7 @@
1
1
  import { ANALYTICS_MEDIA_CHANNEL, sanitiseAnalyticsPayload } from '@atlaskit/media-common/analytics';
2
2
  var componentName = 'mediaViewer';
3
3
  var packageName = "@atlaskit/media-viewer";
4
- var packageVersion = "0.0.0-development";
4
+ var packageVersion = "52.5.4";
5
5
  export { packageName, packageVersion, componentName, componentName as component };
6
6
  export function getFileAttributes(fileState) {
7
7
  if (!fileState) {
@@ -6,7 +6,7 @@ import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
6
6
  import { getFeatureFlagKeysAllProducts } from '@atlaskit/media-common';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
8
  var packageName = "@atlaskit/media-viewer";
9
- var packageVersion = "0.0.0-development";
9
+ var packageVersion = "52.5.4";
10
10
  var ufoExperience;
11
11
  var getExperience = function getExperience() {
12
12
  if (!ufoExperience) {
@@ -12,6 +12,8 @@ import React from 'react';
12
12
  import Folder24Icon from '@atlaskit/icon-file-type/glyph/folder/24';
13
13
  import { downloadUrl } from '@atlaskit/media-common';
14
14
  import { MediaTypeIcon } from '@atlaskit/media-ui/media-type-icon';
15
+ import { globalMediaEventEmitter } from '@atlaskit/media-client';
16
+ import { fg } from '@atlaskit/platform-feature-flags';
15
17
  import { ArchiveSidebarFolderWrapper, ArchiveSidebarFileEntryWrapper, SidebarItemWrapper } from './styleWrappers';
16
18
  import { getMediaTypeFromFilename, isMacPrivateFile, rejectAfter } from '../../utils';
17
19
  import { CustomButtonItem } from './custom-button-item';
@@ -84,21 +86,28 @@ var ArchiveSidebarFolderEntryBase = /*#__PURE__*/function (_React$Component) {
84
86
  });
85
87
  case 3:
86
88
  blob = _context.sent;
87
- name = _this.formatName(root, entry.name);
89
+ name = _this.formatName(root, entry.name); // Emit media-viewed event if feature flag is enabled
90
+ if (_this.props.fileId && fg('download_event_for_jira_attachments')) {
91
+ globalMediaEventEmitter.emit('media-viewed', {
92
+ fileId: _this.props.fileId,
93
+ viewingLevel: 'download',
94
+ childFileName: name
95
+ });
96
+ }
88
97
  downloadUrl(URL.createObjectURL(blob), {
89
98
  name: name
90
99
  });
91
- _context.next = 11;
100
+ _context.next = 12;
92
101
  break;
93
- case 8:
94
- _context.prev = 8;
102
+ case 9:
103
+ _context.prev = 9;
95
104
  _context.t0 = _context["catch"](0);
96
105
  _this.props.onError(_context.t0, entry);
97
- case 11:
106
+ case 12:
98
107
  case "end":
99
108
  return _context.stop();
100
109
  }
101
- }, _callee, null, [[0, 8]]);
110
+ }, _callee, null, [[0, 9]]);
102
111
  }));
103
112
  return function (_x, _x2) {
104
113
  return _ref.apply(this, arguments);
@@ -91,7 +91,8 @@ var ArchiveSidebarRenderer = /*#__PURE__*/function (_Component) {
91
91
  mediaClient: mediaClient,
92
92
  isArchiveEntryLoading: isArchiveEntryLoading,
93
93
  onError: onError,
94
- shouldRenderAbuseModal: !isErrorFileState(selectedFileState) && !!selectedFileState.abuseClassification
94
+ shouldRenderAbuseModal: !isErrorFileState(selectedFileState) && !!selectedFileState.abuseClassification,
95
+ fileId: selectedFileState.id
95
96
  }));
96
97
  }
97
98
  }]);
@@ -41,6 +41,7 @@ export var ArchiveSidebar = /*#__PURE__*/function (_React$Component) {
41
41
  case 5:
42
42
  archive = _context.sent;
43
43
  Object.values(archive.entries).forEach(function (zipEntry) {
44
+ // eslint-disable-next-line no-param-reassign
44
45
  zipEntry.name = _this.state.currentArchiveSidebarFolder.name + zipEntry.name;
45
46
  });
46
47
  return _context.abrupt("return", archive);
@@ -96,7 +97,7 @@ export var ArchiveSidebar = /*#__PURE__*/function (_React$Component) {
96
97
  }());
97
98
  _defineProperty(_this, "onFolderEntrySelected", /*#__PURE__*/function () {
98
99
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(folder, isArchive) {
99
- var _this$props, entries, mediaClient, folderName, archiveEntries, _this$props2, isArchiveEntryLoading, onError, shouldRenderAbuseModal, currentFolderName;
100
+ var _this$props, entries, mediaClient, folderName, archiveEntries, _this$props2, isArchiveEntryLoading, onError, shouldRenderAbuseModal, fileId, currentFolderName;
100
101
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
101
102
  while (1) switch (_context3.prev = _context3.next) {
102
103
  case 0:
@@ -112,7 +113,7 @@ export var ArchiveSidebar = /*#__PURE__*/function (_React$Component) {
112
113
  entries = _objectSpread(_objectSpread({}, entries), archiveEntries);
113
114
  folderName = extractArchiveFolderName(folder.name);
114
115
  case 7:
115
- _this$props2 = _this.props, isArchiveEntryLoading = _this$props2.isArchiveEntryLoading, onError = _this$props2.onError, shouldRenderAbuseModal = _this$props2.shouldRenderAbuseModal;
116
+ _this$props2 = _this.props, isArchiveEntryLoading = _this$props2.isArchiveEntryLoading, onError = _this$props2.onError, shouldRenderAbuseModal = _this$props2.shouldRenderAbuseModal, fileId = _this$props2.fileId;
116
117
  currentFolderName = folderName || folder.name;
117
118
  _this.setState({
118
119
  currentArchiveSidebarFolder: {
@@ -123,7 +124,8 @@ export var ArchiveSidebar = /*#__PURE__*/function (_React$Component) {
123
124
  onEntrySelected: _this.onEntrySelected,
124
125
  mediaClient: mediaClient,
125
126
  onError: onError,
126
- shouldRenderAbuseModal: shouldRenderAbuseModal
127
+ shouldRenderAbuseModal: shouldRenderAbuseModal,
128
+ fileId: fileId
127
129
  }
128
130
  });
129
131
  case 10:
@@ -143,7 +145,8 @@ export var ArchiveSidebar = /*#__PURE__*/function (_React$Component) {
143
145
  onHeaderClicked = _this$props3.onHeaderClicked,
144
146
  isArchiveEntryLoading = _this$props3.isArchiveEntryLoading,
145
147
  onError = _this$props3.onError,
146
- shouldRenderAbuseModal = _this$props3.shouldRenderAbuseModal;
148
+ shouldRenderAbuseModal = _this$props3.shouldRenderAbuseModal,
149
+ fileId = _this$props3.fileId;
147
150
  var folderParent = getFolderParent(_this.state.currentArchiveSidebarFolder.root);
148
151
  _this.setState({
149
152
  currentArchiveSidebarFolder: {
@@ -154,7 +157,8 @@ export var ArchiveSidebar = /*#__PURE__*/function (_React$Component) {
154
157
  onEntrySelected: _this.onEntrySelected,
155
158
  mediaClient: mediaClient,
156
159
  onError: onError,
157
- shouldRenderAbuseModal: shouldRenderAbuseModal
160
+ shouldRenderAbuseModal: shouldRenderAbuseModal,
161
+ fileId: fileId
158
162
  }
159
163
  });
160
164
 
@@ -165,7 +169,8 @@ export var ArchiveSidebar = /*#__PURE__*/function (_React$Component) {
165
169
  _entries = props.entries,
166
170
  _mediaClient = props.mediaClient,
167
171
  _onError = props.onError,
168
- _shouldRenderAbuseModal = props.shouldRenderAbuseModal;
172
+ _shouldRenderAbuseModal = props.shouldRenderAbuseModal,
173
+ _fileId = props.fileId;
169
174
  _this.state = {
170
175
  currentArchiveSidebarFolder: {
171
176
  isArchiveEntryLoading: _isArchiveEntryLoading,
@@ -176,7 +181,8 @@ export var ArchiveSidebar = /*#__PURE__*/function (_React$Component) {
176
181
  hideHeader: true,
177
182
  mediaClient: _mediaClient,
178
183
  onError: _onError,
179
- shouldRenderAbuseModal: _shouldRenderAbuseModal
184
+ shouldRenderAbuseModal: _shouldRenderAbuseModal,
185
+ fileId: _fileId
180
186
  }
181
187
  };
182
188
  return _this;
@@ -37,6 +37,7 @@ import { CodeViewRenderer } from '../codeViewer/codeViewerRenderer';
37
37
  import { DEFAULT_LANGUAGE } from '../codeViewer/util';
38
38
  import { MAX_FILE_SIZE_SUPPORTED_BY_CODEVIEWER } from '../../item-viewer';
39
39
  import { NativePdfViewer } from './nativePdfViewer';
40
+ import { fg } from '@atlaskit/platform-feature-flags';
40
41
  export var getArchiveEntriesFromFileState = /*#__PURE__*/function () {
41
42
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(fileState, mediaClient, collectionName) {
42
43
  var url, reader, archive;
@@ -176,6 +177,9 @@ export var ArchiveViewerBase = /*#__PURE__*/function (_BaseViewer) {
176
177
  }))
177
178
  });
178
179
  _this.props.onSuccess();
180
+ if (fg('download_event_for_jira_attachments')) {
181
+ _this.onMediaDisplayed();
182
+ }
179
183
  });
180
184
  return _this;
181
185
  }
@@ -13,6 +13,7 @@ import { Outcome } from '../../domain';
13
13
  import { BaseViewer } from '../base-viewer';
14
14
  import { ZoomLevel } from '../../domain/zoomLevel';
15
15
  import { DocViewer as DocViewerComponent } from './doc-viewer';
16
+ import { fg } from '@atlaskit/platform-feature-flags';
16
17
  export var DocViewer = /*#__PURE__*/function (_BaseViewer) {
17
18
  function DocViewer() {
18
19
  var _this;
@@ -55,7 +56,10 @@ export var DocViewer = /*#__PURE__*/function (_BaseViewer) {
55
56
  this.setState({
56
57
  content: Outcome.successful(item.id)
57
58
  });
58
- case 2:
59
+ if (fg('download_event_for_jira_attachments')) {
60
+ this.onMediaDisplayed();
61
+ }
62
+ case 3:
59
63
  case "end":
60
64
  return _context.stop();
61
65
  }
@@ -16,6 +16,7 @@ export interface ArchiveSidebarFolderProps {
16
16
  isArchiveEntryLoading: boolean;
17
17
  onError: (error: ArchiveViewerError, entry?: ZipEntry) => void;
18
18
  shouldRenderAbuseModal: boolean;
19
+ fileId?: string;
19
20
  }
20
21
  export declare const ArchiveSidebarFolderEntry: React.FC<import("react-intl-next").WithIntlProps<ArchiveSidebarFolderProps & WrappedComponentProps>> & {
21
22
  WrappedComponent: React.ComponentType<ArchiveSidebarFolderProps & WrappedComponentProps>;
@@ -13,6 +13,7 @@ export interface ArchiveSidebarProps {
13
13
  isArchiveEntryLoading: boolean;
14
14
  onError: (error: ArchiveViewerError, entry?: ZipEntry) => void;
15
15
  shouldRenderAbuseModal: boolean;
16
+ fileId?: string;
16
17
  }
17
18
  export type ArchiveSidebarState = {
18
19
  currentArchiveSidebarFolder: ArchiveSidebarFolderProps;
@@ -16,6 +16,7 @@ export interface ArchiveSidebarFolderProps {
16
16
  isArchiveEntryLoading: boolean;
17
17
  onError: (error: ArchiveViewerError, entry?: ZipEntry) => void;
18
18
  shouldRenderAbuseModal: boolean;
19
+ fileId?: string;
19
20
  }
20
21
  export declare const ArchiveSidebarFolderEntry: React.FC<import("react-intl-next").WithIntlProps<ArchiveSidebarFolderProps & WrappedComponentProps>> & {
21
22
  WrappedComponent: React.ComponentType<ArchiveSidebarFolderProps & WrappedComponentProps>;
@@ -13,6 +13,7 @@ export interface ArchiveSidebarProps {
13
13
  isArchiveEntryLoading: boolean;
14
14
  onError: (error: ArchiveViewerError, entry?: ZipEntry) => void;
15
15
  shouldRenderAbuseModal: boolean;
16
+ fileId?: string;
16
17
  }
17
18
  export type ArchiveSidebarState = {
18
19
  currentArchiveSidebarFolder: ArchiveSidebarFolderProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-viewer",
3
- "version": "52.5.3",
3
+ "version": "52.5.5",
4
4
  "description": "MediaViewer is Atlassian's powerful solution for viewing files on the web. It's both powerful and extendable yet easy-to-integrate",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -35,7 +35,7 @@
35
35
  "@atlaskit/button": "^23.9.0",
36
36
  "@atlaskit/code": "^17.4.0",
37
37
  "@atlaskit/css": "^0.19.0",
38
- "@atlaskit/form": "^15.1.0",
38
+ "@atlaskit/form": "^15.2.0",
39
39
  "@atlaskit/heading": "^5.2.0",
40
40
  "@atlaskit/icon": "^29.3.0",
41
41
  "@atlaskit/icon-file-type": "^7.0.0",
@@ -82,6 +82,7 @@
82
82
  },
83
83
  "devDependencies": {
84
84
  "@af/integration-testing": "workspace:^",
85
+ "@af/suppress-react-warnings": "workspace:^",
85
86
  "@af/visual-regression": "workspace:^",
86
87
  "@atlaskit/media-core": "^37.0.0",
87
88
  "@atlaskit/media-integration-test-helpers": "workspace:^",
@@ -125,6 +126,9 @@
125
126
  },
126
127
  "media_viewer_prevent_rerender_on_polling": {
127
128
  "type": "boolean"
129
+ },
130
+ "download_event_for_jira_attachments": {
131
+ "type": "boolean"
128
132
  }
129
133
  },
130
134
  "techstack": {