@atlaskit/media-card 80.0.0 → 80.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/media-card
2
2
 
3
+ ## 80.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 80.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`b6bb07e5d72ac`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b6bb07e5d72ac) -
14
+ [ux] Fix for #hot-301450, add new media option for fallback media name fetcher to allow confluence
15
+ to use the attachment service instead of the media service to get filenames. After DC -> Cloud
16
+ migration filenames were not properly copied across to the media service causing inline media to
17
+ show an error.
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies
22
+
3
23
  ## 80.0.0
4
24
 
5
25
  ### Major Changes
@@ -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 = "0.0.0-development";
23
+ var packageVersion = "80.1.0";
24
24
  var CardBase = exports.CardBase = function CardBase(_ref) {
25
25
  var identifier = _ref.identifier,
26
26
  otherProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
@@ -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 = "0.0.0-development";
90
+ var packageVersion = "80.1.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: "0.0.0-development",
119
+ packageName: "80.1.0",
120
120
  componentName: 'mediaInlineCard',
121
121
  component: 'mediaInlineCard'
122
122
  };
@@ -22,6 +22,7 @@ var _analytics = require("../utils/analytics");
22
22
  var _mediaInlineCardAnalytics = require("./mediaInlineCardAnalytics");
23
23
  var _mediaClientReact = require("@atlaskit/media-client-react");
24
24
  var _usePressTracing = _interopRequireDefault(require("@atlaskit/react-ufo/use-press-tracing"));
25
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
25
26
  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); }
26
27
  // UI component which renders an inline link in the appropiate state based on a media file
27
28
  var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
@@ -33,7 +34,8 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
33
34
  onClick = _ref.onClick,
34
35
  mediaViewerItems = _ref.mediaViewerItems,
35
36
  intl = _ref.intl,
36
- viewerOptions = _ref.viewerOptions;
37
+ viewerOptions = _ref.viewerOptions,
38
+ fallbackMediaNameFetcher = _ref.fallbackMediaNameFetcher;
37
39
  var _useState = (0, _react.useState)(),
38
40
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
39
41
  fileState = _useState2[0],
@@ -54,6 +56,15 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
54
56
  _useState0 = (0, _slicedToArray2.default)(_useState9, 2),
55
57
  isMediaViewerVisible = _useState0[0],
56
58
  setMediaViewerVisible = _useState0[1];
59
+ var _useState1 = (0, _react.useState)(),
60
+ _useState10 = (0, _slicedToArray2.default)(_useState1, 2),
61
+ fallbackMediaName = _useState10[0],
62
+ setFallbackMediaName = _useState10[1];
63
+ var _useState11 = (0, _react.useState)(false),
64
+ _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
65
+ fallbackMediaNameFetchFailed = _useState12[0],
66
+ setFallbackMediaNameFetchFailed = _useState12[1];
67
+ var fallbackMediaNameFetchAttempted = (0, _react.useRef)(false);
57
68
  var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
58
69
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
59
70
  var pressTracing = (0, _usePressTracing.default)('click-media-inline-card');
@@ -131,6 +142,16 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
131
142
  subscription === null || subscription === void 0 || subscription.unsubscribe();
132
143
  };
133
144
  }, [identifier.collectionName, identifier.id, mediaClient.file]);
145
+ (0, _react.useEffect)(function () {
146
+ if (fileState && fileState.status !== 'error' && !fileState.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current && (0, _expValEquals.expValEquals)('platform_editor_media_name_fallback', 'isEnabled', true)) {
147
+ fallbackMediaNameFetchAttempted.current = true;
148
+ fallbackMediaNameFetcher(fileState.id).then(function (name) {
149
+ return setFallbackMediaName(name);
150
+ }, function () {
151
+ return setFallbackMediaNameFetchFailed(true);
152
+ });
153
+ }
154
+ }, [fileState, fallbackMediaNameFetcher]);
134
155
  if (subscribeError) {
135
156
  var errorMessage = (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'uploading' ? _mediaUi.messages.failed_to_upload : _mediaUi.messages.couldnt_load_file;
136
157
  var errorReason = (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'uploading' ? 'upload' : 'metadata-fetch';
@@ -153,18 +174,29 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
153
174
  }), renderMediaViewer()));
