cozy-ui-plus 7.0.0 → 8.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 +16 -0
- package/dist/stylesheet.css +0 -231
- package/package.json +2 -2
- package/dist/UploadQueue/FileUploadProgress.js +0 -86
- package/dist/UploadQueue/Item.js +0 -132
- package/dist/UploadQueue/Pending.js +0 -23
- package/dist/UploadQueue/RemainingTime.js +0 -59
- package/dist/UploadQueue/helpers.js +0 -13
- package/dist/UploadQueue/index.js +0 -275
- package/dist/UploadQueue/useStatusIcon.js +0 -60
- package/dist/src/UploadQueue/FileUploadProgress.d.ts +0 -4
- package/dist/src/UploadQueue/Item.d.ts +0 -3
- package/dist/src/UploadQueue/Pending.d.ts +0 -3
- package/dist/src/UploadQueue/RemainingTime.d.ts +0 -4
- package/dist/src/UploadQueue/helpers.d.ts +0 -1
- package/dist/src/UploadQueue/index.d.ts +0 -42
- package/dist/src/UploadQueue/index.spec.d.ts +0 -1
- package/dist/src/UploadQueue/useStatusIcon.d.ts +0 -1
- package/src/UploadQueue/FileUploadProgress.jsx +0 -50
- package/src/UploadQueue/Item.jsx +0 -99
- package/src/UploadQueue/Pending.jsx +0 -12
- package/src/UploadQueue/Readme.md +0 -95
- package/src/UploadQueue/RemainingTime.jsx +0 -27
- package/src/UploadQueue/helpers.js +0 -3
- package/src/UploadQueue/index.jsx +0 -160
- package/src/UploadQueue/index.spec.jsx +0 -177
- package/src/UploadQueue/locales/en.json +0 -10
- package/src/UploadQueue/locales/es.json +0 -10
- package/src/UploadQueue/locales/fr.json +0 -10
- package/src/UploadQueue/locales/ru.json +0 -10
- package/src/UploadQueue/locales/vi.json +0 -10
- package/src/UploadQueue/styles.styl +0 -155
- package/src/UploadQueue/useStatusIcon.js +0 -32
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.uploadStatus = exports.formatRemainingTime = exports.default = exports.UploadQueue = void 0;
|
|
9
|
-
|
|
10
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
-
|
|
18
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
-
|
|
22
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
-
|
|
24
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
27
|
-
|
|
28
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
29
|
-
|
|
30
|
-
var _LinearProgress = _interopRequireDefault(require("cozy-ui/transpiled/react/LinearProgress"));
|
|
31
|
-
|
|
32
|
-
var _List = _interopRequireDefault(require("cozy-ui/transpiled/react/List"));
|
|
33
|
-
|
|
34
|
-
var _Typography = _interopRequireDefault(require("cozy-ui/transpiled/react/Typography"));
|
|
35
|
-
|
|
36
|
-
var _Button = _interopRequireDefault(require("cozy-ui/transpiled/react/deprecated/Button"));
|
|
37
|
-
|
|
38
|
-
var _styles = require("cozy-ui/transpiled/react/styles");
|
|
39
|
-
|
|
40
|
-
var _twakeI18n = require("twake-i18n");
|
|
41
|
-
|
|
42
|
-
var _Item = _interopRequireDefault(require("./Item"));
|
|
43
|
-
|
|
44
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
45
|
-
|
|
46
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
47
|
-
|
|
48
|
-
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); }; }
|
|
49
|
-
|
|
50
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
51
|
-
|
|
52
|
-
var localeEn = {
|
|
53
|
-
header: "Uploading %{smart_count} photo to %{app} |||| Uploading %{smart_count} photos to %{app}",
|
|
54
|
-
header_mobile: "Uploading %{done} of %{smart_count}",
|
|
55
|
-
header_done: "Uploaded %{done} out of %{smart_count} successfully",
|
|
56
|
-
close: "close",
|
|
57
|
-
item: {
|
|
58
|
-
pending: "Pending",
|
|
59
|
-
remainingTime: "%{time} remaining"
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
var localeEs = {
|
|
63
|
-
header: "Subiendo %{smart_count} foto a %{app} |||| Subiendo %{smart_count} fotos a %{app}",
|
|
64
|
-
header_mobile: "Subiendo %{done} de %{smart_count}",
|
|
65
|
-
header_done: "Subidos %{done} de %{smart_count} con \xE9xito",
|
|
66
|
-
close: "cerrar",
|
|
67
|
-
item: {
|
|
68
|
-
pending: "Pendiente",
|
|
69
|
-
remainingTime: "%{time} restante |||| %{time} restantes"
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var localeFr = {
|
|
73
|
-
header: "Import de %{smart_count} fichier dans votre %{app} |||| Import de %{smart_count} fichiers dans votre %{app}",
|
|
74
|
-
header_mobile: "Import de %{done} sur %{smart_count}",
|
|
75
|
-
header_done: "%{done} sur %{smart_count} \xE9l\xE9ment import\xE9 |||| %{done} sur %{smart_count} \xE9l\xE9ments import\xE9s",
|
|
76
|
-
close: "Fermer",
|
|
77
|
-
item: {
|
|
78
|
-
pending: "En attente",
|
|
79
|
-
remainingTime: "%{time} restante |||| %{time} restantes"
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
var localeRu = {
|
|
83
|
-
header: "\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 %{smart_count} \u0444\u043E\u0442\u043E \u0432 %{app} |||| \u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 %{smart_count} \u0444\u043E\u0442\u043E \u0432 %{app}",
|
|
84
|
-
header_mobile: "\u0417\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043E %{done} \u0438\u0437 %{smart_count}",
|
|
85
|
-
header_done: "\u0423\u0441\u043F\u0435\u0448\u043D\u043E \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043E %{done} \u0438\u0437 %{smart_count}",
|
|
86
|
-
close: "\u0437\u0430\u043A\u0440\u044B\u0442\u044C",
|
|
87
|
-
item: {
|
|
88
|
-
pending: "\u0412 \u043E\u0436\u0438\u0434\u0430\u043D\u0438\u0438",
|
|
89
|
-
remainingTime: "\u041E\u0441\u0442\u0430\u043B\u043E\u0441\u044C %{time}"
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
var localeVi = {
|
|
93
|
-
header: "\u0110ang t\u1EA3i l\xEAn %{smart_count} \u1EA3nh v\xE0o %{app} |||| \u0110ang t\u1EA3i l\xEAn %{smart_count} \u1EA3nh v\xE0o %{app}",
|
|
94
|
-
header_mobile: "\u0110\xE3 t\u1EA3i l\xEAn %{done} trong s\u1ED1 %{smart_count}",
|
|
95
|
-
header_done: "\u0110\xE3 t\u1EA3i l\xEAn th\xE0nh c\xF4ng %{done} trong s\u1ED1 %{smart_count}",
|
|
96
|
-
close: "\u0111\xF3ng",
|
|
97
|
-
item: {
|
|
98
|
-
pending: "\u0110ang ch\u1EDD",
|
|
99
|
-
remainingTime: "C\xF2n l\u1EA1i %{time}"
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
var styles = {
|
|
103
|
-
"upload-queue": "styles__upload-queue___3EfQa",
|
|
104
|
-
"upload-queue__threshold-bar": "styles__upload-queue__threshold-bar___e-fnL",
|
|
105
|
-
"upload-queue__progress-caption": "styles__upload-queue__progress-caption___37X7k",
|
|
106
|
-
"upload-queue__upload-progress": "styles__upload-queue__upload-progress___2Z9qx",
|
|
107
|
-
"upload-queue--popover": "styles__upload-queue--popover___2Oj-U",
|
|
108
|
-
"upload-queue--visible": "styles__upload-queue--visible___3FkzH",
|
|
109
|
-
"upload-queue-header": "styles__upload-queue-header___1nUv9",
|
|
110
|
-
"upload-queue-header-inner": "styles__upload-queue-header-inner___-pA9p",
|
|
111
|
-
"upload-queue-progress": "styles__upload-queue-progress___3ijZA",
|
|
112
|
-
"upload-queue-content": "styles__upload-queue-content___29pyu",
|
|
113
|
-
"upload-queue--collapsed": "styles__upload-queue--collapsed___3Er09",
|
|
114
|
-
"upload-queue-list": "styles__upload-queue-list___30_J-",
|
|
115
|
-
"upload-queue-item--error": "styles__upload-queue-item--error___1ChsD",
|
|
116
|
-
"upload-queue-item--done": "styles__upload-queue-item--done___1eJjw",
|
|
117
|
-
"item-file": "styles__item-file___AdWET",
|
|
118
|
-
"item-status": "styles__item-status___2xjeD",
|
|
119
|
-
"spin": "styles__spin___1u3cT",
|
|
120
|
-
"shake": "styles__shake___pfzot"
|
|
121
|
-
};
|
|
122
|
-
var locales = {
|
|
123
|
-
en: localeEn,
|
|
124
|
-
es: localeEs,
|
|
125
|
-
fr: localeFr,
|
|
126
|
-
ru: localeRu,
|
|
127
|
-
vi: localeVi
|
|
128
|
-
};
|
|
129
|
-
var CANCEL = 'cancel';
|
|
130
|
-
var PENDING = 'pending';
|
|
131
|
-
var LOADING = 'loading';
|
|
132
|
-
var CREATED = 'created';
|
|
133
|
-
var UPDATED = 'updated';
|
|
134
|
-
var FAILED = 'failed';
|
|
135
|
-
var CONFLICT = 'conflict';
|
|
136
|
-
var QUOTA = 'quota';
|
|
137
|
-
var NETWORK = 'network';
|
|
138
|
-
var DONE_STATUSES = [CREATED, UPDATED];
|
|
139
|
-
var ERROR_STATUSES = [CONFLICT, NETWORK, QUOTA, FAILED];
|
|
140
|
-
var uploadStatus = {
|
|
141
|
-
CANCEL: CANCEL,
|
|
142
|
-
PENDING: PENDING,
|
|
143
|
-
LOADING: LOADING,
|
|
144
|
-
CREATED: CREATED,
|
|
145
|
-
UPDATED: UPDATED,
|
|
146
|
-
FAILED: FAILED,
|
|
147
|
-
CONFLICT: CONFLICT,
|
|
148
|
-
QUOTA: QUOTA,
|
|
149
|
-
NETWORK: NETWORK,
|
|
150
|
-
DONE_STATUSES: DONE_STATUSES,
|
|
151
|
-
ERROR_STATUSES: ERROR_STATUSES
|
|
152
|
-
};
|
|
153
|
-
exports.uploadStatus = uploadStatus;
|
|
154
|
-
|
|
155
|
-
var formatRemainingTime = function formatRemainingTime(durationInSec) {
|
|
156
|
-
var later = Date.now() + durationInSec * 1000;
|
|
157
|
-
return (0, _twakeI18n.formatLocallyDistanceToNow)(later);
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
exports.formatRemainingTime = formatRemainingTime;
|
|
161
|
-
var QueueLinearProgress = (0, _styles.withStyles)({
|
|
162
|
-
root: {
|
|
163
|
-
height: '2px'
|
|
164
|
-
}
|
|
165
|
-
})(_LinearProgress.default);
|
|
166
|
-
|
|
167
|
-
var UploadQueue = /*#__PURE__*/function (_Component) {
|
|
168
|
-
(0, _inherits2.default)(UploadQueue, _Component);
|
|
169
|
-
|
|
170
|
-
var _super = _createSuper(UploadQueue);
|
|
171
|
-
|
|
172
|
-
function UploadQueue() {
|
|
173
|
-
var _this;
|
|
174
|
-
|
|
175
|
-
(0, _classCallCheck2.default)(this, UploadQueue);
|
|
176
|
-
|
|
177
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
178
|
-
args[_key] = arguments[_key];
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
182
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
183
|
-
collapsed: false
|
|
184
|
-
});
|
|
185
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "toggleCollapsed", function () {
|
|
186
|
-
_this.setState(function (state) {
|
|
187
|
-
return {
|
|
188
|
-
collapsed: !state.collapsed
|
|
189
|
-
};
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
return _this;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
(0, _createClass2.default)(UploadQueue, [{
|
|
196
|
-
key: "render",
|
|
197
|
-
value: function render() {
|
|
198
|
-
var _cx;
|
|
199
|
-
|
|
200
|
-
var _this$props = this.props,
|
|
201
|
-
t = _this$props.t,
|
|
202
|
-
queue = _this$props.queue,
|
|
203
|
-
doneCount = _this$props.doneCount,
|
|
204
|
-
successCount = _this$props.successCount,
|
|
205
|
-
purgeQueue = _this$props.purgeQueue,
|
|
206
|
-
popover = _this$props.popover,
|
|
207
|
-
getMimeTypeIcon = _this$props.getMimeTypeIcon,
|
|
208
|
-
app = _this$props.app;
|
|
209
|
-
var collapsed = this.state.collapsed;
|
|
210
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
211
|
-
"data-testid": "upload-queue",
|
|
212
|
-
className: (0, _classnames.default)(styles['upload-queue'], (_cx = {}, (0, _defineProperty2.default)(_cx, styles['upload-queue--visible'], queue.length !== 0), (0, _defineProperty2.default)(_cx, styles['upload-queue--collapsed'], collapsed), (0, _defineProperty2.default)(_cx, styles['upload-queue--popover'], popover), _cx))
|
|
213
|
-
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
214
|
-
className: styles['upload-queue-header'],
|
|
215
|
-
onDoubleClick: this.toggleCollapsed
|
|
216
|
-
}, doneCount < queue.length && /*#__PURE__*/_react.default.createElement("div", {
|
|
217
|
-
className: styles['upload-queue-header-inner']
|
|
218
|
-
}, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
219
|
-
variant: "h6",
|
|
220
|
-
className: "u-hide--mob"
|
|
221
|
-
}, t('header', {
|
|
222
|
-
smart_count: queue.length,
|
|
223
|
-
app: app
|
|
224
|
-
})), /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
225
|
-
color: "primary",
|
|
226
|
-
variant: "h6",
|
|
227
|
-
className: "u-hide--tablet"
|
|
228
|
-
}, t('header_mobile', {
|
|
229
|
-
done: doneCount,
|
|
230
|
-
smart_count: queue.length
|
|
231
|
-
}))), doneCount >= queue.length && /*#__PURE__*/_react.default.createElement("div", {
|
|
232
|
-
"data-testid": "upload-queue-success",
|
|
233
|
-
className: styles['upload-queue-header-inner']
|
|
234
|
-
}, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
235
|
-
variant: "h6"
|
|
236
|
-
}, t('header_done', {
|
|
237
|
-
done: successCount,
|
|
238
|
-
smart_count: queue.length
|
|
239
|
-
})), /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
240
|
-
subtle: true,
|
|
241
|
-
className: "u-mv-0",
|
|
242
|
-
label: t('close'),
|
|
243
|
-
onClick: purgeQueue
|
|
244
|
-
}))), /*#__PURE__*/_react.default.createElement(QueueLinearProgress, {
|
|
245
|
-
variant: "determinate",
|
|
246
|
-
value: doneCount / queue.length * 100
|
|
247
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
248
|
-
className: styles['upload-queue-content']
|
|
249
|
-
}, /*#__PURE__*/_react.default.createElement(_List.default, {
|
|
250
|
-
className: "u-pv-0"
|
|
251
|
-
}, queue.map(function (item, index) {
|
|
252
|
-
return /*#__PURE__*/_react.default.createElement(_Item.default, (0, _extends2.default)({
|
|
253
|
-
key: index
|
|
254
|
-
}, item, {
|
|
255
|
-
getMimeTypeIcon: getMimeTypeIcon
|
|
256
|
-
}));
|
|
257
|
-
}))));
|
|
258
|
-
}
|
|
259
|
-
}]);
|
|
260
|
-
return UploadQueue;
|
|
261
|
-
}(_react.Component);
|
|
262
|
-
|
|
263
|
-
exports.UploadQueue = UploadQueue;
|
|
264
|
-
UploadQueue.defaultProps = {
|
|
265
|
-
/**
|
|
266
|
-
* @type {Boolean}
|
|
267
|
-
* Displays the queue in a popover at the bottom right of the screen
|
|
268
|
-
* Use false to disable
|
|
269
|
-
*/
|
|
270
|
-
popover: true
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
var _default = (0, _twakeI18n.withLocales)(locales)(UploadQueue);
|
|
274
|
-
|
|
275
|
-
exports.default = _default;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.useStatusIcon = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
|
-
var _Icon = _interopRequireDefault(require("cozy-ui/transpiled/react/Icon"));
|
|
13
|
-
|
|
14
|
-
var _CheckCircle = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/CheckCircle"));
|
|
15
|
-
|
|
16
|
-
var _CrossCircle = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/CrossCircle"));
|
|
17
|
-
|
|
18
|
-
var _Warning = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Warning"));
|
|
19
|
-
|
|
20
|
-
var _Spinner = _interopRequireDefault(require("cozy-ui/transpiled/react/Spinner"));
|
|
21
|
-
|
|
22
|
-
var _index = require("./index");
|
|
23
|
-
|
|
24
|
-
var useStatusIcon = function useStatusIcon(statusToUse, progress) {
|
|
25
|
-
var CANCEL = _index.uploadStatus.CANCEL,
|
|
26
|
-
LOADING = _index.uploadStatus.LOADING,
|
|
27
|
-
DONE_STATUSES = _index.uploadStatus.DONE_STATUSES,
|
|
28
|
-
ERROR_STATUSES = _index.uploadStatus.ERROR_STATUSES,
|
|
29
|
-
PENDING = _index.uploadStatus.PENDING;
|
|
30
|
-
var SuccessIcon = _CheckCircle.default;
|
|
31
|
-
var ErrorIcon = _CrossCircle.default;
|
|
32
|
-
var statusIcon;
|
|
33
|
-
|
|
34
|
-
if (statusToUse === LOADING) {
|
|
35
|
-
statusIcon = !progress ? /*#__PURE__*/_react.default.createElement(_Spinner.default, {
|
|
36
|
-
color: "var(--primaryColor)"
|
|
37
|
-
}) : null;
|
|
38
|
-
} else if (statusToUse === CANCEL) {
|
|
39
|
-
statusIcon = /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
40
|
-
icon: ErrorIcon,
|
|
41
|
-
color: "var(--errorColor)"
|
|
42
|
-
});
|
|
43
|
-
} else if (ERROR_STATUSES.includes(statusToUse)) {
|
|
44
|
-
statusIcon = /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
45
|
-
icon: _Warning.default,
|
|
46
|
-
color: "var(--errorColor)"
|
|
47
|
-
});
|
|
48
|
-
} else if (DONE_STATUSES.includes(statusToUse)) {
|
|
49
|
-
statusIcon = /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
50
|
-
icon: SuccessIcon,
|
|
51
|
-
color: "var(--successColor)"
|
|
52
|
-
});
|
|
53
|
-
} else if (statusToUse === PENDING) {
|
|
54
|
-
statusIcon = null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return statusIcon;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
exports.useStatusIcon = useStatusIcon;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function numberOfReferencesForPluralForm(durationInSec: any): 1 | 2;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export namespace uploadStatus {
|
|
2
|
-
export { CANCEL };
|
|
3
|
-
export { PENDING };
|
|
4
|
-
export { LOADING };
|
|
5
|
-
export { CREATED };
|
|
6
|
-
export { UPDATED };
|
|
7
|
-
export { FAILED };
|
|
8
|
-
export { CONFLICT };
|
|
9
|
-
export { QUOTA };
|
|
10
|
-
export { NETWORK };
|
|
11
|
-
export { DONE_STATUSES };
|
|
12
|
-
export { ERROR_STATUSES };
|
|
13
|
-
}
|
|
14
|
-
export function formatRemainingTime(durationInSec: any): string;
|
|
15
|
-
export class UploadQueue extends React.Component<any, any, any> {
|
|
16
|
-
constructor(props: Readonly<any>);
|
|
17
|
-
constructor(props: any, context?: any);
|
|
18
|
-
state: {
|
|
19
|
-
collapsed: boolean;
|
|
20
|
-
};
|
|
21
|
-
toggleCollapsed: () => void;
|
|
22
|
-
render(): JSX.Element;
|
|
23
|
-
}
|
|
24
|
-
export namespace UploadQueue {
|
|
25
|
-
namespace defaultProps {
|
|
26
|
-
let popover: boolean;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
declare const _default: any;
|
|
30
|
-
export default _default;
|
|
31
|
-
declare const CANCEL: "cancel";
|
|
32
|
-
declare const PENDING: "pending";
|
|
33
|
-
declare const LOADING: "loading";
|
|
34
|
-
declare const CREATED: "created";
|
|
35
|
-
declare const UPDATED: "updated";
|
|
36
|
-
declare const FAILED: "failed";
|
|
37
|
-
declare const CONFLICT: "conflict";
|
|
38
|
-
declare const QUOTA: "quota";
|
|
39
|
-
declare const NETWORK: "network";
|
|
40
|
-
declare const DONE_STATUSES: string[];
|
|
41
|
-
declare const ERROR_STATUSES: string[];
|
|
42
|
-
import React from 'react';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function useStatusIcon(statusToUse: any, progress: any): JSX.Element;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
import { useIntervalWhen } from 'rooks'
|
|
3
|
-
|
|
4
|
-
import LinearProgress from 'cozy-ui/transpiled/react/LinearProgress'
|
|
5
|
-
import { withStyles } from 'cozy-ui/transpiled/react/styles'
|
|
6
|
-
|
|
7
|
-
import RemainingTime from './RemainingTime'
|
|
8
|
-
import styles from './styles.styl'
|
|
9
|
-
|
|
10
|
-
const FileLinearProgress = withStyles(theme => ({
|
|
11
|
-
root: {
|
|
12
|
-
borderRadius: theme.shape.borderRadius
|
|
13
|
-
},
|
|
14
|
-
colorPrimary: {
|
|
15
|
-
backgroundColor: theme.palette.background.default
|
|
16
|
-
},
|
|
17
|
-
barColorPrimary: {
|
|
18
|
-
backgroundColor: 'var(--emerald)'
|
|
19
|
-
}
|
|
20
|
-
}))(LinearProgress)
|
|
21
|
-
|
|
22
|
-
const FileUploadProgress = ({ progress: progressProps }) => {
|
|
23
|
-
const [progress, setProgress] = useState(progressProps)
|
|
24
|
-
useIntervalWhen(
|
|
25
|
-
() => {
|
|
26
|
-
setProgress(progressProps)
|
|
27
|
-
},
|
|
28
|
-
1000,
|
|
29
|
-
true,
|
|
30
|
-
true
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<div className={styles['upload-queue__upload-progress']}>
|
|
35
|
-
<div className="u-flex-grow-1 u-pr-1">
|
|
36
|
-
<FileLinearProgress
|
|
37
|
-
variant="determinate"
|
|
38
|
-
value={(progress.loaded / progress.total) * 100}
|
|
39
|
-
/>
|
|
40
|
-
</div>
|
|
41
|
-
<div className="u-flex-shrink">
|
|
42
|
-
{progress.remainingTime ? (
|
|
43
|
-
<RemainingTime durationInSec={progress.remainingTime} />
|
|
44
|
-
) : null}
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export default FileUploadProgress
|
package/src/UploadQueue/Item.jsx
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import cx from 'classnames'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import { splitFilename } from 'cozy-client/dist/models/file'
|
|
5
|
-
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
6
|
-
import ListItem from 'cozy-ui/transpiled/react/ListItem'
|
|
7
|
-
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
8
|
-
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
|
|
9
|
-
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
10
|
-
import { Img } from 'cozy-ui/transpiled/react/deprecated/Media'
|
|
11
|
-
import { translate } from 'twake-i18n'
|
|
12
|
-
|
|
13
|
-
import FileUploadProgress from './FileUploadProgress'
|
|
14
|
-
import Pending from './Pending'
|
|
15
|
-
import { uploadStatus } from './index'
|
|
16
|
-
import styles from './styles.styl'
|
|
17
|
-
import { useStatusIcon } from './useStatusIcon'
|
|
18
|
-
|
|
19
|
-
const Item = ({ file, status, isDirectory, progress, getMimeTypeIcon }) => {
|
|
20
|
-
const { CANCEL, LOADING, DONE_STATUSES, ERROR_STATUSES, PENDING } =
|
|
21
|
-
uploadStatus
|
|
22
|
-
const { filename, extension } = splitFilename(file)
|
|
23
|
-
let done = false
|
|
24
|
-
let error = false
|
|
25
|
-
/**
|
|
26
|
-
* Status came from the Upload Queue, but sometimes we're using
|
|
27
|
-
* manual upload without using the Upload Queue system but we're still
|
|
28
|
-
* using the UI component. When this is the case, the file handles on
|
|
29
|
-
* his own its status.
|
|
30
|
-
*/
|
|
31
|
-
const statusToUse = file.status ? file.status : status
|
|
32
|
-
|
|
33
|
-
if (statusToUse !== LOADING && statusToUse !== CANCEL) {
|
|
34
|
-
if (ERROR_STATUSES.includes(statusToUse)) {
|
|
35
|
-
error = true
|
|
36
|
-
} else if (DONE_STATUSES.includes(statusToUse)) {
|
|
37
|
-
done = true
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const statusIcon = useStatusIcon(statusToUse, progress)
|
|
42
|
-
|
|
43
|
-
const isPending =
|
|
44
|
-
statusToUse !== LOADING &&
|
|
45
|
-
statusToUse !== CANCEL &&
|
|
46
|
-
!ERROR_STATUSES.includes(statusToUse) &&
|
|
47
|
-
!DONE_STATUSES.includes(statusToUse) &&
|
|
48
|
-
statusToUse === PENDING
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<ListItem
|
|
52
|
-
divider
|
|
53
|
-
data-testid="upload-queue-item"
|
|
54
|
-
className={cx({
|
|
55
|
-
[styles['upload-queue-item--done']]: done,
|
|
56
|
-
[styles['upload-queue-item--error']]: error
|
|
57
|
-
})}
|
|
58
|
-
>
|
|
59
|
-
{getMimeTypeIcon ? (
|
|
60
|
-
<ListItemIcon className="u-ta-center">
|
|
61
|
-
<Icon
|
|
62
|
-
icon={getMimeTypeIcon(isDirectory, file.name, file.type)}
|
|
63
|
-
size={32}
|
|
64
|
-
className="u-mr-1"
|
|
65
|
-
/>
|
|
66
|
-
</ListItemIcon>
|
|
67
|
-
) : null}
|
|
68
|
-
<ListItemText
|
|
69
|
-
disableTypography
|
|
70
|
-
primary={
|
|
71
|
-
<div data-testid="upload-queue-item-name" className="u-ellipsis">
|
|
72
|
-
<Typography variant="body1" className="u-ellipsis">
|
|
73
|
-
{filename}
|
|
74
|
-
{extension && (
|
|
75
|
-
<Typography
|
|
76
|
-
component="span"
|
|
77
|
-
variant="body1"
|
|
78
|
-
color="textSecondary"
|
|
79
|
-
className="u-dib"
|
|
80
|
-
>
|
|
81
|
-
{extension}
|
|
82
|
-
</Typography>
|
|
83
|
-
)}
|
|
84
|
-
</Typography>
|
|
85
|
-
</div>
|
|
86
|
-
}
|
|
87
|
-
secondary={progress ? <FileUploadProgress progress={progress} /> : null}
|
|
88
|
-
/>
|
|
89
|
-
{statusIcon && (
|
|
90
|
-
<ListItemIcon>
|
|
91
|
-
<Img>{statusIcon}</Img>
|
|
92
|
-
</ListItemIcon>
|
|
93
|
-
)}
|
|
94
|
-
{isPending && <Pending />}
|
|
95
|
-
</ListItem>
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export default translate()(Item)
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
4
|
-
import { translate } from 'twake-i18n'
|
|
5
|
-
|
|
6
|
-
const Pending = translate()(props => (
|
|
7
|
-
<Typography variant="subtitle1" color="primary">
|
|
8
|
-
{props.t('item.pending')}
|
|
9
|
-
</Typography>
|
|
10
|
-
))
|
|
11
|
-
|
|
12
|
-
export default Pending
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
Dumb component to display a list of files being uploaded.
|
|
2
|
-
|
|
3
|
-
On mobile, the list of files being displayed is not shown, only
|
|
4
|
-
a small banner is shown.
|
|
5
|
-
|
|
6
|
-
The popover attribute should be used to automatically layout
|
|
7
|
-
the upload queue:
|
|
8
|
-
|
|
9
|
-
- in a fixed bottom-right position on desktop
|
|
10
|
-
- underneath the top-bar on mobile
|
|
11
|
-
|
|
12
|
-
```jsx
|
|
13
|
-
import isTesting from '../helpers/isTesting'
|
|
14
|
-
import FileIcon from 'cozy-ui/transpiled/react/Icons/File'
|
|
15
|
-
import UploadQueue from 'cozy-ui/transpiled/react/UploadQueue'
|
|
16
|
-
import Checkbox from 'cozy-ui/transpiled/react/Checkbox'
|
|
17
|
-
|
|
18
|
-
const initialState = {
|
|
19
|
-
popover: false
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const data = {
|
|
23
|
-
queue: [{
|
|
24
|
-
file: { name: 'Photo.jpg', type: 'file' },
|
|
25
|
-
status: 'created'
|
|
26
|
-
}, {
|
|
27
|
-
file: { name: 'Photo - conflict error.jpg', type: 'file' },
|
|
28
|
-
status: 'conflict'
|
|
29
|
-
}, {
|
|
30
|
-
file: { name: 'Photo - quota error.jpg', type: 'file' },
|
|
31
|
-
status: 'quota'
|
|
32
|
-
}, {
|
|
33
|
-
file: { name: 'Photo - network error.jpg', type: 'file' },
|
|
34
|
-
status: 'network'
|
|
35
|
-
}, {
|
|
36
|
-
file: { name: 'Photo - generic failure error.jpg', type: 'file' },
|
|
37
|
-
status: 'failed'
|
|
38
|
-
}, {
|
|
39
|
-
file: { name: 'Photo - generic failure error with a very long name - really long - 2020/04/16.txt', type: 'file' },
|
|
40
|
-
status: 'failed'
|
|
41
|
-
}, {
|
|
42
|
-
file: { name: 'File with a very long name - really long - 2020/04/16.txt', type: 'file' },
|
|
43
|
-
progress: {
|
|
44
|
-
loaded: 100,
|
|
45
|
-
total: 400,
|
|
46
|
-
speed: 135000,
|
|
47
|
-
remainingTime: 120
|
|
48
|
-
},
|
|
49
|
-
status: 'loading'
|
|
50
|
-
}, {
|
|
51
|
-
file: { name: 'Directory' },
|
|
52
|
-
status: 'pending'
|
|
53
|
-
}],
|
|
54
|
-
doneCount: 1,
|
|
55
|
-
successCount: 1
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
;
|
|
59
|
-
|
|
60
|
-
<>
|
|
61
|
-
<Checkbox label="Popover" value={state.popover} onChange={() => setState({ popover: !state.popover })} />
|
|
62
|
-
<UploadQueue
|
|
63
|
-
lang='fr'
|
|
64
|
-
app='Cozy Drive'
|
|
65
|
-
getMimeTypeIcon={() => FileIcon}
|
|
66
|
-
queue={data.queue}
|
|
67
|
-
doneCount={data.doneCount}
|
|
68
|
-
successCount={data.successCount}
|
|
69
|
-
popover={state.popover}
|
|
70
|
-
purgeQueue={() => {}}
|
|
71
|
-
/>
|
|
72
|
-
{isTesting() && (
|
|
73
|
-
<>
|
|
74
|
-
<UploadQueue
|
|
75
|
-
lang='fr'
|
|
76
|
-
app='Cozy Drive'
|
|
77
|
-
getMimeTypeIcon={() => FileIcon}
|
|
78
|
-
queue={data.queue}
|
|
79
|
-
doneCount={data.queue.length}
|
|
80
|
-
successCount={data.queue.length}
|
|
81
|
-
popover={false}
|
|
82
|
-
/>
|
|
83
|
-
<UploadQueue
|
|
84
|
-
lang='fr'
|
|
85
|
-
app='Cozy Drive'
|
|
86
|
-
getMimeTypeIcon={() => FileIcon}
|
|
87
|
-
queue={data.queue}
|
|
88
|
-
doneCount={data.doneCount}
|
|
89
|
-
successCount={data.successCount}
|
|
90
|
-
popover={true}
|
|
91
|
-
/>
|
|
92
|
-
</>
|
|
93
|
-
)}
|
|
94
|
-
</>
|
|
95
|
-
```
|