@atlaskit/media-picker 66.3.2 → 66.4.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/components/browser/browser.js +4 -4
  3. package/dist/cjs/components/clipboard/clipboard.js +4 -4
  4. package/dist/cjs/components/dropzone/dropzone.js +7 -4
  5. package/dist/cjs/components/{uploadRejectionFlagGroup/UploadRejectionFlagGroup.js → errorFlagGroup/ErrorFlagGroup.js} +6 -4
  6. package/dist/cjs/components/errorFlagGroup/messages.js +24 -0
  7. package/dist/cjs/components/localUploadReact.js +8 -7
  8. package/dist/cjs/service/uploadServiceImpl.js +16 -0
  9. package/dist/cjs/util/analytics.js +1 -1
  10. package/dist/cjs/util/ufoExperiences.js +1 -1
  11. package/dist/es2019/components/browser/browser.js +4 -4
  12. package/dist/es2019/components/clipboard/clipboard.js +4 -4
  13. package/dist/es2019/components/dropzone/dropzone.js +7 -4
  14. package/dist/es2019/components/{uploadRejectionFlagGroup/UploadRejectionFlagGroup.js → errorFlagGroup/ErrorFlagGroup.js} +7 -5
  15. package/dist/es2019/components/errorFlagGroup/messages.js +18 -0
  16. package/dist/es2019/components/localUploadReact.js +8 -7
  17. package/dist/es2019/service/uploadServiceImpl.js +14 -0
  18. package/dist/es2019/util/analytics.js +1 -1
  19. package/dist/es2019/util/ufoExperiences.js +1 -1
  20. package/dist/esm/components/browser/browser.js +4 -4
  21. package/dist/esm/components/clipboard/clipboard.js +4 -4
  22. package/dist/esm/components/dropzone/dropzone.js +7 -4
  23. package/dist/esm/components/{uploadRejectionFlagGroup/UploadRejectionFlagGroup.js → errorFlagGroup/ErrorFlagGroup.js} +7 -5
  24. package/dist/esm/components/errorFlagGroup/messages.js +18 -0
  25. package/dist/esm/components/localUploadReact.js +8 -7
  26. package/dist/esm/service/uploadServiceImpl.js +16 -0
  27. package/dist/esm/util/analytics.js +1 -1
  28. package/dist/esm/util/ufoExperiences.js +1 -1
  29. package/dist/types/components/errorFlagGroup/ErrorFlagGroup.d.ts +11 -0
  30. package/dist/types/components/errorFlagGroup/messages.d.ts +17 -0
  31. package/dist/types/components/localUploadReact.d.ts +5 -5
  32. package/dist/types/service/types.d.ts +2 -1
  33. package/dist/types/service/uploadServiceImpl.d.ts +3 -1
  34. package/dist/types/types.d.ts +5 -0
  35. package/dist/types-ts4.5/components/errorFlagGroup/ErrorFlagGroup.d.ts +11 -0
  36. package/dist/types-ts4.5/components/errorFlagGroup/messages.d.ts +17 -0
  37. package/dist/types-ts4.5/components/localUploadReact.d.ts +5 -5
  38. package/dist/types-ts4.5/service/types.d.ts +2 -1
  39. package/dist/types-ts4.5/service/uploadServiceImpl.d.ts +3 -1
  40. package/dist/types-ts4.5/types.d.ts +5 -0
  41. package/package.json +7 -7
  42. package/dist/cjs/components/uploadRejectionFlagGroup/messages.js +0 -19
  43. package/dist/es2019/components/uploadRejectionFlagGroup/messages.js +0 -13
  44. package/dist/esm/components/uploadRejectionFlagGroup/messages.js +0 -13
  45. package/dist/types/components/uploadRejectionFlagGroup/UploadRejectionFlagGroup.d.ts +0 -11
  46. package/dist/types/components/uploadRejectionFlagGroup/messages.d.ts +0 -12
  47. package/dist/types-ts4.5/components/uploadRejectionFlagGroup/UploadRejectionFlagGroup.d.ts +0 -11
  48. package/dist/types-ts4.5/components/uploadRejectionFlagGroup/messages.d.ts +0 -12
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/media-picker
2
2
 
3
+ ## 66.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#88717](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/88717) [`d92770eae702`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d92770eae702) - Adding internal eslint opt outs for a new rule `@atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop`.
8
+
9
+ ## 66.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#83551](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83551) [`332beba24a19`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/332beba24a19) - [ux] Displays an error message when an empty file is uploaded
14
+
3
15
  ## 66.3.2
4
16
 
5
17
  ### Patch Changes
@@ -18,7 +18,7 @@ var _mediaCommon = require("@atlaskit/media-common");
18
18
  var _uuidValidate = _interopRequireDefault(require("uuid-validate"));
19
19
  var _localUploadReact = require("../localUploadReact");
20
20
  var _analytics = require("../../util/analytics");
21
- var _UploadRejectionFlagGroup = _interopRequireDefault(require("../uploadRejectionFlagGroup/UploadRejectionFlagGroup"));
21
+ var _ErrorFlagGroup = _interopRequireDefault(require("../errorFlagGroup/ErrorFlagGroup"));
22
22
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
23
23
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
24
24
  var defaultConfig = {
@@ -137,9 +137,9 @@ var BrowserBase = exports.BrowserBase = /*#__PURE__*/function (_LocalUploadCompo
137
137
  multiple: replaceFileId ? false : multiple /* if the consumer passes the fileId we must work in single selection mode */,
138
138
  accept: fileExtensions,
139
139
  onChange: this.onFilePicked
140
- }), children ? children(this.browse) : null, /*#__PURE__*/_react.default.createElement(_UploadRejectionFlagGroup.default, {
141
- flagData: this.state.uploadRejectionFlags,
142
- onFlagDismissed: this.dismissUploadRejectionFlag
140
+ }), children ? children(this.browse) : null, /*#__PURE__*/_react.default.createElement(_ErrorFlagGroup.default, {
141
+ flagData: this.state.errorFlags,
142
+ onFlagDismissed: this.dismissErrorFlag
143
143
  }));
144
144
  }
145
145
  }]);
@@ -18,7 +18,7 @@ var _localUploadReact = require("../localUploadReact");
18
18
  var _types = require("../../service/types");
19
19
  var _analytics = require("../../util/analytics");
20
20
  var _appendTimestamp = require("../../util/appendTimestamp");
21
- var _UploadRejectionFlagGroup = _interopRequireDefault(require("../uploadRejectionFlagGroup/UploadRejectionFlagGroup"));
21
+ var _ErrorFlagGroup = _interopRequireDefault(require("../errorFlagGroup/ErrorFlagGroup"));
22
22
  var _class;
23
23
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
24
24
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
@@ -214,9 +214,9 @@ var ClipboardBase = exports.ClipboardBase = /*#__PURE__*/function (_LocalUploadC
214
214
  }, {
215
215
  key: "render",
216
216
  value: function render() {
217
- return /*#__PURE__*/_react.default.createElement(_UploadRejectionFlagGroup.default, {
218
- flagData: this.state.uploadRejectionFlags,
219
- onFlagDismissed: this.dismissUploadRejectionFlag
217
+ return /*#__PURE__*/_react.default.createElement(_ErrorFlagGroup.default, {
218
+ flagData: this.state.errorFlags,
219
+ onFlagDismissed: this.dismissErrorFlag
220
220
  });
221
221
  }
222
222
  }]);
@@ -21,7 +21,7 @@ var _browser = require("@atlaskit/media-ui/browser");
21
21
  var _flatFiles = require("flat-files");
