@atlaskit/media-card 70.10.0 → 72.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 +79 -0
- package/dist/cjs/errors.js +76 -5
- package/dist/cjs/files/cardImageView/index.js +58 -89
- package/dist/cjs/files/index.js +0 -6
- package/dist/cjs/index.js +16 -6
- package/dist/cjs/root/card/cardAnalytics.js +33 -19
- package/dist/cjs/root/card/cardConstants.js +8 -0
- package/dist/cjs/root/card/cardLoader.js +66 -124
- package/dist/cjs/root/card/cardState.js +50 -0
- package/dist/cjs/root/card/getCardPreview/cache.js +5 -0
- package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +50 -0
- package/dist/cjs/root/card/getCardPreview/helpers.js +13 -21
- package/dist/cjs/root/card/getCardPreview/index.js +171 -100
- package/dist/cjs/root/card/getCardStatus.js +7 -1
- package/dist/cjs/root/card/index.js +407 -322
- package/dist/cjs/root/cardView.js +115 -76
- package/dist/cjs/root/index.js +9 -1
- package/dist/cjs/root/inline/loader.js +22 -21
- package/dist/cjs/root/inline/{inlineMediaCard.js → mediaInlineCard.js} +72 -25
- package/dist/cjs/root/inlinePlayer.js +5 -15
- package/dist/cjs/root/ui/iconMessage/index.js +17 -9
- package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +36 -115
- package/dist/cjs/root/ui/styled.js +1 -1
- package/dist/cjs/root/ui/titleBox/failedTitleBox.js +7 -3
- package/dist/cjs/utils/analytics.js +26 -43
- package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +16 -9
- package/dist/cjs/utils/dimensionComparer.js +1 -1
- package/dist/cjs/utils/document.js +12 -0
- package/dist/cjs/utils/getDataURIDimension.js +13 -2
- package/dist/cjs/utils/metadata.js +11 -3
- package/dist/cjs/utils/objectURLCache.js +6 -0
- package/dist/cjs/utils/resizeModeToMediaImageProps.js +13 -0
- package/dist/cjs/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/errors.js +42 -2
- package/dist/es2019/files/cardImageView/index.js +12 -46
- package/dist/es2019/files/index.js +1 -1
- package/dist/es2019/index.js +3 -3
- package/dist/es2019/root/card/cardAnalytics.js +23 -17
- package/dist/es2019/root/card/cardConstants.js +1 -0
- package/dist/es2019/root/card/cardLoader.js +47 -53
- package/dist/es2019/root/card/cardState.js +26 -0
- package/dist/es2019/root/card/getCardPreview/cache.js +5 -0
- package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +35 -0
- package/dist/es2019/root/card/getCardPreview/helpers.js +2 -12
- package/dist/es2019/root/card/getCardPreview/index.js +112 -79
- package/dist/es2019/root/card/getCardStatus.js +1 -0
- package/dist/es2019/root/card/index.js +356 -254
- package/dist/es2019/root/cardView.js +98 -58
- package/dist/es2019/root/index.js +2 -1
- package/dist/es2019/root/inline/loader.js +16 -15
- package/dist/es2019/root/inline/mediaInlineCard.js +132 -0
- package/dist/es2019/root/inlinePlayer.js +5 -13
- package/dist/es2019/root/ui/iconMessage/index.js +10 -6
- package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +26 -74
- package/dist/es2019/root/ui/styled.js +1 -0
- package/dist/es2019/root/ui/titleBox/failedTitleBox.js +5 -3
- package/dist/es2019/utils/analytics.js +29 -40
- package/dist/es2019/utils/cardActions/cardActionsDropdownMenu.js +8 -4
- package/dist/es2019/utils/dimensionComparer.js +1 -1
- package/dist/es2019/utils/document.js +1 -0
- package/dist/es2019/utils/getDataURIDimension.js +8 -0
- package/dist/es2019/utils/metadata.js +12 -4
- package/dist/es2019/utils/objectURLCache.js +5 -0
- package/dist/es2019/utils/resizeModeToMediaImageProps.js +6 -0
- package/dist/es2019/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/errors.js +60 -1
- package/dist/esm/files/cardImageView/index.js +55 -87
- package/dist/esm/files/index.js +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/root/card/cardAnalytics.js +23 -18
- package/dist/esm/root/card/cardConstants.js +1 -0
- package/dist/esm/root/card/cardLoader.js +66 -126
- package/dist/esm/root/card/cardState.js +32 -0
- package/dist/esm/root/card/getCardPreview/cache.js +6 -0
- package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +35 -0
- package/dist/esm/root/card/getCardPreview/helpers.js +13 -21
- package/dist/esm/root/card/getCardPreview/index.js +142 -95
- package/dist/esm/root/card/getCardStatus.js +3 -0
- package/dist/esm/root/card/index.js +416 -325
- package/dist/esm/root/cardView.js +114 -73
- package/dist/esm/root/index.js +2 -1
- package/dist/esm/root/inline/loader.js +23 -22
- package/dist/esm/root/inline/mediaInlineCard.js +145 -0
- package/dist/esm/root/inlinePlayer.js +5 -13
- package/dist/esm/root/ui/iconMessage/index.js +12 -7
- package/dist/esm/root/ui/imageRenderer/imageRenderer.js +28 -106
- package/dist/esm/root/ui/styled.js +1 -1
- package/dist/esm/root/ui/titleBox/failedTitleBox.js +6 -3
- package/dist/esm/utils/analytics.js +22 -35
- package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +16 -9
- package/dist/esm/utils/dimensionComparer.js +1 -1
- package/dist/esm/utils/document.js +3 -0
- package/dist/esm/utils/getDataURIDimension.js +8 -0
- package/dist/esm/utils/metadata.js +12 -4
- package/dist/esm/utils/objectURLCache.js +6 -0
- package/dist/esm/utils/resizeModeToMediaImageProps.js +6 -0
- package/dist/esm/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/errors.d.ts +15 -1
- package/dist/types/files/cardImageView/index.d.ts +5 -12
- package/dist/types/files/cardImageView/styled.d.ts +1 -1
- package/dist/types/files/index.d.ts +1 -1
- package/dist/types/index.d.ts +11 -13
- package/dist/types/root/card/cardAnalytics.d.ts +5 -7
- package/dist/types/root/card/cardConstants.d.ts +1 -0
- package/dist/types/root/card/cardLoader.d.ts +4 -18
- package/dist/types/root/card/cardState.d.ts +5 -0
- package/dist/types/root/card/getCardPreview/cache.d.ts +4 -2
- package/dist/types/root/card/getCardPreview/filePreviewStatus.d.ts +5 -0
- package/dist/types/root/card/getCardPreview/helpers.d.ts +4 -5
- package/dist/types/root/card/getCardPreview/index.d.ts +25 -14
- package/dist/types/root/card/getCardStatus.d.ts +1 -0
- package/dist/types/root/card/index.d.ts +18 -15
- package/dist/types/root/cardView.d.ts +14 -8
- package/dist/types/root/index.d.ts +1 -0
- package/dist/types/root/inline/loader.d.ts +8 -8
- package/dist/types/root/inline/{inlineMediaCard.d.ts → mediaInlineCard.d.ts} +4 -4
- package/dist/types/root/inlinePlayer.d.ts +1 -1
- package/dist/types/root/ui/iconMessage/index.d.ts +7 -2
- package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +5 -18
- package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +2 -0
- package/dist/types/types.d.ts +9 -1
- package/dist/types/utils/analytics.d.ts +20 -21
- package/dist/types/utils/cardDimensions.d.ts +5 -1
- package/dist/types/utils/dimensionComparer.d.ts +1 -1
- package/dist/types/utils/document.d.ts +2 -0
- package/dist/types/utils/getDataURIDimension.d.ts +3 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/lazyContent/styled.d.ts +1 -1
- package/dist/types/utils/lightCards/types.d.ts +1 -1
- package/dist/types/utils/metadata.d.ts +2 -2
- package/dist/types/utils/objectURLCache.d.ts +2 -1
- package/dist/types/utils/resizeModeToMediaImageProps.d.ts +5 -0
- package/dist/types/utils/shouldDisplayImageThumbnail.d.ts +1 -1
- package/example-helpers/developmentUseMessage.tsx +14 -0
- package/example-helpers/index.tsx +55 -4
- package/example-helpers/selectableCard.tsx +2 -1
- package/package.json +18 -14
- package/dist/cjs/root/card/getCardPreview/types.js +0 -5
- package/dist/cjs/utils/fileAttributesContext.js +0 -40
- package/dist/es2019/root/card/getCardPreview/types.js +0 -1
- package/dist/es2019/root/inline/inlineMediaCard.js +0 -92
- package/dist/es2019/utils/fileAttributesContext.js +0 -19
- package/dist/esm/root/card/getCardPreview/types.js +0 -1
- package/dist/esm/root/inline/inlineMediaCard.js +0 -100
- package/dist/esm/utils/fileAttributesContext.js +0 -18
- package/dist/types/root/card/getCardPreview/types.d.ts +0 -5
- package/dist/types/utils/fileAttributesContext.d.ts +0 -10
|
@@ -12,7 +12,7 @@ import { Wrapper } from './styled';
|
|
|
12
12
|
import { createAndFireMediaCardEvent } from '../utils/analytics';
|
|
13
13
|
import { attachDetailsToActions } from '../actions';
|
|
14
14
|
import { getErrorMessage } from '../utils/getErrorMessage';
|
|
15
|
-
import { toHumanReadableMediaSize } from '@atlaskit/media-ui';
|
|
15
|
+
import { toHumanReadableMediaSize, messages } from '@atlaskit/media-ui';
|
|
16
16
|
import { NewFileExperienceWrapper, CardImageContainer, calcBreakpointSize } from './ui/styled';
|
|
17
17
|
import { ImageRenderer } from './ui/imageRenderer/imageRenderer';
|
|
18
18
|
import { TitleBox } from './ui/titleBox/titleBox';
|
|
@@ -26,10 +26,10 @@ import Tooltip from '@atlaskit/tooltip';
|
|
|
26
26
|
import { IconWrapper } from './ui/iconWrapper/styled';
|
|
27
27
|
import { MimeTypeIcon } from '@atlaskit/media-ui/mime-type-icon';
|
|
28
28
|
import SpinnerIcon from '@atlaskit/spinner';
|
|
29
|
-
import { PreviewUnavailable, CreatingPreview,
|
|
30
|
-
import { LoadingRateLimited } from './ui/loadingRateLimited/loadingRateLimited';
|
|
29
|
+
import { PreviewUnavailable, CreatingPreview, FailedToUpload, PreviewCurrentlyUnavailable, FailedToLoad } from './ui/iconMessage';
|
|
31
30
|
import { isRateLimitedError, isPollingError } from '@atlaskit/media-client';
|
|
32
|
-
|
|
31
|
+
import { newFileExperienceClassName } from './card/cardConstants';
|
|
32
|
+
import { isUploadError } from '../errors';
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* This is classic vanilla CardView class. To create an instance of class one would need to supply
|
|
@@ -40,15 +40,37 @@ export class CardViewBase extends React.Component {
|
|
|
40
40
|
super(...args);
|
|
41
41
|
|
|
42
42
|
_defineProperty(this, "state", {
|
|
43
|
-
|
|
43
|
+
didImageRender: false
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
_defineProperty(this, "divRef", /*#__PURE__*/React.createRef());
|
|
47
47
|
|
|
48
|
-
_defineProperty(this, "
|
|
48
|
+
_defineProperty(this, "onImageLoad", () => {
|
|
49
|
+
const {
|
|
50
|
+
onImageLoad
|
|
51
|
+
} = this.props; // We render the icon & icon message always, even if there is dataURI available.
|
|
52
|
+
// If the image fails to load/render, the icon will remain, i.e. the user won't see a change until
|
|
53
|
+
// the root card decides to chage status to error.
|
|
54
|
+
// If the image renders successfully, we switch this variable to hide the icon & icon message
|
|
55
|
+
// behind the thumbnail in case the image has transparency.
|
|
56
|
+
// It is less likely that root component replaces a suceeded dataURI for a failed one
|
|
57
|
+
// than the opposite case. Therefore we prefer to hide the icon instead show when the image fails,
|
|
58
|
+
// for a smoother transition
|
|
59
|
+
|
|
49
60
|
this.setState({
|
|
50
|
-
|
|
61
|
+
didImageRender: true
|
|
51
62
|
});
|
|
63
|
+
onImageLoad && onImageLoad();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
_defineProperty(this, "onImageError", () => {
|
|
67
|
+
const {
|
|
68
|
+
onImageError
|
|
69
|
+
} = this.props;
|
|
70
|
+
this.setState({
|
|
71
|
+
didImageRender: false
|
|
72
|
+
});
|
|
73
|
+
onImageError && onImageError();
|
|
52
74
|
});
|
|
53
75
|
|
|
54
76
|
_defineProperty(this, "saveElementWidth", () => {
|
|
@@ -87,17 +109,14 @@ export class CardViewBase extends React.Component {
|
|
|
87
109
|
dataURI
|
|
88
110
|
} = this.props;
|
|
89
111
|
const {
|
|
90
|
-
mediaType,
|
|
91
112
|
name
|
|
92
113
|
} = metadata || {};
|
|
93
114
|
const shouldUsePointerCursor = status !== 'error' && status !== 'failed-processing';
|
|
94
|
-
const shouldDisplayBackground = !dataURI || !disableOverlay;
|
|
115
|
+
const shouldDisplayBackground = !dataURI || !disableOverlay || status === 'error' || status === 'failed-processing';
|
|
95
116
|
const isPlayButtonClickable = !!(this.shouldRenderPlayButton() && disableOverlay);
|
|
96
|
-
const isTickBoxSelectable = !disableOverlay && !!selectable && !selected; //
|
|
97
|
-
// Intention is to show full file name when it's truncate in titlebox,
|
|
98
|
-
// and to hide it when no titlebox exists.
|
|
117
|
+
const isTickBoxSelectable = !disableOverlay && !!selectable && !selected; // Disable tooltip for Media Single
|
|
99
118
|
|
|
100
|
-
const shouldDisplayTooltip =
|
|
119
|
+
const shouldDisplayTooltip = !disableOverlay;
|
|
101
120
|
return /*#__PURE__*/React.createElement(NewFileExperienceWrapper, {
|
|
102
121
|
className: newFileExperienceClassName,
|
|
103
122
|
"data-testid": testId || 'media-card-view',
|
|
@@ -106,7 +125,6 @@ export class CardViewBase extends React.Component {
|
|
|
106
125
|
onClick: onClick,
|
|
107
126
|
onMouseEnter: onMouseEnter,
|
|
108
127
|
innerRef: this.divRef,
|
|
109
|
-
mediaType: mediaType,
|
|
110
128
|
breakpoint: this.breakpoint,
|
|
111
129
|
shouldUsePointerCursor: shouldUsePointerCursor,
|
|
112
130
|
disableOverlay: !!disableOverlay,
|
|
@@ -166,7 +184,9 @@ export class CardViewBase extends React.Component {
|
|
|
166
184
|
actions: actionsWithDetails,
|
|
167
185
|
disableOverlay: disableOverlay,
|
|
168
186
|
previewOrientation: previewOrientation,
|
|
169
|
-
alt: alt
|
|
187
|
+
alt: alt,
|
|
188
|
+
onImageLoad: this.onImageLoad,
|
|
189
|
+
onImageError: this.onImageError
|
|
170
190
|
});
|
|
171
191
|
});
|
|
172
192
|
|
|
@@ -177,23 +197,23 @@ export class CardViewBase extends React.Component {
|
|
|
177
197
|
metadata,
|
|
178
198
|
disableOverlay,
|
|
179
199
|
error,
|
|
180
|
-
selectable
|
|
200
|
+
selectable,
|
|
201
|
+
disableAnimation
|
|
181
202
|
} = this.props;
|
|
182
203
|
const {
|
|
183
204
|
name,
|
|
184
205
|
mediaType
|
|
185
206
|
} = metadata || {};
|
|
186
207
|
const {
|
|
187
|
-
|
|
208
|
+
didImageRender
|
|
188
209
|
} = this.state;
|
|
189
210
|
const isZeroSize = !!(metadata && metadata.size === 0);
|
|
190
211
|
const defaultConfig = {
|
|
191
|
-
renderTypeIcon:
|
|
192
|
-
renderImageRenderer: !!dataURI
|
|
212
|
+
renderTypeIcon: !didImageRender,
|
|
213
|
+
renderImageRenderer: !!dataURI,
|
|
193
214
|
renderPlayButton: !!dataURI && mediaType === 'video',
|
|
194
215
|
renderBlanket: !disableOverlay,
|
|
195
|
-
renderTitleBox:
|
|
196
|
-
renderFailedTitleBox: !!isImageFailedToLoad,
|
|
216
|
+
renderTitleBox: !disableOverlay && !!name,
|
|
197
217
|
renderTickBox: !disableOverlay && !!selectable
|
|
198
218
|
};
|
|
199
219
|
|
|
@@ -206,46 +226,61 @@ export class CardViewBase extends React.Component {
|
|
|
206
226
|
};
|
|
207
227
|
|
|
208
228
|
case 'processing':
|
|
229
|
+
case 'loading-preview':
|
|
209
230
|
return { ...defaultConfig,
|
|
210
|
-
iconMessage:
|
|
231
|
+
iconMessage: !didImageRender && !isZeroSize ? /*#__PURE__*/React.createElement(CreatingPreview, {
|
|
232
|
+
disableAnimation: disableAnimation
|
|
233
|
+
}) : undefined
|
|
211
234
|
};
|
|
212
235
|
|
|
213
236
|
case 'complete':
|
|
214
|
-
return
|
|
215
|
-
};
|
|
237
|
+
return defaultConfig;
|
|
216
238
|
|
|
217
239
|
case 'error':
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
240
|
+
case 'failed-processing':
|
|
241
|
+
const baseErrorConfig = { ...defaultConfig,
|
|
242
|
+
renderTypeIcon: true,
|
|
243
|
+
renderImageRenderer: false,
|
|
244
|
+
renderTitleBox: false,
|
|
245
|
+
renderPlayButton: false
|
|
246
|
+
};
|
|
247
|
+
let iconMessage;
|
|
248
|
+
let customTitleMessage;
|
|
249
|
+
const {
|
|
250
|
+
secondaryError
|
|
251
|
+
} = error || {};
|
|
252
|
+
|
|
253
|
+
if (isRateLimitedError(secondaryError) || isPollingError(secondaryError)) {
|
|
254
|
+
iconMessage = /*#__PURE__*/React.createElement(PreviewCurrentlyUnavailable, null);
|
|
255
|
+
} else if (isUploadError(error)) {
|
|
256
|
+
iconMessage = /*#__PURE__*/React.createElement(FailedToUpload, null);
|
|
257
|
+
customTitleMessage = messages.failed_to_upload;
|
|
258
|
+
} else if (!metadata) {
|
|
259
|
+
iconMessage = /*#__PURE__*/React.createElement(FailedToLoad, null);
|
|
231
260
|
} else {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
261
|
+
iconMessage = /*#__PURE__*/React.createElement(PreviewUnavailable, null);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (!disableOverlay) {
|
|
265
|
+
const renderFailedTitleBox = !name || !!customTitleMessage;
|
|
266
|
+
return { ...baseErrorConfig,
|
|
267
|
+
renderTitleBox: !!name && !customTitleMessage,
|
|
268
|
+
renderFailedTitleBox,
|
|
269
|
+
iconMessage: !renderFailedTitleBox ? iconMessage : undefined,
|
|
270
|
+
customTitleMessage
|
|
235
271
|
};
|
|
236
272
|
}
|
|
237
273
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
renderFailedTitleBox: !!isImageFailedToLoad || !dataURI && !metadata,
|
|
241
|
-
iconMessage: !!metadata && !isZeroSize ? /*#__PURE__*/React.createElement(PreviewUnavailable, null) : undefined
|
|
274
|
+
return { ...baseErrorConfig,
|
|
275
|
+
iconMessage
|
|
242
276
|
};
|
|
243
277
|
|
|
244
278
|
case 'loading':
|
|
245
279
|
default:
|
|
246
280
|
return { ...defaultConfig,
|
|
281
|
+
renderPlayButton: false,
|
|
247
282
|
renderTypeIcon: false,
|
|
248
|
-
renderSpinner:
|
|
283
|
+
renderSpinner: !didImageRender
|
|
249
284
|
};
|
|
250
285
|
}
|
|
251
286
|
});
|
|
@@ -263,7 +298,7 @@ export class CardViewBase extends React.Component {
|
|
|
263
298
|
renderFailedTitleBox,
|
|
264
299
|
renderTickBox,
|
|
265
300
|
isFixedBlanket,
|
|
266
|
-
|
|
301
|
+
customTitleMessage
|
|
267
302
|
} = this.getRenderConfigByStatus();
|
|
268
303
|
const {
|
|
269
304
|
progress,
|
|
@@ -282,7 +317,7 @@ export class CardViewBase extends React.Component {
|
|
|
282
317
|
"data-test-status": status,
|
|
283
318
|
"data-test-progress": progress,
|
|
284
319
|
"data-test-selected": selected ? true : undefined
|
|
285
|
-
}, renderTypeIcon && this.renderMediaTypeIcon(hasTitleBox, iconMessage), renderSpinner && this.renderSpinner(hasTitleBox), renderImageRenderer && this.renderImageRenderer(), renderPlayButton && this.renderPlayButton(hasTitleBox), renderBlanket && this.renderBlanket(!!isFixedBlanket), renderTitleBox && this.renderTitleBox(), renderFailedTitleBox && this.renderFailedTitleBox(), renderProgressBar && this.renderProgressBar(!
|
|
320
|
+
}, renderTypeIcon && this.renderMediaTypeIcon(hasTitleBox, iconMessage), renderSpinner && this.renderSpinner(hasTitleBox), renderImageRenderer && this.renderImageRenderer(), renderPlayButton && this.renderPlayButton(hasTitleBox), renderBlanket && this.renderBlanket(!!isFixedBlanket), renderTitleBox && this.renderTitleBox(), renderFailedTitleBox && this.renderFailedTitleBox(customTitleMessage), renderProgressBar && this.renderProgressBar(!hasTitleBox), renderTickBox && this.renderTickBox()), this.renderActionsBar());
|
|
286
321
|
});
|
|
287
322
|
}
|
|
288
323
|
|
|
@@ -299,13 +334,14 @@ export class CardViewBase extends React.Component {
|
|
|
299
334
|
}) {
|
|
300
335
|
const {
|
|
301
336
|
dataURI
|
|
302
|
-
} = this.props;
|
|
337
|
+
} = this.props; // We should only switch didImageRender to false
|
|
338
|
+
// when dataURI goes undefined, not when it is updated.
|
|
339
|
+
// as this method could be triggered after onImageLoad callback,
|
|
340
|
+
// falling on a race condition
|
|
303
341
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
});
|
|
308
|
-
}
|
|
342
|
+
prevDataURI && !dataURI && this.setState({
|
|
343
|
+
didImageRender: false
|
|
344
|
+
});
|
|
309
345
|
}
|
|
310
346
|
|
|
311
347
|
// This width is only used to calculate breakpoints, dimensions are passed down as
|
|
@@ -424,9 +460,10 @@ export class CardViewBase extends React.Component {
|
|
|
424
460
|
});
|
|
425
461
|
}
|
|
426
462
|
|
|
427
|
-
renderFailedTitleBox() {
|
|
463
|
+
renderFailedTitleBox(customMessage) {
|
|
428
464
|
return /*#__PURE__*/React.createElement(FailedTitleBox, {
|
|
429
|
-
breakpoint: this.breakpoint
|
|
465
|
+
breakpoint: this.breakpoint,
|
|
466
|
+
customMessage: customMessage
|
|
430
467
|
});
|
|
431
468
|
}
|
|
432
469
|
|
|
@@ -451,17 +488,20 @@ export class CardViewBase extends React.Component {
|
|
|
451
488
|
alt,
|
|
452
489
|
resizeMode,
|
|
453
490
|
onDisplayImage,
|
|
454
|
-
|
|
491
|
+
nativeLazyLoad,
|
|
492
|
+
forceSyncDisplay
|
|
455
493
|
} = this.props;
|
|
456
494
|
return !!dataURI && /*#__PURE__*/React.createElement(ImageRenderer, {
|
|
457
495
|
dataURI: dataURI,
|
|
458
496
|
mediaType: mediaType,
|
|
459
|
-
mediaItemType: mediaItemType,
|
|
460
497
|
previewOrientation: previewOrientation,
|
|
461
498
|
alt: alt,
|
|
462
499
|
resizeMode: resizeMode,
|
|
463
500
|
onDisplayImage: onDisplayImage,
|
|
464
|
-
|
|
501
|
+
onImageLoad: this.onImageLoad,
|
|
502
|
+
onImageError: this.onImageError,
|
|
503
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
504
|
+
forceSyncDisplay: forceSyncDisplay
|
|
465
505
|
});
|
|
466
506
|
}
|
|
467
507
|
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default as Card } from './card/cardLoader';
|
|
1
|
+
export { default as Card } from './card/cardLoader';
|
|
2
|
+
export { default as MediaInlineCard } from './inline/loader';
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export default class
|
|
3
|
+
import { MediaInlineCardLoadingView } from '@atlaskit/media-ui';
|
|
4
|
+
export default class MediaInlineCardLoader extends React.PureComponent {
|
|
5
5
|
constructor(...args) {
|
|
6
6
|
super(...args);
|
|
7
7
|
|
|
8
8
|
_defineProperty(this, "state", {
|
|
9
|
-
|
|
9
|
+
MediaInlineCard: MediaInlineCardLoader.MediaInlineCard,
|
|
10
|
+
ErrorBoundary: MediaInlineCardLoader.ErrorBoundary
|
|
10
11
|
});
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
async componentDidMount() {
|
|
14
|
-
if (!this.state.
|
|
15
|
+
if (!this.state.MediaInlineCard) {
|
|
15
16
|
try {
|
|
16
17
|
const [mediaClient, cardModule, mediaCardErrorBoundaryModule] = await Promise.all([import(
|
|
17
18
|
/* webpackChunkName: "@atlaskit-internal_media-client" */
|
|
18
19
|
'@atlaskit/media-client'), import(
|
|
19
20
|
/* webpackChunkName: "@atlaskit-internal_inline-media-card" */
|
|
20
|
-
'./
|
|
21
|
+
'./mediaInlineCard'), import(
|
|
21
22
|
/* webpackChunkName: "@atlaskit-internal_media-card-error-boundary" */
|
|
22
23
|
'../media-card-analytics-error-boundary')]);
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
MediaInlineCardLoader.MediaInlineCard = mediaClient.withMediaClient(cardModule.MediaInlineCard);
|
|
25
|
+
MediaInlineCardLoader.ErrorBoundary = mediaCardErrorBoundaryModule.default;
|
|
25
26
|
this.setState({
|
|
26
|
-
|
|
27
|
-
ErrorBoundary:
|
|
27
|
+
MediaInlineCard: MediaInlineCardLoader.MediaInlineCard,
|
|
28
|
+
ErrorBoundary: MediaInlineCardLoader.ErrorBoundary
|
|
28
29
|
});
|
|
29
30
|
} catch (error) {}
|
|
30
31
|
}
|
|
@@ -32,19 +33,19 @@ export default class InlineMediaCardLoader extends React.PureComponent {
|
|
|
32
33
|
|
|
33
34
|
render() {
|
|
34
35
|
const {
|
|
35
|
-
|
|
36
|
+
MediaInlineCard,
|
|
36
37
|
ErrorBoundary
|
|
37
38
|
} = this.state;
|
|
38
39
|
|
|
39
|
-
if (!
|
|
40
|
-
return /*#__PURE__*/React.createElement(
|
|
41
|
-
|
|
40
|
+
if (!MediaInlineCard || !ErrorBoundary) {
|
|
41
|
+
return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
|
|
42
|
+
message: ""
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(
|
|
46
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(MediaInlineCard, this.props));
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
_defineProperty(
|
|
51
|
+
_defineProperty(MediaInlineCardLoader, "displayName", 'MediaInlineCardLoader');
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import { injectIntl } from 'react-intl';
|
|
4
|
+
import { MediaInlineCardLoadedView, MediaInlineCardLoadingView, MediaInlineCardErroredView, messages } from '@atlaskit/media-ui';
|
|
5
|
+
import { MediaTypeIcon } from '@atlaskit/media-ui/media-type-icon';
|
|
6
|
+
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
7
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
8
|
+
import { formatDate } from '@atlaskit/media-ui/formatDate';
|
|
9
|
+
// UI component which renders an inline link in the appropiate state based on a media file
|
|
10
|
+
export const MediaInlineCardInternal = ({
|
|
11
|
+
mediaClient,
|
|
12
|
+
identifier,
|
|
13
|
+
shouldOpenMediaViewer,
|
|
14
|
+
isSelected,
|
|
15
|
+
onClick,
|
|
16
|
+
mediaViewerDataSource,
|
|
17
|
+
intl
|
|
18
|
+
}) => {
|
|
19
|
+
const [fileState, setFileState] = useState();
|
|
20
|
+
const [isErrored, setIsErrored] = useState(false);
|
|
21
|
+
const [isMediaViewerVisible, setMediaViewerVisible] = useState(false);
|
|
22
|
+
|
|
23
|
+
const onMediaInlineCardClick = event => {
|
|
24
|
+
if (shouldOpenMediaViewer) {
|
|
25
|
+
setMediaViewerVisible(true);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (onClick) {
|
|
29
|
+
onClick(event);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const onMediaViewerClose = () => setMediaViewerVisible(false);
|
|
34
|
+
|
|
35
|
+
const renderMediaViewer = () => {
|
|
36
|
+
if (isMediaViewerVisible) {
|
|
37
|
+
const dataSource = mediaViewerDataSource || {
|
|
38
|
+
list: []
|
|
39
|
+
};
|
|
40
|
+
return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(MediaViewer, {
|
|
41
|
+
collectionName: identifier.collectionName || '',
|
|
42
|
+
dataSource: dataSource,
|
|
43
|
+
mediaClientConfig: mediaClient.mediaClientConfig,
|
|
44
|
+
selectedItem: identifier,
|
|
45
|
+
onClose: onMediaViewerClose
|
|
46
|
+
}), document.body);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return null;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
mediaClient.file.getFileState(identifier.id, {
|
|
54
|
+
collectionName: identifier.collectionName
|
|
55
|
+
}).subscribe({
|
|
56
|
+
next: fileState => {
|
|
57
|
+
setFileState(fileState);
|
|
58
|
+
},
|
|
59
|
+
error: () => {
|
|
60
|
+
setIsErrored(true);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}, [identifier.collectionName, identifier.id, mediaClient.file]);
|
|
64
|
+
|
|
65
|
+
if (!fileState) {
|
|
66
|
+
return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
|
|
67
|
+
message: intl.formatMessage(messages.loading_file),
|
|
68
|
+
isSelected: isSelected
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (isErrored) {
|
|
73
|
+
return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
|
|
74
|
+
message: intl.formatMessage(messages.couldnt_load_file),
|
|
75
|
+
isSelected: isSelected
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (fileState.status === 'error') {
|
|
80
|
+
return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
|
|
81
|
+
message: fileState.message || '',
|
|
82
|
+
isSelected: isSelected
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (fileState.status === 'failed-processing') {
|
|
87
|
+
return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
|
|
88
|
+
message: intl.formatMessage(messages.couldnt_load_file),
|
|
89
|
+
isSelected: isSelected
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (fileState.status === 'uploading') {
|
|
94
|
+
return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
|
|
95
|
+
message: fileState.name,
|
|
96
|
+
isSelected: isSelected
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const {
|
|
101
|
+
mediaType,
|
|
102
|
+
name
|
|
103
|
+
} = fileState;
|
|
104
|
+
const linkIcon = /*#__PURE__*/React.createElement(MediaTypeIcon, {
|
|
105
|
+
testId: 'media-inline-card-file-type-icon',
|
|
106
|
+
size: "small",
|
|
107
|
+
type: mediaType
|
|
108
|
+
});
|
|
109
|
+
const mediaViewer = renderMediaViewer();
|
|
110
|
+
let formattedDate;
|
|
111
|
+
|
|
112
|
+
if (fileState.createdAt) {
|
|
113
|
+
const {
|
|
114
|
+
locale = 'en'
|
|
115
|
+
} = intl || {
|
|
116
|
+
locale: 'en'
|
|
117
|
+
};
|
|
118
|
+
formattedDate = formatDate(fileState.createdAt, locale);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
122
|
+
position: "bottom",
|
|
123
|
+
content: formattedDate,
|
|
124
|
+
tag: "span"
|
|
125
|
+
}, /*#__PURE__*/React.createElement(MediaInlineCardLoadedView, {
|
|
126
|
+
icon: linkIcon,
|
|
127
|
+
title: name,
|
|
128
|
+
onClick: onMediaInlineCardClick,
|
|
129
|
+
isSelected: isSelected
|
|
130
|
+
})), mediaViewer);
|
|
131
|
+
};
|
|
132
|
+
export const MediaInlineCard = injectIntl(MediaInlineCardInternal);
|
|
@@ -7,8 +7,6 @@ import { CustomMediaPlayer, InactivityDetector } from '@atlaskit/media-ui';
|
|
|
7
7
|
import { InlinePlayerWrapper } from './styled';
|
|
8
8
|
import { defaultImageCardDimensions } from '..';
|
|
9
9
|
import { CardLoading } from '../utils/lightCards/cardLoading';
|
|
10
|
-
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
11
|
-
import { createAndFireMediaCardEvent } from '../utils/analytics';
|
|
12
10
|
export const inlinePlayerClassName = 'media-card-inline-player';
|
|
13
11
|
export const getPreferredVideoArtifact = fileState => {
|
|
14
12
|
if (fileState.status === 'processed' || fileState.status === 'processing') {
|
|
@@ -193,9 +191,10 @@ export class InlinePlayerBase extends Component {
|
|
|
193
191
|
onClick: onClick,
|
|
194
192
|
innerRef: forwardRef || undefined,
|
|
195
193
|
dimensions: dimensions
|
|
196
|
-
}, /*#__PURE__*/React.createElement(InactivityDetector, null,
|
|
194
|
+
}, /*#__PURE__*/React.createElement(InactivityDetector, null, checkMouseMovement => /*#__PURE__*/React.createElement(CustomMediaPlayer, {
|
|
197
195
|
type: "video",
|
|
198
196
|
src: fileSrc,
|
|
197
|
+
fileId: identifier.id,
|
|
199
198
|
isAutoPlay: true,
|
|
200
199
|
isHDAvailable: false,
|
|
201
200
|
onDownloadClick: this.onDownloadClick,
|
|
@@ -203,7 +202,8 @@ export class InlinePlayerBase extends Component {
|
|
|
203
202
|
lastWatchTimeConfig: {
|
|
204
203
|
contentId: identifier.id
|
|
205
204
|
},
|
|
206
|
-
originalDimensions: originalDimensions
|
|
205
|
+
originalDimensions: originalDimensions,
|
|
206
|
+
showControls: checkMouseMovement
|
|
207
207
|
})));
|
|
208
208
|
}
|
|
209
209
|
|
|
@@ -218,12 +218,4 @@ const InlinePlayerForwardRef = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
218
218
|
forwardRef: ref
|
|
219
219
|
}));
|
|
220
220
|
});
|
|
221
|
-
export const InlinePlayer =
|
|
222
|
-
onClick: createAndFireMediaCardEvent({
|
|
223
|
-
eventType: 'ui',
|
|
224
|
-
action: 'clicked',
|
|
225
|
-
actionSubject: 'mediaCard',
|
|
226
|
-
actionSubjectId: 'mediaCardInlinePlayer',
|
|
227
|
-
attributes: {}
|
|
228
|
-
})
|
|
229
|
-
})(InlinePlayerForwardRef);
|
|
221
|
+
export const InlinePlayer = InlinePlayerForwardRef;
|
|
@@ -13,16 +13,20 @@ export const IconMessage = ({
|
|
|
13
13
|
reducedFont: reducedFont
|
|
14
14
|
}, /*#__PURE__*/React.createElement(FormattedMessage, messageDescriptor));
|
|
15
15
|
};
|
|
16
|
-
export const CreatingPreview =
|
|
16
|
+
export const CreatingPreview = ({
|
|
17
|
+
disableAnimation
|
|
18
|
+
}) => /*#__PURE__*/React.createElement(IconMessage, {
|
|
17
19
|
messageDescriptor: messages.creating_preview,
|
|
18
|
-
animated:
|
|
19
|
-
})
|
|
20
|
+
animated: !disableAnimation
|
|
21
|
+
});
|
|
20
22
|
export const PreviewUnavailable = props => /*#__PURE__*/React.createElement(IconMessage, _extends({}, props, {
|
|
21
23
|
messageDescriptor: messages.preview_unavailable
|
|
22
24
|
}));
|
|
23
|
-
export const
|
|
24
|
-
messageDescriptor: messages.
|
|
25
|
-
|
|
25
|
+
export const FailedToLoad = props => /*#__PURE__*/React.createElement(IconMessage, _extends({}, props, {
|
|
26
|
+
messageDescriptor: messages.failed_to_load
|
|
27
|
+
}));
|
|
28
|
+
export const FailedToUpload = props => /*#__PURE__*/React.createElement(IconMessage, _extends({}, props, {
|
|
29
|
+
messageDescriptor: messages.failed_to_upload
|
|
26
30
|
}));
|
|
27
31
|
export const PreviewCurrentlyUnavailable = props => /*#__PURE__*/React.createElement(IconMessage, _extends({}, props, {
|
|
28
32
|
messageDescriptor: messages.preview_currently_unavailable,
|