@atlaskit/media-picker 64.3.0 → 64.4.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 +17 -0
- package/dist/cjs/components/browser/index.js +26 -28
- package/dist/cjs/components/clipboard/index.js +24 -26
- package/dist/cjs/components/dropzone/dropzone.js +58 -57
- package/dist/cjs/components/dropzone/index.js +33 -35
- package/dist/cjs/components/localUploadReact.js +29 -31
- package/dist/cjs/service/types.js +4 -4
- package/dist/cjs/service/uploadServiceImpl.js +181 -128
- package/dist/cjs/util/analytics.js +3 -1
- package/dist/cjs/util/getPreviewFromBlob.js +30 -32
- package/dist/cjs/util/getPreviewFromImage.js +31 -33
- package/dist/cjs/util/ufoExperiences.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/dropzone/dropzone.js +7 -3
- package/dist/es2019/service/types.js +3 -3
- package/dist/es2019/service/uploadServiceImpl.js +62 -33
- package/dist/es2019/util/analytics.js +4 -1
- package/dist/es2019/util/ufoExperiences.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/browser/index.js +22 -24
- package/dist/esm/components/clipboard/index.js +20 -22
- package/dist/esm/components/dropzone/dropzone.js +58 -57
- package/dist/esm/components/dropzone/index.js +27 -29
- package/dist/esm/components/localUploadReact.js +29 -31
- package/dist/esm/service/types.js +3 -3
- package/dist/esm/service/uploadServiceImpl.js +181 -128
- package/dist/esm/util/analytics.js +4 -1
- package/dist/esm/util/getPreviewFromBlob.js +30 -32
- package/dist/esm/util/getPreviewFromImage.js +31 -33
- package/dist/esm/util/ufoExperiences.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/service/types.d.ts +7 -1
- package/dist/types/service/uploadServiceImpl.d.ts +5 -2
- package/package.json +4 -5
|
@@ -71,7 +71,7 @@ export class UploadServiceImpl {
|
|
|
71
71
|
replaceFileId
|
|
72
72
|
}]);
|
|
73
73
|
}
|
|
74
|
-
addFilesWithSource(files, featureFlags) {
|
|
74
|
+
async addFilesWithSource(files, featureFlags) {
|
|
75
75
|
if (files.length === 0) {
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
@@ -93,47 +93,68 @@ export class UploadServiceImpl {
|
|
|
93
93
|
const touchFileDescriptors = [];
|
|
94
94
|
for (let i = 0; i < files.length; i++) {
|
|
95
95
|
const {
|
|
96
|
-
replaceFileId
|
|
96
|
+
replaceFileId,
|
|
97
|
+
file
|
|
97
98
|
} = files[i];
|
|
98
99
|
touchFileDescriptors.push({
|
|
99
100
|
fileId: replaceFileId || uuidV4(),
|
|
100
101
|
occurrenceKey: uuidV4(),
|
|
101
102
|
collection,
|
|
103
|
+
size: file.size,
|
|
102
104
|
expireAfter
|
|
103
105
|
});
|
|
104
106
|
}
|
|
105
107
|
const traceContext = {
|
|
106
108
|
traceId: getRandomHex(8)
|
|
107
109
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
let touchedFiles;
|
|
111
|
+
let caughtError;
|
|
112
|
+
try {
|
|
113
|
+
touchedFiles = await mediaClient.file.touchFiles(touchFileDescriptors, collection, traceContext);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
caughtError = error;
|
|
116
|
+
}
|
|
117
|
+
const cancellableFileUploads = files.map(({
|
|
118
|
+
file,
|
|
119
|
+
source
|
|
120
|
+
}, i) => {
|
|
121
|
+
var _touchedFiles, _touchedFiles2;
|
|
114
122
|
const {
|
|
115
123
|
fileId: id,
|
|
116
124
|
occurrenceKey
|
|
117
125
|
} = touchFileDescriptors[i];
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return mediaClient.mediaStore.createUpload(1, collection, traceContext).then(res => {
|
|
131
|
-
return res.data[0].id;
|
|
132
|
-
});
|
|
133
|
-
}
|
|
126
|
+
|
|
127
|
+
// exclude rejected files from being uploaded
|
|
128
|
+
const rejectedFile = (_touchedFiles = touchedFiles) === null || _touchedFiles === void 0 ? void 0 : _touchedFiles.rejected.find(({
|
|
129
|
+
fileId: rejectedFileId
|
|
130
|
+
}) => rejectedFileId === id);
|
|
131
|
+
if (rejectedFile) {
|
|
132
|
+
if (this.fileRejectionHandler) {
|
|
133
|
+
this.fileRejectionHandler({
|
|
134
|
+
reason: 'fileSizeLimitExceeded',
|
|
135
|
+
file,
|
|
136
|
+
limit: rejectedFile.error.limit
|
|
137
|
+
});
|
|
134
138
|
}
|
|
135
|
-
|
|
136
|
-
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
const touchedFile = (_touchedFiles2 = touchedFiles) === null || _touchedFiles2 === void 0 ? void 0 : _touchedFiles2.created.find(touchedFile => touchedFile.fileId === id);
|
|
142
|
+
let deferredUploadId;
|
|
143
|
+
const isIdConflictError = caughtError && caughtError instanceof RequestError && caughtError.metadata && caughtError.metadata.statusCode === 409;
|
|
144
|
+
if (touchedFile) {
|
|
145
|
+
deferredUploadId = Promise.resolve(touchedFile.uploadId);
|
|
146
|
+
} else if (isIdConflictError) {
|
|
147
|
+
// will occur when the backend receives a fileId that already exists in which case
|
|
148
|
+
// we will create a single upload session for that file and use that uploadId
|
|
149
|
+
deferredUploadId = mediaClient.mediaStore.createUpload(1, collection, traceContext).then(res => {
|
|
150
|
+
return res.data[0].id;
|
|
151
|
+
});
|
|
152
|
+
} else {
|
|
153
|
+
// in the case of unexpected errors, we want to defer the throwing of the error
|
|
154
|
+
// until after the files-added has been emitted,
|
|
155
|
+
// allows editor to show a broken media card for unexpected errors
|
|
156
|
+
deferredUploadId = Promise.reject(caughtError);
|
|
157
|
+
}
|
|
137
158
|
const uploadableFile = {
|
|
138
159
|
collection,
|
|
139
160
|
content: file,
|
|
@@ -164,16 +185,17 @@ export class UploadServiceImpl {
|
|
|
164
185
|
controller.abort();
|
|
165
186
|
}
|
|
166
187
|
};
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
188
|
+
const {
|
|
189
|
+
unsubscribe
|
|
190
|
+
} = sourceFileObservable.subscribe({
|
|
191
|
+
next: state => {
|
|
170
192
|
if (state.status === 'processing') {
|
|
171
|
-
|
|
193
|
+
unsubscribe();
|
|
172
194
|
if (shouldCopyFileToRecents) {
|
|
173
195
|
mediaClient.emit('file-added', state);
|
|
174
196
|
globalMediaEventEmitter.emit('file-added', state);
|
|
175
197
|
}
|
|
176
|
-
onFileSuccess(cancellableFileUpload, id, traceContext);
|
|
198
|
+
this.onFileSuccess(cancellableFileUpload, id, traceContext);
|
|
177
199
|
}
|
|
178
200
|
},
|
|
179
201
|
error: error => {
|
|
@@ -183,12 +205,16 @@ export class UploadServiceImpl {
|
|
|
183
205
|
this.cancellableFilesUploads[id] = cancellableFileUpload;
|
|
184
206
|
return cancellableFileUpload;
|
|
185
207
|
});
|
|
186
|
-
const
|
|
208
|
+
const filteredCancellableFileUploads = cancellableFileUploads.filter(this.isCancellableFileUpload);
|
|
209
|
+
const mediaFiles = filteredCancellableFileUploads.map(cancellableFileUpload => cancellableFileUpload.mediaFile);
|
|
187
210
|
this.emit('files-added', {
|
|
188
211
|
files: mediaFiles,
|
|
189
212
|
traceContext
|
|
190
213
|
});
|
|
191
|
-
this.emitPreviews(
|
|
214
|
+
this.emitPreviews(filteredCancellableFileUploads);
|
|
215
|
+
}
|
|
216
|
+
isCancellableFileUpload(fileUpload) {
|
|
217
|
+
return fileUpload !== null;
|
|
192
218
|
}
|
|
193
219
|
cancel(id) {
|
|
194
220
|
if (id) {
|
|
@@ -258,4 +284,7 @@ export class UploadServiceImpl {
|
|
|
258
284
|
releaseCancellableFile(mediaFile) {
|
|
259
285
|
delete this.cancellableFilesUploads[mediaFile.id];
|
|
260
286
|
}
|
|
287
|
+
onFileRejection(handler) {
|
|
288
|
+
this.fileRejectionHandler = handler;
|
|
289
|
+
}
|
|
261
290
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { isRequestError } from '@atlaskit/media-client';
|
|
2
|
+
|
|
3
|
+
// Component name will be prefixed with "media-picker-" in logs. Check ufoExperiences in utils files
|
|
4
|
+
|
|
2
5
|
const packageName = "@atlaskit/media-picker";
|
|
3
|
-
const packageVersion = "64.
|
|
6
|
+
const packageVersion = "64.4.0";
|
|
4
7
|
export function getPackageAttributes(componentName) {
|
|
5
8
|
return {
|
|
6
9
|
packageName,
|
|
@@ -2,7 +2,7 @@ import { ConcurrentExperience, ExperiencePerformanceTypes, ExperienceTypes } fro
|
|
|
2
2
|
import { getFeatureFlagKeysAllProducts } from '@atlaskit/media-common';
|
|
3
3
|
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
4
4
|
const packageName = "@atlaskit/media-picker";
|
|
5
|
-
const packageVersion = "64.
|
|
5
|
+
const packageVersion = "64.4.0";
|
|
6
6
|
let ufoExperience;
|
|
7
7
|
const initExperience = (id, componentName) => {
|
|
8
8
|
if (!ufoExperience) {
|
package/dist/es2019/version.json
CHANGED
|
@@ -43,30 +43,28 @@ export var BrowserLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
43
43
|
var _UNSAFE_componentWillMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
44
44
|
var _yield$Promise$all, _yield$Promise$all2, mediaClient, browserModule;
|
|
45
45
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
46
|
-
while (1) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return _context.stop();
|
|
69
|
-
}
|
|
46
|
+
while (1) switch (_context.prev = _context.next) {
|
|
47
|
+
case 0:
|
|
48
|
+
if (this.state.Browser) {
|
|
49
|
+
_context.next = 9;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
_context.next = 3;
|
|
53
|
+
return Promise.all([import( /* webpackChunkName: "@atlaskit-internal_media-client" */'@atlaskit/media-client'), import( /* webpackChunkName: "@atlaskit-internal_media-browser" */'./browser')]);
|
|
54
|
+
case 3:
|
|
55
|
+
_yield$Promise$all = _context.sent;
|
|
56
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
57
|
+
mediaClient = _yield$Promise$all2[0];
|
|
58
|
+
browserModule = _yield$Promise$all2[1];
|
|
59
|
+
BrowserLoader.Browser = mediaClient.withMediaClient(browserModule.Browser, this.props.featureFlags);
|
|
60
|
+
if (this.mounted) {
|
|
61
|
+
this.setState({
|
|
62
|
+
Browser: BrowserLoader.Browser
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
case 9:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context.stop();
|
|
70
68
|
}
|
|
71
69
|
}, _callee, this);
|
|
72
70
|
}));
|
|
@@ -32,28 +32,26 @@ export var ClipboardLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
32
32
|
var _UNSAFE_componentWillMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
33
33
|
var _yield$Promise$all, _yield$Promise$all2, mediaClient, clipboardModule;
|
|
34
34
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
35
|
-
while (1) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return _context.stop();
|
|
56
|
-
}
|
|
35
|
+
while (1) switch (_context.prev = _context.next) {
|
|
36
|
+
case 0:
|
|
37
|
+
if (this.state.Clipboard) {
|
|
38
|
+
_context.next = 9;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
_context.next = 3;
|
|
42
|
+
return Promise.all([import( /* webpackChunkName: "@atlaskit-internal_media-client" */'@atlaskit/media-client'), import( /* webpackChunkName: "@atlaskit-internal_media-clipboard" */'./clipboard')]);
|
|
43
|
+
case 3:
|
|
44
|
+
_yield$Promise$all = _context.sent;
|
|
45
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
46
|
+
mediaClient = _yield$Promise$all2[0];
|
|
47
|
+
clipboardModule = _yield$Promise$all2[1];
|
|
48
|
+
ClipboardLoader.Clipboard = mediaClient.withMediaClient(clipboardModule.Clipboard, this.props.featureFlags);
|
|
49
|
+
this.setState({
|
|
50
|
+
Clipboard: ClipboardLoader.Clipboard
|
|
51
|
+
});
|
|
52
|
+
case 9:
|
|
53
|
+
case "end":
|
|
54
|
+
return _context.stop();
|
|
57
55
|
}
|
|
58
56
|
}, _callee, this);
|
|
59
57
|
}));
|
|
@@ -78,45 +78,43 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
78
78
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(dragEvent) {
|
|
79
79
|
var featureFlags, flattenedDirectoryFiles, files;
|
|
80
80
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
81
|
-
while (1) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
_context.next = 2;
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
return _context.abrupt("return");
|
|
89
|
-
case 2:
|
|
90
|
-
dragEvent.preventDefault();
|
|
91
|
-
dragEvent.stopPropagation();
|
|
92
|
-
featureFlags = _this.props.featureFlags; // refreshes uploadParams as only set once in parent constructor
|
|
93
|
-
_this.setUploadParams(_this.props.config.uploadParams);
|
|
94
|
-
/*
|
|
95
|
-
* Only enable support for folders if (1) the browser is supported (2) feature flag is enabled
|
|
96
|
-
* The file flattening library used to add support for Folders uses a function called webkitEntry.
|
|
97
|
-
* Some browser types are not supported https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitEntries
|
|
98
|
-
*/
|
|
99
|
-
if (!(isWebkitSupported() && getMediaFeatureFlag('folderUploads', featureFlags))) {
|
|
100
|
-
_context.next = 15;
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
_this.fireAnalyticsForFolders(dragEvent.dataTransfer.items);
|
|
104
|
-
_context.next = 10;
|
|
105
|
-
return _this.getFilesFromDragEvent(dragEvent.dataTransfer.items);
|
|
106
|
-
case 10:
|
|
107
|
-
flattenedDirectoryFiles = _context.sent;
|
|
108
|
-
_this.onDropFolders(flattenedDirectoryFiles.length);
|
|
109
|
-
_this.uploadService.addFiles(flattenedDirectoryFiles, featureFlags);
|
|
110
|
-
_context.next = 18;
|
|
81
|
+
while (1) switch (_context.prev = _context.next) {
|
|
82
|
+
case 0:
|
|
83
|
+
if (dragEvent.dataTransfer) {
|
|
84
|
+
_context.next = 2;
|
|
111
85
|
break;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
86
|
+
}
|
|
87
|
+
return _context.abrupt("return");
|
|
88
|
+
case 2:
|
|
89
|
+
dragEvent.preventDefault();
|
|
90
|
+
dragEvent.stopPropagation();
|
|
91
|
+
featureFlags = _this.props.featureFlags; // refreshes uploadParams as only set once in parent constructor
|
|
92
|
+
_this.setUploadParams(_this.props.config.uploadParams);
|
|
93
|
+
/*
|
|
94
|
+
* Only enable support for folders if (1) the browser is supported (2) feature flag is enabled
|
|
95
|
+
* The file flattening library used to add support for Folders uses a function called webkitEntry.
|
|
96
|
+
* Some browser types are not supported https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitEntries
|
|
97
|
+
*/
|
|
98
|
+
if (!(isWebkitSupported() && getMediaFeatureFlag('folderUploads', featureFlags))) {
|
|
99
|
+
_context.next = 15;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
_this.fireAnalyticsForFolders(dragEvent.dataTransfer.items);
|
|
103
|
+
_context.next = 10;
|
|
104
|
+
return _this.getFilesFromDragEvent(dragEvent.dataTransfer.items);
|
|
105
|
+
case 10:
|
|
106
|
+
flattenedDirectoryFiles = _context.sent;
|
|
107
|
+
_this.onDropFolders(flattenedDirectoryFiles.length);
|
|
108
|
+
_this.uploadService.addFiles(flattenedDirectoryFiles, featureFlags);
|
|
109
|
+
_context.next = 18;
|
|
110
|
+
break;
|
|
111
|
+
case 15:
|
|
112
|
+
_this.onDrop(dragEvent);
|
|
113
|
+
files = Array.from(dragEvent.dataTransfer.files);
|
|
114
|
+
_this.uploadService.addFiles(files, featureFlags);
|
|
115
|
+
case 18:
|
|
116
|
+
case "end":
|
|
117
|
+
return _context.stop();
|
|
120
118
|
}
|
|
121
119
|
}, _callee);
|
|
122
120
|
}));
|
|
@@ -124,6 +122,9 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
124
122
|
return _ref.apply(this, arguments);
|
|
125
123
|
};
|
|
126
124
|
}());
|
|
125
|
+
/*
|
|
126
|
+
* Checks how many folders are uploaded in a single drag and drop. Then, fires an analytic event in accordance to this.
|
|
127
|
+
*/
|
|
127
128
|
_defineProperty(_assertThisInitialized(_this), "fireAnalyticsForFolders", function (items) {
|
|
128
129
|
//convert DataTransferItemList into an array of DataTransferItem(s)
|
|
129
130
|
var toArray = Array.from(items);
|
|
@@ -144,27 +145,28 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
144
145
|
_this.fireAnalyticsEvent('folderDroppedInto', folderCount);
|
|
145
146
|
}
|
|
146
147
|
});
|
|
148
|
+
/*
|
|
149
|
+
* Files dropped contains a directory. Thus, flatten the directory to return an array of Files.
|
|
150
|
+
*/
|
|
147
151
|
_defineProperty(_assertThisInitialized(_this), "getFilesFromDragEvent", /*#__PURE__*/function () {
|
|
148
152
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(dragEventItemList) {
|
|
149
153
|
var items, fileSystemEntries, files;
|
|
150
154
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
151
|
-
while (1) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return _context2.stop();
|
|
167
|
-
}
|
|
155
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
156
|
+
case 0:
|
|
157
|
+
items = dragEventItemList; //If items consist of directory or directories, flatten it to grab the files only. Else, just get the files
|
|
158
|
+
_context2.next = 3;
|
|
159
|
+
return getFilesFromItems(items);
|
|
160
|
+
case 3:
|
|
161
|
+
fileSystemEntries = _context2.sent;
|
|
162
|
+
_context2.next = 6;
|
|
163
|
+
return getFilesFromFileSystemEntries(fileSystemEntries);
|
|
164
|
+
case 6:
|
|
165
|
+
files = _context2.sent;
|
|
166
|
+
return _context2.abrupt("return", _this.filterFilesAgainstBlacklist(files));
|
|
167
|
+
case 8:
|
|
168
|
+
case "end":
|
|
169
|
+
return _context2.stop();
|
|
168
170
|
}
|
|
169
171
|
}, _callee2);
|
|
170
172
|
}));
|
|
@@ -181,6 +183,7 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
181
183
|
return !blacklist.includes(file.name);
|
|
182
184
|
});
|
|
183
185
|
});
|
|
186
|
+
// Similar to the onDrop event, but for folders.
|
|
184
187
|
_defineProperty(_assertThisInitialized(_this), "onDropFolders", function (fileCount) {
|
|
185
188
|
if (fileCount > 0) {
|
|
186
189
|
_this.sendAnalyticsAndEmitDragLeave(fileCount);
|
|
@@ -252,8 +255,6 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
252
255
|
// This is required for IE11
|
|
253
256
|
return dataTransfer.files.length;
|
|
254
257
|
}
|
|
255
|
-
|
|
256
|
-
// Similar to the onDrop event, but for folders.
|
|
257
258
|
}, {
|
|
258
259
|
key: "emitDragOver",
|
|
259
260
|
value: function emitDragOver(payload) {
|
|
@@ -33,37 +33,35 @@ export var DropzoneLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
33
33
|
var _UNSAFE_componentWillMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
34
34
|
var _yield$Promise$all, _yield$Promise$all2, mediaClient, dropzoneModule, mediaPickerErrorBoundaryModule;
|
|
35
35
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
36
|
-
while (1) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (!(!this.state.Dropzone || !this.state.MediaPickerErrorBoundary)) {
|
|
40
|
-
_context.next = 16;
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
_context.prev = 1;
|
|
44
|
-
_context.next = 4;
|
|
45
|
-
return Promise.all([import( /* webpackChunkName: "@atlaskit-internal_media-client" */'@atlaskit/media-client'), import( /* webpackChunkName: "@atlaskit-internal_media-dropzone" */'./dropzone'), import( /* webpackChunkName: "@atlaskit-internal_media-picker-error-boundary" */'../media-picker-analytics-error-boundary')]);
|
|
46
|
-
case 4:
|
|
47
|
-
_yield$Promise$all = _context.sent;
|
|
48
|
-
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
|
|
49
|
-
mediaClient = _yield$Promise$all2[0];
|
|
50
|
-
dropzoneModule = _yield$Promise$all2[1];
|
|
51
|
-
mediaPickerErrorBoundaryModule = _yield$Promise$all2[2];
|
|
52
|
-
DropzoneLoader.Dropzone = mediaClient.withMediaClient(dropzoneModule.Dropzone, this.props.featureFlags);
|
|
53
|
-
DropzoneLoader.MediaPickerErrorBoundary = mediaPickerErrorBoundaryModule.default;
|
|
54
|
-
this.setState({
|
|
55
|
-
Dropzone: DropzoneLoader.Dropzone,
|
|
56
|
-
MediaPickerErrorBoundary: DropzoneLoader.MediaPickerErrorBoundary
|
|
57
|
-
});
|
|
36
|
+
while (1) switch (_context.prev = _context.next) {
|
|
37
|
+
case 0:
|
|
38
|
+
if (!(!this.state.Dropzone || !this.state.MediaPickerErrorBoundary)) {
|
|
58
39
|
_context.next = 16;
|
|
59
40
|
break;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
41
|
+
}
|
|
42
|
+
_context.prev = 1;
|
|
43
|
+
_context.next = 4;
|
|
44
|
+
return Promise.all([import( /* webpackChunkName: "@atlaskit-internal_media-client" */'@atlaskit/media-client'), import( /* webpackChunkName: "@atlaskit-internal_media-dropzone" */'./dropzone'), import( /* webpackChunkName: "@atlaskit-internal_media-picker-error-boundary" */'../media-picker-analytics-error-boundary')]);
|
|
45
|
+
case 4:
|
|
46
|
+
_yield$Promise$all = _context.sent;
|
|
47
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
|
|
48
|
+
mediaClient = _yield$Promise$all2[0];
|
|
49
|
+
dropzoneModule = _yield$Promise$all2[1];
|
|
50
|
+
mediaPickerErrorBoundaryModule = _yield$Promise$all2[2];
|
|
51
|
+
DropzoneLoader.Dropzone = mediaClient.withMediaClient(dropzoneModule.Dropzone, this.props.featureFlags);
|
|
52
|
+
DropzoneLoader.MediaPickerErrorBoundary = mediaPickerErrorBoundaryModule.default;
|
|
53
|
+
this.setState({
|
|
54
|
+
Dropzone: DropzoneLoader.Dropzone,
|
|
55
|
+
MediaPickerErrorBoundary: DropzoneLoader.MediaPickerErrorBoundary
|
|
56
|
+
});
|
|
57
|
+
_context.next = 16;
|
|
58
|
+
break;
|
|
59
|
+
case 14:
|
|
60
|
+
_context.prev = 14;
|
|
61
|
+
_context.t0 = _context["catch"](1);
|
|
62
|
+
case 16:
|
|
63
|
+
case "end":
|
|
64
|
+
return _context.stop();
|
|
67
65
|
}
|
|
68
66
|
}, _callee, this, [[1, 14]]);
|
|
69
67
|
}));
|
|
@@ -89,43 +89,41 @@ export var LocalUploadComponentReact = /*#__PURE__*/function (_Component) {
|
|
|
89
89
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(payload) {
|
|
90
90
|
var fileId, _payload$error, errorName, rawError, traceContext, _end2, _end2$duration, uploadDurationMsec;
|
|
91
91
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
92
|
-
while (1) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
status: 'fail',
|
|
106
|
-
failReason: errorName,
|
|
107
|
-
error: !!rawError ? getMediaClientErrorReason(rawError) : 'unknown',
|
|
108
|
-
request: !!rawError ? getRequestMetadata(rawError) : undefined,
|
|
109
|
-
fileAttributes: {
|
|
110
|
-
fileId: fileId
|
|
111
|
-
},
|
|
112
|
-
uploadDurationMsec: uploadDurationMsec,
|
|
113
|
-
traceContext: traceContext
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
failMediaUploadUfoExperience(fileId, {
|
|
92
|
+
while (1) switch (_context.prev = _context.next) {
|
|
93
|
+
case 0:
|
|
94
|
+
fileId = payload.fileId, _payload$error = payload.error, errorName = _payload$error.name, rawError = _payload$error.rawError, traceContext = payload.traceContext;
|
|
95
|
+
_end2 = end("MediaPicker.fireUpload.".concat(fileId)), _end2$duration = _end2.duration, uploadDurationMsec = _end2$duration === void 0 ? -1 : _end2$duration;
|
|
96
|
+
_this.createAndFireAnalyticsEvent({
|
|
97
|
+
eventType: 'operational',
|
|
98
|
+
action: 'failed',
|
|
99
|
+
actionSubject: 'mediaUpload',
|
|
100
|
+
actionSubjectId: 'localMedia',
|
|
101
|
+
attributes: {
|
|
102
|
+
sourceType: 'local',
|
|
103
|
+
serviceName: 'upload',
|
|
104
|
+
status: 'fail',
|
|
117
105
|
failReason: errorName,
|
|
118
106
|
error: !!rawError ? getMediaClientErrorReason(rawError) : 'unknown',
|
|
119
107
|
request: !!rawError ? getRequestMetadata(rawError) : undefined,
|
|
120
108
|
fileAttributes: {
|
|
121
109
|
fileId: fileId
|
|
122
110
|
},
|
|
123
|
-
uploadDurationMsec: uploadDurationMsec
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
111
|
+
uploadDurationMsec: uploadDurationMsec,
|
|
112
|
+
traceContext: traceContext
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
failMediaUploadUfoExperience(fileId, {
|
|
116
|
+
failReason: errorName,
|
|
117
|
+
error: !!rawError ? getMediaClientErrorReason(rawError) : 'unknown',
|
|
118
|
+
request: !!rawError ? getRequestMetadata(rawError) : undefined,
|
|
119
|
+
fileAttributes: {
|
|
120
|
+
fileId: fileId
|
|
121
|
+
},
|
|
122
|
+
uploadDurationMsec: uploadDurationMsec
|
|
123
|
+
});
|
|
124
|
+
case 4:
|
|
125
|
+
case "end":
|
|
126
|
+
return _context.stop();
|
|
129
127
|
}
|
|
130
128
|
}, _callee);
|
|
131
129
|
}));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export var MAX_FILE_SIZE_FOR_PREVIEW = 10e6; // 10 MB
|
|
2
2
|
|
|
3
|
-
export var LocalFileSource
|
|
4
|
-
(function (LocalFileSource) {
|
|
3
|
+
export var LocalFileSource = /*#__PURE__*/function (LocalFileSource) {
|
|
5
4
|
LocalFileSource["PastedFile"] = "pastedFile";
|
|
6
5
|
LocalFileSource["PastedScreenshot"] = "pastedScreenshot";
|
|
7
6
|
LocalFileSource["LocalUpload"] = "localUpload";
|
|
8
|
-
|
|
7
|
+
return LocalFileSource;
|
|
8
|
+
}({});
|