22
22
  var _localUploadReact = require("../localUploadReact");
23
23
  var _analytics = require("../../util/analytics");
24
- var _UploadRejectionFlagGroup = _interopRequireDefault(require("../uploadRejectionFlagGroup/UploadRejectionFlagGroup"));
24
+ var _ErrorFlagGroup = _interopRequireDefault(require("../errorFlagGroup/ErrorFlagGroup"));
25
25
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
26
26
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
27
27
  function dragContainsFiles(event) {
@@ -42,9 +42,12 @@ var DropzoneBase = exports.DropzoneBase = /*#__PURE__*/function (_LocalUploadCom
42
42
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "uiActive", false);
43
43
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "addContainerListeners", function () {
44
44
  var container = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.getContainer();
45
+ // TODO: migrate this file to Pragmatic drag and drop
46
+ /* eslint-disable @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop */
45
47
  container.addEventListener('dragover', _this.onDragOver, false);
46
48
  container.addEventListener('dragleave', _this.onDragLeave, false);
47
49
  container.addEventListener('drop', _this.onFileDropped);
50
+ /* eslint-enable @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop */
48
51
  });
49
52
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "removeContainerListeners", function () {
50
53
  var container = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.getContainer();
@@ -317,9 +320,9 @@ var DropzoneBase = exports.DropzoneBase = /*#__PURE__*/function (_LocalUploadCom
317
320
  }, {
318
321
  key: "render",
319
322
  value: function render() {
320
- return /*#__PURE__*/_react.default.createElement(_UploadRejectionFlagGroup.default, {
321
- flagData: this.state.uploadRejectionFlags,
322
- onFlagDismissed: this.dismissUploadRejectionFlag
323
+ return /*#__PURE__*/_react.default.createElement(_ErrorFlagGroup.default, {
324
+ flagData: this.state.errorFlags,
325
+ onFlagDismissed: this.dismissErrorFlag
323
326
  });
324
327
  }
325
328
  }]);
@@ -58,15 +58,17 @@ var FlagGroupContent = function FlagGroupContent(_ref) {
58
58
  size: "medium"
59
59
  }),
60
60
  key: i,
61
- title: intl.formatMessage(_messages.uploadRejectionFlagMessages.title),
62
- description: intl.formatMessage(_messages.uploadRejectionFlagMessages.description, {
61
+ title: intl.formatMessage(_messages.errorFlagMessages.errorTitle),
62
+ description: data.reason === 'fileEmpty' ? intl.formatMessage(_messages.errorFlagMessages.fileEmptyDescription, {
63
+ fileName: data.fileName
64
+ }) : intl.formatMessage(_messages.errorFlagMessages.uploadRejectionDescription, {
63
65
  fileName: data.fileName,
64
66
  limit: formatFileSize(data.limit)
65
67
  })
66
68
  });
67
69
  }));
68
70
  };
69
- var UploadRejectionFlagGroup = function UploadRejectionFlagGroup(_ref2) {
71
+ var ErrorFlagGroup = function ErrorFlagGroup(_ref2) {
70
72
  var flagData = _ref2.flagData,
71
73
  onFlagDismissed = _ref2.onFlagDismissed,
72
74
  intl = _ref2.intl;
@@ -80,6 +82,6 @@ var UploadRejectionFlagGroup = function UploadRejectionFlagGroup(_ref2) {
80
82
  onFlagDismissed: onFlagDismissed
81
83
  }));
82
84
  };