154
175
  }
155
176
 
156
- // Empty file handling
177
+ // Empty file handling — try the fallback name fetcher first if available
157
178
  if (fileState && !fileState.name) {
158
- var _error = new _errors.MediaCardError('metadata-fetch', new _mediaClient.FileFetcherError('emptyFileName', {
159
- id: fileState.id
160
- }));
161
- fireFailedOperationalEvent(_error);
162
- return renderContent( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardErroredView, {
163
- innerRef: copyNodeRef,
164
- message: (intl || defaultIntl).formatMessage(_mediaUi.messages.couldnt_load_file),
165
- isSelected: isSelected,
166
- onClick: onMediaInlineCardClick
167
- }), renderMediaViewer()));
179
+ if (fallbackMediaNameFetcher && !fallbackMediaNameFetchFailed && !fallbackMediaName && (0, _expValEquals.expValEquals)('platform_editor_media_name_fallback', 'isEnabled', true)) {
180
+ // Fetch not yet attempted or in flight — show loading
181
+ return /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardLoadingView, {
182
+ innerRef: copyNodeRef,
183
+ message: (intl || defaultIntl).formatMessage(_mediaUi.messages.loading_file),
184
+ isSelected: isSelected
185
+ });
186
+ }
187
+ if (!(0, _expValEquals.expValEquals)('platform_editor_media_name_fallback', 'isEnabled', true) || !fallbackMediaName) {
188
+ // No fetcher provided or fetch failed — show error
189
+ var _error = new _errors.MediaCardError('metadata-fetch', new _mediaClient.FileFetcherError('emptyFileName', {
190
+ id: fileState.id
191
+ }));
192
+ fireFailedOperationalEvent(_error);
193
+ return renderContent( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardErroredView, {
194
+ innerRef: copyNodeRef,
195
+ message: (intl || defaultIntl).formatMessage(_mediaUi.messages.couldnt_load_file),
196
+ isSelected: isSelected,
197
+ onClick: onMediaInlineCardClick
198
+ }), renderMediaViewer()));
199
+ }
168
200
  }
