@atlaskit/media-card 81.0.4 → 81.1.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 +12 -0
- package/dist/cjs/card/card.js +1 -1
- package/dist/cjs/card/fileCard.js +51 -24
- package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/cjs/inline/loader.js +1 -1
- package/dist/cjs/inline/mediaInlineCard.js +2 -1
- package/dist/cjs/utils/ufoExperiences.js +1 -1
- package/dist/es2019/card/card.js +1 -1
- package/dist/es2019/card/fileCard.js +29 -5
- package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/es2019/inline/loader.js +1 -1
- package/dist/es2019/inline/mediaInlineCard.js +2 -1
- package/dist/es2019/utils/ufoExperiences.js +1 -1
- package/dist/esm/card/card.js +1 -1
- package/dist/esm/card/fileCard.js +51 -24
- package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/esm/inline/loader.js +1 -1
- package/dist/esm/inline/mediaInlineCard.js +2 -1
- package/dist/esm/utils/ufoExperiences.js +1 -1
- package/dist/types/card/fileCard.d.ts +7 -1
- package/dist/types/types.d.ts +6 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/media-card
|
|
2
2
|
|
|
3
|
+
## 81.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`19773530cd51c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/19773530cd51c) -
|
|
8
|
+
Add fallbackMediaNameFetcher support to MediaCard (FileCard) and MediaViewer (header display),
|
|
9
|
+
gated behind the platform_editor_media_name_fallback_viewer_card experiment
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 81.0.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/card/card.js
CHANGED
|
@@ -20,7 +20,7 @@ var _label = _interopRequireDefault(require("@atlaskit/react-ufo/label"));
|
|
|
20
20
|
var _excluded = ["identifier"];
|
|
21
21
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
22
22
|
var packageName = "@atlaskit/media-card";
|
|
23
|
-
var packageVersion = "81.0.
|
|
23
|
+
var packageVersion = "81.0.4";
|
|
24
24
|
var CardBase = exports.CardBase = function CardBase(_ref) {
|
|
25
25
|
var identifier = _ref.identifier,
|
|
26
26
|
otherProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
@@ -17,6 +17,7 @@ var _mediaClientReact = require("@atlaskit/media-client-react");
|
|
|
17
17
|
var _mediaCommon = require("@atlaskit/media-common");
|
|
18
18
|
var _mediaViewer = require("@atlaskit/media-viewer");
|
|
19
19
|
var _react = _interopRequireWildcard(require("react"));
|
|
20
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
20
21
|
var _useCallbackRef = require("use-callback-ref");
|
|
21
22
|
var _errors = require("../errors");
|
|
22
23
|
var _types = require("../types");
|
|
@@ -98,7 +99,8 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
98
99
|
ssrItemDetails = _ref.ssrItemDetails,
|
|
99
100
|
ssrFileState = _ref.ssrFileState,
|
|
100
101
|
onError = _ref.onError,
|
|
101
|
-
mediaViewerExtensions = _ref.mediaViewerExtensions
|
|
102
|
+
mediaViewerExtensions = _ref.mediaViewerExtensions,
|
|
103
|
+
fallbackMediaNameFetcher = _ref.fallbackMediaNameFetcher;
|
|
102
104
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
103
105
|
formatMessage = _useIntl.formatMessage;
|
|
104
106
|
var _useState = (0, _react.useState)(false),
|
|
@@ -150,6 +152,12 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
150
152
|
initialFileState: initialFileState
|
|
151
153
|
}),
|
|
152
154
|
fileState = _useFileState.fileState;
|
|
155
|
+
var _useState7 = (0, _react.useState)(),
|
|
156
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
157
|
+
fallbackMediaName = _useState8[0],
|
|
158
|
+
setFallbackMediaName = _useState8[1];
|
|
159
|
+
var fallbackMediaNameFetchAttempted = (0, _react.useRef)(false);
|
|
160
|
+
var lastFetchedFileId = (0, _react.useRef)();
|
|
153
161
|
var prevFileState = (0, _usePrevious.usePrevious)(fileState && (0, _mediaClient.isErrorFileState)(fileState) ? undefined : fileState);
|
|
154
162
|
var fileStateValue = (0, _react.useMemo)(function () {
|
|
155
163
|
if (fileState && !(0, _mediaClient.isErrorFileState)(fileState)) {
|
|
@@ -158,6 +166,23 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
158
166
|
return prevFileState;
|
|
159
167
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
160
168
|
}, [fileState]);
|
|
169
|
+
(0, _react.useEffect)(function () {
|
|
170
|
+
// Reset fetch state when the file identity changes
|
|
171
|
+
var currentId = fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.id;
|
|
172
|
+
if (currentId && currentId !== lastFetchedFileId.current && (0, _expValEquals.expValEquals)('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true)) {
|
|
173
|
+
fallbackMediaNameFetchAttempted.current = false;
|
|
174
|
+
setFallbackMediaName(undefined);
|
|
175
|
+
lastFetchedFileId.current = currentId;
|
|
176
|
+
}
|
|
177
|
+
if (fileStateValue && !fileStateValue.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current && (0, _expValEquals.expValEquals)('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true)) {
|
|
178
|
+
fallbackMediaNameFetchAttempted.current = true;
|
|
179
|
+
fallbackMediaNameFetcher(fileStateValue.id).then(function (name) {
|
|
180
|
+
setFallbackMediaName(name);
|
|
181
|
+
}, function () {
|
|
182
|
+
// Silently ignore fetch failures
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}, [fileStateValue, fallbackMediaNameFetcher]);
|
|
161
186
|
var dateOverrides = (0, _react.useContext)(_dateOverrideContext.DateOverrideContext);
|
|
162
187
|
var overridenDate = dateOverrides === null || dateOverrides === void 0 ? void 0 : dateOverrides[identifier.id];
|
|
163
188
|
|
|
@@ -179,22 +204,22 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
179
204
|
|
|
180
205
|
// Generate unique traceId for file
|
|
181
206
|
var traceContext = (0, _react.useMemo)(traceContextRetriever, []);
|
|
182
|
-
var
|
|
183
|
-
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
184
|
-
status = _useState8[0],
|
|
185
|
-
setStatus = _useState8[1];
|
|
186
|
-
var _useState9 = (0, _react.useState)(false),
|
|
207
|
+
var _useState9 = (0, _react.useState)('loading'),
|
|
187
208
|
_useState0 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
188
|
-
|
|
189
|
-
|
|
209
|
+
status = _useState0[0],
|
|
210
|
+
setStatus = _useState0[1];
|
|
190
211
|
var _useState1 = (0, _react.useState)(false),
|
|
191
212
|
_useState10 = (0, _slicedToArray2.default)(_useState1, 2),
|
|
192
|
-
|
|
193
|
-
|
|
213
|
+
isPlayingFile = _useState10[0],
|
|
214
|
+
setIsPlayingFile = _useState10[1];
|
|
194
215
|
var _useState11 = (0, _react.useState)(false),
|
|
195
216
|
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
196
|
-
|
|
197
|
-
|
|
217
|
+
shouldAutoplay = _useState12[0],
|
|
218
|
+
setShouldAutoplay = _useState12[1];
|
|
219
|
+
var _useState13 = (0, _react.useState)(false),
|
|
220
|
+
_useState14 = (0, _slicedToArray2.default)(_useState13, 2),
|
|
221
|
+
previewDidRender = _useState14[0],
|
|
222
|
+
setPreviewDidRender = _useState14[1];
|
|
198
223
|
var mediaBlobUrlAttrs = (0, _react.useMemo)(function () {
|
|
199
224
|
var id = identifier.id,
|
|
200
225
|
collection = identifier.collectionName;
|
|
@@ -243,18 +268,18 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
243
268
|
instanceId: internalOccurrenceKey,
|
|
244
269
|
enabled: shouldSendPerformanceEvent
|
|
245
270
|
});
|
|
246
|
-
var
|
|
247
|
-
|
|
248
|
-
error =
|
|
249
|
-
setError =
|
|
271
|
+
var _useState15 = (0, _react.useState)(),
|
|
272
|
+
_useState16 = (0, _slicedToArray2.default)(_useState15, 2),
|
|
273
|
+
error = _useState16[0],
|
|
274
|
+
setError = _useState16[1];
|
|
250
275
|
|
|
251
276
|
// CXP-2723 TODO: TEMPORARY VARIABLES
|
|
252
277
|
var finalError = error || (previewError && previewError.primaryReason !== 'failed-processing' && (fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.mimeType) !== 'image/svg+xml' ? previewError : undefined);
|
|
253
278
|
var finalStatus = finalError ? 'error' : status === 'failed-processing' && (fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.mimeType) === 'image/svg+xml' ? 'loading-preview' : status;
|
|
254
|
-
var
|
|
255
|
-
|
|
256
|
-
mediaViewerSelectedItem =
|
|
257
|
-
setMediaViewerSelectedItem =
|
|
279
|
+
var _useState17 = (0, _react.useState)(null),
|
|
280
|
+
_useState18 = (0, _slicedToArray2.default)(_useState17, 2),
|
|
281
|
+
mediaViewerSelectedItem = _useState18[0],
|
|
282
|
+
setMediaViewerSelectedItem = _useState18[1];
|
|
258
283
|
var uploadProgressRef = (0, _react.useRef)();
|
|
259
284
|
|
|
260
285
|
// Store latest auth provider event (emit with fireOperationalEventRef)
|
|
@@ -270,11 +295,12 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
270
295
|
return 'failed';
|
|
271
296
|
}
|
|
272
297
|
};
|
|
298
|
+
var resolvedFallbackName = (0, _expValEquals.expValEquals)('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true) ? fallbackMediaName : undefined;
|
|
273
299
|
if ((0, _platformFeatureFlags.fg)('dfo_attachments_late_render_fix')) {
|
|
274
300
|
if (fileStateValue) {
|
|
275
301
|
return {
|
|
276
302
|
id: fileStateValue.id,
|
|
277
|
-
name: fileStateValue.name || ssrItemDetails && ssrItemDetails.filename,
|
|
303
|
+
name: fileStateValue.name || resolvedFallbackName || ssrItemDetails && ssrItemDetails.filename,
|
|
278
304
|
size: fileStateValue.size,
|
|
279
305
|
mimeType: fileStateValue.mimeType || ssrItemDetails && ssrItemDetails.mimetype,
|
|
280
306
|
createdAt: fileStateValue.createdAt || ssrItemDetails && ssrItemDetails.createdDate,
|
|
@@ -294,7 +320,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
294
320
|
if (fileStateValue) {
|
|
295
321
|
return {
|
|
296
322
|
id: fileStateValue.id,
|
|
297
|
-
name: fileStateValue.name,
|
|
323
|
+
name: fileStateValue.name || resolvedFallbackName,
|
|
298
324
|
size: fileStateValue.size,
|
|
299
325
|
mimeType: fileStateValue.mimeType,
|
|
300
326
|
createdAt: fileStateValue.createdAt,
|
|
@@ -308,7 +334,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
308
334
|
};
|
|
309
335
|
}
|
|
310
336
|
}
|
|
311
|
-
}, [fileStateValue, identifier.id, ssrItemDetails]);
|
|
337
|
+
}, [fileStateValue, identifier.id, ssrItemDetails, fallbackMediaName]);
|
|
312
338
|
var fileAttributes = (0, _react.useMemo)(function () {
|
|
313
339
|
return {
|
|
314
340
|
fileMediatype: metadata.mediaType,
|
|
@@ -804,6 +830,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
804
830
|
contextId: contextId,
|
|
805
831
|
featureFlags: featureFlags,
|
|
806
832
|
viewerOptions: viewerOptions,
|
|
807
|
-
extensions: mediaViewerExtensions
|
|
833
|
+
extensions: mediaViewerExtensions,
|
|
834
|
+
fallbackMediaNameFetcher: fallbackMediaNameFetcher
|
|
808
835
|
}) : null, getSsrScriptProps && /*#__PURE__*/_react.default.createElement("script", getSsrScriptProps()));
|
|
809
836
|
};
|
|
@@ -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 = "81.0.
|
|
90
|
+
var packageVersion = "81.0.4";
|
|
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)({
|
|
@@ -116,7 +116,7 @@ var MediaInlineCardLoader = exports.default = /*#__PURE__*/function (_React$Pure
|
|
|
116
116
|
ErrorBoundary = _this$state.ErrorBoundary;
|
|
117
117
|
var analyticsContext = {
|
|
118
118
|
packageVersion: "@atlaskit/media-card",
|
|
119
|
-
packageName: "81.0.
|
|
119
|
+
packageName: "81.0.4",
|
|
120
120
|
componentName: 'mediaInlineCard',
|
|
121
121
|
component: 'mediaInlineCard'
|
|
122
122
|
};
|
|
@@ -120,7 +120,8 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
|
|
|
120
120
|
mediaClientConfig: mediaClient.mediaClientConfig,
|
|
121
121
|
selectedItem: identifier,
|
|
122
122
|
onClose: onMediaViewerClose,
|
|
123
|
-
viewerOptions: viewerOptions
|
|
123
|
+
viewerOptions: viewerOptions,
|
|
124
|
+
fallbackMediaNameFetcher: (0, _expValEquals.expValEquals)('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true) ? fallbackMediaNameFetcher : undefined
|
|
124
125
|
}), document.body);
|
|
125
126
|
}
|
|
126
127
|
return null;
|
|
@@ -19,7 +19,7 @@ var _globalScope = require("./globalScope/globalScope");
|
|
|
19
19
|
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; }
|
|
20
20
|
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; }
|
|
21
21
|
var packageName = "@atlaskit/media-card";
|
|
22
|
-
var packageVersion = "81.0.
|
|
22
|
+
var packageVersion = "81.0.4";
|
|
23
23
|
var SAMPLE_RATE = 0.05;
|
|
24
24
|
|
|
25
25
|
/**
|
package/dist/es2019/card/card.js
CHANGED
|
@@ -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 = "81.0.
|
|
12
|
+
const packageVersion = "81.0.4";
|
|
13
13
|
export const CardBase = ({
|
|
14
14
|
identifier,
|
|
15
15
|
...otherProps
|
|
@@ -4,6 +4,7 @@ import { useFileState, useMediaClient } from '@atlaskit/media-client-react';
|
|
|
4
4
|
import { isMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser, getRandomTelemetryId } from '@atlaskit/media-common';
|
|
5
5
|
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
6
6
|
import React, { Suspense, useEffect, useMemo, useRef, useState, useCallback } from 'react';
|
|
7
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
8
|
import { useMergeRefs } from 'use-callback-ref';
|
|
8
9
|
import { MediaCardError } from '../errors';
|
|
9
10
|
import { isSSRPreview } from '../types';
|
|
@@ -79,7 +80,8 @@ export const FileCard = ({
|
|
|
79
80
|
ssrItemDetails,
|
|
80
81
|
ssrFileState,
|
|
81
82
|
onError,
|
|
82
|
-
mediaViewerExtensions
|
|
83
|
+
mediaViewerExtensions,
|
|
84
|
+
fallbackMediaNameFetcher
|
|
83
85
|
}) => {
|
|
84
86
|
const {
|
|
85
87
|
formatMessage
|
|
@@ -123,6 +125,9 @@ export const FileCard = ({
|
|
|
123
125
|
includeHashForDuplicateFiles,
|
|
124
126
|
initialFileState
|
|
125
127
|
});
|
|
128
|
+
const [fallbackMediaName, setFallbackMediaName] = useState();
|
|
129
|
+
const fallbackMediaNameFetchAttempted = useRef(false);
|
|
130
|
+
const lastFetchedFileId = useRef();
|
|
126
131
|
const prevFileState = usePrevious(fileState && isErrorFileState(fileState) ? undefined : fileState);
|
|
127
132
|
const fileStateValue = useMemo(() => {
|
|
128
133
|
if (fileState && !isErrorFileState(fileState)) {
|
|
@@ -131,6 +136,23 @@ export const FileCard = ({
|
|
|
131
136
|
return prevFileState;
|
|
132
137
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
133
138
|
}, [fileState]);
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
// Reset fetch state when the file identity changes
|
|
141
|
+
const currentId = fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.id;
|
|
142
|
+
if (currentId && currentId !== lastFetchedFileId.current && expValEquals('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true)) {
|
|
143
|
+
fallbackMediaNameFetchAttempted.current = false;
|
|
144
|
+
setFallbackMediaName(undefined);
|
|
145
|
+
lastFetchedFileId.current = currentId;
|
|
146
|
+
}
|
|
147
|
+
if (fileStateValue && !fileStateValue.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current && expValEquals('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true)) {
|
|
148
|
+
fallbackMediaNameFetchAttempted.current = true;
|
|
149
|
+
fallbackMediaNameFetcher(fileStateValue.id).then(name => {
|
|
150
|
+
setFallbackMediaName(name);
|
|
151
|
+
}, () => {
|
|
152
|
+
// Silently ignore fetch failures
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}, [fileStateValue, fallbackMediaNameFetcher]);
|
|
134
156
|
const dateOverrides = useContext(DateOverrideContext);
|
|
135
157
|
const overridenDate = dateOverrides === null || dateOverrides === void 0 ? void 0 : dateOverrides[identifier.id];
|
|
136
158
|
|
|
@@ -223,11 +245,12 @@ export const FileCard = ({
|
|
|
223
245
|
return 'failed';
|
|
224
246
|
}
|
|
225
247
|
};
|
|
248
|
+
const resolvedFallbackName = expValEquals('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true) ? fallbackMediaName : undefined;
|
|
226
249
|
if (fg('dfo_attachments_late_render_fix')) {
|
|
227
250
|
if (fileStateValue) {
|
|
228
251
|
return {
|
|
229
252
|
id: fileStateValue.id,
|
|
230
|
-
name: fileStateValue.name || ssrItemDetails && ssrItemDetails.filename,
|
|
253
|
+
name: fileStateValue.name || resolvedFallbackName || ssrItemDetails && ssrItemDetails.filename,
|
|
231
254
|
size: fileStateValue.size,
|
|
232
255
|
mimeType: fileStateValue.mimeType || ssrItemDetails && ssrItemDetails.mimetype,
|
|
233
256
|
createdAt: fileStateValue.createdAt || ssrItemDetails && ssrItemDetails.createdDate,
|
|
@@ -247,7 +270,7 @@ export const FileCard = ({
|
|
|
247
270
|
if (fileStateValue) {
|
|
248
271
|
return {
|
|
249
272
|
id: fileStateValue.id,
|
|
250
|
-
name: fileStateValue.name,
|
|
273
|
+
name: fileStateValue.name || resolvedFallbackName,
|
|
251
274
|
size: fileStateValue.size,
|
|
252
275
|
mimeType: fileStateValue.mimeType,
|
|
253
276
|
createdAt: fileStateValue.createdAt,
|
|
@@ -261,7 +284,7 @@ export const FileCard = ({
|
|
|
261
284
|
};
|
|
262
285
|
}
|
|
263
286
|
}
|
|
264
|
-
}, [fileStateValue, identifier.id, ssrItemDetails]);
|
|
287
|
+
}, [fileStateValue, identifier.id, ssrItemDetails, fallbackMediaName]);
|
|
265
288
|
const fileAttributes = useMemo(() => {
|
|
266
289
|
return {
|
|
267
290
|
fileMediatype: metadata.mediaType,
|
|
@@ -722,6 +745,7 @@ export const FileCard = ({
|
|
|
722
745
|
contextId: contextId,
|
|
723
746
|
featureFlags: featureFlags,
|
|
724
747
|
viewerOptions: viewerOptions,
|
|
725
|
-
extensions: mediaViewerExtensions
|
|
748
|
+
extensions: mediaViewerExtensions,
|
|
749
|
+
fallbackMediaNameFetcher: fallbackMediaNameFetcher
|
|
726
750
|
}) : null, getSsrScriptProps && /*#__PURE__*/React.createElement("script", getSsrScriptProps()));
|
|
727
751
|
};
|
|
@@ -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 = "81.0.
|
|
69
|
+
const packageVersion = "81.0.4";
|
|
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: "81.0.
|
|
40
|
+
packageName: "81.0.4",
|
|
41
41
|
componentName: 'mediaInlineCard',
|
|
42
42
|
component: 'mediaInlineCard'
|
|
43
43
|
};
|
|
@@ -88,7 +88,8 @@ export const MediaInlineCardInternal = ({
|
|
|
88
88
|
mediaClientConfig: mediaClient.mediaClientConfig,
|
|
89
89
|
selectedItem: identifier,
|
|
90
90
|
onClose: onMediaViewerClose,
|
|
91
|
-
viewerOptions: viewerOptions
|
|
91
|
+
viewerOptions: viewerOptions,
|
|
92
|
+
fallbackMediaNameFetcher: expValEquals('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true) ? fallbackMediaNameFetcher : undefined
|
|
92
93
|
}), document.body);
|
|
93
94
|
}
|
|
94
95
|
return null;
|
|
@@ -9,7 +9,7 @@ import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
|
9
9
|
import { getActiveInteraction } from '@atlaskit/react-ufo/interaction-metrics';
|
|
10
10
|
import { getMediaGlobalScope } from './globalScope/globalScope';
|
|
11
11
|
const packageName = "@atlaskit/media-card";
|
|
12
|
-
const packageVersion = "81.0.
|
|
12
|
+
const packageVersion = "81.0.4";
|
|
13
13
|
const SAMPLE_RATE = 0.05;
|
|
14
14
|
|
|
15
15
|
/**
|
package/dist/esm/card/card.js
CHANGED
|
@@ -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 = "81.0.
|
|
14
|
+
var packageVersion = "81.0.4";
|
|
15
15
|
export var CardBase = function CardBase(_ref) {
|
|
16
16
|
var identifier = _ref.identifier,
|
|
17
17
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -11,6 +11,7 @@ import { useFileState, useMediaClient } from '@atlaskit/media-client-react';
|
|
|
11
11
|
import { isMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser, getRandomTelemetryId } from '@atlaskit/media-common';
|
|
12
12
|
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
13
13
|
import React, { Suspense, useEffect, useMemo, useRef, useState, useCallback } from 'react';
|
|
14
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
15
|
import { useMergeRefs } from 'use-callback-ref';
|
|
15
16
|
import { MediaCardError } from '../errors';
|
|
16
17
|
import { isSSRPreview } from '../types';
|
|
@@ -90,7 +91,8 @@ export var FileCard = function FileCard(_ref) {
|
|
|
90
91
|
ssrItemDetails = _ref.ssrItemDetails,
|
|
91
92
|
ssrFileState = _ref.ssrFileState,
|
|
92
93
|
onError = _ref.onError,
|
|
93
|
-
mediaViewerExtensions = _ref.mediaViewerExtensions
|
|
94
|
+
mediaViewerExtensions = _ref.mediaViewerExtensions,
|
|
95
|
+
fallbackMediaNameFetcher = _ref.fallbackMediaNameFetcher;
|
|
94
96
|
var _useIntl = useIntl(),
|
|
95
97
|
formatMessage = _useIntl.formatMessage;
|
|
96
98
|
var _useState = useState(false),
|
|
@@ -142,6 +144,12 @@ export var FileCard = function FileCard(_ref) {
|
|
|
142
144
|
initialFileState: initialFileState
|
|
143
145
|
}),
|
|
144
146
|
fileState = _useFileState.fileState;
|
|
147
|
+
var _useState7 = useState(),
|
|
148
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
149
|
+
fallbackMediaName = _useState8[0],
|
|
150
|
+
setFallbackMediaName = _useState8[1];
|
|
151
|
+
var fallbackMediaNameFetchAttempted = useRef(false);
|
|
152
|
+
var lastFetchedFileId = useRef();
|
|
145
153
|
var prevFileState = usePrevious(fileState && isErrorFileState(fileState) ? undefined : fileState);
|
|
146
154
|
var fileStateValue = useMemo(function () {
|
|
147
155
|
if (fileState && !isErrorFileState(fileState)) {
|
|
@@ -150,6 +158,23 @@ export var FileCard = function FileCard(_ref) {
|
|
|
150
158
|
return prevFileState;
|
|
151
159
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
152
160
|
}, [fileState]);
|
|
161
|
+
useEffect(function () {
|
|
162
|
+
// Reset fetch state when the file identity changes
|
|
163
|
+
var currentId = fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.id;
|
|
164
|
+
if (currentId && currentId !== lastFetchedFileId.current && expValEquals('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true)) {
|
|
165
|
+
fallbackMediaNameFetchAttempted.current = false;
|
|
166
|
+
setFallbackMediaName(undefined);
|
|
167
|
+
lastFetchedFileId.current = currentId;
|
|
168
|
+
}
|
|
169
|
+
if (fileStateValue && !fileStateValue.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current && expValEquals('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true)) {
|
|
170
|
+
fallbackMediaNameFetchAttempted.current = true;
|
|
171
|
+
fallbackMediaNameFetcher(fileStateValue.id).then(function (name) {
|
|
172
|
+
setFallbackMediaName(name);
|
|
173
|
+
}, function () {
|
|
174
|
+
// Silently ignore fetch failures
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}, [fileStateValue, fallbackMediaNameFetcher]);
|
|
153
178
|
var dateOverrides = useContext(DateOverrideContext);
|
|
154
179
|
var overridenDate = dateOverrides === null || dateOverrides === void 0 ? void 0 : dateOverrides[identifier.id];
|
|
155
180
|
|
|
@@ -171,22 +196,22 @@ export var FileCard = function FileCard(_ref) {
|
|
|
171
196
|
|
|
172
197
|
// Generate unique traceId for file
|
|
173
198
|
var traceContext = useMemo(traceContextRetriever, []);
|
|
174
|
-
var
|
|
175
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
176
|
-
status = _useState8[0],
|
|
177
|
-
setStatus = _useState8[1];
|
|
178
|
-
var _useState9 = useState(false),
|
|
199
|
+
var _useState9 = useState('loading'),
|
|
179
200
|
_useState0 = _slicedToArray(_useState9, 2),
|
|
180
|
-
|
|
181
|
-
|
|
201
|
+
status = _useState0[0],
|
|
202
|
+
setStatus = _useState0[1];
|
|
182
203
|
var _useState1 = useState(false),
|
|
183
204
|
_useState10 = _slicedToArray(_useState1, 2),
|
|
184
|
-
|
|
185
|
-
|
|
205
|
+
isPlayingFile = _useState10[0],
|
|
206
|
+
setIsPlayingFile = _useState10[1];
|
|
186
207
|
var _useState11 = useState(false),
|
|
187
208
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
188
|
-
|
|
189
|
-
|
|
209
|
+
shouldAutoplay = _useState12[0],
|
|
210
|
+
setShouldAutoplay = _useState12[1];
|
|
211
|
+
var _useState13 = useState(false),
|
|
212
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
213
|
+
previewDidRender = _useState14[0],
|
|
214
|
+
setPreviewDidRender = _useState14[1];
|
|
190
215
|
var mediaBlobUrlAttrs = useMemo(function () {
|
|
191
216
|
var id = identifier.id,
|
|
192
217
|
collection = identifier.collectionName;
|
|
@@ -235,18 +260,18 @@ export var FileCard = function FileCard(_ref) {
|
|
|
235
260
|
instanceId: internalOccurrenceKey,
|
|
236
261
|
enabled: shouldSendPerformanceEvent
|
|
237
262
|
});
|
|
238
|
-
var
|
|
239
|
-
|
|
240
|
-
error =
|
|
241
|
-
setError =
|
|
263
|
+
var _useState15 = useState(),
|
|
264
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
265
|
+
error = _useState16[0],
|
|
266
|
+
setError = _useState16[1];
|
|
242
267
|
|
|
243
268
|
// CXP-2723 TODO: TEMPORARY VARIABLES
|
|
244
269
|
var finalError = error || (previewError && previewError.primaryReason !== 'failed-processing' && (fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.mimeType) !== 'image/svg+xml' ? previewError : undefined);
|
|
245
270
|
var finalStatus = finalError ? 'error' : status === 'failed-processing' && (fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.mimeType) === 'image/svg+xml' ? 'loading-preview' : status;
|
|
246
|
-
var
|
|
247
|
-
|
|
248
|
-
mediaViewerSelectedItem =
|
|
249
|
-
setMediaViewerSelectedItem =
|
|
271
|
+
var _useState17 = useState(null),
|
|
272
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
273
|
+
mediaViewerSelectedItem = _useState18[0],
|
|
274
|
+
setMediaViewerSelectedItem = _useState18[1];
|
|
250
275
|
var uploadProgressRef = useRef();
|
|
251
276
|
|
|
252
277
|
// Store latest auth provider event (emit with fireOperationalEventRef)
|
|
@@ -262,11 +287,12 @@ export var FileCard = function FileCard(_ref) {
|
|
|
262
287
|
return 'failed';
|
|
263
288
|
}
|
|
264
289
|
};
|
|
290
|
+
var resolvedFallbackName = expValEquals('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true) ? fallbackMediaName : undefined;
|
|
265
291
|
if (fg('dfo_attachments_late_render_fix')) {
|
|
266
292
|
if (fileStateValue) {
|
|
267
293
|
return {
|
|
268
294
|
id: fileStateValue.id,
|
|
269
|
-
name: fileStateValue.name || ssrItemDetails && ssrItemDetails.filename,
|
|
295
|
+
name: fileStateValue.name || resolvedFallbackName || ssrItemDetails && ssrItemDetails.filename,
|
|
270
296
|
size: fileStateValue.size,
|
|
271
297
|
mimeType: fileStateValue.mimeType || ssrItemDetails && ssrItemDetails.mimetype,
|
|
272
298
|
createdAt: fileStateValue.createdAt || ssrItemDetails && ssrItemDetails.createdDate,
|
|
@@ -286,7 +312,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
286
312
|
if (fileStateValue) {
|
|
287
313
|
return {
|
|
288
314
|
id: fileStateValue.id,
|
|
289
|
-
name: fileStateValue.name,
|
|
315
|
+
name: fileStateValue.name || resolvedFallbackName,
|
|
290
316
|
size: fileStateValue.size,
|
|
291
317
|
mimeType: fileStateValue.mimeType,
|
|
292
318
|
createdAt: fileStateValue.createdAt,
|
|
@@ -300,7 +326,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
300
326
|
};
|
|
301
327
|
}
|
|
302
328
|
}
|
|
303
|
-
}, [fileStateValue, identifier.id, ssrItemDetails]);
|
|
329
|
+
}, [fileStateValue, identifier.id, ssrItemDetails, fallbackMediaName]);
|
|
304
330
|
var fileAttributes = useMemo(function () {
|
|
305
331
|
return {
|
|
306
332
|
fileMediatype: metadata.mediaType,
|
|
@@ -796,6 +822,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
796
822
|
contextId: contextId,
|
|
797
823
|
featureFlags: featureFlags,
|
|
798
824
|
viewerOptions: viewerOptions,
|
|
799
|
-
extensions: mediaViewerExtensions
|
|
825
|
+
extensions: mediaViewerExtensions,
|
|
826
|
+
fallbackMediaNameFetcher: fallbackMediaNameFetcher
|
|
800
827
|
}) : null, getSsrScriptProps && /*#__PURE__*/React.createElement("script", getSsrScriptProps()));
|
|
801
828
|
};
|
|
@@ -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 = "81.0.
|
|
83
|
+
var packageVersion = "81.0.4";
|
|
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: "81.0.
|
|
104
|
+
packageName: "81.0.4",
|
|
105
105
|
componentName: 'mediaInlineCard',
|
|
106
106
|
component: 'mediaInlineCard'
|
|
107
107
|
};
|
|
@@ -111,7 +111,8 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
|
|
|
111
111
|
mediaClientConfig: mediaClient.mediaClientConfig,
|
|
112
112
|
selectedItem: identifier,
|
|
113
113
|
onClose: onMediaViewerClose,
|
|
114
|
-
viewerOptions: viewerOptions
|
|
114
|
+
viewerOptions: viewerOptions,
|
|
115
|
+
fallbackMediaNameFetcher: expValEquals('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true) ? fallbackMediaNameFetcher : undefined
|
|
115
116
|
}), document.body);
|
|
116
117
|
}
|
|
117
118
|
return null;
|
|
@@ -13,7 +13,7 @@ import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
|
13
13
|
import { getActiveInteraction } from '@atlaskit/react-ufo/interaction-metrics';
|
|
14
14
|
import { getMediaGlobalScope } from './globalScope/globalScope';
|
|
15
15
|
var packageName = "@atlaskit/media-card";
|
|
16
|
-
var packageVersion = "81.0.
|
|
16
|
+
var packageVersion = "81.0.4";
|
|
17
17
|
var SAMPLE_RATE = 0.05;
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -77,5 +77,11 @@ export interface FileCardProps extends CardEventProps {
|
|
|
77
77
|
readonly onError?: (reason: MediaFilePreviewErrorPrimaryReason | MediaCardErrorPrimaryReason) => void;
|
|
78
78
|
/** Extensions for the media viewer (e.g. comment button in header). */
|
|
79
79
|
readonly mediaViewerExtensions?: MediaViewerExtensions;
|
|
80
|
+
/**
|
|
81
|
+
* Optional fallback fetcher to retrieve the media filename from another service.
|
|
82
|
+
* Workaround for #hot-301450 where media service is missing filenames for DC -> Cloud migrated media.
|
|
83
|
+
* Receives the file ID and should resolve to the filename string.
|
|
84
|
+
*/
|
|
85
|
+
readonly fallbackMediaNameFetcher?: (id: string) => Promise<string>;
|
|
80
86
|
}
|
|
81
|
-
export declare const FileCard: ({ appearance, resizeMode, isLazy, disableOverlay, featureFlags, identifier, ssr, dimensions, originalDimensions, contextId, alt, actions, shouldEnableDownloadButton, useInlinePlayer, shouldOpenMediaViewer, onFullscreenChange, selectable, selected, testId, titleBoxBgColor, titleBoxIcon, backgroundColor, isAIGenerating, onPreviewRender, shouldHideTooltip, mediaViewerItems, onClick, onMouseEnter, videoControlsWrapperRef, viewerOptions, includeHashForDuplicateFiles, ssrItemDetails, ssrFileState, onError, mediaViewerExtensions, }: FileCardProps) => React.JSX.Element;
|
|
87
|
+
export declare const FileCard: ({ appearance, resizeMode, isLazy, disableOverlay, featureFlags, identifier, ssr, dimensions, originalDimensions, contextId, alt, actions, shouldEnableDownloadButton, useInlinePlayer, shouldOpenMediaViewer, onFullscreenChange, selectable, selected, testId, titleBoxBgColor, titleBoxIcon, backgroundColor, isAIGenerating, onPreviewRender, shouldHideTooltip, mediaViewerItems, onClick, onMouseEnter, videoControlsWrapperRef, viewerOptions, includeHashForDuplicateFiles, ssrItemDetails, ssrFileState, onError, mediaViewerExtensions, fallbackMediaNameFetcher, }: FileCardProps) => React.JSX.Element;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -124,6 +124,12 @@ export interface CardProps extends SharedCardProps, CardEventProps {
|
|
|
124
124
|
readonly onError?: (reason: MediaFilePreviewErrorPrimaryReason | MediaCardErrorPrimaryReason) => void;
|
|
125
125
|
/** Extensions for the media viewer (e.g. comment button in header). */
|
|
126
126
|
readonly mediaViewerExtensions?: MediaViewerExtensions;
|
|
127
|
+
/**
|
|
128
|
+
* Optional fallback fetcher to retrieve the media filename from another service.
|
|
129
|
+
* Workaround for #hot-301450 where media service is missing filenames for DC -> Cloud migrated media.
|
|
130
|
+
* Receives the file ID and should resolve to the filename string.
|
|
131
|
+
*/
|
|
132
|
+
readonly fallbackMediaNameFetcher?: (id: string) => Promise<string>;
|
|
127
133
|
}
|
|
128
134
|
export interface CardState {
|
|
129
135
|
status: CardStatus;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-card",
|
|
3
|
-
"version": "81.0
|
|
3
|
+
"version": "81.1.0",
|
|
4
4
|
"description": "Includes all media card related components, CardView, CardViewSmall, Card...",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
"@atlaskit/media-state": "^3.0.0",
|
|
44
44
|
"@atlaskit/media-svg": "^3.0.0",
|
|
45
45
|
"@atlaskit/media-ui": "^30.1.0",
|
|
46
|
-
"@atlaskit/media-viewer": "^54.
|
|
46
|
+
"@atlaskit/media-viewer": "^54.1.0",
|
|
47
47
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
48
48
|
"@atlaskit/primitives": "^20.0.0",
|
|
49
49
|
"@atlaskit/progress-bar": "^5.0.0",
|
|
50
50
|
"@atlaskit/react-ufo": "^7.1.0",
|
|
51
51
|
"@atlaskit/spinner": "^20.0.0",
|
|
52
52
|
"@atlaskit/theme": "^26.0.0",
|
|
53
|
-
"@atlaskit/tmp-editor-statsig": "^108.
|
|
53
|
+
"@atlaskit/tmp-editor-statsig": "^108.3.0",
|
|
54
54
|
"@atlaskit/tokens": "^14.0.0",
|
|
55
55
|
"@atlaskit/tooltip": "^23.0.0",
|
|
56
56
|
"@atlaskit/ufo": "^1.0.0",
|