@atlaskit/media-viewer 54.6.6 → 54.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/analytics/events/operational/previewTooLarge.js +29 -0
- package/dist/cjs/analytics/index.js +1 -1
- package/dist/cjs/analytics/ufoExperiences.js +1 -1
- package/dist/cjs/errorMessage.js +26 -1
- package/dist/es2019/analytics/events/operational/previewTooLarge.js +24 -0
- package/dist/es2019/analytics/index.js +1 -1
- package/dist/es2019/analytics/ufoExperiences.js +1 -1
- package/dist/es2019/errorMessage.js +25 -1
- package/dist/esm/analytics/events/operational/previewTooLarge.js +23 -0
- package/dist/esm/analytics/index.js +1 -1
- package/dist/esm/analytics/ufoExperiences.js +1 -1
- package/dist/esm/errorMessage.js +26 -1
- package/dist/types/analytics/events/index.d.ts +2 -1
- package/dist/types/analytics/events/operational/_mediaFile.d.ts +1 -1
- package/dist/types/analytics/events/operational/previewTooLarge.d.ts +9 -0
- package/dist/types/errorMessage.d.ts +4 -1
- package/example-helpers/MainWrapper.tsx +1 -1
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/media-viewer
|
|
2
2
|
|
|
3
|
+
## 54.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`143ebd1ce2710`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/143ebd1ce2710) -
|
|
8
|
+
Show a dedicated "File is too large to preview" heading instead of the generic "Something went
|
|
9
|
+
wrong" copy when a file exceeds the size limit supported by the browser-based viewer (currently:
|
|
10
|
+
code/text files over the 10MB CodeViewer limit, both in the main viewer and inside ZIP archives).
|
|
11
|
+
These failures are reported via the `previewTooLarge` analytics event rather than `loadFailed`,
|
|
12
|
+
since they aren't load failures. Behind the `platform_media_too_large_preview_state` feature gate.
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 54.6.6
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createPreviewTooLargeEvent = void 0;
|
|
7
|
+
var _ = require("../..");
|
|
8
|
+
var _errors = require("../../../errors");
|
|
9
|
+
var createPreviewTooLargeEvent = exports.createPreviewTooLargeEvent = function createPreviewTooLargeEvent(error, fileState) {
|
|
10
|
+
var _getFileAttributes = (0, _.getFileAttributes)(fileState),
|
|
11
|
+
fileId = _getFileAttributes.fileId,
|
|
12
|
+
fileMediatype = _getFileAttributes.fileMediatype,
|
|
13
|
+
fileMimetype = _getFileAttributes.fileMimetype,
|
|
14
|
+
fileSize = _getFileAttributes.fileSize;
|
|
15
|
+
return {
|
|
16
|
+
eventType: 'operational',
|
|
17
|
+
actionSubject: 'mediaFile',
|
|
18
|
+
action: 'previewTooLarge',
|
|
19
|
+
attributes: {
|
|
20
|
+
failReason: (0, _errors.getPrimaryErrorReason)(error),
|
|
21
|
+
fileAttributes: {
|
|
22
|
+
fileId: fileId,
|
|
23
|
+
fileMediatype: fileMediatype,
|
|
24
|
+
fileMimetype: fileMimetype,
|
|
25
|
+
fileSize: fileSize
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -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 = "54.6.
|
|
13
|
+
var packageVersion = exports.packageVersion = "54.6.6";
|
|
14
14
|
function getFileAttributes(fileState) {
|
|
15
15
|
if (!fileState) {
|
|
16
16
|
return {
|
|
@@ -14,7 +14,7 @@ var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
|
14
14
|
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; }
|
|
15
15
|
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; }
|
|
16
16
|
var packageName = "@atlaskit/media-viewer";
|
|
17
|
-
var packageVersion = "54.6.
|
|
17
|
+
var packageVersion = "54.6.6";
|
|
18
18
|
var ufoExperience;
|
|
19
19
|
var getExperience = function getExperience() {
|
|
20
20
|
if (!ufoExperience) {
|
package/dist/cjs/errorMessage.js
CHANGED
|
@@ -15,12 +15,14 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
15
15
|
var _reactIntl = require("react-intl");
|
|
16
16
|
var _messages = require("@atlaskit/media-ui/messages");
|
|
17
17
|
var _withAnalyticsEvents = _interopRequireDefault(require("@atlaskit/analytics-next/withAnalyticsEvents"));
|
|
18
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
19
|
var _styleWrappers = require("./styleWrappers");
|
|
19
20
|
var _errorImages = require("./error-images");
|
|
20
21
|
var _analytics = require("./analytics");
|
|
21
22
|
var _errors = require("./errors");
|
|
22
23
|
var _loadFailed = require("./analytics/events/operational/loadFailed");
|
|
23
24
|
var _previewUnsupported = require("./analytics/events/operational/previewUnsupported");
|
|
25
|
+
var _previewTooLarge = require("./analytics/events/operational/previewTooLarge");
|
|
24
26
|
var _ufoExperiences = require("./analytics/ufoExperiences");
|
|
25
27
|
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; }
|
|
26
28
|
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; }
|
|
@@ -62,6 +64,17 @@ var ErrorMessage = exports.ErrorMessage = /*#__PURE__*/function (_React$Componen
|
|
|
62
64
|
messages: [_messages.messages.unsupported_file_format, _messages.messages.archive_format_not_supported]
|
|
63
65
|
};
|
|
64
66
|
}
|
|
67
|
+
|
|
68
|
+
// Code/text files (in the main viewer or inside a ZIP archive) over the
|
|
69
|
+
// CodeViewer's 10MB limit aren't a load failure - the file is simply too
|
|
70
|
+
// large for this viewer to preview. Show a dedicated "File is too large to
|
|
71
|
+
// preview" heading instead of the generic "Something went wrong" copy.
|
|
72
|
+
if (ErrorMessage.isPreviewTooLarge(error) && (0, _platformFeatureFlags.fg)('platform_media_too_large_preview_state')) {
|
|
73
|
+
return {
|
|
74
|
+
icon: errorLoadingFileImage(formatMessage),
|
|
75
|
+
messages: [_messages.messages.file_too_large_to_preview, _messages.messages.file_too_large_description]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
65
78
|
var errorInfo = {
|
|
66
79
|
icon: errorLoadingFileImage(formatMessage),
|
|
67
80
|
messages: [_messages.messages.something_went_wrong, _messages.messages.couldnt_generate_preview]
|
|
@@ -121,10 +134,21 @@ var ErrorMessage = exports.ErrorMessage = /*#__PURE__*/function (_React$Componen
|
|
|
121
134
|
value: function isPreviewUnsupported(error) {
|
|
122
135
|
return ErrorMessage.previewUnsupportedReasons.includes((0, _errors.getPrimaryErrorReason)(error));
|
|
123
136
|
}
|
|
137
|
+
|
|
138
|
+
// Error reasons that mean the file exceeds the size limit supported by the
|
|
139
|
+
// browser-based viewer (not a load failure). These are reported as the
|
|
140
|
+
// informational, non-SLI `previewTooLarge` metric instead of `loadFailed`.
|
|
141
|
+
}, {
|
|
142
|
+
key: "isPreviewTooLarge",
|
|
143
|
+
value: function isPreviewTooLarge(error) {
|
|
144
|
+
return ErrorMessage.previewTooLargeReasons.includes((0, _errors.getPrimaryErrorReason)(error));
|
|
145
|
+
}
|
|
124
146
|
}, {
|
|
125
147
|
key: "getEventPayload",
|
|
126
148
|
value: function getEventPayload(error, fileId, fileState, traceContext) {
|
|
127
|
-
if (fileState && ErrorMessage.
|
|
149
|
+
if (fileState && ErrorMessage.isPreviewTooLarge(error) && (0, _platformFeatureFlags.fg)('platform_media_too_large_preview_state')) {
|
|
150
|
+
return (0, _previewTooLarge.createPreviewTooLargeEvent)(error, fileState);
|
|
151
|
+
} else if (fileState && ErrorMessage.isPreviewUnsupported(error)) {
|
|
128
152
|
// this is not an SLI (load failure), its just a useful metric for files
|
|
129
153
|
// whose format the browser-based viewer can't preview.
|
|
130
154
|
return (0, _previewUnsupported.createPreviewUnsupportedEvent)(fileState);
|
|
@@ -135,5 +159,6 @@ var ErrorMessage = exports.ErrorMessage = /*#__PURE__*/function (_React$Componen
|
|
|
135
159
|
}]);
|
|
136
160
|
}(_react.default.Component); // @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
|
|
137
161
|
(0, _defineProperty2.default)(ErrorMessage, "previewUnsupportedReasons", ['unsupported', 'imageviewer-unsupported-mime']);
|
|
162
|
+
(0, _defineProperty2.default)(ErrorMessage, "previewTooLargeReasons", ['codeviewer-file-size-exceeds', 'archiveviewer-codeviewer-file-size-exceeds']);
|
|
138
163
|
var ErroMsg = (0, _withAnalyticsEvents.default)()((0, _reactIntl.injectIntl)(ErrorMessage));
|
|
139
164
|
var _default = exports.default = ErroMsg;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getFileAttributes } from '../..';
|
|
2
|
+
import { getPrimaryErrorReason } from '../../../errors';
|
|
3
|
+
export const createPreviewTooLargeEvent = (error, fileState) => {
|
|
4
|
+
const {
|
|
5
|
+
fileId,
|
|
6
|
+
fileMediatype,
|
|
7
|
+
fileMimetype,
|
|
8
|
+
fileSize
|
|
9
|
+
} = getFileAttributes(fileState);
|
|
10
|
+
return {
|
|
11
|
+
eventType: 'operational',
|
|
12
|
+
actionSubject: 'mediaFile',
|
|
13
|
+
action: 'previewTooLarge',
|
|
14
|
+
attributes: {
|
|
15
|
+
failReason: getPrimaryErrorReason(error),
|
|
16
|
+
fileAttributes: {
|
|
17
|
+
fileId,
|
|
18
|
+
fileMediatype,
|
|
19
|
+
fileMimetype,
|
|
20
|
+
fileSize
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -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 = "54.6.
|
|
4
|
+
const packageVersion = "54.6.6";
|
|
5
5
|
export { packageName, packageVersion, componentName, componentName as component };
|
|
6
6
|
export function getFileAttributes(fileState) {
|
|
7
7
|
if (!fileState) {
|
|
@@ -4,7 +4,7 @@ import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
|
4
4
|
import { getFeatureFlagKeysAllProducts } from '@atlaskit/media-common';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
6
6
|
const packageName = "@atlaskit/media-viewer";
|
|
7
|
-
const packageVersion = "54.6.
|
|
7
|
+
const packageVersion = "54.6.6";
|
|
8
8
|
let ufoExperience;
|
|
9
9
|
const getExperience = () => {
|
|
10
10
|
if (!ufoExperience) {
|
|
@@ -3,12 +3,14 @@ import React from 'react';
|
|
|
3
3
|
import { FormattedMessage, injectIntl } from 'react-intl';
|
|
4
4
|
import { messages as i18nMessages } from '@atlaskit/media-ui/messages';
|
|
5
5
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { ErrorMessageWrapper, ErrorImage } from './styleWrappers';
|
|
7
8
|
import { errorLoadingFile } from './error-images';
|
|
8
9
|
import { fireAnalytics } from './analytics';
|
|
9
10
|
import { getPrimaryErrorReason, getSecondaryErrorReason } from './errors';
|
|
10
11
|
import { createLoadFailedEvent } from './analytics/events/operational/loadFailed';
|
|
11
12
|
import { createPreviewUnsupportedEvent } from './analytics/events/operational/previewUnsupported';
|
|
13
|
+
import { createPreviewTooLargeEvent } from './analytics/events/operational/previewTooLarge';
|
|
12
14
|
import { failMediaFileUfoExperience } from './analytics/ufoExperiences';
|
|
13
15
|
const errorLoadingFileImage = formatMessage => /*#__PURE__*/React.createElement(ErrorImage, {
|
|
14
16
|
src: errorLoadingFile,
|
|
@@ -38,6 +40,17 @@ export class ErrorMessage extends React.Component {
|
|
|
38
40
|
messages: [i18nMessages.unsupported_file_format, i18nMessages.archive_format_not_supported]
|
|
39
41
|
};
|
|
40
42
|
}
|
|
43
|
+
|
|
44
|
+
// Code/text files (in the main viewer or inside a ZIP archive) over the
|
|
45
|
+
// CodeViewer's 10MB limit aren't a load failure - the file is simply too
|
|
46
|
+
// large for this viewer to preview. Show a dedicated "File is too large to
|
|
47
|
+
// preview" heading instead of the generic "Something went wrong" copy.
|
|
48
|
+
if (ErrorMessage.isPreviewTooLarge(error) && fg('platform_media_too_large_preview_state')) {
|
|
49
|
+
return {
|
|
50
|
+
icon: errorLoadingFileImage(formatMessage),
|
|
51
|
+
messages: [i18nMessages.file_too_large_to_preview, i18nMessages.file_too_large_description]
|
|
52
|
+
};
|
|
53
|
+
}
|
|
41
54
|
const errorInfo = {
|
|
42
55
|
icon: errorLoadingFileImage(formatMessage),
|
|
43
56
|
messages: [i18nMessages.something_went_wrong, i18nMessages.couldnt_generate_preview]
|
|
@@ -83,8 +96,18 @@ export class ErrorMessage extends React.Component {
|
|
|
83
96
|
static isPreviewUnsupported(error) {
|
|
84
97
|
return ErrorMessage.previewUnsupportedReasons.includes(getPrimaryErrorReason(error));
|
|
85
98
|
}
|
|
99
|
+
|
|
100
|
+
// Error reasons that mean the file exceeds the size limit supported by the
|
|
101
|
+
// browser-based viewer (not a load failure). These are reported as the
|
|
102
|
+
// informational, non-SLI `previewTooLarge` metric instead of `loadFailed`.
|
|
103
|
+
|
|
104
|
+
static isPreviewTooLarge(error) {
|
|
105
|
+
return ErrorMessage.previewTooLargeReasons.includes(getPrimaryErrorReason(error));
|
|
106
|
+
}
|
|
86
107
|
static getEventPayload(error, fileId, fileState, traceContext) {
|
|
87
|
-
if (fileState && ErrorMessage.
|
|
108
|
+
if (fileState && ErrorMessage.isPreviewTooLarge(error) && fg('platform_media_too_large_preview_state')) {
|
|
109
|
+
return createPreviewTooLargeEvent(error, fileState);
|
|
110
|
+
} else if (fileState && ErrorMessage.isPreviewUnsupported(error)) {
|
|
88
111
|
// this is not an SLI (load failure), its just a useful metric for files
|
|
89
112
|
// whose format the browser-based viewer can't preview.
|
|
90
113
|
return createPreviewUnsupportedEvent(fileState);
|
|
@@ -107,5 +130,6 @@ export class ErrorMessage extends React.Component {
|
|
|
107
130
|
|
|
108
131
|
// @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
|
|
109
132
|
_defineProperty(ErrorMessage, "previewUnsupportedReasons", ['unsupported', 'imageviewer-unsupported-mime']);
|
|
133
|
+
_defineProperty(ErrorMessage, "previewTooLargeReasons", ['codeviewer-file-size-exceeds', 'archiveviewer-codeviewer-file-size-exceeds']);
|
|
110
134
|
const ErroMsg = withAnalyticsEvents()(injectIntl(ErrorMessage));
|
|
111
135
|
export default ErroMsg;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getFileAttributes } from '../..';
|
|
2
|
+
import { getPrimaryErrorReason } from '../../../errors';
|
|
3
|
+
export var createPreviewTooLargeEvent = function createPreviewTooLargeEvent(error, fileState) {
|
|
4
|
+
var _getFileAttributes = getFileAttributes(fileState),
|
|
5
|
+
fileId = _getFileAttributes.fileId,
|
|
6
|
+
fileMediatype = _getFileAttributes.fileMediatype,
|
|
7
|
+
fileMimetype = _getFileAttributes.fileMimetype,
|
|
8
|
+
fileSize = _getFileAttributes.fileSize;
|
|
9
|
+
return {
|
|
10
|
+
eventType: 'operational',
|
|
11
|
+
actionSubject: 'mediaFile',
|
|
12
|
+
action: 'previewTooLarge',
|
|
13
|
+
attributes: {
|
|
14
|
+
failReason: getPrimaryErrorReason(error),
|
|
15
|
+
fileAttributes: {
|
|
16
|
+
fileId: fileId,
|
|
17
|
+
fileMediatype: fileMediatype,
|
|
18
|
+
fileMimetype: fileMimetype,
|
|
19
|
+
fileSize: fileSize
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -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 = "54.6.
|
|
4
|
+
var packageVersion = "54.6.6";
|
|
5
5
|
export { packageName, packageVersion, componentName, componentName as component };
|
|
6
6
|
export function getFileAttributes(fileState) {
|
|
7
7
|
if (!fileState) {
|
|
@@ -7,7 +7,7 @@ import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
|
7
7
|
import { getFeatureFlagKeysAllProducts } from '@atlaskit/media-common';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
9
9
|
var packageName = "@atlaskit/media-viewer";
|
|
10
|
-
var packageVersion = "54.6.
|
|
10
|
+
var packageVersion = "54.6.6";
|
|
11
11
|
var ufoExperience;
|
|
12
12
|
var getExperience = function getExperience() {
|
|
13
13
|
if (!ufoExperience) {
|
package/dist/esm/errorMessage.js
CHANGED
|
@@ -12,12 +12,14 @@ import React from 'react';
|
|
|
12
12
|
import { FormattedMessage, injectIntl } from 'react-intl';
|
|
13
13
|
import { messages as i18nMessages } from '@atlaskit/media-ui/messages';
|
|
14
14
|
import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
15
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
16
|
import { ErrorMessageWrapper, ErrorImage } from './styleWrappers';
|
|
16
17
|
import { errorLoadingFile } from './error-images';
|
|
17
18
|
import { fireAnalytics } from './analytics';
|
|
18
19
|
import { getPrimaryErrorReason, getSecondaryErrorReason } from './errors';
|
|
19
20
|
import { createLoadFailedEvent } from './analytics/events/operational/loadFailed';
|
|
20
21
|
import { createPreviewUnsupportedEvent } from './analytics/events/operational/previewUnsupported';
|
|
22
|
+
import { createPreviewTooLargeEvent } from './analytics/events/operational/previewTooLarge';
|
|
21
23
|
import { failMediaFileUfoExperience } from './analytics/ufoExperiences';
|
|
22
24
|
var errorLoadingFileImage = function errorLoadingFileImage(formatMessage) {
|
|
23
25
|
return /*#__PURE__*/React.createElement(ErrorImage, {
|
|
@@ -55,6 +57,17 @@ export var ErrorMessage = /*#__PURE__*/function (_React$Component) {
|
|
|
55
57
|
messages: [i18nMessages.unsupported_file_format, i18nMessages.archive_format_not_supported]
|
|
56
58
|
};
|
|
57
59
|
}
|
|
60
|
+
|
|
61
|
+
// Code/text files (in the main viewer or inside a ZIP archive) over the
|
|
62
|
+
// CodeViewer's 10MB limit aren't a load failure - the file is simply too
|
|
63
|
+
// large for this viewer to preview. Show a dedicated "File is too large to
|
|
64
|
+
// preview" heading instead of the generic "Something went wrong" copy.
|
|
65
|
+
if (ErrorMessage.isPreviewTooLarge(error) && fg('platform_media_too_large_preview_state')) {
|
|
66
|
+
return {
|
|
67
|
+
icon: errorLoadingFileImage(formatMessage),
|
|
68
|
+
messages: [i18nMessages.file_too_large_to_preview, i18nMessages.file_too_large_description]
|
|
69
|
+
};
|
|
70
|
+
}
|
|
58
71
|
var errorInfo = {
|
|
59
72
|
icon: errorLoadingFileImage(formatMessage),
|
|
60
73
|
messages: [i18nMessages.something_went_wrong, i18nMessages.couldnt_generate_preview]
|
|
@@ -114,10 +127,21 @@ export var ErrorMessage = /*#__PURE__*/function (_React$Component) {
|
|
|
114
127
|
value: function isPreviewUnsupported(error) {
|
|
115
128
|
return ErrorMessage.previewUnsupportedReasons.includes(getPrimaryErrorReason(error));
|
|
116
129
|
}
|
|
130
|
+
|
|
131
|
+
// Error reasons that mean the file exceeds the size limit supported by the
|
|
132
|
+
// browser-based viewer (not a load failure). These are reported as the
|
|
133
|
+
// informational, non-SLI `previewTooLarge` metric instead of `loadFailed`.
|
|
134
|
+
}, {
|
|
135
|
+
key: "isPreviewTooLarge",
|
|
136
|
+
value: function isPreviewTooLarge(error) {
|
|
137
|
+
return ErrorMessage.previewTooLargeReasons.includes(getPrimaryErrorReason(error));
|
|
138
|
+
}
|
|
117
139
|
}, {
|
|
118
140
|
key: "getEventPayload",
|
|
119
141
|
value: function getEventPayload(error, fileId, fileState, traceContext) {
|
|
120
|
-
if (fileState && ErrorMessage.
|
|
142
|
+
if (fileState && ErrorMessage.isPreviewTooLarge(error) && fg('platform_media_too_large_preview_state')) {
|
|
143
|
+
return createPreviewTooLargeEvent(error, fileState);
|
|
144
|
+
} else if (fileState && ErrorMessage.isPreviewUnsupported(error)) {
|
|
121
145
|
// this is not an SLI (load failure), its just a useful metric for files
|
|
122
146
|
// whose format the browser-based viewer can't preview.
|
|
123
147
|
return createPreviewUnsupportedEvent(fileState);
|
|
@@ -130,5 +154,6 @@ export var ErrorMessage = /*#__PURE__*/function (_React$Component) {
|
|
|
130
154
|
|
|
131
155
|
// @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
|
|
132
156
|
_defineProperty(ErrorMessage, "previewUnsupportedReasons", ['unsupported', 'imageviewer-unsupported-mime']);
|
|
157
|
+
_defineProperty(ErrorMessage, "previewTooLargeReasons", ['codeviewer-file-size-exceeds', 'archiveviewer-codeviewer-file-size-exceeds']);
|
|
133
158
|
var ErroMsg = withAnalyticsEvents()(injectIntl(ErrorMessage));
|
|
134
159
|
export default ErroMsg;
|
|
@@ -3,6 +3,7 @@ import { type LoadFailedEventPayload } from './operational/loadFailed';
|
|
|
3
3
|
import { type DownloadFailedEventPayload, type DownloadSucceededEventPayload } from './operational/download';
|
|
4
4
|
import { type LoadSucceededEventPayload } from './operational/loadSucceeded';
|
|
5
5
|
import { type PreviewUnsupportedEventPayload } from './operational/previewUnsupported';
|
|
6
|
+
import { type PreviewTooLargeEventPayload } from './operational/previewTooLarge';
|
|
6
7
|
import { type ZipEntryLoadFailedEventPayload } from './operational/zipEntryLoadFailed';
|
|
7
8
|
import { type ZipEntryLoadSucceededEventPayload } from './operational/zipEntryLoadSucceeded';
|
|
8
9
|
import { type ModalEventPayload } from './screen/modal';
|
|
@@ -14,4 +15,4 @@ import { type FailedPreviewDownloadButtonClickedEventPayload } from './ui/failed
|
|
|
14
15
|
import { type NavigatedEventPayload } from './ui/navigated';
|
|
15
16
|
import { type ZoomInButtonClickEventPayload } from './ui/zoomInButtonClicked';
|
|
16
17
|
import { type ZoomOutButtonClickEventPayload } from './ui/zoomOutButtonClicked';
|
|
17
|
-
export type MediaViewerEventPayload = CommencedEventPayload | LoadFailedEventPayload | LoadSucceededEventPayload | PreviewUnsupportedEventPayload | ZipEntryLoadFailedEventPayload | ZipEntryLoadSucceededEventPayload | ModalEventPayload | PdfPasswordInputScreenEventPayload | PasswordPdfScreenEventPayload | ClosedEventPayload | DownloadButtonClickedEventPayload | FailedPreviewDownloadButtonClickedEventPayload | NavigatedEventPayload | ZoomInButtonClickEventPayload | ZoomOutButtonClickEventPayload | DownloadFailedEventPayload | DownloadSucceededEventPayload;
|
|
18
|
+
export type MediaViewerEventPayload = CommencedEventPayload | LoadFailedEventPayload | LoadSucceededEventPayload | PreviewUnsupportedEventPayload | PreviewTooLargeEventPayload | ZipEntryLoadFailedEventPayload | ZipEntryLoadSucceededEventPayload | ModalEventPayload | PdfPasswordInputScreenEventPayload | PasswordPdfScreenEventPayload | ClosedEventPayload | DownloadButtonClickedEventPayload | FailedPreviewDownloadButtonClickedEventPayload | NavigatedEventPayload | ZoomInButtonClickEventPayload | ZoomOutButtonClickEventPayload | DownloadFailedEventPayload | DownloadSucceededEventPayload;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type OperationalEventPayload, type OperationalAttributes } from '@atlaskit/media-common';
|
|
2
2
|
/** common definition used by other mediaFile events */
|
|
3
|
-
export type MediaFileEventPayload<Attributes extends OperationalAttributes, Action extends 'commenced' | 'loadSucceeded' | 'loadFailed' | 'previewUnsupported' | 'zipEntryLoadSucceeded' | 'zipEntryLoadFailed' | 'downloadSucceeded' | 'downloadFailed'> = OperationalEventPayload<Attributes, Action, 'mediaFile'>;
|
|
3
|
+
export type MediaFileEventPayload<Attributes extends OperationalAttributes, Action extends 'commenced' | 'loadSucceeded' | 'loadFailed' | 'previewUnsupported' | 'previewTooLarge' | 'zipEntryLoadSucceeded' | 'zipEntryLoadFailed' | 'downloadSucceeded' | 'downloadFailed'> = OperationalEventPayload<Attributes, Action, 'mediaFile'>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type FileState } from '@atlaskit/media-client';
|
|
2
|
+
import { type WithFileAttributes } from '@atlaskit/media-common';
|
|
3
|
+
import { type MediaFileEventPayload } from './_mediaFile';
|
|
4
|
+
import { type MediaViewerError, type PrimaryErrorReason } from '../../../errors';
|
|
5
|
+
export type PreviewTooLargeAttributes = WithFileAttributes & {
|
|
6
|
+
failReason: PrimaryErrorReason;
|
|
7
|
+
};
|
|
8
|
+
export type PreviewTooLargeEventPayload = MediaFileEventPayload<PreviewTooLargeAttributes, 'previewTooLarge'>;
|
|
9
|
+
export declare const createPreviewTooLargeEvent: (error: MediaViewerError, fileState: FileState) => PreviewTooLargeEventPayload;
|
|
@@ -6,6 +6,7 @@ import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next/withAnal
|
|
|
6
6
|
import { type PrimaryErrorReason, type SecondaryErrorReason, type MediaViewerError } from './errors';
|
|
7
7
|
import { type LoadFailedEventPayload } from './analytics/events/operational/loadFailed';
|
|
8
8
|
import { type PreviewUnsupportedEventPayload } from './analytics/events/operational/previewUnsupported';
|
|
9
|
+
import { type PreviewTooLargeEventPayload } from './analytics/events/operational/previewTooLarge';
|
|
9
10
|
import { type FileStateFlags } from './components/types';
|
|
10
11
|
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
11
12
|
export type Props = Readonly<{
|
|
@@ -28,7 +29,9 @@ export declare class ErrorMessage extends React.Component<Props & WrappedCompone
|
|
|
28
29
|
componentDidMount(): void;
|
|
29
30
|
private static readonly previewUnsupportedReasons;
|
|
30
31
|
static isPreviewUnsupported(error: MediaViewerError): boolean;
|
|
31
|
-
static
|
|
32
|
+
private static readonly previewTooLargeReasons;
|
|
33
|
+
static isPreviewTooLarge(error: MediaViewerError): boolean;
|
|
34
|
+
static getEventPayload(error: MediaViewerError, fileId: string, fileState?: FileState, traceContext?: MediaTraceContext): PreviewUnsupportedEventPayload | PreviewTooLargeEventPayload | LoadFailedEventPayload;
|
|
32
35
|
render(): React.JSX.Element;
|
|
33
36
|
}
|
|
34
37
|
declare const ErroMsg: React.ComponentType<Props & WithAnalyticsEventsProps>;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { jsx } from '@emotion/react';
|
|
7
7
|
import { type ReactNode, type FC } from 'react';
|
|
8
8
|
import { enableMediaUfoLogger } from '@atlaskit/media-test-helpers';
|
|
9
|
-
import { payloadPublisher } from '@atlassian/ufo';
|
|
9
|
+
import { payloadPublisher } from '@atlassian/ufo/publisher';
|
|
10
10
|
import {
|
|
11
11
|
containerStyles,
|
|
12
12
|
groupStyles,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-viewer",
|
|
3
|
-
"version": "54.
|
|
3
|
+
"version": "54.7.0",
|
|
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/"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@atlaskit/media-document-viewer": "^2.1.0",
|
|
46
46
|
"@atlaskit/media-state": "^3.1.0",
|
|
47
47
|
"@atlaskit/media-svg": "^3.2.0",
|
|
48
|
-
"@atlaskit/media-ui": "^30.
|
|
48
|
+
"@atlaskit/media-ui": "^30.14.0",
|
|
49
49
|
"@atlaskit/menu": "^10.1.0",
|
|
50
50
|
"@atlaskit/platform-feature-flags": "^2.1.0",
|
|
51
51
|
"@atlaskit/portal": "^6.3.0",
|
|
@@ -152,6 +152,9 @@
|
|
|
152
152
|
},
|
|
153
153
|
"platform_media_unsupported_mime_routing": {
|
|
154
154
|
"type": "boolean"
|
|
155
|
+
},
|
|
156
|
+
"platform_media_too_large_preview_state": {
|
|
157
|
+
"type": "boolean"
|
|
155
158
|
}
|
|
156
159
|
},
|
|
157
160
|
"techstack": {
|