@atlaskit/media-card 82.0.0 → 82.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 +35 -0
- package/dist/cjs/card/card.js +1 -1
- package/dist/cjs/card/fileCard.js +32 -22
- 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 +5 -6
- package/dist/cjs/utils/ufoExperiences.js +1 -1
- package/dist/es2019/card/card.js +1 -1
- package/dist/es2019/card/fileCard.js +31 -20
- 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 +5 -6
- package/dist/es2019/utils/ufoExperiences.js +1 -1
- package/dist/esm/card/card.js +1 -1
- package/dist/esm/card/fileCard.js +32 -22
- 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 +5 -6
- package/dist/esm/utils/ufoExperiences.js +1 -1
- package/dist/types/card/fileCard.d.ts +2 -1
- package/dist/types/inline/mediaInlineCard.d.ts +1 -0
- package/dist/types/types.d.ts +1 -1
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @atlaskit/media-card
|
|
2
2
|
|
|
3
|
+
## 82.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`a432278c5cb5c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a432278c5cb5c) -
|
|
8
|
+
[ux] Add opt-in consumer extension points so a product can host its own sidebar content — such as
|
|
9
|
+
Confluence comments — inside Media Viewer, and restore that viewer state across remounts. All of
|
|
10
|
+
the new behaviour is gated behind the `cc_comments_media_viewer_sidebar` experiment; with the
|
|
11
|
+
experiment off both packages behave exactly as before.
|
|
12
|
+
|
|
13
|
+
`@atlaskit/media-viewer` adds nine optional fields to `MediaViewerExtensions` and exports the new
|
|
14
|
+
`MediaViewerNavigationDirection` type. Consumers can intercept the close and navigate paths with
|
|
15
|
+
`onPreviewClose`, `onSidebarClose` and `onNavigation` — each receives a `proceed()` callback, so a
|
|
16
|
+
consumer can defer or swallow the action while, for example, prompting about an unsaved comment.
|
|
17
|
+
Viewer state can be persisted and restored through `getMediaViewerSelectedItem`,
|
|
18
|
+
`onSelectedItemChange`, `defaultSidebarVisible` and `onSidebarVisibilityChange`, and the existing
|
|
19
|
+
`sidebar` extension accepts `label` and `title`. The previously shipped `sidebar` and
|
|
20
|
+
`headerActions` fields are unchanged and are not gated.
|
|
21
|
+
|
|
22
|
+
`@atlaskit/media-card` adds no new prop of its own, but `Card`/`FileCard` consumers can now pass
|
|
23
|
+
`getMediaViewerSelectedItem` and `onSelectedItemChange` through the existing
|
|
24
|
+
`mediaViewerExtensions` prop to seed the Media Viewer selected item on mount and be notified when
|
|
25
|
+
it opens or closes — new remount-restore behaviour that also requires this release of
|
|
26
|
+
`@atlaskit/media-viewer` to typecheck.
|
|
27
|
+
|
|
28
|
+
Both packages add `@atlaskit/platform-feature-experiments` as a runtime dependency.
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- [`ae39a248bd118`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ae39a248bd118) -
|
|
33
|
+
FFCLEANUP-147994 clean up fg relating to fallback media name fetcher
|
|
34
|
+
platform_editor_media_name_fallback, platform_editor_media_file_rename_on_fallback,
|
|
35
|
+
platform_editor_media_file_rename_on_fallback, platform_editor_media_name_fallback_viewer_card
|
|
36
|
+
- Updated dependencies
|
|
37
|
+
|
|
3
38
|
## 82.0.0
|
|
4
39
|
|
|
5
40
|
### Major Changes
|
package/dist/cjs/card/card.js
CHANGED
|
@@ -8,7 +8,7 @@ var _reactIntl = require("react-intl");
|
|
|
8
8
|
var _mediaCommon = require("@atlaskit/media-common");
|
|
9
9
|
var _CardWithPerformanceObserver = require("./CardWithPerformanceObserver");
|
|
10
10
|
var packageName = "@atlaskit/media-card";
|
|
11
|
-
var packageVersion = "
|
|
11
|
+
var packageVersion = "82.0.0";
|
|
12
12
|
var Card = exports.Card = (0, _mediaCommon.withMediaAnalyticsContext)({
|
|
13
13
|
packageVersion: packageVersion,
|
|
14
14
|
packageName: packageName,
|
|
@@ -23,10 +23,10 @@ var _mediaCommon = require("@atlaskit/media-common");
|
|
|
23
23
|
var _useFilePreview2 = require("@atlaskit/media-file-preview/use-file-preview");
|
|
24
24
|
var _abuseModal = require("@atlaskit/media-ui/abuseModal");
|
|
25
25
|
var _mediaViewer = require("@atlaskit/media-viewer");
|
|
26
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
26
27
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
27
28
|
var _getActiveTrace = require("@atlaskit/react-ufo/get-active-trace");
|
|
28
29
|
var _usePressTracing = _interopRequireDefault(require("@atlaskit/react-ufo/use-press-tracing"));
|
|
29
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
30
30
|
var _dateOverrideContext = require("../dateOverrideContext");
|
|
31
31
|
var _isSSRPreview = require("../isSSRPreview");
|
|
32
32
|
var _MediaCardError = require("../MediaCardError");
|
|
@@ -184,12 +184,10 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
184
184
|
(0, _react.useEffect)(function () {
|
|
185
185
|
// Reset fetch state when the file identity changes
|
|
186
186
|
var currentId = fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.id;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
if (fileStateValue && !fileStateValue.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current && (0, _expValEquals.expValEquals)('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true)) {
|
|
187
|
+
fallbackMediaNameFetchAttempted.current = false;
|
|
188
|
+
setFallbackMediaName(undefined);
|
|
189
|
+
lastFetchedFileId.current = currentId;
|
|
190
|
+
if (fileStateValue && !fileStateValue.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current) {
|
|
193
191
|
fallbackMediaNameFetchAttempted.current = true;
|
|
194
192
|
fallbackMediaNameFetcher(fileStateValue.id).then(function (name) {
|
|
195
193
|
setFallbackMediaName(name);
|
|
@@ -291,10 +289,30 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
291
289
|
// CXP-2723 TODO: TEMPORARY VARIABLES
|
|
292
290
|
var finalError = error || (previewError && previewError.primaryReason !== 'failed-processing' && (fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.mimeType) !== 'image/svg+xml' ? previewError : undefined);
|
|
293
291
|
var finalStatus = finalError ? 'error' : status === 'failed-processing' && (fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.mimeType) === 'image/svg+xml' ? 'loading-preview' : status;
|
|
294
|
-
|
|
292
|
+
|
|
293
|
+
// Experiment gate for the Confluence comments-in-media-viewer work. Only the
|
|
294
|
+
// viewer-state persistence callbacks introduced by that series are gated —
|
|
295
|
+
// `mediaViewerExtensions` itself is still forwarded to MediaViewer so the
|
|
296
|
+
// previously shipped `sidebar` and `headerActions` keep working with the
|
|
297
|
+
// experiment off.
|
|
298
|
+
var _ref2 = (0, _isExperimentEnabled.isExperimentEnabled)('cc_comments_media_viewer_sidebar') ? mediaViewerExtensions !== null && mediaViewerExtensions !== void 0 ? mediaViewerExtensions : {} : {},
|
|
299
|
+
getMediaViewerSelectedItem = _ref2.getMediaViewerSelectedItem,
|
|
300
|
+
onSelectedItemChange = _ref2.onSelectedItemChange;
|
|
301
|
+
var _useState17 = (0, _react.useState)(function () {
|
|
302
|
+
var _getMediaViewerSelect;
|
|
303
|
+
return (_getMediaViewerSelect = getMediaViewerSelectedItem === null || getMediaViewerSelectedItem === void 0 ? void 0 : getMediaViewerSelectedItem(identifier)) !== null && _getMediaViewerSelect !== void 0 ? _getMediaViewerSelect : null;
|
|
304
|
+
}),
|
|
295
305
|
_useState18 = (0, _slicedToArray2.default)(_useState17, 2),
|
|
296
306
|
mediaViewerSelectedItem = _useState18[0],
|
|
297
307
|
setMediaViewerSelectedItem = _useState18[1];
|
|
308
|
+
var openMediaViewer = (0, _react.useCallback)(function () {
|
|
309
|
+
setMediaViewerSelectedItem(identifier);
|
|
310
|
+
onSelectedItemChange === null || onSelectedItemChange === void 0 || onSelectedItemChange(identifier);
|
|
311
|
+
}, [identifier, onSelectedItemChange]);
|
|
312
|
+
var closeMediaViewer = (0, _react.useCallback)(function () {
|
|
313
|
+
setMediaViewerSelectedItem(null);
|
|
314
|
+
onSelectedItemChange === null || onSelectedItemChange === void 0 || onSelectedItemChange(null);
|
|
315
|
+
}, [onSelectedItemChange]);
|
|
298
316
|
var uploadProgressRef = (0, _react.useRef)();
|
|
299
317
|
|
|
300
318
|
// Store latest auth provider event (emit with fireOperationalEventRef)
|
|
@@ -310,12 +328,11 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
310
328
|
return 'failed';
|
|
311
329
|
}
|
|
312
330
|
};
|
|
313
|
-
var resolvedFallbackName = (0, _expValEquals.expValEquals)('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true) ? fallbackMediaName : undefined;
|
|
314
331
|
if ((0, _fg.fg)('dfo_attachments_late_render_fix')) {
|
|
315
332
|
if (fileStateValue) {
|
|
316
333
|
return {
|
|
317
334
|
id: fileStateValue.id,
|
|
318
|
-
name: fileStateValue.name ||
|
|
335
|
+
name: fileStateValue.name || fallbackMediaName || ssrItemDetails && ssrItemDetails.filename,
|
|
319
336
|
size: fileStateValue.size,
|
|
320
337
|
mimeType: fileStateValue.mimeType || ssrItemDetails && ssrItemDetails.mimetype,
|
|
321
338
|
createdAt: fileStateValue.createdAt || ssrItemDetails && ssrItemDetails.createdDate,
|
|
@@ -335,7 +352,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
335
352
|
if (fileStateValue) {
|
|
336
353
|
return {
|
|
337
354
|
id: fileStateValue.id,
|
|
338
|
-
name: fileStateValue.name ||
|
|
355
|
+
name: fileStateValue.name || fallbackMediaName,
|
|
339
356
|
size: fileStateValue.size,
|
|
340
357
|
mimeType: fileStateValue.mimeType,
|
|
341
358
|
createdAt: fileStateValue.createdAt,
|
|
@@ -385,7 +402,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
385
402
|
var computedActions = (0, _react.useMemo)(function () {
|
|
386
403
|
if (finalStatus === 'failed-processing' || shouldEnableDownloadButton) {
|
|
387
404
|
var handler = /*#__PURE__*/function () {
|
|
388
|
-
var
|
|
405
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
389
406
|
return _regenerator.default.wrap(function (_context2) {
|
|
390
407
|
while (1) switch (_context2.prev = _context2.next) {
|
|
391
408
|
case 0:
|
|
@@ -406,7 +423,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
406
423
|
}, _callee2);
|
|
407
424
|
}));
|
|
408
425
|
return function handler() {
|
|
409
|
-
return
|
|
426
|
+
return _ref4.apply(this, arguments);
|
|
410
427
|
};
|
|
411
428
|
}();
|
|
412
429
|
var downloadAction = (0, _createDownloadAction.createDownloadAction)({
|
|
@@ -593,12 +610,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
593
610
|
setIsPlayingFile(true);
|
|
594
611
|
setShouldAutoplay(true);
|
|
595
612
|
} else if (shouldOpenMediaViewer) {
|
|
596
|
-
|
|
597
|
-
id: identifier.id,
|
|
598
|
-
mediaItemType: 'file',
|
|
599
|
-
collectionName: identifier.collectionName,
|
|
600
|
-
occurrenceKey: identifier.occurrenceKey
|
|
601
|
-
});
|
|
613
|
+
openMediaViewer();
|
|
602
614
|
}
|
|
603
615
|
|
|
604
616
|
// Abort VC when click file card
|
|
@@ -851,9 +863,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
851
863
|
items: mediaViewerItems || [],
|
|
852
864
|
mediaClientConfig: mediaClient.config,
|
|
853
865
|
selectedItem: mediaViewerSelectedItem,
|
|
854
|
-
onClose:
|
|
855
|
-
setMediaViewerSelectedItem(null);
|
|
856
|
-
},
|
|
866
|
+
onClose: closeMediaViewer,
|
|
857
867
|
contextId: contextId,
|
|
858
868
|
featureFlags: featureFlags,
|
|
859
869
|
viewerOptions: viewerOptions,
|
|
@@ -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 = "
|
|
90
|
+
var packageVersion = "82.0.0";
|
|
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: "
|
|
119
|
+
packageName: "82.0.0",
|
|
120
120
|
componentName: 'mediaInlineCard',
|
|
121
121
|
component: 'mediaInlineCard'
|
|
122
122
|
};
|
|
@@ -23,7 +23,6 @@ var _mimeTypeIcon = require("@atlaskit/media-ui/mime-type-icon");
|
|
|
23
23
|
var _mediaViewer = require("@atlaskit/media-viewer");
|
|
24
24
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
25
25
|
var _usePressTracing = _interopRequireDefault(require("@atlaskit/react-ufo/use-press-tracing"));
|
|
26
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
27
26
|
var _Tooltip = _interopRequireDefault(require("@atlaskit/tooltip/Tooltip"));
|
|
28
27
|
var _MediaCardError = require("../MediaCardError");
|
|
29
28
|
var _fireMediaCardEvent = require("../utils/analytics/fireMediaCardEvent");
|
|
@@ -131,7 +130,7 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
|
|
|
131
130
|
selectedItem: identifier,
|
|
132
131
|
onClose: onMediaViewerClose,
|
|
133
132
|
viewerOptions: viewerOptions,
|
|
134
|
-
fallbackMediaNameFetcher:
|
|
133
|
+
fallbackMediaNameFetcher: fallbackMediaNameFetcher
|
|
135
134
|
}), document.body);
|
|
136
135
|
}
|
|
137
136
|
return null;
|
|
@@ -164,7 +163,7 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
|
|
|
164
163
|
};
|
|
165
164
|
}, [identifier.collectionName, identifier.id, mediaClient.file]);
|
|
166
165
|
(0, _react.useEffect)(function () {
|
|
167
|
-
if (fileState && fileState.status !== 'error' && !fileState.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current
|
|
166
|
+
if (fileState && fileState.status !== 'error' && !fileState.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current) {
|
|
168
167
|
fallbackMediaNameFetchAttempted.current = true;
|
|
169
168
|
fallbackMediaNameFetcher(fileState.id).then(function (name) {
|
|
170
169
|
return setFallbackMediaName(name);
|
|
@@ -197,7 +196,7 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
|
|
|
197
196
|
|
|
198
197
|
// Empty file handling — try the fallback name fetcher first if available
|
|
199
198
|
if (fileState && !fileState.name) {
|
|
200
|
-
if (fallbackMediaNameFetcher && !fallbackMediaNameFetchFailed && !fallbackMediaName
|
|
199
|
+
if (fallbackMediaNameFetcher && !fallbackMediaNameFetchFailed && !fallbackMediaName) {
|
|
201
200
|
// Fetch not yet attempted or in flight — show loading
|
|
202
201
|
return /*#__PURE__*/_react.default.createElement(_LoadingView.MediaInlineCardLoadingView, {
|
|
203
202
|
innerRef: copyNodeRef,
|
|
@@ -205,7 +204,7 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
|
|
|
205
204
|
isSelected: isSelected
|
|
206
205
|
});
|
|
207
206
|
}
|
|
208
|
-
if (!
|
|
207
|
+
if (!fallbackMediaName) {
|
|
209
208
|
// No fetcher provided or fetch failed — show error
|
|
210
209
|
var _error = new _MediaCardError.MediaCardError('metadata-fetch', new _mediaClient.FileFetcherError('emptyFileName', {
|
|
211
210
|
id: fileState.id
|
|
@@ -241,7 +240,7 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
|
|
|
241
240
|
var mediaType = fileState.mediaType,
|
|
242
241
|
fileStateName = fileState.name,
|
|
243
242
|
mimeType = fileState.mimeType;
|
|
244
|
-
var name =
|
|
243
|
+
var name = fileStateName || fallbackMediaName;
|
|
245
244
|
var linkIcon = /*#__PURE__*/_react.default.createElement(_mimeTypeIcon.MimeTypeIcon, {
|
|
246
245
|
testId: 'media-inline-card-file-type-icon',
|
|
247
246
|
size: "small",
|
|
@@ -23,7 +23,7 @@ var _getMediaGlobalScope = require("./globalScope/getMediaGlobalScope");
|
|
|
23
23
|
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; }
|
|
24
24
|
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; }
|
|
25
25
|
var packageName = "@atlaskit/media-card";
|
|
26
|
-
var packageVersion = "
|
|
26
|
+
var packageVersion = "82.0.0";
|
|
27
27
|
var SAMPLE_RATE = 0.05;
|
|
28
28
|
|
|
29
29
|
/**
|
package/dist/es2019/card/card.js
CHANGED
|
@@ -2,7 +2,7 @@ import { injectIntl } from 'react-intl';
|
|
|
2
2
|
import { withMediaAnalyticsContext } from '@atlaskit/media-common';
|
|
3
3
|
import { CardWithPerformanceObserver } from './CardWithPerformanceObserver';
|
|
4
4
|
const packageName = "@atlaskit/media-card";
|
|
5
|
-
const packageVersion = "
|
|
5
|
+
const packageVersion = "82.0.0";
|
|
6
6
|
export const Card = withMediaAnalyticsContext({
|
|
7
7
|
packageVersion,
|
|
8
8
|
packageName,
|
|
@@ -11,10 +11,10 @@ import { isMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser, getRan
|
|
|
11
11
|
import { useFilePreview } from '@atlaskit/media-file-preview/use-file-preview';
|
|
12
12
|
import { AbuseModal } from '@atlaskit/media-ui/abuseModal';
|
|
13
13
|
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
14
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
14
15
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
15
16
|
import { getActiveTrace } from '@atlaskit/react-ufo/get-active-trace';
|
|
16
17
|
import usePressTracing from '@atlaskit/react-ufo/use-press-tracing';
|
|
17
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
18
18
|
import { DateOverrideContext } from '../dateOverrideContext';
|
|
19
19
|
import { isSSRPreview } from '../isSSRPreview';
|
|
20
20
|
import { MediaCardError } from '../MediaCardError';
|
|
@@ -152,12 +152,10 @@ export const FileCard = ({
|
|
|
152
152
|
useEffect(() => {
|
|
153
153
|
// Reset fetch state when the file identity changes
|
|
154
154
|
const currentId = fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.id;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
if (fileStateValue && !fileStateValue.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current && expValEquals('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true)) {
|
|
155
|
+
fallbackMediaNameFetchAttempted.current = false;
|
|
156
|
+
setFallbackMediaName(undefined);
|
|
157
|
+
lastFetchedFileId.current = currentId;
|
|
158
|
+
if (fileStateValue && !fileStateValue.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current) {
|
|
161
159
|
fallbackMediaNameFetchAttempted.current = true;
|
|
162
160
|
fallbackMediaNameFetcher(fileStateValue.id).then(name => {
|
|
163
161
|
setFallbackMediaName(name);
|
|
@@ -242,7 +240,28 @@ export const FileCard = ({
|
|
|
242
240
|
// CXP-2723 TODO: TEMPORARY VARIABLES
|
|
243
241
|
const finalError = error || (previewError && previewError.primaryReason !== 'failed-processing' && (fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.mimeType) !== 'image/svg+xml' ? previewError : undefined);
|
|
244
242
|
const finalStatus = finalError ? 'error' : status === 'failed-processing' && (fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.mimeType) === 'image/svg+xml' ? 'loading-preview' : status;
|
|
245
|
-
|
|
243
|
+
|
|
244
|
+
// Experiment gate for the Confluence comments-in-media-viewer work. Only the
|
|
245
|
+
// viewer-state persistence callbacks introduced by that series are gated —
|
|
246
|
+
// `mediaViewerExtensions` itself is still forwarded to MediaViewer so the
|
|
247
|
+
// previously shipped `sidebar` and `headerActions` keep working with the
|
|
248
|
+
// experiment off.
|
|
249
|
+
const {
|
|
250
|
+
getMediaViewerSelectedItem,
|
|
251
|
+
onSelectedItemChange
|
|
252
|
+
} = isExperimentEnabled('cc_comments_media_viewer_sidebar') ? mediaViewerExtensions !== null && mediaViewerExtensions !== void 0 ? mediaViewerExtensions : {} : {};
|
|
253
|
+
const [mediaViewerSelectedItem, setMediaViewerSelectedItem] = useState(() => {
|
|
254
|
+
var _getMediaViewerSelect;
|
|
255
|
+
return (_getMediaViewerSelect = getMediaViewerSelectedItem === null || getMediaViewerSelectedItem === void 0 ? void 0 : getMediaViewerSelectedItem(identifier)) !== null && _getMediaViewerSelect !== void 0 ? _getMediaViewerSelect : null;
|
|
256
|
+
});
|
|
257
|
+
const openMediaViewer = useCallback(() => {
|
|
258
|
+
setMediaViewerSelectedItem(identifier);
|
|
259
|
+
onSelectedItemChange === null || onSelectedItemChange === void 0 ? void 0 : onSelectedItemChange(identifier);
|
|
260
|
+
}, [identifier, onSelectedItemChange]);
|
|
261
|
+
const closeMediaViewer = useCallback(() => {
|
|
262
|
+
setMediaViewerSelectedItem(null);
|
|
263
|
+
onSelectedItemChange === null || onSelectedItemChange === void 0 ? void 0 : onSelectedItemChange(null);
|
|
264
|
+
}, [onSelectedItemChange]);
|
|
246
265
|
const uploadProgressRef = useRef();
|
|
247
266
|
|
|
248
267
|
// Store latest auth provider event (emit with fireOperationalEventRef)
|
|
@@ -258,12 +277,11 @@ export const FileCard = ({
|
|
|
258
277
|
return 'failed';
|
|
259
278
|
}
|
|
260
279
|
};
|
|
261
|
-
const resolvedFallbackName = expValEquals('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true) ? fallbackMediaName : undefined;
|
|
262
280
|
if (fg('dfo_attachments_late_render_fix')) {
|
|
263
281
|
if (fileStateValue) {
|
|
264
282
|
return {
|
|
265
283
|
id: fileStateValue.id,
|
|
266
|
-
name: fileStateValue.name ||
|
|
284
|
+
name: fileStateValue.name || fallbackMediaName || ssrItemDetails && ssrItemDetails.filename,
|
|
267
285
|
size: fileStateValue.size,
|
|
268
286
|
mimeType: fileStateValue.mimeType || ssrItemDetails && ssrItemDetails.mimetype,
|
|
269
287
|
createdAt: fileStateValue.createdAt || ssrItemDetails && ssrItemDetails.createdDate,
|
|
@@ -283,7 +301,7 @@ export const FileCard = ({
|
|
|
283
301
|
if (fileStateValue) {
|
|
284
302
|
return {
|
|
285
303
|
id: fileStateValue.id,
|
|
286
|
-
name: fileStateValue.name ||
|
|
304
|
+
name: fileStateValue.name || fallbackMediaName,
|
|
287
305
|
size: fileStateValue.size,
|
|
288
306
|
mimeType: fileStateValue.mimeType,
|
|
289
307
|
createdAt: fileStateValue.createdAt,
|
|
@@ -507,12 +525,7 @@ export const FileCard = ({
|
|
|
507
525
|
setIsPlayingFile(true);
|
|
508
526
|
setShouldAutoplay(true);
|
|
509
527
|
} else if (shouldOpenMediaViewer) {
|
|
510
|
-
|
|
511
|
-
id: identifier.id,
|
|
512
|
-
mediaItemType: 'file',
|
|
513
|
-
collectionName: identifier.collectionName,
|
|
514
|
-
occurrenceKey: identifier.occurrenceKey
|
|
515
|
-
});
|
|
528
|
+
openMediaViewer();
|
|
516
529
|
}
|
|
517
530
|
|
|
518
531
|
// Abort VC when click file card
|
|
@@ -764,9 +777,7 @@ export const FileCard = ({
|
|
|
764
777
|
items: mediaViewerItems || [],
|
|
765
778
|
mediaClientConfig: mediaClient.config,
|
|
766
779
|
selectedItem: mediaViewerSelectedItem,
|
|
767
|
-
onClose:
|
|
768
|
-
setMediaViewerSelectedItem(null);
|
|
769
|
-
},
|
|
780
|
+
onClose: closeMediaViewer,
|
|
770
781
|
contextId: contextId,
|
|
771
782
|
featureFlags: featureFlags,
|
|
772
783
|
viewerOptions: viewerOptions,
|
|
@@ -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 = "
|
|
69
|
+
const packageVersion = "82.0.0";
|
|
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: "
|
|
40
|
+
packageName: "82.0.0",
|
|
41
41
|
componentName: 'mediaInlineCard',
|
|
42
42
|
component: 'mediaInlineCard'
|
|
43
43
|
};
|
|
@@ -14,7 +14,6 @@ import { MimeTypeIcon } from '@atlaskit/media-ui/mime-type-icon';
|
|
|
14
14
|
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
15
15
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
16
16
|
import usePressTracing from '@atlaskit/react-ufo/use-press-tracing';
|
|
17
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
18
17
|
import Tooltip from '@atlaskit/tooltip/Tooltip';
|
|
19
18
|
import { MediaCardError } from '../MediaCardError';
|
|
20
19
|
import { fireMediaCardEvent } from '../utils/analytics/fireMediaCardEvent';
|
|
@@ -97,7 +96,7 @@ export const MediaInlineCardInternal = ({
|
|
|
97
96
|
selectedItem: identifier,
|
|
98
97
|
onClose: onMediaViewerClose,
|
|
99
98
|
viewerOptions: viewerOptions,
|
|
100
|
-
fallbackMediaNameFetcher:
|
|
99
|
+
fallbackMediaNameFetcher: fallbackMediaNameFetcher
|
|
101
100
|
}), document.body);
|
|
102
101
|
}
|
|
103
102
|
return null;
|
|
@@ -130,7 +129,7 @@ export const MediaInlineCardInternal = ({
|
|
|
130
129
|
};
|
|
131
130
|
}, [identifier.collectionName, identifier.id, mediaClient.file]);
|
|
132
131
|
useEffect(() => {
|
|
133
|
-
if (fileState && fileState.status !== 'error' && !fileState.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current
|
|
132
|
+
if (fileState && fileState.status !== 'error' && !fileState.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current) {
|
|
134
133
|
fallbackMediaNameFetchAttempted.current = true;
|
|
135
134
|
fallbackMediaNameFetcher(fileState.id).then(name => setFallbackMediaName(name), () => setFallbackMediaNameFetchFailed(true));
|
|
136
135
|
}
|
|
@@ -159,7 +158,7 @@ export const MediaInlineCardInternal = ({
|
|
|
159
158
|
|
|
160
159
|
// Empty file handling — try the fallback name fetcher first if available
|
|
161
160
|
if (fileState && !fileState.name) {
|
|
162
|
-
if (fallbackMediaNameFetcher && !fallbackMediaNameFetchFailed && !fallbackMediaName
|
|
161
|
+
if (fallbackMediaNameFetcher && !fallbackMediaNameFetchFailed && !fallbackMediaName) {
|
|
163
162
|
// Fetch not yet attempted or in flight — show loading
|
|
164
163
|
return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
|
|
165
164
|
innerRef: copyNodeRef,
|
|
@@ -167,7 +166,7 @@ export const MediaInlineCardInternal = ({
|
|
|
167
166
|
isSelected: isSelected
|
|
168
167
|
});
|
|
169
168
|
}
|
|
170
|
-
if (!
|
|
169
|
+
if (!fallbackMediaName) {
|
|
171
170
|
// No fetcher provided or fetch failed — show error
|
|
172
171
|
const error = new MediaCardError('metadata-fetch', new FileFetcherError('emptyFileName', {
|
|
173
172
|
id: fileState.id
|
|
@@ -205,7 +204,7 @@ export const MediaInlineCardInternal = ({
|
|
|
205
204
|
name: fileStateName,
|
|
206
205
|
mimeType
|
|
207
206
|
} = fileState;
|
|
208
|
-
const name =
|
|
207
|
+
const name = fileStateName || fallbackMediaName;
|
|
209
208
|
const linkIcon = /*#__PURE__*/React.createElement(MimeTypeIcon, {
|
|
210
209
|
testId: 'media-inline-card-file-type-icon',
|
|
211
210
|
size: "small",
|
|
@@ -12,7 +12,7 @@ import { extractErrorInfo } from './analytics/extractErrorInfo';
|
|
|
12
12
|
import { getRenderErrorRequestMetadata } from './analytics/getRenderErrorRequestMetadata';
|
|
13
13
|
import { getMediaGlobalScope } from './globalScope/getMediaGlobalScope';
|
|
14
14
|
const packageName = "@atlaskit/media-card";
|
|
15
|
-
const packageVersion = "
|
|
15
|
+
const packageVersion = "82.0.0";
|
|
16
16
|
const SAMPLE_RATE = 0.05;
|
|
17
17
|
|
|
18
18
|
/**
|
package/dist/esm/card/card.js
CHANGED
|
@@ -2,7 +2,7 @@ import { injectIntl } from 'react-intl';
|
|
|
2
2
|
import { withMediaAnalyticsContext } from '@atlaskit/media-common';
|
|
3
3
|
import { CardWithPerformanceObserver } from './CardWithPerformanceObserver';
|
|
4
4
|
var packageName = "@atlaskit/media-card";
|
|
5
|
-
var packageVersion = "
|
|
5
|
+
var packageVersion = "82.0.0";
|
|
6
6
|
export var Card = withMediaAnalyticsContext({
|
|
7
7
|
packageVersion: packageVersion,
|
|
8
8
|
packageName: packageName,
|
|
@@ -18,10 +18,10 @@ import { isMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser, getRan
|
|
|
18
18
|
import { useFilePreview } from '@atlaskit/media-file-preview/use-file-preview';
|
|
19
19
|
import { AbuseModal } from '@atlaskit/media-ui/abuseModal';
|
|
20
20
|
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
21
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
21
22
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
22
23
|
import { getActiveTrace } from '@atlaskit/react-ufo/get-active-trace';
|
|
23
24
|
import usePressTracing from '@atlaskit/react-ufo/use-press-tracing';
|
|
24
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
25
25
|
import { DateOverrideContext } from '../dateOverrideContext';
|
|
26
26
|
import { isSSRPreview } from '../isSSRPreview';
|
|
27
27
|
import { MediaCardError } from '../MediaCardError';
|
|
@@ -176,12 +176,10 @@ export var FileCard = function FileCard(_ref) {
|
|
|
176
176
|
useEffect(function () {
|
|
177
177
|
// Reset fetch state when the file identity changes
|
|
178
178
|
var currentId = fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.id;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
if (fileStateValue && !fileStateValue.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current && expValEquals('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true)) {
|
|
179
|
+
fallbackMediaNameFetchAttempted.current = false;
|
|
180
|
+
setFallbackMediaName(undefined);
|
|
181
|
+
lastFetchedFileId.current = currentId;
|
|
182
|
+
if (fileStateValue && !fileStateValue.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current) {
|
|
185
183
|
fallbackMediaNameFetchAttempted.current = true;
|
|
186
184
|
fallbackMediaNameFetcher(fileStateValue.id).then(function (name) {
|
|
187
185
|
setFallbackMediaName(name);
|
|
@@ -283,10 +281,30 @@ export var FileCard = function FileCard(_ref) {
|
|
|
283
281
|
// CXP-2723 TODO: TEMPORARY VARIABLES
|
|
284
282
|
var finalError = error || (previewError && previewError.primaryReason !== 'failed-processing' && (fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.mimeType) !== 'image/svg+xml' ? previewError : undefined);
|
|
285
283
|
var finalStatus = finalError ? 'error' : status === 'failed-processing' && (fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.mimeType) === 'image/svg+xml' ? 'loading-preview' : status;
|
|
286
|
-
|
|
284
|
+
|
|
285
|
+
// Experiment gate for the Confluence comments-in-media-viewer work. Only the
|
|
286
|
+
// viewer-state persistence callbacks introduced by that series are gated —
|
|
287
|
+
// `mediaViewerExtensions` itself is still forwarded to MediaViewer so the
|
|
288
|
+
// previously shipped `sidebar` and `headerActions` keep working with the
|
|
289
|
+
// experiment off.
|
|
290
|
+
var _ref2 = isExperimentEnabled('cc_comments_media_viewer_sidebar') ? mediaViewerExtensions !== null && mediaViewerExtensions !== void 0 ? mediaViewerExtensions : {} : {},
|
|
291
|
+
getMediaViewerSelectedItem = _ref2.getMediaViewerSelectedItem,
|
|
292
|
+
onSelectedItemChange = _ref2.onSelectedItemChange;
|
|
293
|
+
var _useState17 = useState(function () {
|
|
294
|
+
var _getMediaViewerSelect;
|
|
295
|
+
return (_getMediaViewerSelect = getMediaViewerSelectedItem === null || getMediaViewerSelectedItem === void 0 ? void 0 : getMediaViewerSelectedItem(identifier)) !== null && _getMediaViewerSelect !== void 0 ? _getMediaViewerSelect : null;
|
|
296
|
+
}),
|
|
287
297
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
288
298
|
mediaViewerSelectedItem = _useState18[0],
|
|
289
299
|
setMediaViewerSelectedItem = _useState18[1];
|
|
300
|
+
var openMediaViewer = useCallback(function () {
|
|
301
|
+
setMediaViewerSelectedItem(identifier);
|
|
302
|
+
onSelectedItemChange === null || onSelectedItemChange === void 0 || onSelectedItemChange(identifier);
|
|
303
|
+
}, [identifier, onSelectedItemChange]);
|
|
304
|
+
var closeMediaViewer = useCallback(function () {
|
|
305
|
+
setMediaViewerSelectedItem(null);
|
|
306
|
+
onSelectedItemChange === null || onSelectedItemChange === void 0 || onSelectedItemChange(null);
|
|
307
|
+
}, [onSelectedItemChange]);
|
|
290
308
|
var uploadProgressRef = useRef();
|
|
291
309
|
|
|
292
310
|
// Store latest auth provider event (emit with fireOperationalEventRef)
|
|
@@ -302,12 +320,11 @@ export var FileCard = function FileCard(_ref) {
|
|
|
302
320
|
return 'failed';
|
|
303
321
|
}
|
|
304
322
|
};
|
|
305
|
-
var resolvedFallbackName = expValEquals('platform_editor_media_name_fallback_viewer_card', 'isEnabled', true) ? fallbackMediaName : undefined;
|
|
306
323
|
if (fg('dfo_attachments_late_render_fix')) {
|
|
307
324
|
if (fileStateValue) {
|
|
308
325
|
return {
|
|
309
326
|
id: fileStateValue.id,
|
|
310
|
-
name: fileStateValue.name ||
|
|
327
|
+
name: fileStateValue.name || fallbackMediaName || ssrItemDetails && ssrItemDetails.filename,
|
|
311
328
|
size: fileStateValue.size,
|
|
312
329
|
mimeType: fileStateValue.mimeType || ssrItemDetails && ssrItemDetails.mimetype,
|
|
313
330
|
createdAt: fileStateValue.createdAt || ssrItemDetails && ssrItemDetails.createdDate,
|
|
@@ -327,7 +344,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
327
344
|
if (fileStateValue) {
|
|
328
345
|
return {
|
|
329
346
|
id: fileStateValue.id,
|
|
330
|
-
name: fileStateValue.name ||
|
|
347
|
+
name: fileStateValue.name || fallbackMediaName,
|
|
331
348
|
size: fileStateValue.size,
|
|
332
349
|
mimeType: fileStateValue.mimeType,
|
|
333
350
|
createdAt: fileStateValue.createdAt,
|
|
@@ -377,7 +394,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
377
394
|
var computedActions = useMemo(function () {
|
|
378
395
|
if (finalStatus === 'failed-processing' || shouldEnableDownloadButton) {
|
|
379
396
|
var handler = /*#__PURE__*/function () {
|
|
380
|
-
var
|
|
397
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
381
398
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
382
399
|
while (1) switch (_context2.prev = _context2.next) {
|
|
383
400
|
case 0:
|
|
@@ -398,7 +415,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
398
415
|
}, _callee2);
|
|
399
416
|
}));
|
|
400
417
|
return function handler() {
|
|
401
|
-
return
|
|
418
|
+
return _ref4.apply(this, arguments);
|
|
402
419
|
};
|
|
403
420
|
}();
|
|
404
421
|
var downloadAction = createDownloadAction({
|
|
@@ -585,12 +602,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
585
602
|
setIsPlayingFile(true);
|
|
586
603
|
setShouldAutoplay(true);
|
|
587
604
|
} else if (shouldOpenMediaViewer) {
|
|
588
|
-
|
|
589
|
-
id: identifier.id,
|
|
590
|
-
mediaItemType: 'file',
|
|
591
|
-
collectionName: identifier.collectionName,
|
|
592
|
-
occurrenceKey: identifier.occurrenceKey
|
|
593
|
-
});
|
|
605
|
+
openMediaViewer();
|
|
594
606
|
}
|
|
595
607
|
|
|
596
608
|
// Abort VC when click file card
|
|
@@ -843,9 +855,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
843
855
|
items: mediaViewerItems || [],
|
|
844
856
|
mediaClientConfig: mediaClient.config,
|
|
845
857
|
selectedItem: mediaViewerSelectedItem,
|
|
846
|
-
onClose:
|
|
847
|
-
setMediaViewerSelectedItem(null);
|
|
848
|
-
},
|
|
858
|
+
onClose: closeMediaViewer,
|
|
849
859
|
contextId: contextId,
|
|
850
860
|
featureFlags: featureFlags,
|
|
851
861
|
viewerOptions: viewerOptions,
|
|
@@ -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 = "
|
|
83
|
+
var packageVersion = "82.0.0";
|
|
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: "
|
|
104
|
+
packageName: "82.0.0",
|
|
105
105
|
componentName: 'mediaInlineCard',
|
|
106
106
|
component: 'mediaInlineCard'
|
|
107
107
|
};
|
|
@@ -15,7 +15,6 @@ import { MimeTypeIcon } from '@atlaskit/media-ui/mime-type-icon';
|
|
|
15
15
|
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
16
16
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
17
17
|
import usePressTracing from '@atlaskit/react-ufo/use-press-tracing';
|
|
18
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
19
18
|
import Tooltip from '@atlaskit/tooltip/Tooltip';
|
|
20
19
|
import { MediaCardError } from '../MediaCardError';
|
|
21
20
|
import { fireMediaCardEvent } from '../utils/analytics/fireMediaCardEvent';
|
|
@@ -122,7 +121,7 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
|
|
|
122
121
|
selectedItem: identifier,
|
|
123
122
|
onClose: onMediaViewerClose,
|
|
124
123
|
viewerOptions: viewerOptions,
|
|
125
|
-
fallbackMediaNameFetcher:
|
|
124
|
+
fallbackMediaNameFetcher: fallbackMediaNameFetcher
|
|
126
125
|
}), document.body);
|
|
127
126
|
}
|
|
128
127
|
return null;
|
|
@@ -155,7 +154,7 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
|
|
|
155
154
|
};
|
|
156
155
|
}, [identifier.collectionName, identifier.id, mediaClient.file]);
|
|
157
156
|
useEffect(function () {
|
|
158
|
-
if (fileState && fileState.status !== 'error' && !fileState.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current
|
|
157
|
+
if (fileState && fileState.status !== 'error' && !fileState.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current) {
|
|
159
158
|
fallbackMediaNameFetchAttempted.current = true;
|
|
160
159
|
fallbackMediaNameFetcher(fileState.id).then(function (name) {
|
|
161
160
|
return setFallbackMediaName(name);
|
|
@@ -188,7 +187,7 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
|
|
|
188
187
|
|
|
189
188
|
// Empty file handling — try the fallback name fetcher first if available
|
|
190
189
|
if (fileState && !fileState.name) {
|
|
191
|
-
if (fallbackMediaNameFetcher && !fallbackMediaNameFetchFailed && !fallbackMediaName
|
|
190
|
+
if (fallbackMediaNameFetcher && !fallbackMediaNameFetchFailed && !fallbackMediaName) {
|
|
192
191
|
// Fetch not yet attempted or in flight — show loading
|
|
193
192
|
return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
|
|
194
193
|
innerRef: copyNodeRef,
|
|
@@ -196,7 +195,7 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
|
|
|
196
195
|
isSelected: isSelected
|
|
197
196
|
});
|
|
198
197
|
}
|
|
199
|
-
if (!
|
|
198
|
+
if (!fallbackMediaName) {
|
|
200
199
|
// No fetcher provided or fetch failed — show error
|
|
201
200
|
var _error = new MediaCardError('metadata-fetch', new FileFetcherError('emptyFileName', {
|
|
202
201
|
id: fileState.id
|
|
@@ -232,7 +231,7 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
|
|
|
232
231
|
var mediaType = fileState.mediaType,
|
|
233
232
|
fileStateName = fileState.name,
|
|
234
233
|
mimeType = fileState.mimeType;
|
|
235
|
-
var name =
|
|
234
|
+
var name = fileStateName || fallbackMediaName;
|
|
236
235
|
var linkIcon = /*#__PURE__*/React.createElement(MimeTypeIcon, {
|
|
237
236
|
testId: 'media-inline-card-file-type-icon',
|
|
238
237
|
size: "small",
|
|
@@ -16,7 +16,7 @@ import { extractErrorInfo } from './analytics/extractErrorInfo';
|
|
|
16
16
|
import { getRenderErrorRequestMetadata } from './analytics/getRenderErrorRequestMetadata';
|
|
17
17
|
import { getMediaGlobalScope } from './globalScope/getMediaGlobalScope';
|
|
18
18
|
var packageName = "@atlaskit/media-card";
|
|
19
|
-
var packageVersion = "
|
|
19
|
+
var packageVersion = "82.0.0";
|
|
20
20
|
var SAMPLE_RATE = 0.05;
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -89,12 +89,13 @@ export interface FileCardProps extends CardEventProps {
|
|
|
89
89
|
readonly ssrMediaItem?: SsrMediaItem;
|
|
90
90
|
/** General Error handling include status errors and display errors*/
|
|
91
91
|
readonly onError?: (reason: MediaFilePreviewErrorPrimaryReason | MediaCardErrorPrimaryReason) => void;
|
|
92
|
-
/** Extensions for the media viewer (e.g. comment button in header). */
|
|
92
|
+
/** Extensions for the media viewer (e.g. comment button in header, sidebar with comment indicator). */
|
|
93
93
|
readonly mediaViewerExtensions?: MediaViewerExtensions;
|
|
94
94
|
/**
|
|
95
95
|
* Optional fallback fetcher to retrieve the media filename from another service.
|
|
96
96
|
* Workaround for #hot-301450 where media service is missing filenames for DC -> Cloud migrated media.
|
|
97
97
|
* Receives the file ID and should resolve to the filename string.
|
|
98
|
+
* TODO: Remove this prop when fallback-fetcher usage is sufficiently low.
|
|
98
99
|
*/
|
|
99
100
|
readonly fallbackMediaNameFetcher?: (id: string) => Promise<string>;
|
|
100
101
|
}
|
|
@@ -17,6 +17,7 @@ export interface MediaInlineCardProps {
|
|
|
17
17
|
* Optional fallback fetcher to retrieve the media filename from another service
|
|
18
18
|
* Workaround for #hot-301450 where media service is missing filenames for DC -> Cloud migrated media
|
|
19
19
|
* Receives the file ID and should resolve to the filename string.
|
|
20
|
+
* TODO: Remove this prop when fallback-fetcher usage is sufficiently low.
|
|
20
21
|
*/
|
|
21
22
|
fallbackMediaNameFetcher?: (id: string) => Promise<string>;
|
|
22
23
|
/**
|
package/dist/types/types.d.ts
CHANGED
|
@@ -132,7 +132,7 @@ export interface CardProps extends SharedCardProps, CardEventProps {
|
|
|
132
132
|
readonly ssrMediaItem?: SsrMediaItem;
|
|
133
133
|
/** General Error handling include status errors and display errors*/
|
|
134
134
|
readonly onError?: (reason: MediaFilePreviewErrorPrimaryReason | MediaCardErrorPrimaryReason) => void;
|
|
135
|
-
/** Extensions for the media viewer (e.g. comment button in header). */
|
|
135
|
+
/** Extensions for the media viewer (e.g. comment button in header, sidebar with comment indicator). */
|
|
136
136
|
readonly mediaViewerExtensions?: MediaViewerExtensions;
|
|
137
137
|
/**
|
|
138
138
|
* Optional fallback fetcher to retrieve the media filename from another service.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-card",
|
|
3
|
-
"version": "82.
|
|
3
|
+
"version": "82.1.0",
|
|
4
4
|
"description": "Includes all media card related components, CardView, CardViewSmall, Card...",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
"@atlaskit/media-state": "^4.0.0",
|
|
47
47
|
"@atlaskit/media-svg": "^4.0.0",
|
|
48
48
|
"@atlaskit/media-ui": "^31.0.0",
|
|
49
|
-
"@atlaskit/media-viewer": "^54.
|
|
49
|
+
"@atlaskit/media-viewer": "^54.9.0",
|
|
50
|
+
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
50
51
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
51
52
|
"@atlaskit/primitives": "^22.5.0",
|
|
52
53
|
"@atlaskit/progress-bar": "^5.3.0",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"@atlaskit/react-ufo": "^8.0.0",
|
|
55
56
|
"@atlaskit/section-message": "^10.2.0",
|
|
56
57
|
"@atlaskit/theme": "^28.2.0",
|
|
57
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
58
|
+
"@atlaskit/tmp-editor-statsig": "^206.0.0",
|
|
58
59
|
"@atlaskit/tokens": "^20.0.0",
|
|
59
60
|
"@atlaskit/tooltip": "^24.3.0",
|
|
60
61
|
"@atlaskit/ufo": "^2.0.0",
|
|
@@ -92,6 +93,7 @@
|
|
|
92
93
|
"@atlaskit/ssr": "workspace:^",
|
|
93
94
|
"@atlaskit/toggle": "^17.3.0",
|
|
94
95
|
"@atlassian/a11y-jest-testing": "^0.17.0",
|
|
96
|
+
"@atlassian/experiment-test-utils": "^0.2.0",
|
|
95
97
|
"@atlassian/feature-flags-test-utils": "^1.3.0",
|
|
96
98
|
"@atlassian/testing-library": "^0.11.0",
|
|
97
99
|
"@atlassian/ufo": "^1.0.0",
|