169
201
  if ((fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'uploading') {
170
202
  return /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardLoadingView, {
@@ -186,8 +218,9 @@ var MediaInlineCardInternal = exports.MediaInlineCardInternal = function MediaIn
186
218
  fireFailedOperationalEvent(undefined, 'failed-processing');
187
219
  }
188
220
  var mediaType = fileState.mediaType,
189
- name = fileState.name,
221
+ fileStateName = fileState.name,
190
222
  mimeType = fileState.mimeType;
223
+ var name = (0, _expValEquals.expValEquals)('platform_editor_media_name_fallback', 'isEnabled', true) ? fileStateName || fallbackMediaName : fileStateName;
191
224
  var linkIcon = /*#__PURE__*/_react.default.createElement(_mimeTypeIcon.MimeTypeIcon, {
192
225
  testId: 'media-inline-card-file-type-icon',
193
226
  size: "small",
@@ -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 = "0.0.0-development";
22
+ var packageVersion = "80.1.0";
23
23
  var SAMPLE_RATE = 0.05;
24
24
 
25
25
  /**
@@ -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 = "0.0.0-development";
12
+ const packageVersion = "80.1.0";
13
13
  export const CardBase = ({
14
14
  identifier,
15
15
  ...otherProps
@@ -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 = "0.0.0-development";
69
+ const packageVersion = "80.1.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: "0.0.0-development",
40
+ packageName: "80.1.0",
41
41
  componentName: 'mediaInlineCard',
42
42
  component: 'mediaInlineCard'
43
43
  };
@@ -5,7 +5,7 @@ import { formatDate } from '@atlaskit/media-ui/formatDate';
5
5
  import { MimeTypeIcon } from '@atlaskit/media-ui/mime-type-icon';
6
6
  import { MediaViewer } from '@atlaskit/media-viewer';
7
7
  import Tooltip from '@atlaskit/tooltip';
8
- import React, { useEffect, useState } from 'react';
8
+ import React, { useEffect, useRef, useState } from 'react';
9
9
  import ReactDOM from 'react-dom';
10
10
  import { createIntl, injectIntl, IntlProvider } from 'react-intl';
11
11
  import { MediaCardError } from '../errors';
@@ -13,6 +13,7 @@ import { fireMediaCardEvent } from '../utils/analytics';
13
13
  import { getErrorStatusPayload, getFailedProcessingStatusPayload, getSucceededStatusPayload } from './mediaInlineCardAnalytics';
14
14
  import { useCopyIntent } from '@atlaskit/media-client-react';
15
15
  import usePressTracing from '@atlaskit/react-ufo/use-press-tracing';
16
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
16
17
  // UI component which renders an inline link in the appropiate state based on a media file
17
18
  export const MediaInlineCardInternal = ({
18
19
  mediaClient,
@@ -23,13 +24,17 @@ export const MediaInlineCardInternal = ({
23
24
  onClick,
24
25
  mediaViewerItems,
25
26
  intl,
26
- viewerOptions
27
+ viewerOptions,
28
+ fallbackMediaNameFetcher
27
29
  }) => {
28
30
  const [fileState, setFileState] = useState();
29
31
  const [subscribeError, setSubscribeError] = useState();
30
32
  const [isSucceededEventSent, setIsSucceededEventSent] = useState(false);
31
33
  const [isFailedEventSent, setIsFailedEventSent] = useState(false);
32
34
  const [isMediaViewerVisible, setMediaViewerVisible] = useState(false);
35
+ const [fallbackMediaName, setFallbackMediaName] = useState();
36
+ const [fallbackMediaNameFetchFailed, setFallbackMediaNameFetchFailed] = useState(false);
37
+ const fallbackMediaNameFetchAttempted = useRef(false);
33
38
  const {
34
39
  createAnalyticsEvent
35
40
  } = useAnalyticsEvents();
@@ -105,6 +110,12 @@ export const MediaInlineCardInternal = ({
105
110
  subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
106
111
  };
107
112
  }, [identifier.collectionName, identifier.id, mediaClient.file]);
113
+ useEffect(() => {
114
+ if (fileState && fileState.status !== 'error' && !fileState.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current && expValEquals('platform_editor_media_name_fallback', 'isEnabled', true)) {
115
+ fallbackMediaNameFetchAttempted.current = true;
116
+ fallbackMediaNameFetcher(fileState.id).then(name => setFallbackMediaName(name), () => setFallbackMediaNameFetchFailed(true));
117
+ }
118
+ }, [fileState, fallbackMediaNameFetcher]);
108
119
  if (subscribeError) {
109
120
  const errorMessage = (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'uploading' ? messages.failed_to_upload : messages.couldnt_load_file;
110
121
  const errorReason = (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'uploading' ? 'upload' : 'metadata-fetch';
@@ -127,18 +138,29 @@ export const MediaInlineCardInternal = ({
127
138
  }), renderMediaViewer()));
128
139
  }
129
140
 
130
- // Empty file handling
141
+ // Empty file handling — try the fallback name fetcher first if available
131
142
  if (fileState && !fileState.name) {
132
- const error = new MediaCardError('metadata-fetch', new FileFetcherError('emptyFileName', {
133
- id: fileState.id
134
- }));
135
- fireFailedOperationalEvent(error);
136
- return renderContent( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
137
- innerRef: copyNodeRef,
138
- message: (intl || defaultIntl).formatMessage(messages.couldnt_load_file),
139
- isSelected: isSelected,
140
- onClick: onMediaInlineCardClick
141
- }), renderMediaViewer()));
143
+ if (fallbackMediaNameFetcher && !fallbackMediaNameFetchFailed && !fallbackMediaName && expValEquals('platform_editor_media_name_fallback', 'isEnabled', true)) {
144
+ // Fetch not yet attempted or in flight — show loading
145
+ return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
146
+ innerRef: copyNodeRef,
147
+ message: (intl || defaultIntl).formatMessage(messages.loading_file),
148
+ isSelected: isSelected
149
+ });
150
+ }
151
+ if (!expValEquals('platform_editor_media_name_fallback', 'isEnabled', true) || !fallbackMediaName) {
152
+ // No fetcher provided or fetch failed — show error
153
+ const error = new MediaCardError('metadata-fetch', new FileFetcherError('emptyFileName', {
154
+ id: fileState.id
155
+ }));
156
+ fireFailedOperationalEvent(error);
157
+ return renderContent( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
158
+ innerRef: copyNodeRef,
159
+ message: (intl || defaultIntl).formatMessage(messages.couldnt_load_file),
160
+ isSelected: isSelected,
161
+ onClick: onMediaInlineCardClick
162
+ }), renderMediaViewer()));
163
+ }
142
164
  }
143
165
  if ((fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'uploading') {
144
166
  return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
@@ -161,9 +183,10 @@ export const MediaInlineCardInternal = ({
161
183
  }
162
184
  const {
163
185
  mediaType,
164
- name,
186
+ name: fileStateName,
165
187
  mimeType
166
188
  } = fileState;
189
+ const name = expValEquals('platform_editor_media_name_fallback', 'isEnabled', true) ? fileStateName || fallbackMediaName : fileStateName;
167
190
  const linkIcon = /*#__PURE__*/React.createElement(MimeTypeIcon, {
168
191
  testId: 'media-inline-card-file-type-icon',
169
192
  size: "small",
@@ -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 = "0.0.0-development";
12
+ const packageVersion = "80.1.0";
13
13
  const SAMPLE_RATE = 0.05;
14
14
 
15
15
  /**
@@ -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 = "0.0.0-development";
14
+ var packageVersion = "80.1.0";
15
15
  export var CardBase = function CardBase(_ref) {
16
16
  var identifier = _ref.identifier,
17
17
  otherProps = _objectWithoutProperties(_ref, _excluded);
@@ -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 = "0.0.0-development";
83
+ var packageVersion = "80.1.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: "0.0.0-development",
104
+ packageName: "80.1.0",
105
105
  componentName: 'mediaInlineCard',
106
106
  component: 'mediaInlineCard'
107
107
  };
@@ -6,7 +6,7 @@ import { formatDate } from '@atlaskit/media-ui/formatDate';
6
6
  import { MimeTypeIcon } from '@atlaskit/media-ui/mime-type-icon';
7
7
  import { MediaViewer } from '@atlaskit/media-viewer';
8
8
  import Tooltip from '@atlaskit/tooltip';
9
- import React, { useEffect, useState } from 'react';
9
+ import React, { useEffect, useRef, useState } from 'react';
10
10
  import ReactDOM from 'react-dom';
11
11
  import { createIntl, injectIntl, IntlProvider } from 'react-intl';
12
12
  import { MediaCardError } from '../errors';
@@ -14,6 +14,7 @@ import { fireMediaCardEvent } from '../utils/analytics';
14
14
  import { getErrorStatusPayload, getFailedProcessingStatusPayload, getSucceededStatusPayload } from './mediaInlineCardAnalytics';
15
15
  import { useCopyIntent } from '@atlaskit/media-client-react';
16
16
  import usePressTracing from '@atlaskit/react-ufo/use-press-tracing';
17
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
17
18
  // UI component which renders an inline link in the appropiate state based on a media file
18
19
  export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
19
20
  var mediaClient = _ref.mediaClient,
@@ -24,7 +25,8 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
24
25
  onClick = _ref.onClick,
25
26
  mediaViewerItems = _ref.mediaViewerItems,
26
27
  intl = _ref.intl,
27
- viewerOptions = _ref.viewerOptions;
28
+ viewerOptions = _ref.viewerOptions,
29
+ fallbackMediaNameFetcher = _ref.fallbackMediaNameFetcher;
28
30
  var _useState = useState(),
29
31
  _useState2 = _slicedToArray(_useState, 2),
30
32
  fileState = _useState2[0],
@@ -45,6 +47,15 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
45
47
  _useState0 = _slicedToArray(_useState9, 2),
46
48
  isMediaViewerVisible = _useState0[0],
47
49
  setMediaViewerVisible = _useState0[1];
50
+ var _useState1 = useState(),
51
+ _useState10 = _slicedToArray(_useState1, 2),
52
+ fallbackMediaName = _useState10[0],
53
+ setFallbackMediaName = _useState10[1];
54
+ var _useState11 = useState(false),
55
+ _useState12 = _slicedToArray(_useState11, 2),
56
+ fallbackMediaNameFetchFailed = _useState12[0],
57
+ setFallbackMediaNameFetchFailed = _useState12[1];
58
+ var fallbackMediaNameFetchAttempted = useRef(false);
48
59
  var _useAnalyticsEvents = useAnalyticsEvents(),
49
60
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
50
61
  var pressTracing = usePressTracing('click-media-inline-card');
@@ -122,6 +133,16 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
122
133
  subscription === null || subscription === void 0 || subscription.unsubscribe();
123
134
  };
124
135
  }, [identifier.collectionName, identifier.id, mediaClient.file]);
136
+ useEffect(function () {
137
+ if (fileState && fileState.status !== 'error' && !fileState.name && fallbackMediaNameFetcher && !fallbackMediaNameFetchAttempted.current && expValEquals('platform_editor_media_name_fallback', 'isEnabled', true)) {
138
+ fallbackMediaNameFetchAttempted.current = true;
139
+ fallbackMediaNameFetcher(fileState.id).then(function (name) {
140
+ return setFallbackMediaName(name);
141
+ }, function () {
142
+ return setFallbackMediaNameFetchFailed(true);
143
+ });
144
+ }
145
+ }, [fileState, fallbackMediaNameFetcher]);
125
146
  if (subscribeError) {
126
147
  var errorMessage = (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'uploading' ? messages.failed_to_upload : messages.couldnt_load_file;
127
148
  var errorReason = (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'uploading' ? 'upload' : 'metadata-fetch';
@@ -144,18 +165,29 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
144
165
  }), renderMediaViewer()));
145
166
  }
146
167
 
147
- // Empty file handling
168
+ // Empty file handling — try the fallback name fetcher first if available
148
169
  if (fileState && !fileState.name) {
149
- var _error = new MediaCardError('metadata-fetch', new FileFetcherError('emptyFileName', {
150
- id: fileState.id
151
- }));
152
- fireFailedOperationalEvent(_error);
153
- return renderContent( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
154
- innerRef: copyNodeRef,
155
- message: (intl || defaultIntl).formatMessage(messages.couldnt_load_file),
156
- isSelected: isSelected,
157
- onClick: onMediaInlineCardClick
158
- }), renderMediaViewer()));
170
+ if (fallbackMediaNameFetcher && !fallbackMediaNameFetchFailed && !fallbackMediaName && expValEquals('platform_editor_media_name_fallback', 'isEnabled', true)) {
171
+ // Fetch not yet attempted or in flight — show loading
172
+ return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
173
+ innerRef: copyNodeRef,
174
+ message: (intl || defaultIntl).formatMessage(messages.loading_file),
175
+ isSelected: isSelected
176
+ });
177
+ }
178
+ if (!expValEquals('platform_editor_media_name_fallback', 'isEnabled', true) || !fallbackMediaName) {
179
+ // No fetcher provided or fetch failed — show error
180
+ var _error = new MediaCardError('metadata-fetch', new FileFetcherError('emptyFileName', {
181
+ id: fileState.id
182
+ }));
183
+ fireFailedOperationalEvent(_error);
184
+ return renderContent( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
185
+ innerRef: copyNodeRef,
186
+ message: (intl || defaultIntl).formatMessage(messages.couldnt_load_file),
187
+ isSelected: isSelected,
188
+ onClick: onMediaInlineCardClick
189
+ }), renderMediaViewer()));
190
+ }
159
191
  }
160
192
  if ((fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'uploading') {
161
193
  return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
@@ -177,8 +209,9 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
177
209
  fireFailedOperationalEvent(undefined, 'failed-processing');
178
210
  }
179
211
  var mediaType = fileState.mediaType,
180
- name = fileState.name,
212
+ fileStateName = fileState.name,
181
213
  mimeType = fileState.mimeType;
214
+ var name = expValEquals('platform_editor_media_name_fallback', 'isEnabled', true) ? fileStateName || fallbackMediaName : fileStateName;
182
215
  var linkIcon = /*#__PURE__*/React.createElement(MimeTypeIcon, {
183
216
  testId: 'media-inline-card-file-type-icon',
184
217
  size: "small",
@@ -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 = "0.0.0-development";
16
+ var packageVersion = "80.1.0";
17
17
  var SAMPLE_RATE = 0.05;
18
18
 
19
19
  /**
@@ -7,7 +7,7 @@ type TitleBoxWrapperStyleArgs = {
7
7
  display?: 'none' | 'flex';
8
8
  };
9
9
  export declare const titleBoxWrapperStyles: {
10
- ({ breakpoint, display, }: TitleBoxWrapperStyleArgs): SerializedStyles;
10
+ ({ breakpoint, display }: TitleBoxWrapperStyleArgs): SerializedStyles;
11
11
  displayName: string;
12
12
  };
13
13
  export declare const titleBoxHeaderStyles: {
@@ -12,6 +12,12 @@ export interface MediaInlineCardProps {
12
12
  onClick?: InlineCardOnClickCallback;
13
13
  mediaViewerItems?: Identifier[];
14
14
  viewerOptions?: ViewerOptionsProps;
15
+ /**
16
+ * Optional fallback fetcher to retrieve the media filename from another service
17
+ * Workaround for #hot-301450 where media service is missing filenames for DC -> Cloud migrated media
18
+ * Receives the file ID and should resolve to the filename string.
19
+ */
20
+ fallbackMediaNameFetcher?: (id: string) => Promise<string>;
15
21
  }
16
22
  export declare const MediaInlineCardInternal: FC<MediaInlineCardProps & WrappedComponentProps>;
17
23
  export declare const MediaInlineCard: React.FC<MediaInlineCardProps>;
@@ -7,7 +7,7 @@ type TitleBoxWrapperStyleArgs = {
7
7
  display?: 'none' | 'flex';
8
8
  };
9
9
  export declare const titleBoxWrapperStyles: {
10
- ({ breakpoint, display, }: TitleBoxWrapperStyleArgs): SerializedStyles;
10
+ ({ breakpoint, display }: TitleBoxWrapperStyleArgs): SerializedStyles;
11
11
  displayName: string;
12
12
  };
13
13
  export declare const titleBoxHeaderStyles: {
@@ -12,6 +12,12 @@ export interface MediaInlineCardProps {
12
12
  onClick?: InlineCardOnClickCallback;
13
13
  mediaViewerItems?: Identifier[];
14
14
  viewerOptions?: ViewerOptionsProps;
15
+ /**
16
+ * Optional fallback fetcher to retrieve the media filename from another service
17
+ * Workaround for #hot-301450 where media service is missing filenames for DC -> Cloud migrated media
18
+ * Receives the file ID and should resolve to the filename string.
19
+ */
20
+ fallbackMediaNameFetcher?: (id: string) => Promise<string>;
15
21
  }
16
22
  export declare const MediaInlineCardInternal: FC<MediaInlineCardProps & WrappedComponentProps>;
17
23
  export declare const MediaInlineCard: React.FC<MediaInlineCardProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "80.0.0",
3
+ "version": "80.1.1",
4
4
  "description": "Includes all media card related components, CardView, CardViewSmall, Card...",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -49,7 +49,7 @@
49
49
  "@atlaskit/react-ufo": "^5.14.0",
50
50
  "@atlaskit/spinner": "^19.1.0",
51
51
  "@atlaskit/theme": "^23.1.0",
52
- "@atlaskit/tmp-editor-statsig": "^62.4.0",
52
+ "@atlaskit/tmp-editor-statsig": "^63.0.0",
53
53
  "@atlaskit/tokens": "^13.0.0",
54
54
  "@atlaskit/tooltip": "^21.1.0",
55
55
  "@atlaskit/ufo": "^0.4.0",