cozy-ui 121.1.2 → 121.2.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 +8 -0
- package/dist/cozy-ui.min.css +1 -1
- package/package.json +1 -1
- package/react/Layout/Layout.jsx +3 -1
- package/react/Sidebar/index.jsx +7 -1
- package/react/UploadQueue/FileUploadProgress.jsx +49 -0
- package/react/UploadQueue/Item.jsx +99 -0
- package/react/UploadQueue/Pending.jsx +12 -0
- package/react/UploadQueue/Readme.md +10 -3
- package/react/UploadQueue/RemainingTime.jsx +26 -0
- package/react/UploadQueue/helpers.js +3 -0
- package/react/UploadQueue/index.jsx +3 -172
- package/react/UploadQueue/styles.styl +4 -2
- package/react/UploadQueue/useStatusIcon.js +34 -0
- package/stylus/objects/layouts.styl +12 -2
- package/stylus/objects/sidebar.styl +6 -1
- package/transpiled/react/Layout/Layout.js +6 -2
- package/transpiled/react/Sidebar/index.js +6 -2
- package/transpiled/react/UploadQueue/FileUploadProgress.js +66 -0
- package/transpiled/react/UploadQueue/Item.js +106 -0
- package/transpiled/react/UploadQueue/Pending.js +10 -0
- package/transpiled/react/UploadQueue/RemainingTime.js +43 -0
- package/transpiled/react/UploadQueue/helpers.js +4 -0
- package/transpiled/react/UploadQueue/index.js +5 -169
- package/transpiled/react/UploadQueue/useStatusIcon.js +45 -0
- package/transpiled/react/stylesheet.css +1 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import LinearProgress from '@material-ui/core/LinearProgress';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { useIntervalWhen } from 'rooks';
|
|
5
|
+
import RemainingTime from "cozy-ui/transpiled/react/UploadQueue/RemainingTime";
|
|
6
|
+
var styles = {
|
|
7
|
+
"upload-queue": "styles__upload-queue___1VtNK",
|
|
8
|
+
"upload-queue__threshold-bar": "styles__upload-queue__threshold-bar___tTYal",
|
|
9
|
+
"upload-queue__progress-caption": "styles__upload-queue__progress-caption___1-vXY",
|
|
10
|
+
"upload-queue__upload-progress": "styles__upload-queue__upload-progress___1q-uS",
|
|
11
|
+
"upload-queue--popover": "styles__upload-queue--popover___2z1a4",
|
|
12
|
+
"upload-queue--visible": "styles__upload-queue--visible___DjVRs",
|
|
13
|
+
"upload-queue-header": "styles__upload-queue-header___c9Vf2",
|
|
14
|
+
"upload-queue-header-inner": "styles__upload-queue-header-inner___26wpB",
|
|
15
|
+
"upload-queue-progress": "styles__upload-queue-progress___1CmN-",
|
|
16
|
+
"upload-queue-content": "styles__upload-queue-content___3MPHo",
|
|
17
|
+
"upload-queue--collapsed": "styles__upload-queue--collapsed___3cchD",
|
|
18
|
+
"upload-queue-list": "styles__upload-queue-list___OVvJm",
|
|
19
|
+
"upload-queue-item--error": "styles__upload-queue-item--error___2sSeV",
|
|
20
|
+
"upload-queue-item--done": "styles__upload-queue-item--done___2PSJI",
|
|
21
|
+
"item-file": "styles__item-file___1kfDn",
|
|
22
|
+
"item-status": "styles__item-status___3FNcY",
|
|
23
|
+
"spin": "styles__spin___3GZIp",
|
|
24
|
+
"shake": "styles__shake___u1Pks"
|
|
25
|
+
};
|
|
26
|
+
import { withStyles } from "cozy-ui/transpiled/react/styles";
|
|
27
|
+
var FileLinearProgress = withStyles(function (theme) {
|
|
28
|
+
return {
|
|
29
|
+
root: {
|
|
30
|
+
borderRadius: theme.shape.borderRadius
|
|
31
|
+
},
|
|
32
|
+
colorPrimary: {
|
|
33
|
+
backgroundColor: theme.palette.background.default
|
|
34
|
+
},
|
|
35
|
+
barColorPrimary: {
|
|
36
|
+
backgroundColor: 'var(--emerald)'
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
})(LinearProgress);
|
|
40
|
+
|
|
41
|
+
var FileUploadProgress = function FileUploadProgress(_ref) {
|
|
42
|
+
var progressProps = _ref.progress;
|
|
43
|
+
|
|
44
|
+
var _useState = useState(progressProps),
|
|
45
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
46
|
+
progress = _useState2[0],
|
|
47
|
+
setProgress = _useState2[1];
|
|
48
|
+
|
|
49
|
+
useIntervalWhen(function () {
|
|
50
|
+
setProgress(progressProps);
|
|
51
|
+
}, 1000, true, true);
|
|
52
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: styles['upload-queue__upload-progress']
|
|
54
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
className: "u-flex-grow-1 u-pr-1"
|
|
56
|
+
}, /*#__PURE__*/React.createElement(FileLinearProgress, {
|
|
57
|
+
variant: "determinate",
|
|
58
|
+
value: progress.loaded / progress.total * 100
|
|
59
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: "u-flex-shrink"
|
|
61
|
+
}, progress.remainingTime ? /*#__PURE__*/React.createElement(RemainingTime, {
|
|
62
|
+
durationInSec: progress.remainingTime
|
|
63
|
+
}) : null));
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default FileUploadProgress;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { splitFilename } from 'cozy-client/dist/models/file';
|
|
5
|
+
import FileUploadProgress from "cozy-ui/transpiled/react/UploadQueue/FileUploadProgress";
|
|
6
|
+
import Pending from "cozy-ui/transpiled/react/UploadQueue/Pending";
|
|
7
|
+
import { uploadStatus } from "cozy-ui/transpiled/react/UploadQueue/index";
|
|
8
|
+
var styles = {
|
|
9
|
+
"upload-queue": "styles__upload-queue___1VtNK",
|
|
10
|
+
"upload-queue__threshold-bar": "styles__upload-queue__threshold-bar___tTYal",
|
|
11
|
+
"upload-queue__progress-caption": "styles__upload-queue__progress-caption___1-vXY",
|
|
12
|
+
"upload-queue__upload-progress": "styles__upload-queue__upload-progress___1q-uS",
|
|
13
|
+
"upload-queue--popover": "styles__upload-queue--popover___2z1a4",
|
|
14
|
+
"upload-queue--visible": "styles__upload-queue--visible___DjVRs",
|
|
15
|
+
"upload-queue-header": "styles__upload-queue-header___c9Vf2",
|
|
16
|
+
"upload-queue-header-inner": "styles__upload-queue-header-inner___26wpB",
|
|
17
|
+
"upload-queue-progress": "styles__upload-queue-progress___1CmN-",
|
|
18
|
+
"upload-queue-content": "styles__upload-queue-content___3MPHo",
|
|
19
|
+
"upload-queue--collapsed": "styles__upload-queue--collapsed___3cchD",
|
|
20
|
+
"upload-queue-list": "styles__upload-queue-list___OVvJm",
|
|
21
|
+
"upload-queue-item--error": "styles__upload-queue-item--error___2sSeV",
|
|
22
|
+
"upload-queue-item--done": "styles__upload-queue-item--done___2PSJI",
|
|
23
|
+
"item-file": "styles__item-file___1kfDn",
|
|
24
|
+
"item-status": "styles__item-status___3FNcY",
|
|
25
|
+
"spin": "styles__spin___3GZIp",
|
|
26
|
+
"shake": "styles__shake___u1Pks"
|
|
27
|
+
};
|
|
28
|
+
import { useStatusIcon } from "cozy-ui/transpiled/react/UploadQueue/useStatusIcon";
|
|
29
|
+
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
30
|
+
import ListItem from "cozy-ui/transpiled/react/ListItem";
|
|
31
|
+
import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
|
|
32
|
+
import ListItemText from "cozy-ui/transpiled/react/ListItemText";
|
|
33
|
+
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
34
|
+
import { Img } from "cozy-ui/transpiled/react/deprecated/Media";
|
|
35
|
+
import { translate } from "cozy-ui/transpiled/react/providers/I18n";
|
|
36
|
+
|
|
37
|
+
var Item = function Item(_ref) {
|
|
38
|
+
var _cx;
|
|
39
|
+
|
|
40
|
+
var file = _ref.file,
|
|
41
|
+
status = _ref.status,
|
|
42
|
+
isDirectory = _ref.isDirectory,
|
|
43
|
+
progress = _ref.progress,
|
|
44
|
+
getMimeTypeIcon = _ref.getMimeTypeIcon;
|
|
45
|
+
var CANCEL = uploadStatus.CANCEL,
|
|
46
|
+
LOADING = uploadStatus.LOADING,
|
|
47
|
+
DONE_STATUSES = uploadStatus.DONE_STATUSES,
|
|
48
|
+
ERROR_STATUSES = uploadStatus.ERROR_STATUSES,
|
|
49
|
+
PENDING = uploadStatus.PENDING;
|
|
50
|
+
|
|
51
|
+
var _splitFilename = splitFilename(file),
|
|
52
|
+
filename = _splitFilename.filename,
|
|
53
|
+
extension = _splitFilename.extension;
|
|
54
|
+
|
|
55
|
+
var done = false;
|
|
56
|
+
var error = false;
|
|
57
|
+
/**
|
|
58
|
+
* Status came from the Upload Queue, but sometimes we're using
|
|
59
|
+
* manual upload without using the Upload Queue system but we're still
|
|
60
|
+
* using the UI component. When this is the case, the file handles on
|
|
61
|
+
* his own its status.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
var statusToUse = file.status ? file.status : status;
|
|
65
|
+
|
|
66
|
+
if (statusToUse !== LOADING && statusToUse !== CANCEL) {
|
|
67
|
+
if (ERROR_STATUSES.includes(statusToUse)) {
|
|
68
|
+
error = true;
|
|
69
|
+
} else if (DONE_STATUSES.includes(statusToUse)) {
|
|
70
|
+
done = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var statusIcon = useStatusIcon(statusToUse, progress);
|
|
75
|
+
var isPending = statusToUse !== LOADING && statusToUse !== CANCEL && !ERROR_STATUSES.includes(statusToUse) && !DONE_STATUSES.includes(statusToUse) && statusToUse === PENDING;
|
|
76
|
+
return /*#__PURE__*/React.createElement(ListItem, {
|
|
77
|
+
divider: true,
|
|
78
|
+
"data-testid": "upload-queue-item",
|
|
79
|
+
className: cx((_cx = {}, _defineProperty(_cx, styles['upload-queue-item--done'], done), _defineProperty(_cx, styles['upload-queue-item--error'], error), _cx))
|
|
80
|
+
}, getMimeTypeIcon ? /*#__PURE__*/React.createElement(ListItemIcon, {
|
|
81
|
+
className: "u-ta-center"
|
|
82
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
83
|
+
icon: getMimeTypeIcon(isDirectory, file.name, file.type),
|
|
84
|
+
size: 32,
|
|
85
|
+
className: "u-mr-1"
|
|
86
|
+
})) : null, /*#__PURE__*/React.createElement(ListItemText, {
|
|
87
|
+
disableTypography: true,
|
|
88
|
+
primary: /*#__PURE__*/React.createElement("div", {
|
|
89
|
+
"data-testid": "upload-queue-item-name",
|
|
90
|
+
className: "u-ellipsis"
|
|
91
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
92
|
+
variant: "body1",
|
|
93
|
+
className: "u-ellipsis"
|
|
94
|
+
}, filename, extension && /*#__PURE__*/React.createElement(Typography, {
|
|
95
|
+
component: "span",
|
|
96
|
+
variant: "body1",
|
|
97
|
+
color: "textSecondary",
|
|
98
|
+
className: "u-dib"
|
|
99
|
+
}, extension))),
|
|
100
|
+
secondary: progress ? /*#__PURE__*/React.createElement(FileUploadProgress, {
|
|
101
|
+
progress: progress
|
|
102
|
+
}) : null
|
|
103
|
+
}), statusIcon && /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Img, null, statusIcon)), isPending && /*#__PURE__*/React.createElement(Pending, null));
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default translate()(Item);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
3
|
+
import { translate } from "cozy-ui/transpiled/react/providers/I18n";
|
|
4
|
+
var Pending = translate()(function (props) {
|
|
5
|
+
return /*#__PURE__*/React.createElement(Typography, {
|
|
6
|
+
variant: "subtitle1",
|
|
7
|
+
color: "primary"
|
|
8
|
+
}, props.t('item.pending'));
|
|
9
|
+
});
|
|
10
|
+
export default Pending;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { numberOfReferencesForPluralForm } from "cozy-ui/transpiled/react/UploadQueue/helpers";
|
|
4
|
+
import { formatRemainingTime } from "cozy-ui/transpiled/react/UploadQueue/index";
|
|
5
|
+
var styles = {
|
|
6
|
+
"upload-queue": "styles__upload-queue___1VtNK",
|
|
7
|
+
"upload-queue__threshold-bar": "styles__upload-queue__threshold-bar___tTYal",
|
|
8
|
+
"upload-queue__progress-caption": "styles__upload-queue__progress-caption___1-vXY",
|
|
9
|
+
"upload-queue__upload-progress": "styles__upload-queue__upload-progress___1q-uS",
|
|
10
|
+
"upload-queue--popover": "styles__upload-queue--popover___2z1a4",
|
|
11
|
+
"upload-queue--visible": "styles__upload-queue--visible___DjVRs",
|
|
12
|
+
"upload-queue-header": "styles__upload-queue-header___c9Vf2",
|
|
13
|
+
"upload-queue-header-inner": "styles__upload-queue-header-inner___26wpB",
|
|
14
|
+
"upload-queue-progress": "styles__upload-queue-progress___1CmN-",
|
|
15
|
+
"upload-queue-content": "styles__upload-queue-content___3MPHo",
|
|
16
|
+
"upload-queue--collapsed": "styles__upload-queue--collapsed___3cchD",
|
|
17
|
+
"upload-queue-list": "styles__upload-queue-list___OVvJm",
|
|
18
|
+
"upload-queue-item--error": "styles__upload-queue-item--error___2sSeV",
|
|
19
|
+
"upload-queue-item--done": "styles__upload-queue-item--done___2PSJI",
|
|
20
|
+
"item-file": "styles__item-file___1kfDn",
|
|
21
|
+
"item-status": "styles__item-status___3FNcY",
|
|
22
|
+
"spin": "styles__spin___3GZIp",
|
|
23
|
+
"shake": "styles__shake___u1Pks"
|
|
24
|
+
};
|
|
25
|
+
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
26
|
+
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
27
|
+
|
|
28
|
+
var RemainingTime = function RemainingTime(_ref) {
|
|
29
|
+
var durationInSec = _ref.durationInSec;
|
|
30
|
+
|
|
31
|
+
var _useI18n = useI18n(),
|
|
32
|
+
t = _useI18n.t;
|
|
33
|
+
|
|
34
|
+
return /*#__PURE__*/React.createElement(Typography, {
|
|
35
|
+
variant: "caption",
|
|
36
|
+
className: cx(styles['upload-queue__progress-caption'], 'u-ellipsis')
|
|
37
|
+
}, t('item.remainingTime', {
|
|
38
|
+
time: formatRemainingTime(durationInSec),
|
|
39
|
+
smart_count: numberOfReferencesForPluralForm(durationInSec)
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default RemainingTime;
|
|
@@ -6,7 +6,6 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
10
9
|
|
|
11
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
11
|
|
|
@@ -14,9 +13,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
14
13
|
|
|
15
14
|
import LinearProgress from '@material-ui/core/LinearProgress';
|
|
16
15
|
import cx from 'classnames';
|
|
17
|
-
import React, { Component
|
|
18
|
-
import
|
|
19
|
-
import { splitFilename } from 'cozy-client/dist/models/file';
|
|
16
|
+
import React, { Component } from 'react';
|
|
17
|
+
import Item from "cozy-ui/transpiled/react/UploadQueue/Item";
|
|
20
18
|
var localeEn = {
|
|
21
19
|
header: "Uploading %{smart_count} photo to %{app} |||| Uploading %{smart_count} photos to %{app}",
|
|
22
20
|
header_mobile: "Uploading %{done} of %{smart_count}",
|
|
@@ -67,19 +65,9 @@ var styles = {
|
|
|
67
65
|
"spin": "styles__spin___3GZIp",
|
|
68
66
|
"shake": "styles__shake___u1Pks"
|
|
69
67
|
};
|
|
70
|
-
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
71
|
-
import CheckIcon from "cozy-ui/transpiled/react/Icons/Check";
|
|
72
|
-
import CrossIcon from "cozy-ui/transpiled/react/Icons/Cross";
|
|
73
|
-
import WarningIcon from "cozy-ui/transpiled/react/Icons/Warning";
|
|
74
|
-
import Spinner from "cozy-ui/transpiled/react/Spinner";
|
|
75
|
-
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
76
68
|
import List from "cozy-ui/transpiled/react/List";
|
|
77
|
-
import
|
|
78
|
-
import ListItemText from "cozy-ui/transpiled/react/ListItemText";
|
|
79
|
-
import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
|
|
80
|
-
import { Img } from "cozy-ui/transpiled/react/deprecated/Media";
|
|
69
|
+
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
81
70
|
import Button from "cozy-ui/transpiled/react/deprecated/Button";
|
|
82
|
-
import { translate, useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
83
71
|
import { formatLocallyDistanceToNow } from "cozy-ui/transpiled/react/providers/I18n/format";
|
|
84
72
|
import withLocales from "cozy-ui/transpiled/react/providers/I18n/withLocales";
|
|
85
73
|
import { withStyles } from "cozy-ui/transpiled/react/styles";
|
|
@@ -112,167 +100,15 @@ export var uploadStatus = {
|
|
|
112
100
|
DONE_STATUSES: DONE_STATUSES,
|
|
113
101
|
ERROR_STATUSES: ERROR_STATUSES
|
|
114
102
|
};
|
|
115
|
-
var Pending = translate()(function (props) {
|
|
116
|
-
return /*#__PURE__*/React.createElement(Typography, {
|
|
117
|
-
variant: "subtitle1",
|
|
118
|
-
color: "primary"
|
|
119
|
-
}, props.t('item.pending'));
|
|
120
|
-
});
|
|
121
103
|
export var formatRemainingTime = function formatRemainingTime(durationInSec) {
|
|
122
104
|
var later = Date.now() + durationInSec * 1000;
|
|
123
105
|
return formatLocallyDistanceToNow(later);
|
|
124
|
-
}; // https://date-fns.org/v2.28.0/docs/formatDistanceToNow
|
|
125
|
-
|
|
126
|
-
var numberOfReferencesForPluralForm = function numberOfReferencesForPluralForm(durationInSec) {
|
|
127
|
-
return durationInSec < 90 || durationInSec > 2670 && durationInSec < 5370 ? 1 : 2;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
var RemainingTime = function RemainingTime(_ref) {
|
|
131
|
-
var durationInSec = _ref.durationInSec;
|
|
132
|
-
|
|
133
|
-
var _useI18n = useI18n(),
|
|
134
|
-
t = _useI18n.t;
|
|
135
|
-
|
|
136
|
-
return /*#__PURE__*/React.createElement(Typography, {
|
|
137
|
-
variant: "caption",
|
|
138
|
-
className: cx(styles['upload-queue__progress-caption'], 'u-ellipsis')
|
|
139
|
-
}, t('item.remainingTime', {
|
|
140
|
-
time: formatRemainingTime(durationInSec),
|
|
141
|
-
smart_count: numberOfReferencesForPluralForm(durationInSec)
|
|
142
|
-
}));
|
|
143
106
|
};
|
|
144
|
-
|
|
145
|
-
var FileLinearProgress = withStyles(function (theme) {
|
|
146
|
-
return {
|
|
147
|
-
root: {
|
|
148
|
-
borderRadius: theme.shape.borderRadius
|
|
149
|
-
},
|
|
150
|
-
colorPrimary: {
|
|
151
|
-
backgroundColor: theme.palette.background.default
|
|
152
|
-
},
|
|
153
|
-
barColorPrimary: {
|
|
154
|
-
backgroundColor: 'var(--emerald)'
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
})(LinearProgress);
|
|
158
107
|
var QueueLinearProgress = withStyles({
|
|
159
108
|
root: {
|
|
160
109
|
height: '2px'
|
|
161
110
|
}
|
|
162
111
|
})(LinearProgress);
|
|
163
|
-
|
|
164
|
-
var FileUploadProgress = function FileUploadProgress(_ref2) {
|
|
165
|
-
var progressProps = _ref2.progress;
|
|
166
|
-
|
|
167
|
-
var _useState = useState(progressProps),
|
|
168
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
169
|
-
progress = _useState2[0],
|
|
170
|
-
setProgress = _useState2[1];
|
|
171
|
-
|
|
172
|
-
useIntervalWhen(function () {
|
|
173
|
-
setProgress(progressProps);
|
|
174
|
-
}, 1000, true, true);
|
|
175
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
176
|
-
className: styles['upload-queue__upload-progress']
|
|
177
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
178
|
-
className: "u-flex-grow-1 u-pr-1"
|
|
179
|
-
}, /*#__PURE__*/React.createElement(FileLinearProgress, {
|
|
180
|
-
variant: "determinate",
|
|
181
|
-
value: progress.loaded / progress.total * 100
|
|
182
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
183
|
-
className: "u-flex-shrink"
|
|
184
|
-
}, progress.remainingTime ? /*#__PURE__*/React.createElement(RemainingTime, {
|
|
185
|
-
durationInSec: progress.remainingTime
|
|
186
|
-
}) : null));
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
var Item = translate()(function (_ref3) {
|
|
190
|
-
var _cx;
|
|
191
|
-
|
|
192
|
-
var file = _ref3.file,
|
|
193
|
-
status = _ref3.status,
|
|
194
|
-
isDirectory = _ref3.isDirectory,
|
|
195
|
-
progress = _ref3.progress,
|
|
196
|
-
getMimeTypeIcon = _ref3.getMimeTypeIcon;
|
|
197
|
-
var CANCEL = uploadStatus.CANCEL,
|
|
198
|
-
LOADING = uploadStatus.LOADING,
|
|
199
|
-
DONE_STATUSES = uploadStatus.DONE_STATUSES,
|
|
200
|
-
ERROR_STATUSES = uploadStatus.ERROR_STATUSES;
|
|
201
|
-
|
|
202
|
-
var _splitFilename = splitFilename(file),
|
|
203
|
-
filename = _splitFilename.filename,
|
|
204
|
-
extension = _splitFilename.extension;
|
|
205
|
-
|
|
206
|
-
var statusIcon;
|
|
207
|
-
var done = false;
|
|
208
|
-
var error = false;
|
|
209
|
-
/**
|
|
210
|
-
* Status came from the Upload Queue, but sometimes we're using
|
|
211
|
-
* manual upload without using the Upload Queue system but we're still
|
|
212
|
-
* using the UI component. When this is the case, the file handles on
|
|
213
|
-
* his own its status.
|
|
214
|
-
*/
|
|
215
|
-
|
|
216
|
-
var statusToUse = file.status ? file.status : status;
|
|
217
|
-
|
|
218
|
-
if (statusToUse === LOADING) {
|
|
219
|
-
statusIcon = !progress ? /*#__PURE__*/React.createElement(Spinner, {
|
|
220
|
-
className: "u-ml-half",
|
|
221
|
-
color: "var(--primaryColor)"
|
|
222
|
-
}) : null;
|
|
223
|
-
} else if (statusToUse === CANCEL) {
|
|
224
|
-
statusIcon = /*#__PURE__*/React.createElement(Icon, {
|
|
225
|
-
className: "u-ml-half",
|
|
226
|
-
icon: CrossIcon,
|
|
227
|
-
color: "var(--errorColor)"
|
|
228
|
-
});
|
|
229
|
-
} else if (ERROR_STATUSES.includes(statusToUse)) {
|
|
230
|
-
error = true;
|
|
231
|
-
statusIcon = /*#__PURE__*/React.createElement(Icon, {
|
|
232
|
-
className: "u-ml-half",
|
|
233
|
-
icon: WarningIcon,
|
|
234
|
-
color: "var(--errorColor)"
|
|
235
|
-
});
|
|
236
|
-
} else if (DONE_STATUSES.includes(statusToUse)) {
|
|
237
|
-
done = true;
|
|
238
|
-
statusIcon = /*#__PURE__*/React.createElement(Icon, {
|
|
239
|
-
className: "u-ml-half",
|
|
240
|
-
icon: CheckIcon,
|
|
241
|
-
color: "var(--successColor)"
|
|
242
|
-
});
|
|
243
|
-
} else if (statusToUse === PENDING) {
|
|
244
|
-
statusIcon = /*#__PURE__*/React.createElement(Pending, null);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return /*#__PURE__*/React.createElement(ListItem, {
|
|
248
|
-
divider: true,
|
|
249
|
-
"data-testid": "upload-queue-item",
|
|
250
|
-
className: cx('u-ph-1', (_cx = {}, _defineProperty(_cx, styles['upload-queue-item--done'], done), _defineProperty(_cx, styles['upload-queue-item--error'], error), _cx))
|
|
251
|
-
}, getMimeTypeIcon ? /*#__PURE__*/React.createElement(ListItemIcon, {
|
|
252
|
-
className: "u-ta-center"
|
|
253
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
254
|
-
icon: getMimeTypeIcon(isDirectory, file.name, file.type),
|
|
255
|
-
size: 32,
|
|
256
|
-
className: "u-mr-1"
|
|
257
|
-
})) : null, /*#__PURE__*/React.createElement(ListItemText, {
|
|
258
|
-
disableTypography: true
|
|
259
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
260
|
-
"data-testid": "upload-queue-item-name",
|
|
261
|
-
className: "u-ellipsis"
|
|
262
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
263
|
-
variant: "body1",
|
|
264
|
-
className: "u-ellipsis"
|
|
265
|
-
}, filename, extension && /*#__PURE__*/React.createElement(Typography, {
|
|
266
|
-
component: "span",
|
|
267
|
-
variant: "body1",
|
|
268
|
-
color: "textSecondary",
|
|
269
|
-
className: "u-dib"
|
|
270
|
-
}, extension))), progress ? /*#__PURE__*/React.createElement(FileUploadProgress, {
|
|
271
|
-
progress: progress
|
|
272
|
-
}) : null), /*#__PURE__*/React.createElement(Img, {
|
|
273
|
-
className: styles['item-status']
|
|
274
|
-
}, statusIcon));
|
|
275
|
-
});
|
|
276
112
|
export var UploadQueue = /*#__PURE__*/function (_Component) {
|
|
277
113
|
_inherits(UploadQueue, _Component);
|
|
278
114
|
|
|
@@ -307,7 +143,7 @@ export var UploadQueue = /*#__PURE__*/function (_Component) {
|
|
|
307
143
|
_createClass(UploadQueue, [{
|
|
308
144
|
key: "render",
|
|
309
145
|
value: function render() {
|
|
310
|
-
var
|
|
146
|
+
var _cx;
|
|
311
147
|
|
|
312
148
|
var _this$props = this.props,
|
|
313
149
|
t = _this$props.t,
|
|
@@ -321,7 +157,7 @@ export var UploadQueue = /*#__PURE__*/function (_Component) {
|
|
|
321
157
|
var collapsed = this.state.collapsed;
|
|
322
158
|
return /*#__PURE__*/React.createElement("div", {
|
|
323
159
|
"data-testid": "upload-queue",
|
|
324
|
-
className: cx(styles['upload-queue'], (
|
|
160
|
+
className: cx(styles['upload-queue'], (_cx = {}, _defineProperty(_cx, styles['upload-queue--visible'], queue.length !== 0), _defineProperty(_cx, styles['upload-queue--collapsed'], collapsed), _defineProperty(_cx, styles['upload-queue--popover'], popover), _cx))
|
|
325
161
|
}, /*#__PURE__*/React.createElement("h4", {
|
|
326
162
|
className: styles['upload-queue-header'],
|
|
327
163
|
onDoubleClick: this.toggleCollapsed
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { uploadStatus } from "cozy-ui/transpiled/react/UploadQueue/index";
|
|
3
|
+
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
4
|
+
import CheckIcon from "cozy-ui/transpiled/react/Icons/Check";
|
|
5
|
+
import CheckCircleIcon from "cozy-ui/transpiled/react/Icons/CheckCircle";
|
|
6
|
+
import CrossIcon from "cozy-ui/transpiled/react/Icons/Cross";
|
|
7
|
+
import CrossCircleIcon from "cozy-ui/transpiled/react/Icons/CrossCircle";
|
|
8
|
+
import WarningIcon from "cozy-ui/transpiled/react/Icons/Warning";
|
|
9
|
+
import Spinner from "cozy-ui/transpiled/react/Spinner";
|
|
10
|
+
import { isTwakeTheme } from "cozy-ui/transpiled/react/helpers/isTwakeTheme";
|
|
11
|
+
export var useStatusIcon = function useStatusIcon(statusToUse, progress) {
|
|
12
|
+
var CANCEL = uploadStatus.CANCEL,
|
|
13
|
+
LOADING = uploadStatus.LOADING,
|
|
14
|
+
DONE_STATUSES = uploadStatus.DONE_STATUSES,
|
|
15
|
+
ERROR_STATUSES = uploadStatus.ERROR_STATUSES,
|
|
16
|
+
PENDING = uploadStatus.PENDING;
|
|
17
|
+
var SuccessIcon = isTwakeTheme() ? CheckCircleIcon : CheckIcon;
|
|
18
|
+
var ErrorIcon = isTwakeTheme() ? CrossCircleIcon : CrossIcon;
|
|
19
|
+
var statusIcon;
|
|
20
|
+
|
|
21
|
+
if (statusToUse === LOADING) {
|
|
22
|
+
statusIcon = !progress ? /*#__PURE__*/React.createElement(Spinner, {
|
|
23
|
+
color: "var(--primaryColor)"
|
|
24
|
+
}) : null;
|
|
25
|
+
} else if (statusToUse === CANCEL) {
|
|
26
|
+
statusIcon = /*#__PURE__*/React.createElement(Icon, {
|
|
27
|
+
icon: ErrorIcon,
|
|
28
|
+
color: "var(--errorColor)"
|
|
29
|
+
});
|
|
30
|
+
} else if (ERROR_STATUSES.includes(statusToUse)) {
|
|
31
|
+
statusIcon = /*#__PURE__*/React.createElement(Icon, {
|
|
32
|
+
icon: WarningIcon,
|
|
33
|
+
color: "var(--errorColor)"
|
|
34
|
+
});
|
|
35
|
+
} else if (DONE_STATUSES.includes(statusToUse)) {
|
|
36
|
+
statusIcon = /*#__PURE__*/React.createElement(Icon, {
|
|
37
|
+
icon: SuccessIcon,
|
|
38
|
+
color: "var(--successColor)"
|
|
39
|
+
});
|
|
40
|
+
} else if (statusToUse === PENDING) {
|
|
41
|
+
statusIcon = null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return statusIcon;
|
|
45
|
+
};
|