83
- var _default = exports.default = (0, _reactIntlNext.injectIntl)(UploadRejectionFlagGroup, {
85
+ var _default = exports.default = (0, _reactIntlNext.injectIntl)(ErrorFlagGroup, {
84
86
  enforceContext: false
85
87
  });
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.errorFlagMessages = void 0;
7
+ var _reactIntlNext = require("react-intl-next");
8
+ var errorFlagMessages = exports.errorFlagMessages = (0, _reactIntlNext.defineMessages)({
9
+ errorTitle: {
10
+ id: 'fabric.media.errorFlagTitle',
11
+ defaultMessage: 'Your file failed to upload',
12
+ description: 'a title for a flag that describes that a file failed to upload'
13
+ },
14
+ uploadRejectionDescription: {
15
+ id: 'fabric.media.uploadRejectionFlagDescription',
16
+ defaultMessage: '{fileName} is too big to upload. Files must be less than {limit}.',
17
+ description: 'a description for a flag detailing that a file was too large to upload'
18
+ },
19
+ fileEmptyDescription: {
20
+ id: 'fabric.media.fileEmptyFlagDescription',
21
+ defaultMessage: 'The file you selected was empty. Please select another file and try again.',
22
+ description: 'a description for a flag detailing that a file was zero bytes'
23
+ }
24
+ });
@@ -34,16 +34,16 @@ var LocalUploadComponentReact = exports.LocalUploadComponentReact = /*#__PURE__*
34
34
  _this = _super.call(this, props);
35
35
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "uploadComponent", new _component.UploadComponent());
36
36
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
37
- uploadRejectionFlags: []
37
+ errorFlags: []
38
38
  });
39
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "addUploadRejectionFlag", function (rejectionData) {
39
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "addErrorFlag", function (flagData) {
40
40
  _this.setState({
41
- uploadRejectionFlags: [].concat((0, _toConsumableArray2.default)(_this.state.uploadRejectionFlags), [rejectionData])
41
+ errorFlags: [].concat((0, _toConsumableArray2.default)(_this.state.errorFlags), [flagData])
42
42
  });
43
43
  });
44
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "dismissUploadRejectionFlag", function () {
44
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "dismissErrorFlag", function () {
45
45
  _this.setState({
46
- uploadRejectionFlags: _this.state.uploadRejectionFlags.slice(1)
46
+ errorFlags: _this.state.errorFlags.slice(1)
47
47
  });
48
48
  });
49
49
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fireCommencedEvent", function (payload) {
@@ -213,16 +213,17 @@ var LocalUploadComponentReact = exports.LocalUploadComponentReact = /*#__PURE__*
213
213
  _this.uploadService.on('file-preview-update', _this.onFilePreviewUpdate);
214
214
  _this.uploadService.on('file-converting', _this.onFileConverting);
215
215
  _this.uploadService.on('file-upload-error', _this.onUploadError);
216
+ _this.uploadService.onFileEmpty(_this.addErrorFlag);
216
217
  if (tenantUploadParams.onUploadRejection) {
217
218
  var onUploadRejection = tenantUploadParams.onUploadRejection;
218
219
  _this.uploadService.onFileRejection(function (rejectionData) {
219
220
  var shouldOverride = onUploadRejection(rejectionData);
220
221
  if (!shouldOverride) {
221
- _this.addUploadRejectionFlag(rejectionData);
222
+ _this.addErrorFlag(rejectionData);
222
223
  }
223
224
  });
224
225
  } else {
225
- _this.uploadService.onFileRejection(_this.addUploadRejectionFlag);
226
+ _this.uploadService.onFileRejection(_this.addErrorFlag);
226
227
  }
227
228
  return _this;
228
229
  }
@@ -247,6 +247,17 @@ var UploadServiceImpl = exports.UploadServiceImpl = /*#__PURE__*/function () {
247
247
  }
248
248
  return null;
249
249
  }
250
+
251
+ // exclude empty files from being uploaded
252
+ if (file.size === 0) {
253
+ if (_this3.fileEmptyHandler) {
254
+ _this3.fileEmptyHandler({
255
+ reason: 'fileEmpty',
256
+ fileName: file.name
257
+ });
258
+ }
259
+ return null;
260
+ }
250
261
  var touchedFile = (_touchedFiles2 = touchedFiles) === null || _touchedFiles2 === void 0 ? void 0 : _touchedFiles2.created.find(function (touchedFile) {
251
262
  return touchedFile.fileId === id;
252
263
  });
@@ -389,6 +400,11 @@ var UploadServiceImpl = exports.UploadServiceImpl = /*#__PURE__*/function () {
389
400
  value: function releaseCancellableFile(mediaFile) {
390
401
  delete this.cancellableFilesUploads[mediaFile.id];
391
402
  }
403
+ }, {
404
+ key: "onFileEmpty",
405
+ value: function onFileEmpty(handler) {
406
+ this.fileEmptyHandler = handler;
407
+ }
392
408
  }, {
393
409
  key: "onFileRejection",
394
410
  value: function onFileRejection(handler) {
@@ -9,7 +9,7 @@ var _mediaClient = require("@atlaskit/media-client");
9
9
  // Component name will be prefixed with "media-picker-" in logs. Check ufoExperiences in utils files
10
10
 
11
11
  var packageName = "@atlaskit/media-picker";
12
- var packageVersion = "66.3.2";
12
+ var packageVersion = "66.4.1";
13
13
  function getPackageAttributes(componentName) {
14
14
  return {
15
15
  packageName: packageName,
@@ -12,7 +12,7 @@ var _mediaClient = require("@atlaskit/media-client");
12
12
  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; }
13
13
  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; }
14
14
  var packageName = "@atlaskit/media-picker";
15
- var packageVersion = "66.3.2";
15
+ var packageVersion = "66.4.1";
16
16
  var ufoExperience;
17
17
  var initExperience = function initExperience(id, componentName) {
18
18
  if (!ufoExperience) {
@@ -5,7 +5,7 @@ import { withMediaAnalyticsContext } from '@atlaskit/media-common';
5
5
  import isValidId from 'uuid-validate';
6
6
  import { LocalUploadComponentReact } from '../localUploadReact';
7
7
  import { getPackageAttributes } from '../../util/analytics';
8
- import UploadRejectionFlagGroup from '../uploadRejectionFlagGroup/UploadRejectionFlagGroup';
8
+ import ErrorFlagGroup from '../errorFlagGroup/ErrorFlagGroup';
9
9
  const defaultConfig = {
10
10
  uploadParams: {}
11
11
  };
@@ -127,9 +127,9 @@ export class BrowserBase extends LocalUploadComponentReact {
127
127
  multiple: replaceFileId ? false : multiple /* if the consumer passes the fileId we must work in single selection mode */,
128
128
  accept: fileExtensions,
129
129
  onChange: this.onFilePicked
130
- }), children ? children(this.browse) : null, /*#__PURE__*/React.createElement(UploadRejectionFlagGroup, {
131
- flagData: this.state.uploadRejectionFlags,
132
- onFlagDismissed: this.dismissUploadRejectionFlag
130
+ }), children ? children(this.browse) : null, /*#__PURE__*/React.createElement(ErrorFlagGroup, {
131
+ flagData: this.state.errorFlags,
132
+ onFlagDismissed: this.dismissErrorFlag
133
133
  }));
134
134
  }
135
135
  }
@@ -7,7 +7,7 @@ import { LocalUploadComponentReact } from '../localUploadReact';
7
7
  import { LocalFileSource } from '../../service/types';
8
8
  import { getPackageAttributes } from '../../util/analytics';
9
9
  import { appendTimestamp } from '../../util/appendTimestamp';
10
- import UploadRejectionFlagGroup from '../uploadRejectionFlagGroup/UploadRejectionFlagGroup';
10
+ import ErrorFlagGroup from '../errorFlagGroup/ErrorFlagGroup';
11
11
  export const getFilesFromClipboard = files => {
12
12
  return Array.from(files).map(file => {
13
13
  if (file.type.indexOf('image/') === 0) {
@@ -173,9 +173,9 @@ export class ClipboardBase extends LocalUploadComponentReact {
173
173
  this.clipboard.deactivate();
174
174
  }
175
175
  render() {
176
- return /*#__PURE__*/React.createElement(UploadRejectionFlagGroup, {
177
- flagData: this.state.uploadRejectionFlags,
178
- onFlagDismissed: this.dismissUploadRejectionFlag
176
+ return /*#__PURE__*/React.createElement(ErrorFlagGroup, {
177
+ flagData: this.state.errorFlags,
178
+ onFlagDismissed: this.dismissErrorFlag
179
179
  });
180
180
  }
181
181
  }
@@ -6,7 +6,7 @@ import { isWebkitSupported } from '@atlaskit/media-ui/browser';
6
6
  import { getFilesFromItems, getFilesFromFileSystemEntries } from 'flat-files';
7
7
  import { LocalUploadComponentReact } from '../localUploadReact';
8
8
  import { getPackageAttributes } from '../../util/analytics';
9
- import UploadRejectionFlagGroup from '../uploadRejectionFlagGroup/UploadRejectionFlagGroup';
9
+ import ErrorFlagGroup from '../errorFlagGroup/ErrorFlagGroup';
10
10
  function dragContainsFiles(event) {
11
11
  if (!event.dataTransfer) {
12
12
  return false;
@@ -22,9 +22,12 @@ export class DropzoneBase extends LocalUploadComponentReact {
22
22
  super(props, COMPONENT_NAME);
23
23
  _defineProperty(this, "uiActive", false);
24
24
  _defineProperty(this, "addContainerListeners", (container = this.getContainer()) => {
25
+ // TODO: migrate this file to Pragmatic drag and drop
26
+ /* eslint-disable @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop */
25
27
  container.addEventListener('dragover', this.onDragOver, false);
26
28
  container.addEventListener('dragleave', this.onDragLeave, false);
27
29
  container.addEventListener('drop', this.onFileDropped);
30
+ /* eslint-enable @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop */
28
31
  });
29
32
  _defineProperty(this, "removeContainerListeners", (container = this.getContainer()) => {
30
33
  container.removeEventListener('dragover', this.onDragOver, false);
@@ -254,9 +257,9 @@ export class DropzoneBase extends LocalUploadComponentReact {
254
257
  }
255
258
  }
256
259
  render() {
257
- return /*#__PURE__*/React.createElement(UploadRejectionFlagGroup, {
258
- flagData: this.state.uploadRejectionFlags,
259
- onFlagDismissed: this.dismissUploadRejectionFlag
260
+ return /*#__PURE__*/React.createElement(ErrorFlagGroup, {
261
+ flagData: this.state.errorFlags,
262
+ onFlagDismissed: this.dismissErrorFlag
260
263
  });
261
264
  }
262
265
  }
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { AutoDismissFlag, FlagGroup } from '@atlaskit/flag';
3
3
  import FailIcon from '@atlaskit/icon/glyph/cross-circle';
4
4
  import { R300 } from '@atlaskit/theme/colors';
5
- import { uploadRejectionFlagMessages } from './messages';
5
+ import { errorFlagMessages } from './messages';
6
6
  import { injectIntl, IntlProvider, useIntl } from 'react-intl-next';
7
7
  const defaultOptions = {
8
8
  style: 'unit',
@@ -51,14 +51,16 @@ const FlagGroupContent = ({
51
51
  size: "medium"
52
52
  }),
53
53
  key: i,
54
- title: intl.formatMessage(uploadRejectionFlagMessages.title),
55
- description: intl.formatMessage(uploadRejectionFlagMessages.description, {
54
+ title: intl.formatMessage(errorFlagMessages.errorTitle),
55
+ description: data.reason === 'fileEmpty' ? intl.formatMessage(errorFlagMessages.fileEmptyDescription, {
56
+ fileName: data.fileName
57
+ }) : intl.formatMessage(errorFlagMessages.uploadRejectionDescription, {
56
58
  fileName: data.fileName,
57
59
  limit: formatFileSize(data.limit)
58
60
  })
59
61
  })));
60
62
  };
61
- const UploadRejectionFlagGroup = ({
63
+ const ErrorFlagGroup = ({
62
64
  flagData,
63
65
  onFlagDismissed,
64
66
  intl
@@ -73,6 +75,6 @@ const UploadRejectionFlagGroup = ({
73
75
  onFlagDismissed: onFlagDismissed
74
76
  }));
75
77
  };
76
- export default injectIntl(UploadRejectionFlagGroup, {
78
+ export default injectIntl(ErrorFlagGroup, {
77
79
  enforceContext: false
78
80
  });
@@ -0,0 +1,18 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export const errorFlagMessages = defineMessages({
3
+ errorTitle: {
4
+ id: 'fabric.media.errorFlagTitle',
5
+ defaultMessage: 'Your file failed to upload',
6
+ description: 'a title for a flag that describes that a file failed to upload'
7
+ },
8
+ uploadRejectionDescription: {
9
+ id: 'fabric.media.uploadRejectionFlagDescription',
10
+ defaultMessage: '{fileName} is too big to upload. Files must be less than {limit}.',
11
+ description: 'a description for a flag detailing that a file was too large to upload'
12
+ },
13
+ fileEmptyDescription: {
14
+ id: 'fabric.media.fileEmptyFlagDescription',
15
+ defaultMessage: 'The file you selected was empty. Please select another file and try again.',
16
+ description: 'a description for a flag detailing that a file was zero bytes'
17
+ }
18
+ });
@@ -12,16 +12,16 @@ export class LocalUploadComponentReact extends Component {
12
12
  super(props);
13
13
  _defineProperty(this, "uploadComponent", new UploadComponent());
14
14
  _defineProperty(this, "state", {
15
- uploadRejectionFlags: []
15
+ errorFlags: []
16
16
  });
17
- _defineProperty(this, "addUploadRejectionFlag", rejectionData => {
17
+ _defineProperty(this, "addErrorFlag", flagData => {
18
18
  this.setState({
19
- uploadRejectionFlags: [...this.state.uploadRejectionFlags, rejectionData]
19
+ errorFlags: [...this.state.errorFlags, flagData]
20
20
  });
21
21
  });
22
- _defineProperty(this, "dismissUploadRejectionFlag", () => {
22
+ _defineProperty(this, "dismissErrorFlag", () => {
23
23
  this.setState({
24
- uploadRejectionFlags: this.state.uploadRejectionFlags.slice(1)
24
+ errorFlags: this.state.errorFlags.slice(1)
25
25
  });
26
26
  });
27
27
  _defineProperty(this, "fireCommencedEvent", payload => {
@@ -200,6 +200,7 @@ export class LocalUploadComponentReact extends Component {
200
200
  this.uploadService.on('file-preview-update', this.onFilePreviewUpdate);
201
201
  this.uploadService.on('file-converting', this.onFileConverting);
202
202
  this.uploadService.on('file-upload-error', this.onUploadError);
203
+ this.uploadService.onFileEmpty(this.addErrorFlag);
203
204
  if (tenantUploadParams.onUploadRejection) {
204
205
  const {
205
206
  onUploadRejection
@@ -207,11 +208,11 @@ export class LocalUploadComponentReact extends Component {
207
208
  this.uploadService.onFileRejection(rejectionData => {
208
209
  const shouldOverride = onUploadRejection(rejectionData);
209
210
  if (!shouldOverride) {
210
- this.addUploadRejectionFlag(rejectionData);
211
+ this.addErrorFlag(rejectionData);
211
212
  }
212
213
  });
213
214
  } else {
214
- this.uploadService.onFileRejection(this.addUploadRejectionFlag);
215
+ this.uploadService.onFileRejection(this.addErrorFlag);
215
216
  }
216
217
  }
217
218
  setUploadParams(uploadParams) {
@@ -171,6 +171,17 @@ export class UploadServiceImpl {
171
171
  }
172
172
  return null;
173
173
  }
174
+
175
+ // exclude empty files from being uploaded
176
+ if (file.size === 0) {
177
+ if (this.fileEmptyHandler) {
178
+ this.fileEmptyHandler({
179
+ reason: 'fileEmpty',
180
+ fileName: file.name
181
+ });
182
+ }
183
+ return null;
184
+ }
174
185
  const touchedFile = (_touchedFiles2 = touchedFiles) === null || _touchedFiles2 === void 0 ? void 0 : _touchedFiles2.created.find(touchedFile => touchedFile.fileId === id);
175
186
  let deferredUploadId;
176
187
  const isIdConflictError = caughtError instanceof RequestError && ((_caughtError$metadata = caughtError.metadata) === null || _caughtError$metadata === void 0 ? void 0 : _caughtError$metadata.statusCode) === 409;
@@ -297,6 +308,9 @@ export class UploadServiceImpl {
297
308
  releaseCancellableFile(mediaFile) {
298
309
  delete this.cancellableFilesUploads[mediaFile.id];
299
310
  }
311
+ onFileEmpty(handler) {
312
+ this.fileEmptyHandler = handler;
313
+ }
300
314
  onFileRejection(handler) {
301
315
  this.fileRejectionHandler = handler;
302
316
  }
@@ -3,7 +3,7 @@ import { isRequestError } from '@atlaskit/media-client';
3
3
  // Component name will be prefixed with "media-picker-" in logs. Check ufoExperiences in utils files
4
4
 
5
5
  const packageName = "@atlaskit/media-picker";
6
- const packageVersion = "66.3.2";
6
+ const packageVersion = "66.4.1";
7
7
  export function getPackageAttributes(componentName) {
8
8
  return {
9
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 = "66.3.2";
5
+ const packageVersion = "66.4.1";
6
6
  let ufoExperience;
7
7
  const initExperience = (id, componentName) => {
8
8
  if (!ufoExperience) {
@@ -13,7 +13,7 @@ import { withMediaAnalyticsContext } from '@atlaskit/media-common';
13
13
  import isValidId from 'uuid-validate';
14
14
  import { LocalUploadComponentReact } from '../localUploadReact';
15
15
  import { getPackageAttributes } from '../../util/analytics';
16
- import UploadRejectionFlagGroup from '../uploadRejectionFlagGroup/UploadRejectionFlagGroup';
16
+ import ErrorFlagGroup from '../errorFlagGroup/ErrorFlagGroup';
17
17
  var defaultConfig = {
18
18
  uploadParams: {}
19
19
  };
@@ -130,9 +130,9 @@ export var BrowserBase = /*#__PURE__*/function (_LocalUploadComponent) {
130
130
  multiple: replaceFileId ? false : multiple /* if the consumer passes the fileId we must work in single selection mode */,
131
131
  accept: fileExtensions,
132
132
  onChange: this.onFilePicked
133
- }), children ? children(this.browse) : null, /*#__PURE__*/React.createElement(UploadRejectionFlagGroup, {
134
- flagData: this.state.uploadRejectionFlags,
135
- onFlagDismissed: this.dismissUploadRejectionFlag
133
+ }), children ? children(this.browse) : null, /*#__PURE__*/React.createElement(ErrorFlagGroup, {
134
+ flagData: this.state.errorFlags,
135
+ onFlagDismissed: this.dismissErrorFlag
136
136
  }));
137
137
  }
138
138
  }]);
@@ -14,7 +14,7 @@ import { LocalUploadComponentReact } from '../localUploadReact';
14
14
  import { LocalFileSource } from '../../service/types';
15
15
  import { getPackageAttributes } from '../../util/analytics';
16
16
  import { appendTimestamp } from '../../util/appendTimestamp';
17
- import UploadRejectionFlagGroup from '../uploadRejectionFlagGroup/UploadRejectionFlagGroup';
17
+ import ErrorFlagGroup from '../errorFlagGroup/ErrorFlagGroup';
18
18
  export var getFilesFromClipboard = function getFilesFromClipboard(files) {
19
19
  return Array.from(files).map(function (file) {
20
20
  if (file.type.indexOf('image/') === 0) {
@@ -207,9 +207,9 @@ export var ClipboardBase = /*#__PURE__*/function (_LocalUploadComponent) {
207
207
  }, {
208
208
  key: "render",
209
209
  value: function render() {
210
- return /*#__PURE__*/React.createElement(UploadRejectionFlagGroup, {
211
- flagData: this.state.uploadRejectionFlags,
212
- onFlagDismissed: this.dismissUploadRejectionFlag
210
+ return /*#__PURE__*/React.createElement(ErrorFlagGroup, {
211
+ flagData: this.state.errorFlags,
212
+ onFlagDismissed: this.dismissErrorFlag
213
213
  });
214
214
  }
215
215
  }]);
@@ -16,7 +16,7 @@ import { isWebkitSupported } from '@atlaskit/media-ui/browser';
16
16
  import { getFilesFromItems, getFilesFromFileSystemEntries } from 'flat-files';
17
17
  import { LocalUploadComponentReact } from '../localUploadReact';
18
18
  import { getPackageAttributes } from '../../util/analytics';
19
- import UploadRejectionFlagGroup from '../uploadRejectionFlagGroup/UploadRejectionFlagGroup';
19
+ import ErrorFlagGroup from '../errorFlagGroup/ErrorFlagGroup';
20
20
  function dragContainsFiles(event) {
21
21
  if (!event.dataTransfer) {
22
22
  return false;
@@ -35,9 +35,12 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
35
35
  _defineProperty(_assertThisInitialized(_this), "uiActive", false);
36
36
  _defineProperty(_assertThisInitialized(_this), "addContainerListeners", function () {
37
37
  var container = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.getContainer();
38
+ // TODO: migrate this file to Pragmatic drag and drop
39
+ /* eslint-disable @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop */
38
40
  container.addEventListener('dragover', _this.onDragOver, false);
39
41
  container.addEventListener('dragleave', _this.onDragLeave, false);
40
42
  container.addEventListener('drop', _this.onFileDropped);
43
+ /* eslint-enable @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop */
41
44
  });
42
45
  _defineProperty(_assertThisInitialized(_this), "removeContainerListeners", function () {
43
46
  var container = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.getContainer();
@@ -310,9 +313,9 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
310
313
  }, {
311
314
  key: "render",
312
315
  value: function render() {
313
- return /*#__PURE__*/React.createElement(UploadRejectionFlagGroup, {
314
- flagData: this.state.uploadRejectionFlags,
315
- onFlagDismissed: this.dismissUploadRejectionFlag
316
+ return /*#__PURE__*/React.createElement(ErrorFlagGroup, {
317
+ flagData: this.state.errorFlags,
318
+ onFlagDismissed: this.dismissErrorFlag
316
319
  });
317
320
  }
318
321
  }]);
@@ -5,7 +5,7 @@ import React from 'react';
5
5
  import { AutoDismissFlag, FlagGroup } from '@atlaskit/flag';
6
6
  import FailIcon from '@atlaskit/icon/glyph/cross-circle';
7
7
  import { R300 } from '@atlaskit/theme/colors';
8
- import { uploadRejectionFlagMessages } from './messages';
8
+ import { errorFlagMessages } from './messages';
9
9
  import { injectIntl, IntlProvider, useIntl } from 'react-intl-next';
10
10
  var defaultOptions = {
11
11
  style: 'unit',
@@ -51,15 +51,17 @@ var FlagGroupContent = function FlagGroupContent(_ref) {
51
51
  size: "medium"
52
52
  }),
53
53
  key: i,
54
- title: intl.formatMessage(uploadRejectionFlagMessages.title),
55
- description: intl.formatMessage(uploadRejectionFlagMessages.description, {
54
+ title: intl.formatMessage(errorFlagMessages.errorTitle),
55
+ description: data.reason === 'fileEmpty' ? intl.formatMessage(errorFlagMessages.fileEmptyDescription, {
56
+ fileName: data.fileName
57
+ }) : intl.formatMessage(errorFlagMessages.uploadRejectionDescription, {
56
58
  fileName: data.fileName,
57
59
  limit: formatFileSize(data.limit)
58
60
  })
59
61
  });
60
62
  }));
61
63
  };
62
- var UploadRejectionFlagGroup = function UploadRejectionFlagGroup(_ref2) {
64
+ var ErrorFlagGroup = function ErrorFlagGroup(_ref2) {
63
65
  var flagData = _ref2.flagData,
64
66
  onFlagDismissed = _ref2.onFlagDismissed,
65
67
  intl = _ref2.intl;
@@ -73,6 +75,6 @@ var UploadRejectionFlagGroup = function UploadRejectionFlagGroup(_ref2) {
73
75
  onFlagDismissed: onFlagDismissed
74
76
  }));
75
77
  };
76
- export default injectIntl(UploadRejectionFlagGroup, {
78
+ export default injectIntl(ErrorFlagGroup, {
77
79
  enforceContext: false
78
80
  });
@@ -0,0 +1,18 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export var errorFlagMessages = defineMessages({
3
+ errorTitle: {
4
+ id: 'fabric.media.errorFlagTitle',
5
+ defaultMessage: 'Your file failed to upload',
6
+ description: 'a title for a flag that describes that a file failed to upload'
7
+ },
8
+ uploadRejectionDescription: {
9
+ id: 'fabric.media.uploadRejectionFlagDescription',
10
+ defaultMessage: '{fileName} is too big to upload. Files must be less than {limit}.',
11
+ description: 'a description for a flag detailing that a file was too large to upload'
12
+ },
13
+ fileEmptyDescription: {
14
+ id: 'fabric.media.fileEmptyFlagDescription',
15
+ defaultMessage: 'The file you selected was empty. Please select another file and try again.',
16
+ description: 'a description for a flag detailing that a file was zero bytes'
17
+ }
18
+ });
@@ -27,16 +27,16 @@ export var LocalUploadComponentReact = /*#__PURE__*/function (_Component) {
27
27
  _this = _super.call(this, props);
28
28
  _defineProperty(_assertThisInitialized(_this), "uploadComponent", new UploadComponent());
29
29
  _defineProperty(_assertThisInitialized(_this), "state", {
30
- uploadRejectionFlags: []
30
+ errorFlags: []
31
31
  });
32
- _defineProperty(_assertThisInitialized(_this), "addUploadRejectionFlag", function (rejectionData) {
32
+ _defineProperty(_assertThisInitialized(_this), "addErrorFlag", function (flagData) {
33
33
  _this.setState({
34
- uploadRejectionFlags: [].concat(_toConsumableArray(_this.state.uploadRejectionFlags), [rejectionData])
34
+ errorFlags: [].concat(_toConsumableArray(_this.state.errorFlags), [flagData])
35
35
  });
36
36
  });
37
- _defineProperty(_assertThisInitialized(_this), "dismissUploadRejectionFlag", function () {
37
+ _defineProperty(_assertThisInitialized(_this), "dismissErrorFlag", function () {
38
38
  _this.setState({
39
- uploadRejectionFlags: _this.state.uploadRejectionFlags.slice(1)
39
+ errorFlags: _this.state.errorFlags.slice(1)
40
40
  });
41
41
  });
42
42
  _defineProperty(_assertThisInitialized(_this), "fireCommencedEvent", function (payload) {
@@ -206,16 +206,17 @@ export var LocalUploadComponentReact = /*#__PURE__*/function (_Component) {
206
206
  _this.uploadService.on('file-preview-update', _this.onFilePreviewUpdate);
207
207
  _this.uploadService.on('file-converting', _this.onFileConverting);
208
208
  _this.uploadService.on('file-upload-error', _this.onUploadError);
209
+ _this.uploadService.onFileEmpty(_this.addErrorFlag);
209
210
  if (tenantUploadParams.onUploadRejection) {
210
211
  var onUploadRejection = tenantUploadParams.onUploadRejection;
211
212
  _this.uploadService.onFileRejection(function (rejectionData) {
212
213
  var shouldOverride = onUploadRejection(rejectionData);
213
214
  if (!shouldOverride) {
214
- _this.addUploadRejectionFlag(rejectionData);
215
+ _this.addErrorFlag(rejectionData);
215
216
  }
216
217
  });
217
218
  } else {
218
- _this.uploadService.onFileRejection(_this.addUploadRejectionFlag);
219
+ _this.uploadService.onFileRejection(_this.addErrorFlag);
219
220
  }
220
221
  return _this;
221
222
  }
@@ -240,6 +240,17 @@ export var UploadServiceImpl = /*#__PURE__*/function () {
240
240
  }
241
241
  return null;
242
242
  }
243
+
244
+ // exclude empty files from being uploaded
245
+ if (file.size === 0) {
246
+ if (_this3.fileEmptyHandler) {
247
+ _this3.fileEmptyHandler({
248
+ reason: 'fileEmpty',
249
+ fileName: file.name
250
+ });
251
+ }
252
+ return null;
253
+ }
243
254
  var touchedFile = (_touchedFiles2 = touchedFiles) === null || _touchedFiles2 === void 0 ? void 0 : _touchedFiles2.created.find(function (touchedFile) {
244
255
  return touchedFile.fileId === id;
245
256
  });
@@ -382,6 +393,11 @@ export var UploadServiceImpl = /*#__PURE__*/function () {
382
393
  value: function releaseCancellableFile(mediaFile) {
383
394
  delete this.cancellableFilesUploads[mediaFile.id];
384
395
  }
396
+ }, {
397
+ key: "onFileEmpty",
398
+ value: function onFileEmpty(handler) {
399
+ this.fileEmptyHandler = handler;
400
+ }
385
401
  }, {
386
402
  key: "onFileRejection",
387
403
  value: function onFileRejection(handler) {
@@ -3,7 +3,7 @@ import { isRequestError } from '@atlaskit/media-client';
3
3
  // Component name will be prefixed with "media-picker-" in logs. Check ufoExperiences in utils files
4
4
 
5
5
  var packageName = "@atlaskit/media-picker";
6
- var packageVersion = "66.3.2";
6
+ var packageVersion = "66.4.1";
7
7
  export function getPackageAttributes(componentName) {
8
8
  return {
9
9
  packageName: packageName,
@@ -5,7 +5,7 @@ import { ConcurrentExperience, ExperiencePerformanceTypes, ExperienceTypes } fro
5
5
  import { getFeatureFlagKeysAllProducts } from '@atlaskit/media-common';
6
6
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
7
7
  var packageName = "@atlaskit/media-picker";
8
- var packageVersion = "66.3.2";
8
+ var packageVersion = "66.4.1";
9
9
  var ufoExperience;
10
10
  var initExperience = function initExperience(id, componentName) {
11
11
  if (!ufoExperience) {
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { FlagData } from '../../types';
3
+ import { WrappedComponentProps } from 'react-intl-next';
4
+ export interface ErrorFlagGroupProps {
5
+ readonly flagData: FlagData[];
6
+ onFlagDismissed: () => void;
7
+ }
8
+ declare const _default: React.FC<import("react-intl-next").WithIntlProps<ErrorFlagGroupProps & WrappedComponentProps>> & {
9
+ WrappedComponent: React.ComponentType<ErrorFlagGroupProps & WrappedComponentProps>;
10
+ };
11
+ export default _default;
@@ -0,0 +1,17 @@
1
+ export declare const errorFlagMessages: {
2
+ errorTitle: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ uploadRejectionDescription: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
12
+ fileEmptyDescription: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ description: string;
16
+ };
17
+ };
@@ -2,11 +2,11 @@ import { Component } from 'react';
2
2
  import { MediaClient } from '@atlaskit/media-client';
3
3
  import { MediaFeatureFlags } from '@atlaskit/media-common';
4
4
  import { UploadService } from '../service/types';
5
- import { UploadEndEventPayload, UploadErrorEventPayload, UploadPreviewUpdateEventPayload, UploadsStartEventPayload, UploadParams } from '../types';
5
+ import { UploadEndEventPayload, UploadErrorEventPayload, UploadPreviewUpdateEventPayload, UploadsStartEventPayload, UploadParams, FlagData } from '../types';
6
6
  import { UploadComponent } from './component';
7
7
  import { LocalUploadConfig } from './types';
8
8
  import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
9
- import { AnalyticsEventPayload, UploadRejectionData } from '../types';
9
+ import { AnalyticsEventPayload } from '../types';
10
10
  import { ComponentName } from '../util/analytics';
11
11
  export type LocalUploadComponentBaseProps = {
12
12
  mediaClient: MediaClient;
@@ -18,7 +18,7 @@ export type LocalUploadComponentBaseProps = {
18
18
  featureFlags?: MediaFeatureFlags;
19
19
  } & WithAnalyticsEventsProps;
20
20
  export type LocalUploadComponentBaseState = {
21
- uploadRejectionFlags: UploadRejectionData[];
21
+ errorFlags: FlagData[];
22
22
  };
23
23
  export declare class LocalUploadComponentReact<Props extends LocalUploadComponentBaseProps> extends Component<Props, LocalUploadComponentBaseState> {
24
24
  protected readonly componentName: ComponentName;
@@ -26,8 +26,8 @@ export declare class LocalUploadComponentReact<Props extends LocalUploadComponen
26
26
  protected uploadComponent: UploadComponent<import("../types").UploadEventPayloadMap>;
27
27
  state: LocalUploadComponentBaseState;
28
28
  constructor(props: Props, componentName: ComponentName);
29
- private addUploadRejectionFlag;
30
- protected dismissUploadRejectionFlag: () => void;
29
+ private addErrorFlag;
30
+ protected dismissErrorFlag: () => void;
31
31
  private fireCommencedEvent;
32
32
  private fireUploadSucceeded;
33
33
  private fireUploadFailed;
@@ -1,4 +1,4 @@
1
- import { UploadEndEventPayload, UploadErrorEventPayload, UploadPreviewUpdateEventPayload, UploadsStartEventPayload, UploadParams, UploadRejectionData } from '../types';
1
+ import { UploadEndEventPayload, UploadErrorEventPayload, UploadPreviewUpdateEventPayload, UploadsStartEventPayload, UploadParams, UploadRejectionData, FileEmptyData } from '../types';
2
2
  export type UploadServiceEventPayloadTypes = {
3
3
  readonly 'files-added': UploadsStartEventPayload;
4
4
  readonly 'file-preview-update': UploadPreviewUpdateEventPayload;
@@ -16,6 +16,7 @@ export interface UploadService {
16
16
  cancel(id?: string): void;
17
17
  on<E extends keyof UploadServiceEventPayloadTypes>(event: E, listener: UploadServiceEventListener<E>): void;
18
18
  off<E extends keyof UploadServiceEventPayloadTypes>(event: E, listener: UploadServiceEventListener<E>): void;
19
+ onFileEmpty(handler: (fileEmptyData: FileEmptyData) => void): void;
19
20
  onFileRejection(handler: (rejectionData: UploadRejectionData) => void): void;
20
21
  }
21
22
  export declare enum LocalFileSource {
@@ -1,5 +1,5 @@
1
1
  import { MediaClient } from '@atlaskit/media-client';
2
- import { MediaFile, UploadParams } from '../types';
2
+ import { FileEmptyData, MediaFile, UploadParams } from '../types';
3
3
  import { UploadRejectionData } from '../types';
4
4
  import { UploadService, UploadServiceEventListener, UploadServiceEventPayloadTypes } from './types';
5
5
  import { LocalFileSource, LocalFileWithSource } from '../service/types';
@@ -19,6 +19,7 @@ export declare class UploadServiceImpl implements UploadService {
19
19
  private readonly emitter;
20
20
  private cancellableFilesUploads;
21
21
  private fileRejectionHandler?;
22
+ private fileEmptyHandler?;
22
23
  constructor(tenantMediaClient: MediaClient, tenantUploadParams: UploadParams, shouldCopyFileToRecents: boolean, maxUploadBatchSize?: number);
23
24
  setUploadParams(uploadParams: UploadParams): void;
24
25
  private createUploadController;
@@ -36,5 +37,6 @@ export declare class UploadServiceImpl implements UploadService {
36
37
  private releaseCancellableFile;
37
38
  private readonly onFileSuccess;
38
39
  private readonly onFileError;
40
+ onFileEmpty(handler: (fileEmptyData: FileEmptyData) => void): void;
39
41
  onFileRejection(handler: (rejectionData: UploadRejectionData) => void): void;
40
42
  }
@@ -57,6 +57,11 @@ export type UploadRejectionData = {
57
57
  fileName: string;
58
58
  limit: number;
59
59
  };
60
+ export type FileEmptyData = {
61
+ reason: 'fileEmpty';
62
+ fileName: string;
63
+ };
64
+ export type FlagData = UploadRejectionData | FileEmptyData;
60
65
  export interface BrowserConfig extends LocalUploadConfig {
61
66
  readonly multiple?: boolean;
62
67
  readonly fileExtensions?: Array<string>;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { FlagData } from '../../types';
3
+ import { WrappedComponentProps } from 'react-intl-next';
4
+ export interface ErrorFlagGroupProps {
5
+ readonly flagData: FlagData[];
6
+ onFlagDismissed: () => void;
7
+ }
8
+ declare const _default: React.FC<import("react-intl-next").WithIntlProps<ErrorFlagGroupProps & WrappedComponentProps>> & {
9
+ WrappedComponent: React.ComponentType<ErrorFlagGroupProps & WrappedComponentProps>;
10
+ };
11
+ export default _default;
@@ -0,0 +1,17 @@
1
+ export declare const errorFlagMessages: {
2
+ errorTitle: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ uploadRejectionDescription: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
12
+ fileEmptyDescription: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ description: string;
16
+ };
17
+ };
@@ -2,11 +2,11 @@ import { Component } from 'react';
2
2
  import { MediaClient } from '@atlaskit/media-client';
3
3
  import { MediaFeatureFlags } from '@atlaskit/media-common';
4
4
  import { UploadService } from '../service/types';
5
- import { UploadEndEventPayload, UploadErrorEventPayload, UploadPreviewUpdateEventPayload, UploadsStartEventPayload, UploadParams } from '../types';
5
+ import { UploadEndEventPayload, UploadErrorEventPayload, UploadPreviewUpdateEventPayload, UploadsStartEventPayload, UploadParams, FlagData } from '../types';
6
6
  import { UploadComponent } from './component';
7
7
  import { LocalUploadConfig } from './types';
8
8
  import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
9
- import { AnalyticsEventPayload, UploadRejectionData } from '../types';
9
+ import { AnalyticsEventPayload } from '../types';
10
10
  import { ComponentName } from '../util/analytics';
11
11
  export type LocalUploadComponentBaseProps = {
12
12
  mediaClient: MediaClient;
@@ -18,7 +18,7 @@ export type LocalUploadComponentBaseProps = {
18
18
  featureFlags?: MediaFeatureFlags;
19
19
  } & WithAnalyticsEventsProps;
20
20
  export type LocalUploadComponentBaseState = {
21
- uploadRejectionFlags: UploadRejectionData[];
21
+ errorFlags: FlagData[];
22
22
  };
23
23
  export declare class LocalUploadComponentReact<Props extends LocalUploadComponentBaseProps> extends Component<Props, LocalUploadComponentBaseState> {
24
24
  protected readonly componentName: ComponentName;
@@ -26,8 +26,8 @@ export declare class LocalUploadComponentReact<Props extends LocalUploadComponen
26
26
  protected uploadComponent: UploadComponent<import("../types").UploadEventPayloadMap>;
27
27
  state: LocalUploadComponentBaseState;
28
28
  constructor(props: Props, componentName: ComponentName);
29
- private addUploadRejectionFlag;
30
- protected dismissUploadRejectionFlag: () => void;
29
+ private addErrorFlag;
30
+ protected dismissErrorFlag: () => void;
31
31
  private fireCommencedEvent;
32
32
  private fireUploadSucceeded;
33
33
  private fireUploadFailed;
@@ -1,4 +1,4 @@
1
- import { UploadEndEventPayload, UploadErrorEventPayload, UploadPreviewUpdateEventPayload, UploadsStartEventPayload, UploadParams, UploadRejectionData } from '../types';
1
+ import { UploadEndEventPayload, UploadErrorEventPayload, UploadPreviewUpdateEventPayload, UploadsStartEventPayload, UploadParams, UploadRejectionData, FileEmptyData } from '../types';
2
2
  export type UploadServiceEventPayloadTypes = {
3
3
  readonly 'files-added': UploadsStartEventPayload;
4
4
  readonly 'file-preview-update': UploadPreviewUpdateEventPayload;
@@ -16,6 +16,7 @@ export interface UploadService {
16
16
  cancel(id?: string): void;
17
17
  on<E extends keyof UploadServiceEventPayloadTypes>(event: E, listener: UploadServiceEventListener<E>): void;
18
18
  off<E extends keyof UploadServiceEventPayloadTypes>(event: E, listener: UploadServiceEventListener<E>): void;
19
+ onFileEmpty(handler: (fileEmptyData: FileEmptyData) => void): void;
19
20
  onFileRejection(handler: (rejectionData: UploadRejectionData) => void): void;
20
21
  }
21
22
  export declare enum LocalFileSource {
@@ -1,5 +1,5 @@
1
1
  import { MediaClient } from '@atlaskit/media-client';
2
- import { MediaFile, UploadParams } from '../types';
2
+ import { FileEmptyData, MediaFile, UploadParams } from '../types';
3
3
  import { UploadRejectionData } from '../types';
4
4
  import { UploadService, UploadServiceEventListener, UploadServiceEventPayloadTypes } from './types';
5
5
  import { LocalFileSource, LocalFileWithSource } from '../service/types';
@@ -19,6 +19,7 @@ export declare class UploadServiceImpl implements UploadService {
19
19
  private readonly emitter;
20
20
  private cancellableFilesUploads;
21
21
  private fileRejectionHandler?;
22
+ private fileEmptyHandler?;
22
23
  constructor(tenantMediaClient: MediaClient, tenantUploadParams: UploadParams, shouldCopyFileToRecents: boolean, maxUploadBatchSize?: number);
23
24
  setUploadParams(uploadParams: UploadParams): void;
24
25
  private createUploadController;
@@ -36,5 +37,6 @@ export declare class UploadServiceImpl implements UploadService {
36
37
  private releaseCancellableFile;
37
38
  private readonly onFileSuccess;
38
39
  private readonly onFileError;
40
+ onFileEmpty(handler: (fileEmptyData: FileEmptyData) => void): void;
39
41
  onFileRejection(handler: (rejectionData: UploadRejectionData) => void): void;
40
42
  }
@@ -57,6 +57,11 @@ export type UploadRejectionData = {
57
57
  fileName: string;
58
58
  limit: number;
59
59
  };
60
+ export type FileEmptyData = {
61
+ reason: 'fileEmpty';
62
+ fileName: string;
63
+ };
64
+ export type FlagData = UploadRejectionData | FileEmptyData;
60
65
  export interface BrowserConfig extends LocalUploadConfig {
61
66
  readonly multiple?: boolean;
62
67
  readonly fileExtensions?: Array<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-picker",
3
- "version": "66.3.2",
3
+ "version": "66.4.1",
4
4
  "description": "Library for handling file uploads",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -35,14 +35,14 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@atlaskit/analytics-next": "^9.2.0",
38
- "@atlaskit/flag": "^15.1.0",
38
+ "@atlaskit/flag": "^15.3.0",
39
39
  "@atlaskit/icon": "^22.1.0",
40
- "@atlaskit/media-client": "^26.2.0",
40
+ "@atlaskit/media-client": "^26.3.0",
41
41
  "@atlaskit/media-client-react": "^2.0.0",
42
42
  "@atlaskit/media-common": "^11.1.0",
43
- "@atlaskit/media-ui": "^25.4.0",
44
- "@atlaskit/theme": "^12.6.0",
45
- "@atlaskit/tokens": "^1.42.0",
43
+ "@atlaskit/media-ui": "^25.6.0",
44
+ "@atlaskit/theme": "^12.7.0",
45
+ "@atlaskit/tokens": "^1.43.0",
46
46
  "@atlaskit/ufo": "^0.2.0",
47
47
  "@babel/runtime": "^7.0.0",
48
48
  "eventemitter2": "^4.1.0",
@@ -61,7 +61,7 @@
61
61
  "devDependencies": {
62
62
  "@atlaskit/analytics-listeners": "^8.9.0",
63
63
  "@atlaskit/analytics-namespaced-context": "^6.9.0",
64
- "@atlaskit/button": "^17.7.0",
64
+ "@atlaskit/button": "^17.11.0",
65
65
  "@atlaskit/media-core": "^34.2.0",
66
66
  "@atlaskit/media-test-helpers": "^33.0.0",
67
67
  "@atlaskit/ssr": "*",
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.uploadRejectionFlagMessages = void 0;
7
- var _reactIntlNext = require("react-intl-next");
8
- var uploadRejectionFlagMessages = exports.uploadRejectionFlagMessages = (0, _reactIntlNext.defineMessages)({
9
- title: {
10
- id: 'fabric.media.uploadRejectionFlagTitle',
11
- defaultMessage: 'Your file failed to upload',
12
- description: 'a title for a flag that describes that a file failed to upload'
13
- },
14
- description: {
15
- id: 'fabric.media.uploadRejectionFlagDescription',
16
- defaultMessage: '{fileName} is too big to upload. Files must be less than {limit}.',
17
- description: 'a description for a flag that details why a file failed to upload'
18
- }
19
- });
@@ -1,13 +0,0 @@
1
- import { defineMessages } from 'react-intl-next';
2
- export const uploadRejectionFlagMessages = defineMessages({
3
- title: {
4
- id: 'fabric.media.uploadRejectionFlagTitle',
5
- defaultMessage: 'Your file failed to upload',
6
- description: 'a title for a flag that describes that a file failed to upload'
7
- },
8
- description: {
9
- id: 'fabric.media.uploadRejectionFlagDescription',
10
- defaultMessage: '{fileName} is too big to upload. Files must be less than {limit}.',
11
- description: 'a description for a flag that details why a file failed to upload'
12
- }
13
- });
@@ -1,13 +0,0 @@
1
- import { defineMessages } from 'react-intl-next';
2
- export var uploadRejectionFlagMessages = defineMessages({
3
- title: {
4
- id: 'fabric.media.uploadRejectionFlagTitle',
5
- defaultMessage: 'Your file failed to upload',
6
- description: 'a title for a flag that describes that a file failed to upload'
7
- },
8
- description: {
9
- id: 'fabric.media.uploadRejectionFlagDescription',
10
- defaultMessage: '{fileName} is too big to upload. Files must be less than {limit}.',
11
- description: 'a description for a flag that details why a file failed to upload'
12
- }
13
- });
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { UploadRejectionData } from '../../types';
3
- import { WrappedComponentProps } from 'react-intl-next';
4
- export interface UploadRejectionFlagGroupProps {
5
- readonly flagData: UploadRejectionData[];
6
- onFlagDismissed: () => void;
7
- }
8
- declare const _default: React.FC<import("react-intl-next").WithIntlProps<UploadRejectionFlagGroupProps & WrappedComponentProps>> & {
9
- WrappedComponent: React.ComponentType<UploadRejectionFlagGroupProps & WrappedComponentProps>;
10
- };
11
- export default _default;
@@ -1,12 +0,0 @@
1
- export declare const uploadRejectionFlagMessages: {
2
- title: {
3
- id: string;
4
- defaultMessage: string;
5
- description: string;
6
- };
7
- description: {
8
- id: string;
9
- defaultMessage: string;
10
- description: string;
11
- };
12
- };
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { UploadRejectionData } from '../../types';
3
- import { WrappedComponentProps } from 'react-intl-next';
4
- export interface UploadRejectionFlagGroupProps {
5
- readonly flagData: UploadRejectionData[];
6
- onFlagDismissed: () => void;
7
- }
8
- declare const _default: React.FC<import("react-intl-next").WithIntlProps<UploadRejectionFlagGroupProps & WrappedComponentProps>> & {
9
- WrappedComponent: React.ComponentType<UploadRejectionFlagGroupProps & WrappedComponentProps>;
10
- };
11
- export default _default;
@@ -1,12 +0,0 @@
1
- export declare const uploadRejectionFlagMessages: {
2
- title: {
3
- id: string;
4
- defaultMessage: string;
5
- description: string;
6
- };
7
- description: {
8
- id: string;
9
- defaultMessage: string;
10
- description: string;
11
- };
12
- };