@atlaskit/media-card 71.0.0 → 72.0.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 +18 -0
- package/dist/cjs/errors.js +56 -5
- package/dist/cjs/files/cardImageView/index.js +53 -104
- package/dist/cjs/files/index.js +0 -6
- package/dist/cjs/root/card/cardAnalytics.js +3 -15
- package/dist/cjs/root/card/cardSSRView.js +4 -2
- 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 +91 -94
- package/dist/cjs/root/card/getCardStatus.js +7 -1
- package/dist/cjs/root/card/index.js +271 -266
- package/dist/cjs/root/cardView.js +96 -60
- package/dist/cjs/root/inline/loader.js +2 -1
- package/dist/cjs/root/inline/mediaInlineCard.js +4 -3
- package/dist/cjs/root/ui/iconMessage/index.js +12 -5
- package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +30 -124
- package/dist/cjs/root/ui/titleBox/failedTitleBox.js +7 -3
- package/dist/cjs/utils/analytics.js +6 -44
- package/dist/cjs/utils/dimensionComparer.js +1 -1
- package/dist/cjs/utils/metadata.js +11 -3
- package/dist/cjs/utils/objectURLCache.js +6 -0
- package/dist/cjs/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/errors.js +34 -2
- package/dist/es2019/files/cardImageView/index.js +8 -61
- package/dist/es2019/files/index.js +1 -1
- package/dist/es2019/root/card/cardAnalytics.js +3 -14
- package/dist/es2019/root/card/cardSSRView.js +3 -2
- 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 +71 -74
- package/dist/es2019/root/card/getCardStatus.js +1 -0
- package/dist/es2019/root/card/index.js +193 -171
- package/dist/es2019/root/cardView.js +100 -61
- package/dist/es2019/root/inline/loader.js +2 -1
- package/dist/es2019/root/inline/mediaInlineCard.js +4 -3
- package/dist/es2019/root/ui/iconMessage/index.js +5 -3
- package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +21 -88
- package/dist/es2019/root/ui/titleBox/failedTitleBox.js +5 -3
- package/dist/es2019/utils/analytics.js +5 -34
- package/dist/es2019/utils/dimensionComparer.js +1 -1
- package/dist/es2019/utils/metadata.js +12 -4
- package/dist/es2019/utils/objectURLCache.js +5 -0
- package/dist/es2019/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/errors.js +42 -1
- package/dist/esm/files/cardImageView/index.js +51 -102
- package/dist/esm/files/index.js +1 -1
- package/dist/esm/root/card/cardAnalytics.js +3 -15
- package/dist/esm/root/card/cardSSRView.js +3 -2
- 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 +79 -88
- package/dist/esm/root/card/getCardStatus.js +3 -0
- package/dist/esm/root/card/index.js +278 -268
- package/dist/esm/root/cardView.js +98 -61
- package/dist/esm/root/inline/loader.js +2 -1
- package/dist/esm/root/inline/mediaInlineCard.js +4 -3
- package/dist/esm/root/ui/iconMessage/index.js +7 -3
- package/dist/esm/root/ui/imageRenderer/imageRenderer.js +23 -118
- package/dist/esm/root/ui/titleBox/failedTitleBox.js +6 -3
- package/dist/esm/utils/analytics.js +5 -36
- package/dist/esm/utils/dimensionComparer.js +1 -1
- package/dist/esm/utils/metadata.js +12 -4
- package/dist/esm/utils/objectURLCache.js +6 -0
- package/dist/esm/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/errors.d.ts +9 -1
- package/dist/types/files/cardImageView/index.d.ts +4 -13
- 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 +4 -3
- package/dist/types/root/card/cardAnalytics.d.ts +1 -6
- package/dist/types/root/card/cardSSRView.d.ts +1 -1
- package/dist/types/root/card/cardState.d.ts +5 -0
- package/dist/types/root/card/getCardPreview/cache.d.ts +3 -1
- package/dist/types/root/card/getCardPreview/filePreviewStatus.d.ts +5 -0
- package/dist/types/root/card/getCardPreview/helpers.d.ts +3 -4
- package/dist/types/root/card/getCardPreview/index.d.ts +17 -13
- package/dist/types/root/card/getCardStatus.d.ts +1 -0
- package/dist/types/root/card/index.d.ts +11 -10
- package/dist/types/root/cardView.d.ts +11 -8
- package/dist/types/root/inlinePlayer.d.ts +1 -1
- package/dist/types/root/ui/iconMessage/index.d.ts +2 -1
- package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +2 -13
- package/dist/types/root/ui/styledSSR.d.ts +1 -1
- package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +2 -0
- package/dist/types/styles/mixins.d.ts +1 -1
- package/dist/types/types.d.ts +7 -1
- package/dist/types/utils/analytics.d.ts +6 -15
- package/dist/types/utils/cardDimensions.d.ts +4 -4
- package/dist/types/utils/dimensionComparer.d.ts +1 -1
- package/dist/types/utils/metadata.d.ts +2 -2
- package/dist/types/utils/objectURLCache.d.ts +2 -1
- package/example-helpers/index.tsx +21 -0
- package/package.json +6 -5
- 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/utils/fileAttributesContext.js +0 -19
- package/dist/esm/root/card/getCardPreview/types.js +0 -1
- 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 } from './ui/styled';
|
|
17
17
|
import { CardImageContainer, calcBreakpointSize } from './ui/styledSSR';
|
|
18
18
|
import { ImageRenderer } from './ui/imageRenderer/imageRenderer';
|
|
@@ -27,10 +27,10 @@ import Tooltip from '@atlaskit/tooltip';
|
|
|
27
27
|
import { IconWrapper } from './ui/iconWrapper/styled';
|
|
28
28
|
import { MimeTypeIcon } from '@atlaskit/media-ui/mime-type-icon';
|
|
29
29
|
import SpinnerIcon from '@atlaskit/spinner';
|
|
30
|
-
import { PreviewUnavailable, CreatingPreview,
|
|
31
|
-
import { LoadingRateLimited } from './ui/loadingRateLimited/loadingRateLimited';
|
|
30
|
+
import { PreviewUnavailable, CreatingPreview, FailedToUpload, PreviewCurrentlyUnavailable, FailedToLoad } from './ui/iconMessage';
|
|
32
31
|
import { isRateLimitedError, isPollingError } from '@atlaskit/media-client';
|
|
33
32
|
import { newFileExperienceClassName } from './card/cardConstants';
|
|
33
|
+
import { isUploadError } from '../errors';
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* This is classic vanilla CardView class. To create an instance of class one would need to supply
|
|
@@ -41,15 +41,37 @@ export class CardViewBase extends React.Component {
|
|
|
41
41
|
super(...args);
|
|
42
42
|
|
|
43
43
|
_defineProperty(this, "state", {
|
|
44
|
-
|
|
44
|
+
didImageRender: false
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
_defineProperty(this, "divRef", /*#__PURE__*/React.createRef());
|
|
48
48
|
|
|
49
|
-
_defineProperty(this, "
|
|
49
|
+
_defineProperty(this, "onImageLoad", () => {
|
|
50
|
+
const {
|
|
51
|
+
onImageLoad
|
|
52
|
+
} = this.props; // We render the icon & icon message always, even if there is dataURI available.
|
|
53
|
+
// If the image fails to load/render, the icon will remain, i.e. the user won't see a change until
|
|
54
|
+
// the root card decides to chage status to error.
|
|
55
|
+
// If the image renders successfully, we switch this variable to hide the icon & icon message
|
|
56
|
+
// behind the thumbnail in case the image has transparency.
|
|
57
|
+
// It is less likely that root component replaces a suceeded dataURI for a failed one
|
|
58
|
+
// than the opposite case. Therefore we prefer to hide the icon instead show when the image fails,
|
|
59
|
+
// for a smoother transition
|
|
60
|
+
|
|
61
|
+
this.setState({
|
|
62
|
+
didImageRender: true
|
|
63
|
+
});
|
|
64
|
+
onImageLoad && onImageLoad();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
_defineProperty(this, "onImageError", () => {
|
|
68
|
+
const {
|
|
69
|
+
onImageError
|
|
70
|
+
} = this.props;
|
|
50
71
|
this.setState({
|
|
51
|
-
|
|
72
|
+
didImageRender: false
|
|
52
73
|
});
|
|
74
|
+
onImageError && onImageError();
|
|
53
75
|
});
|
|
54
76
|
|
|
55
77
|
_defineProperty(this, "saveElementWidth", () => {
|
|
@@ -91,7 +113,7 @@ export class CardViewBase extends React.Component {
|
|
|
91
113
|
name
|
|
92
114
|
} = metadata || {};
|
|
93
115
|
const shouldUsePointerCursor = status !== 'error' && status !== 'failed-processing';
|
|
94
|
-
const shouldDisplayBackground = !dataURI || !disableOverlay;
|
|
116
|
+
const shouldDisplayBackground = !dataURI || !disableOverlay || status === 'error' || status === 'failed-processing';
|
|
95
117
|
const isPlayButtonClickable = !!(this.shouldRenderPlayButton() && disableOverlay);
|
|
96
118
|
const isTickBoxSelectable = !disableOverlay && !!selectable && !selected; // Make tooltip optional for media singles - images, videos.
|
|
97
119
|
// Intention is to show full file name when it's truncate in titlebox,
|
|
@@ -136,8 +158,7 @@ export class CardViewBase extends React.Component {
|
|
|
136
158
|
previewOrientation,
|
|
137
159
|
alt,
|
|
138
160
|
onDisplayImage,
|
|
139
|
-
actions
|
|
140
|
-
timeElapsedTillCommenced
|
|
161
|
+
actions
|
|
141
162
|
} = this.props;
|
|
142
163
|
const {
|
|
143
164
|
name,
|
|
@@ -167,7 +188,8 @@ export class CardViewBase extends React.Component {
|
|
|
167
188
|
disableOverlay: disableOverlay,
|
|
168
189
|
previewOrientation: previewOrientation,
|
|
169
190
|
alt: alt,
|
|
170
|
-
|
|
191
|
+
onImageLoad: this.onImageLoad,
|
|
192
|
+
onImageError: this.onImageError
|
|
171
193
|
});
|
|
172
194
|
});
|
|
173
195
|
|
|
@@ -186,16 +208,15 @@ export class CardViewBase extends React.Component {
|
|
|
186
208
|
mediaType
|
|
187
209
|
} = metadata || {};
|
|
188
210
|
const {
|
|
189
|
-
|
|
211
|
+
didImageRender
|
|
190
212
|
} = this.state;
|
|
191
213
|
const isZeroSize = !!(metadata && metadata.size === 0);
|
|
192
214
|
const defaultConfig = {
|
|
193
|
-
renderTypeIcon:
|
|
194
|
-
renderImageRenderer: !!dataURI
|
|
215
|
+
renderTypeIcon: !didImageRender,
|
|
216
|
+
renderImageRenderer: !!dataURI,
|
|
195
217
|
renderPlayButton: !!dataURI && mediaType === 'video',
|
|
196
218
|
renderBlanket: !disableOverlay,
|
|
197
|
-
renderTitleBox:
|
|
198
|
-
renderFailedTitleBox: !!isImageFailedToLoad && !metadata,
|
|
219
|
+
renderTitleBox: !disableOverlay && !!name,
|
|
199
220
|
renderTickBox: !disableOverlay && !!selectable
|
|
200
221
|
};
|
|
201
222
|
|
|
@@ -210,55 +231,72 @@ export class CardViewBase extends React.Component {
|
|
|
210
231
|
case 'processing':
|
|
211
232
|
case 'loading-preview':
|
|
212
233
|
return { ...defaultConfig,
|
|
213
|
-
iconMessage:
|
|
234
|
+
iconMessage: !didImageRender && !isZeroSize ? /*#__PURE__*/React.createElement(CreatingPreview, {
|
|
214
235
|
disableAnimation: disableAnimation
|
|
215
236
|
}) : undefined
|
|
216
237
|
};
|
|
217
238
|
|
|
218
239
|
case 'complete':
|
|
219
|
-
return
|
|
220
|
-
iconMessage: !!isImageFailedToLoad && !!metadata ? /*#__PURE__*/React.createElement(PreviewUnavailable, null) : undefined
|
|
221
|
-
};
|
|
240
|
+
return defaultConfig;
|
|
222
241
|
|
|
223
242
|
case 'error':
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
243
|
+
case 'failed-processing':
|
|
244
|
+
const baseErrorConfig = { ...defaultConfig,
|
|
245
|
+
renderTypeIcon: true,
|
|
246
|
+
renderImageRenderer: false,
|
|
247
|
+
renderTitleBox: false,
|
|
248
|
+
renderPlayButton: false
|
|
249
|
+
};
|
|
250
|
+
let iconMessage;
|
|
251
|
+
|
|
252
|
+
if (!!metadata) {
|
|
253
|
+
if (error) {
|
|
254
|
+
const {
|
|
255
|
+
secondaryError
|
|
256
|
+
} = error;
|
|
257
|
+
|
|
258
|
+
if (isRateLimitedError(secondaryError) || secondaryError && isPollingError(secondaryError)) {
|
|
259
|
+
iconMessage = /*#__PURE__*/React.createElement(PreviewCurrentlyUnavailable, null);
|
|
260
|
+
}
|
|
261
|
+
} else if (!isZeroSize) {
|
|
262
|
+
iconMessage = /*#__PURE__*/React.createElement(PreviewUnavailable, null);
|
|
263
|
+
}
|
|
264
|
+
} else if (!!disableOverlay) {
|
|
265
|
+
iconMessage = /*#__PURE__*/React.createElement(FailedToLoad, null);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (error && isUploadError(error)) {
|
|
269
|
+
if (!disableOverlay) {
|
|
270
|
+
return { ...baseErrorConfig,
|
|
271
|
+
renderFailedTitleBox: true,
|
|
272
|
+
customTitleMessage: messages.failed_to_upload
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return { ...baseErrorConfig,
|
|
277
|
+
renderTitleBox: !metadata && !!name,
|
|
278
|
+
iconMessage: /*#__PURE__*/React.createElement(FailedToUpload, null)
|
|
238
279
|
};
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
renderTitleBox:
|
|
244
|
-
renderFailedTitleBox:
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (!disableOverlay) {
|
|
283
|
+
return { ...baseErrorConfig,
|
|
284
|
+
renderTitleBox: !!name,
|
|
285
|
+
renderFailedTitleBox: !metadata,
|
|
286
|
+
iconMessage
|
|
245
287
|
};
|
|
246
288
|
}
|
|
247
289
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
renderTypeIcon: true,
|
|
251
|
-
renderImageRenderer: false,
|
|
252
|
-
renderTitleBox: !!name && !disableOverlay,
|
|
253
|
-
renderFailedTitleBox: !metadata,
|
|
254
|
-
iconMessage: !!metadata && !isZeroSize ? /*#__PURE__*/React.createElement(PreviewUnavailable, null) : undefined
|
|
290
|
+
return { ...baseErrorConfig,
|
|
291
|
+
iconMessage
|
|
255
292
|
};
|
|
256
293
|
|
|
257
294
|
case 'loading':
|
|
258
295
|
default:
|
|
259
296
|
return { ...defaultConfig,
|
|
297
|
+
renderPlayButton: false,
|
|
260
298
|
renderTypeIcon: false,
|
|
261
|
-
renderSpinner:
|
|
299
|
+
renderSpinner: !didImageRender
|
|
262
300
|
};
|
|
263
301
|
}
|
|
264
302
|
});
|
|
@@ -276,7 +314,7 @@ export class CardViewBase extends React.Component {
|
|
|
276
314
|
renderFailedTitleBox,
|
|
277
315
|
renderTickBox,
|
|
278
316
|
isFixedBlanket,
|
|
279
|
-
|
|
317
|
+
customTitleMessage
|
|
280
318
|
} = this.getRenderConfigByStatus();
|
|
281
319
|
const {
|
|
282
320
|
progress,
|
|
@@ -295,7 +333,7 @@ export class CardViewBase extends React.Component {
|
|
|
295
333
|
"data-test-status": status,
|
|
296
334
|
"data-test-progress": progress,
|
|
297
335
|
"data-test-selected": selected ? true : undefined
|
|
298
|
-
}, 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(!hasTitleBox),
|
|
336
|
+
}, 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());
|
|
299
337
|
});
|
|
300
338
|
}
|
|
301
339
|
|
|
@@ -312,13 +350,14 @@ export class CardViewBase extends React.Component {
|
|
|
312
350
|
}) {
|
|
313
351
|
const {
|
|
314
352
|
dataURI
|
|
315
|
-
} = this.props;
|
|
353
|
+
} = this.props; // We should only switch didImageRender to false
|
|
354
|
+
// when dataURI goes undefined, not when it is updated.
|
|
355
|
+
// as this method could be triggered after onImageLoad callback,
|
|
356
|
+
// falling on a race condition
|
|
316
357
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
});
|
|
321
|
-
}
|
|
358
|
+
prevDataURI && !dataURI && this.setState({
|
|
359
|
+
didImageRender: false
|
|
360
|
+
});
|
|
322
361
|
}
|
|
323
362
|
|
|
324
363
|
// This width is only used to calculate breakpoints, dimensions are passed down as
|
|
@@ -437,9 +476,10 @@ export class CardViewBase extends React.Component {
|
|
|
437
476
|
});
|
|
438
477
|
}
|
|
439
478
|
|
|
440
|
-
renderFailedTitleBox() {
|
|
479
|
+
renderFailedTitleBox(customMessage) {
|
|
441
480
|
return /*#__PURE__*/React.createElement(FailedTitleBox, {
|
|
442
|
-
breakpoint: this.breakpoint
|
|
481
|
+
breakpoint: this.breakpoint,
|
|
482
|
+
customMessage: customMessage
|
|
443
483
|
});
|
|
444
484
|
}
|
|
445
485
|
|
|
@@ -464,8 +504,7 @@ export class CardViewBase extends React.Component {
|
|
|
464
504
|
alt,
|
|
465
505
|
resizeMode,
|
|
466
506
|
onDisplayImage,
|
|
467
|
-
mediaItemType
|
|
468
|
-
timeElapsedTillCommenced
|
|
507
|
+
mediaItemType
|
|
469
508
|
} = this.props;
|
|
470
509
|
return !!dataURI && /*#__PURE__*/React.createElement(ImageRenderer, {
|
|
471
510
|
dataURI: dataURI,
|
|
@@ -475,8 +514,8 @@ export class CardViewBase extends React.Component {
|
|
|
475
514
|
alt: alt,
|
|
476
515
|
resizeMode: resizeMode,
|
|
477
516
|
onDisplayImage: onDisplayImage,
|
|
478
|
-
|
|
479
|
-
|
|
517
|
+
onImageLoad: this.onImageLoad,
|
|
518
|
+
onImageError: this.onImageError
|
|
480
519
|
});
|
|
481
520
|
}
|
|
482
521
|
|
|
@@ -6,7 +6,8 @@ export default class MediaInlineCardLoader extends React.PureComponent {
|
|
|
6
6
|
super(...args);
|
|
7
7
|
|
|
8
8
|
_defineProperty(this, "state", {
|
|
9
|
-
MediaInlineCard: MediaInlineCardLoader.MediaInlineCard
|
|
9
|
+
MediaInlineCard: MediaInlineCardLoader.MediaInlineCard,
|
|
10
|
+
ErrorBoundary: MediaInlineCardLoader.ErrorBoundary
|
|
10
11
|
});
|
|
11
12
|
}
|
|
12
13
|
|
|
@@ -113,14 +113,15 @@ export const MediaInlineCardInternal = ({
|
|
|
113
113
|
formattedDate = formatDate(fileState.createdAt, locale);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
116
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
117
117
|
position: "bottom",
|
|
118
|
-
content: formattedDate
|
|
118
|
+
content: formattedDate,
|
|
119
|
+
tag: "span"
|
|
119
120
|
}, /*#__PURE__*/React.createElement(MediaInlineCardLoadedView, {
|
|
120
121
|
icon: linkIcon,
|
|
121
122
|
title: name,
|
|
122
123
|
onClick: onMediaInlineCardClick,
|
|
123
124
|
isSelected: isSelected
|
|
124
|
-
}), mediaViewer);
|
|
125
|
+
})), mediaViewer);
|
|
125
126
|
};
|
|
126
127
|
export const MediaInlineCard = injectIntl(MediaInlineCardInternal);
|
|
@@ -22,9 +22,11 @@ export const CreatingPreview = ({
|
|
|
22
22
|
export const PreviewUnavailable = props => /*#__PURE__*/React.createElement(IconMessage, _extends({}, props, {
|
|
23
23
|
messageDescriptor: messages.preview_unavailable
|
|
24
24
|
}));
|
|
25
|
-
export const
|
|
26
|
-
messageDescriptor: messages.
|
|
27
|
-
|
|
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
|
|
28
30
|
}));
|
|
29
31
|
export const PreviewCurrentlyUnavailable = props => /*#__PURE__*/React.createElement(IconMessage, _extends({}, props, {
|
|
30
32
|
messageDescriptor: messages.preview_currently_unavailable,
|
|
@@ -1,95 +1,28 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import
|
|
3
|
-
import React from 'react';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
4
3
|
import { MediaImage } from '@atlaskit/media-ui';
|
|
5
|
-
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
6
|
-
import { fireMediaCardEvent, RenderEventAction, getRenderSucceededEventPayload, getRenderFailedFileUriPayload, getRenderFailedExternalUriPayload } from '../../../utils/analytics';
|
|
7
|
-
import { withFileAttributes } from '../../../utils/fileAttributesContext';
|
|
8
4
|
import { resizeModeToMediaImageProps } from '../../../utils/resizeModeToMediaImageProps';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (fileAttributes && this.shouldFireEvent(RenderEventAction.SUCCEEDED)) {
|
|
21
|
-
const timeElapsedTillSucceeded = performance.now();
|
|
22
|
-
const durationSinceCommenced = timeElapsedTillCommenced && timeElapsedTillSucceeded - timeElapsedTillCommenced;
|
|
23
|
-
const performanceAttributes = {
|
|
24
|
-
overall: {
|
|
25
|
-
durationSincePageStart: timeElapsedTillSucceeded,
|
|
26
|
-
durationSinceCommenced
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
fireMediaCardEvent(getRenderSucceededEventPayload(fileAttributes, performanceAttributes), createAnalyticsEvent);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
_defineProperty(this, "onImageError", () => {
|
|
34
|
-
const {
|
|
35
|
-
onImageError,
|
|
36
|
-
fileAttributes
|
|
37
|
-
} = this.props;
|
|
38
|
-
onImageError && onImageError();
|
|
39
|
-
|
|
40
|
-
if (fileAttributes && this.shouldFireEvent(RenderEventAction.FAILED)) {
|
|
41
|
-
const {
|
|
42
|
-
createAnalyticsEvent,
|
|
43
|
-
mediaItemType,
|
|
44
|
-
timeElapsedTillCommenced
|
|
45
|
-
} = this.props;
|
|
46
|
-
const timeElapsedTillFailed = performance.now();
|
|
47
|
-
const durationSinceCommenced = timeElapsedTillCommenced && timeElapsedTillFailed - timeElapsedTillCommenced;
|
|
48
|
-
const performanceAttributes = {
|
|
49
|
-
overall: {
|
|
50
|
-
durationSincePageStart: timeElapsedTillFailed,
|
|
51
|
-
durationSinceCommenced
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
if (mediaItemType === 'file') {
|
|
56
|
-
fireMediaCardEvent(getRenderFailedFileUriPayload(fileAttributes, performanceAttributes), createAnalyticsEvent);
|
|
57
|
-
} else if (mediaItemType === 'external-image') {
|
|
58
|
-
fireMediaCardEvent(getRenderFailedExternalUriPayload(fileAttributes, performanceAttributes), createAnalyticsEvent);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
_defineProperty(this, "shouldFireEvent", action => !this.lastAnalyticsAction || this.lastAnalyticsAction !== action);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
componentDidMount() {
|
|
5
|
+
export const ImageRenderer = ({
|
|
6
|
+
dataURI,
|
|
7
|
+
previewOrientation,
|
|
8
|
+
alt,
|
|
9
|
+
resizeMode,
|
|
10
|
+
onImageLoad,
|
|
11
|
+
onImageError,
|
|
12
|
+
onDisplayImage,
|
|
13
|
+
mediaType
|
|
14
|
+
}) => {
|
|
15
|
+
useEffect(() => {
|
|
67
16
|
// TODO: trigger accordingly with the succeeded event. This could be a breaking change
|
|
68
|
-
const {
|
|
69
|
-
onDisplayImage,
|
|
70
|
-
mediaType
|
|
71
|
-
} = this.props;
|
|
72
|
-
|
|
73
17
|
if (mediaType === 'image' && onDisplayImage) {
|
|
74
18
|
onDisplayImage();
|
|
75
19
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return /*#__PURE__*/React.createElement(MediaImage, _extends({
|
|
86
|
-
dataURI: dataURI,
|
|
87
|
-
alt: alt,
|
|
88
|
-
previewOrientation: previewOrientation,
|
|
89
|
-
onImageLoad: this.onImageLoad,
|
|
90
|
-
onImageError: this.onImageError
|
|
91
|
-
}, resizeModeToMediaImageProps(resizeMode)));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
export const ImageRenderer = withAnalyticsEvents()(withFileAttributes(ImageRendererBase));
|
|
20
|
+
}, [mediaType, onDisplayImage]);
|
|
21
|
+
return /*#__PURE__*/React.createElement(MediaImage, _extends({
|
|
22
|
+
dataURI: dataURI,
|
|
23
|
+
alt: alt,
|
|
24
|
+
previewOrientation: previewOrientation,
|
|
25
|
+
onImageLoad: onImageLoad,
|
|
26
|
+
onImageError: onImageError
|
|
27
|
+
}, resizeModeToMediaImageProps(resizeMode)));
|
|
28
|
+
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TitleBoxWrapper, ErrorMessageWrapper } from './styled';
|
|
3
3
|
import EditorWarningIcon from '@atlaskit/icon/glyph/editor/warning';
|
|
4
|
+
import { messages } from '@atlaskit/media-ui';
|
|
4
5
|
import { R300 } from '@atlaskit/theme/colors';
|
|
5
|
-
import {
|
|
6
|
+
import { FormattedMessage } from 'react-intl';
|
|
6
7
|
export const FailedTitleBox = ({
|
|
7
|
-
breakpoint
|
|
8
|
+
breakpoint,
|
|
9
|
+
customMessage = messages.failed_to_load
|
|
8
10
|
}) => {
|
|
9
11
|
return /*#__PURE__*/React.createElement(TitleBoxWrapper, {
|
|
10
12
|
breakpoint: breakpoint
|
|
@@ -12,5 +14,5 @@ export const FailedTitleBox = ({
|
|
|
12
14
|
label: 'Warning',
|
|
13
15
|
size: 'small',
|
|
14
16
|
primaryColor: R300
|
|
15
|
-
}),
|
|
17
|
+
}), /*#__PURE__*/React.createElement(FormattedMessage, customMessage)));
|
|
16
18
|
};
|
|
@@ -2,14 +2,6 @@ import { getMediaClientErrorReason, isRequestError } from '@atlaskit/media-clien
|
|
|
2
2
|
import { ANALYTICS_MEDIA_CHANNEL } from '@atlaskit/media-common';
|
|
3
3
|
import { createAndFireEvent } from '@atlaskit/analytics-next';
|
|
4
4
|
import { isMediaCardError } from '../errors';
|
|
5
|
-
export let RenderEventAction;
|
|
6
|
-
|
|
7
|
-
(function (RenderEventAction) {
|
|
8
|
-
RenderEventAction["COMMENCED"] = "commenced";
|
|
9
|
-
RenderEventAction["SUCCEEDED"] = "succeeded";
|
|
10
|
-
RenderEventAction["FAILED"] = "failed";
|
|
11
|
-
})(RenderEventAction || (RenderEventAction = {}));
|
|
12
|
-
|
|
13
5
|
export const getFileAttributes = (metadata, fileStatus) => ({
|
|
14
6
|
fileMediatype: metadata.mediaType,
|
|
15
7
|
fileMimetype: metadata.mimeType,
|
|
@@ -30,7 +22,7 @@ export const getRenderPreviewableCardPayload = fileAttributes => ({
|
|
|
30
22
|
export const getRenderCommencedEventPayload = (fileAttributes, performanceAttributes) => {
|
|
31
23
|
return {
|
|
32
24
|
eventType: 'operational',
|
|
33
|
-
action:
|
|
25
|
+
action: 'commenced',
|
|
34
26
|
actionSubject: 'mediaCardRender',
|
|
35
27
|
attributes: {
|
|
36
28
|
fileAttributes,
|
|
@@ -40,7 +32,7 @@ export const getRenderCommencedEventPayload = (fileAttributes, performanceAttrib
|
|
|
40
32
|
};
|
|
41
33
|
export const getRenderSucceededEventPayload = (fileAttributes, performanceAttributes) => ({
|
|
42
34
|
eventType: 'operational',
|
|
43
|
-
action:
|
|
35
|
+
action: 'succeeded',
|
|
44
36
|
actionSubject: 'mediaCardRender',
|
|
45
37
|
attributes: {
|
|
46
38
|
fileAttributes,
|
|
@@ -48,30 +40,9 @@ export const getRenderSucceededEventPayload = (fileAttributes, performanceAttrib
|
|
|
48
40
|
status: 'success'
|
|
49
41
|
}
|
|
50
42
|
});
|
|
51
|
-
export const getFailedFileUriFailReason = fileStatus => {
|
|
52
|
-
if (!fileStatus) {
|
|
53
|
-
// This fail reason will come from a bug, most likely.
|
|
54
|
-
return `unknown-uri`;
|
|
55
|
-
} else if (fileStatus === 'uploading') {
|
|
56
|
-
return 'local-uri';
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return 'remote-uri';
|
|
60
|
-
};
|
|
61
|
-
export const getRenderFailedFileUriPayload = (fileAttributes, performanceAttributes) => ({
|
|
62
|
-
eventType: 'operational',
|
|
63
|
-
action: RenderEventAction.FAILED,
|
|
64
|
-
actionSubject: 'mediaCardRender',
|
|
65
|
-
attributes: {
|
|
66
|
-
fileAttributes,
|
|
67
|
-
performanceAttributes,
|
|
68
|
-
status: 'fail',
|
|
69
|
-
failReason: getFailedFileUriFailReason(fileAttributes.fileStatus)
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
43
|
export const getRenderFailedExternalUriPayload = (fileAttributes, performanceAttributes) => ({
|
|
73
44
|
eventType: 'operational',
|
|
74
|
-
action:
|
|
45
|
+
action: 'failed',
|
|
75
46
|
actionSubject: 'mediaCardRender',
|
|
76
47
|
attributes: {
|
|
77
48
|
fileAttributes,
|
|
@@ -112,7 +83,7 @@ export const getRenderErrorRequestMetadata = error => {
|
|
|
112
83
|
};
|
|
113
84
|
export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes, error) => ({
|
|
114
85
|
eventType: 'operational',
|
|
115
|
-
action:
|
|
86
|
+
action: 'failed',
|
|
116
87
|
actionSubject: 'mediaCardRender',
|
|
117
88
|
attributes: {
|
|
118
89
|
fileAttributes,
|
|
@@ -126,7 +97,7 @@ export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes
|
|
|
126
97
|
});
|
|
127
98
|
export const getRenderFailedFileStatusPayload = (fileAttributes, performanceAttributes) => ({
|
|
128
99
|
eventType: 'operational',
|
|
129
|
-
action:
|
|
100
|
+
action: 'failed',
|
|
130
101
|
actionSubject: 'mediaCardRender',
|
|
131
102
|
attributes: {
|
|
132
103
|
fileAttributes,
|
|
@@ -20,7 +20,7 @@ export const canCompareDimension = (current, next) => {
|
|
|
20
20
|
return false;
|
|
21
21
|
};
|
|
22
22
|
export const isBigger = (current, next) => {
|
|
23
|
-
if (canCompareDimension(current.width, next.width) && canCompareDimension(current.height, next.height)) {
|
|
23
|
+
if (!!current && !!next && canCompareDimension(current.width, next.width) && canCompareDimension(current.height, next.height)) {
|
|
24
24
|
const nextIsHigher = parseInt(`${current.width}`, 10) < parseInt(`${next.width}`, 10);
|
|
25
25
|
const nextIsWider = parseInt(`${current.height}`, 10) < parseInt(`${next.height}`, 10);
|
|
26
26
|
return nextIsHigher || nextIsWider;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isErrorFileState } from '@atlaskit/media-client';
|
|
1
|
+
import { isErrorFileState, isFileIdentifier } from '@atlaskit/media-client';
|
|
2
2
|
|
|
3
3
|
const getProcessingStatusFromFileState = status => {
|
|
4
4
|
switch (status) {
|
|
@@ -13,7 +13,7 @@ const getProcessingStatusFromFileState = status => {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const getFileDetailsFromFileState = state => ({
|
|
17
17
|
id: state.id,
|
|
18
18
|
name: state.name,
|
|
19
19
|
size: state.size,
|
|
@@ -21,6 +21,14 @@ export const getFileDetails = state => !isErrorFileState(state) ? {
|
|
|
21
21
|
createdAt: state.createdAt,
|
|
22
22
|
mediaType: state.mediaType,
|
|
23
23
|
processingStatus: getProcessingStatusFromFileState(state.status)
|
|
24
|
-
}
|
|
25
|
-
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const getFileDetails = (identifier, fileState) => {
|
|
27
|
+
return isFileIdentifier(identifier) ? fileState && !isErrorFileState(fileState) ? getFileDetailsFromFileState(fileState) : {
|
|
28
|
+
id: identifier.id
|
|
29
|
+
} : {
|
|
30
|
+
id: identifier.mediaItemType,
|
|
31
|
+
name: identifier.name || identifier.dataURI,
|
|
32
|
+
mediaType: 'image'
|
|
33
|
+
};
|
|
26
34
|
};
|
|
@@ -42,5 +42,10 @@ export class ObjectURLCache {
|
|
|
42
42
|
this.cache.set(key, value);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
remove(key) {
|
|
46
|
+
const removed = this.cache.remove(key);
|
|
47
|
+
removed && URL.revokeObjectURL(removed.dataURI);
|
|
48
|
+
}
|
|
49
|
+
|
|
45
50
|
}
|
|
46
51
|
export const createObjectURLCache = () => new ObjectURLCache(PREVIEW_CACHE_LRU_SIZE);
|
|
@@ -5,7 +5,7 @@ export const shouldDisplayImageThumbnail = (cardStatus, mediaItemType, dataURI,
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
if (dataURI) {
|
|
8
|
-
return mediaItemType === 'external-image' || mimeType && isMimeTypeSupportedByBrowser(mimeType) || cardStatus === 'complete';
|
|
8
|
+
return mediaItemType === 'external-image' || mimeType && isMimeTypeSupportedByBrowser(mimeType) || cardStatus === 'complete' || cardStatus === 'loading-preview';
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
return false;
|
package/dist/es2019/version.json
CHANGED