box-ui-elements 14.0.0 → 14.1.0-beta.3
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/dist/explorer.css +1 -1
- package/dist/explorer.js +7 -7
- package/dist/openwith.css +1 -1
- package/dist/openwith.js +3 -3
- package/dist/picker.css +1 -1
- package/dist/picker.js +10 -10
- package/dist/preview.css +1 -1
- package/dist/preview.js +7 -7
- package/dist/sharing.css +1 -1
- package/dist/sharing.js +4 -4
- package/dist/sidebar.css +1 -1
- package/dist/sidebar.js +5 -5
- package/dist/uploader.css +1 -1
- package/dist/uploader.js +13 -13
- package/es/components/notification/Notification.js +2 -3
- package/es/components/notification/Notification.js.flow +2 -4
- package/es/components/notification/Notification.js.map +1 -1
- package/es/components/notification/Notification.scss +7 -8
- package/es/elements/common/messages.js +8 -0
- package/es/elements/common/messages.js.flow +10 -0
- package/es/elements/common/messages.js.map +1 -1
- package/es/elements/content-uploader/ContentUploader.js +11 -9
- package/es/elements/content-uploader/ContentUploader.js.flow +10 -7
- package/es/elements/content-uploader/ContentUploader.js.map +1 -1
- package/es/elements/content-uploader/ItemAction.js +19 -6
- package/es/elements/content-uploader/ItemAction.js.flow +34 -3
- package/es/elements/content-uploader/ItemAction.js.map +1 -1
- package/es/elements/content-uploader/ItemList.js +5 -4
- package/es/elements/content-uploader/ItemList.js.flow +11 -4
- package/es/elements/content-uploader/ItemList.js.map +1 -1
- package/es/elements/content-uploader/UploadsManager.js +8 -6
- package/es/elements/content-uploader/UploadsManager.js.flow +8 -5
- package/es/elements/content-uploader/UploadsManager.js.map +1 -1
- package/es/elements/content-uploader/actionCellRenderer.js +3 -2
- package/es/elements/content-uploader/actionCellRenderer.js.flow +9 -2
- package/es/elements/content-uploader/actionCellRenderer.js.map +1 -1
- package/es/elements/content-uploader/progressCellRenderer.js +7 -3
- package/es/elements/content-uploader/progressCellRenderer.js.flow +6 -3
- package/es/elements/content-uploader/progressCellRenderer.js.map +1 -1
- package/i18n/bn-IN.js +2 -0
- package/i18n/da-DK.js +2 -0
- package/i18n/de-DE.js +2 -0
- package/i18n/en-AU.js +2 -0
- package/i18n/en-CA.js +2 -0
- package/i18n/en-GB.js +2 -0
- package/i18n/en-US.js +2 -0
- package/i18n/en-US.properties +4 -0
- package/i18n/en-x-pseudo.js +2 -0
- package/i18n/es-419.js +2 -0
- package/i18n/es-ES.js +2 -0
- package/i18n/fi-FI.js +2 -0
- package/i18n/fr-CA.js +2 -0
- package/i18n/fr-FR.js +2 -0
- package/i18n/hi-IN.js +2 -0
- package/i18n/it-IT.js +2 -0
- package/i18n/ja-JP.js +5 -3
- package/i18n/ja-JP.properties +3 -3
- package/i18n/ko-KR.js +2 -0
- package/i18n/nb-NO.js +2 -0
- package/i18n/nl-NL.js +2 -0
- package/i18n/pl-PL.js +2 -0
- package/i18n/pt-BR.js +2 -0
- package/i18n/ru-RU.js +2 -0
- package/i18n/sv-SE.js +2 -0
- package/i18n/tr-TR.js +2 -0
- package/i18n/zh-CN.js +2 -0
- package/i18n/zh-TW.js +2 -0
- package/package.json +1 -1
- package/src/components/notification/Notification.js +2 -4
- package/src/components/notification/Notification.scss +7 -8
- package/src/elements/common/messages.js +10 -0
- package/src/elements/content-uploader/ContentUploader.js +10 -7
- package/src/elements/content-uploader/ItemAction.js +34 -3
- package/src/elements/content-uploader/ItemList.js +11 -4
- package/src/elements/content-uploader/UploadsManager.js +8 -5
- package/src/elements/content-uploader/__tests__/ItemAction.test.js +19 -1
- package/src/elements/content-uploader/__tests__/ItemList.test.js +45 -0
- package/src/elements/content-uploader/actionCellRenderer.js +9 -2
- package/src/elements/content-uploader/progressCellRenderer.js +6 -3
package/i18n/sv-SE.js
CHANGED
|
@@ -333,6 +333,8 @@ export default {
|
|
|
333
333
|
"be.uploadsCancelButtonTooltip": "Avbryt uppladdningen",
|
|
334
334
|
"be.uploadsDefaultErrorMessage": "Något gick fel med uppladdningen. Försök igen.",
|
|
335
335
|
"be.uploadsFileSizeLimitExceededErrorMessage": "Filstorleken överskrider mappägarens filstorleksgräns",
|
|
336
|
+
"be.uploadsFileSizeLimitExceededErrorMessageForUpgradeCta": "This file exceeds your plan’s upload limit. Upgrade now to store larger files.",
|
|
337
|
+
"be.uploadsFileSizeLimitExceededUpgradeMessageForUpgradeCta": "Upgrade",
|
|
336
338
|
"be.uploadsItemNameInUseErrorMessage": "Det finns redan en fil med det här namnet.",
|
|
337
339
|
"be.uploadsManagerUploadComplete": "Klar",
|
|
338
340
|
"be.uploadsManagerUploadFailed": "Några uppladdningar misslyckades",
|
package/i18n/tr-TR.js
CHANGED
|
@@ -333,6 +333,8 @@ export default {
|
|
|
333
333
|
"be.uploadsCancelButtonTooltip": "Bu yüklemeyi iptal et",
|
|
334
334
|
"be.uploadsDefaultErrorMessage": "Yüklemeyle ilgili bir şeyler ters gitti. Lütfen tekrar deneyin.",
|
|
335
335
|
"be.uploadsFileSizeLimitExceededErrorMessage": "Dosya boyutu klasör sahibinin dosya boyutu sınırını aşıyor",
|
|
336
|
+
"be.uploadsFileSizeLimitExceededErrorMessageForUpgradeCta": "This file exceeds your plan’s upload limit. Upgrade now to store larger files.",
|
|
337
|
+
"be.uploadsFileSizeLimitExceededUpgradeMessageForUpgradeCta": "Upgrade",
|
|
336
338
|
"be.uploadsItemNameInUseErrorMessage": "Bu ada sahip bir dosya zaten var.",
|
|
337
339
|
"be.uploadsManagerUploadComplete": "Tamamlandı",
|
|
338
340
|
"be.uploadsManagerUploadFailed": "Bazı Yüklemeler Başarısız Oldu",
|
package/i18n/zh-CN.js
CHANGED
|
@@ -333,6 +333,8 @@ export default {
|
|
|
333
333
|
"be.uploadsCancelButtonTooltip": "取消此上传",
|
|
334
334
|
"be.uploadsDefaultErrorMessage": "上传时出错。请重试。",
|
|
335
335
|
"be.uploadsFileSizeLimitExceededErrorMessage": "文件大小超过文件夹所有者设置的文件大小限制",
|
|
336
|
+
"be.uploadsFileSizeLimitExceededErrorMessageForUpgradeCta": "This file exceeds your plan’s upload limit. Upgrade now to store larger files.",
|
|
337
|
+
"be.uploadsFileSizeLimitExceededUpgradeMessageForUpgradeCta": "Upgrade",
|
|
336
338
|
"be.uploadsItemNameInUseErrorMessage": "具有此名称的文件已存在。",
|
|
337
339
|
"be.uploadsManagerUploadComplete": "已完成",
|
|
338
340
|
"be.uploadsManagerUploadFailed": "部分上传失败",
|
package/i18n/zh-TW.js
CHANGED
|
@@ -333,6 +333,8 @@ export default {
|
|
|
333
333
|
"be.uploadsCancelButtonTooltip": "取消此次上傳",
|
|
334
334
|
"be.uploadsDefaultErrorMessage": "上傳時發生錯誤。請再試一次。",
|
|
335
335
|
"be.uploadsFileSizeLimitExceededErrorMessage": "檔案大小超過資料夾擁有者的檔案大小限制",
|
|
336
|
+
"be.uploadsFileSizeLimitExceededErrorMessageForUpgradeCta": "This file exceeds your plan’s upload limit. Upgrade now to store larger files.",
|
|
337
|
+
"be.uploadsFileSizeLimitExceededUpgradeMessageForUpgradeCta": "Upgrade",
|
|
336
338
|
"be.uploadsItemNameInUseErrorMessage": "具有此名稱的檔案已存在。",
|
|
337
339
|
"be.uploadsManagerUploadComplete": "已完成",
|
|
338
340
|
"be.uploadsManagerUploadFailed": "部分上傳失敗",
|
package/package.json
CHANGED
|
@@ -3,8 +3,6 @@ import * as React from 'react';
|
|
|
3
3
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
|
|
6
|
-
import { bdlGray } from '../../styles/variables';
|
|
7
|
-
|
|
8
6
|
import IconAlertCircle from '../../icons/general/IconAlertCircle';
|
|
9
7
|
import IconBell from '../../icons/general/IconBell';
|
|
10
8
|
import IconClose from '../../icons/general/IconClose';
|
|
@@ -109,7 +107,7 @@ class Notification extends React.Component<Props> {
|
|
|
109
107
|
return (
|
|
110
108
|
<div className={classes}>
|
|
111
109
|
{React.cloneElement(ICON_RENDERER[type](), {
|
|
112
|
-
color:
|
|
110
|
+
color: '#fff',
|
|
113
111
|
height: 20,
|
|
114
112
|
width: 20,
|
|
115
113
|
})}
|
|
@@ -120,7 +118,7 @@ class Notification extends React.Component<Props> {
|
|
|
120
118
|
onClick={this.onClose}
|
|
121
119
|
type="button"
|
|
122
120
|
>
|
|
123
|
-
<IconClose color=
|
|
121
|
+
<IconClose color="#FFF" height={18} width={18} />
|
|
124
122
|
</button>
|
|
125
123
|
</div>
|
|
126
124
|
);
|
|
@@ -21,24 +21,24 @@
|
|
|
21
21
|
margin: 10px auto;
|
|
22
22
|
padding: 10px 10px 10px 20px;
|
|
23
23
|
overflow: hidden;
|
|
24
|
-
color: $
|
|
24
|
+
color: $white;
|
|
25
25
|
font-weight: bold;
|
|
26
|
-
background-color: $bdl-gray-
|
|
26
|
+
background-color: $bdl-gray-80;
|
|
27
27
|
border-radius: 4px;
|
|
28
28
|
box-shadow: 0 2px 6px fade-out($black, .85);
|
|
29
29
|
opacity: .9;
|
|
30
30
|
transition: opacity .1s ease-out;
|
|
31
31
|
|
|
32
32
|
&.info {
|
|
33
|
-
background-color: $bdl-green-light
|
|
33
|
+
background-color: $bdl-green-light;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
&.warn {
|
|
37
|
-
background-color: $bdl-yellorange
|
|
37
|
+
background-color: $bdl-yellorange;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
&.error {
|
|
41
|
-
background-color: $bdl-watermelon-red
|
|
41
|
+
background-color: $bdl-watermelon-red;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
&.is-hidden {
|
|
@@ -71,15 +71,14 @@
|
|
|
71
71
|
button,
|
|
72
72
|
a {
|
|
73
73
|
flex: none;
|
|
74
|
-
color: $
|
|
75
|
-
border-color: $bdl-gray;
|
|
74
|
+
color: $white;
|
|
76
75
|
|
|
77
76
|
&.btn.is-disabled,
|
|
78
77
|
&.btn:not(.is-disabled) {
|
|
79
78
|
margin: 0 5px;
|
|
80
79
|
padding: 7px 13px;
|
|
81
80
|
background-color: transparent;
|
|
82
|
-
border-color:
|
|
81
|
+
border-color: $bdl-gray-10;
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
&.close-btn {
|
|
@@ -687,6 +687,16 @@ const messages = defineMessages({
|
|
|
687
687
|
description: 'Error message shown when file size exceeds the limit',
|
|
688
688
|
defaultMessage: 'File size exceeds the folder owner’s file size limit',
|
|
689
689
|
},
|
|
690
|
+
uploadsFileSizeLimitExceededErrorMessageForUpgradeCta: {
|
|
691
|
+
id: 'be.uploadsFileSizeLimitExceededErrorMessageForUpgradeCta',
|
|
692
|
+
description: 'Error message shown when file size exceeds the limit',
|
|
693
|
+
defaultMessage: 'This file exceeds your plan’s upload limit. Upgrade now to store larger files.',
|
|
694
|
+
},
|
|
695
|
+
uploadsFileSizeLimitExceededUpgradeMessageForUpgradeCta: {
|
|
696
|
+
id: 'be.uploadsFileSizeLimitExceededUpgradeMessageForUpgradeCta',
|
|
697
|
+
description: 'Upgrade message shown when file size exceeds the limit',
|
|
698
|
+
defaultMessage: 'Upgrade',
|
|
699
|
+
},
|
|
690
700
|
uploadsStorageLimitErrorMessage: {
|
|
691
701
|
id: 'be.uploadsStorageLimitErrorMessage',
|
|
692
702
|
description: 'Error message shown when account storage limit has been reached',
|
|
@@ -90,6 +90,7 @@ type Props = {
|
|
|
90
90
|
onMinimize?: Function,
|
|
91
91
|
onProgress: Function,
|
|
92
92
|
onResume: Function,
|
|
93
|
+
onUpgradeCTAClick?: Function,
|
|
93
94
|
onUpload: Function,
|
|
94
95
|
overwrite: boolean,
|
|
95
96
|
requestInterceptor?: Function,
|
|
@@ -1203,17 +1204,18 @@ class ContentUploader extends Component<Props, State> {
|
|
|
1203
1204
|
*/
|
|
1204
1205
|
render() {
|
|
1205
1206
|
const {
|
|
1207
|
+
className,
|
|
1208
|
+
fileLimit,
|
|
1209
|
+
isDraggingItemsToUploadsManager = false,
|
|
1210
|
+
isFolderUploadEnabled,
|
|
1211
|
+
isResumableUploadsEnabled,
|
|
1212
|
+
isTouch,
|
|
1206
1213
|
language,
|
|
1214
|
+
measureRef,
|
|
1207
1215
|
messages,
|
|
1208
1216
|
onClose,
|
|
1209
|
-
|
|
1210
|
-
measureRef,
|
|
1211
|
-
isTouch,
|
|
1212
|
-
fileLimit,
|
|
1217
|
+
onUpgradeCTAClick,
|
|
1213
1218
|
useUploadsManager,
|
|
1214
|
-
isResumableUploadsEnabled,
|
|
1215
|
-
isFolderUploadEnabled,
|
|
1216
|
-
isDraggingItemsToUploadsManager = false,
|
|
1217
1219
|
}: Props = this.props;
|
|
1218
1220
|
const { view, items, errorCode, isUploadsManagerExpanded }: State = this.state;
|
|
1219
1221
|
const isEmpty = items.length === 0;
|
|
@@ -1240,6 +1242,7 @@ class ContentUploader extends Component<Props, State> {
|
|
|
1240
1242
|
items={items}
|
|
1241
1243
|
onItemActionClick={this.onClick}
|
|
1242
1244
|
onRemoveActionClick={this.removeFileFromUploadQueue}
|
|
1245
|
+
onUpgradeCTAClick={onUpgradeCTAClick}
|
|
1243
1246
|
onUploadsManagerActionClick={this.clickAllWithStatus}
|
|
1244
1247
|
toggleUploadsManager={this.toggleUploadsManager}
|
|
1245
1248
|
view={view}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import { injectIntl } from 'react-intl';
|
|
7
|
+
import { FormattedMessage, injectIntl } from 'react-intl';
|
|
8
8
|
import type { InjectIntlProvidedProps } from 'react-intl';
|
|
9
9
|
import IconCheck from '../../icons/general/IconCheck';
|
|
10
10
|
import IconClose from '../../icons/general/IconClose';
|
|
@@ -12,9 +12,17 @@ import IconInProgress from './IconInProgress';
|
|
|
12
12
|
import IconRetry from '../../icons/general/IconRetry';
|
|
13
13
|
import LoadingIndicator from '../../components/loading-indicator';
|
|
14
14
|
import PlainButton from '../../components/plain-button/PlainButton';
|
|
15
|
+
import PrimaryButton from '../../components/primary-button/PrimaryButton';
|
|
15
16
|
import Tooltip from '../../components/tooltip';
|
|
16
17
|
import messages from '../common/messages';
|
|
17
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
ERROR_CODE_UPLOAD_FILE_SIZE_LIMIT_EXCEEDED,
|
|
20
|
+
STATUS_PENDING,
|
|
21
|
+
STATUS_IN_PROGRESS,
|
|
22
|
+
STATUS_STAGED,
|
|
23
|
+
STATUS_COMPLETE,
|
|
24
|
+
STATUS_ERROR,
|
|
25
|
+
} from '../../constants';
|
|
18
26
|
import type { UploadStatus } from '../../common/types/upload';
|
|
19
27
|
|
|
20
28
|
import './ItemAction.scss';
|
|
@@ -22,15 +30,26 @@ import './ItemAction.scss';
|
|
|
22
30
|
const ICON_CHECK_COLOR = '#26C281';
|
|
23
31
|
|
|
24
32
|
type Props = {
|
|
33
|
+
error?: Object,
|
|
25
34
|
isFolder?: boolean,
|
|
26
35
|
isResumableUploadsEnabled: boolean,
|
|
27
36
|
onClick: Function,
|
|
37
|
+
onUpgradeCTAClick?: Function,
|
|
28
38
|
status: UploadStatus,
|
|
29
39
|
} & InjectIntlProvidedProps;
|
|
30
40
|
|
|
31
|
-
const ItemAction = ({
|
|
41
|
+
const ItemAction = ({
|
|
42
|
+
error = {},
|
|
43
|
+
intl,
|
|
44
|
+
isFolder = false,
|
|
45
|
+
isResumableUploadsEnabled,
|
|
46
|
+
onClick,
|
|
47
|
+
onUpgradeCTAClick,
|
|
48
|
+
status,
|
|
49
|
+
}: Props) => {
|
|
32
50
|
let icon = <IconClose />;
|
|
33
51
|
let tooltip;
|
|
52
|
+
const { code } = error;
|
|
34
53
|
|
|
35
54
|
if (isFolder && status !== STATUS_PENDING) {
|
|
36
55
|
return null;
|
|
@@ -66,6 +85,18 @@ const ItemAction = ({ status, onClick, intl, isResumableUploadsEnabled, isFolder
|
|
|
66
85
|
break;
|
|
67
86
|
}
|
|
68
87
|
|
|
88
|
+
if (status === STATUS_ERROR && code === ERROR_CODE_UPLOAD_FILE_SIZE_LIMIT_EXCEEDED && !!onUpgradeCTAClick) {
|
|
89
|
+
return (
|
|
90
|
+
<PrimaryButton
|
|
91
|
+
onClick={onUpgradeCTAClick}
|
|
92
|
+
data-resin-target="large_version_error_inline_upgrade_cta"
|
|
93
|
+
type="button"
|
|
94
|
+
>
|
|
95
|
+
<FormattedMessage {...messages.uploadsFileSizeLimitExceededUpgradeMessageForUpgradeCta} />
|
|
96
|
+
</PrimaryButton>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
69
100
|
return (
|
|
70
101
|
<div className="bcu-item-action">
|
|
71
102
|
{tooltip ? (
|
|
@@ -20,14 +20,21 @@ type Props = {
|
|
|
20
20
|
items: UploadItem[],
|
|
21
21
|
onClick: Function,
|
|
22
22
|
onRemoveClick?: (item: UploadItem) => void,
|
|
23
|
+
onUpgradeCTAClick?: Function,
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
const ItemList = ({
|
|
26
|
+
const ItemList = ({
|
|
27
|
+
isResumableUploadsEnabled = false,
|
|
28
|
+
items,
|
|
29
|
+
onClick,
|
|
30
|
+
onRemoveClick = noop,
|
|
31
|
+
onUpgradeCTAClick,
|
|
32
|
+
}: Props) => (
|
|
26
33
|
<AutoSizer>
|
|
27
34
|
{({ width, height }) => {
|
|
28
35
|
const nameCell = nameCellRenderer(isResumableUploadsEnabled);
|
|
29
|
-
const progressCell = progressCellRenderer();
|
|
30
|
-
const actionCell = actionCellRenderer(isResumableUploadsEnabled, onClick);
|
|
36
|
+
const progressCell = progressCellRenderer(!!onUpgradeCTAClick);
|
|
37
|
+
const actionCell = actionCellRenderer(isResumableUploadsEnabled, onClick, onUpgradeCTAClick);
|
|
31
38
|
const removeCell = removeCellRenderer(onRemoveClick);
|
|
32
39
|
|
|
33
40
|
return (
|
|
@@ -56,7 +63,7 @@ const ItemList = ({ isResumableUploadsEnabled = false, items, onClick, onRemoveC
|
|
|
56
63
|
cellRenderer={actionCell}
|
|
57
64
|
dataKey="status"
|
|
58
65
|
flexShrink={0}
|
|
59
|
-
width={25}
|
|
66
|
+
width={onUpgradeCTAClick ? 100 : 25}
|
|
60
67
|
/>
|
|
61
68
|
{isResumableUploadsEnabled && (
|
|
62
69
|
<Column
|
|
@@ -21,22 +21,24 @@ type Props = {
|
|
|
21
21
|
items: UploadItem[],
|
|
22
22
|
onItemActionClick: Function,
|
|
23
23
|
onRemoveActionClick: (item: UploadItem) => void,
|
|
24
|
+
onUpgradeCTAClick?: Function,
|
|
24
25
|
onUploadsManagerActionClick: Function,
|
|
25
26
|
toggleUploadsManager: Function,
|
|
26
27
|
view: View,
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
const UploadsManager = ({
|
|
31
|
+
isExpanded,
|
|
32
|
+
isVisible,
|
|
33
|
+
isResumableUploadsEnabled,
|
|
34
|
+
isDragging,
|
|
30
35
|
items,
|
|
31
|
-
view,
|
|
32
36
|
onItemActionClick,
|
|
33
37
|
onRemoveActionClick,
|
|
38
|
+
onUpgradeCTAClick,
|
|
34
39
|
onUploadsManagerActionClick,
|
|
35
40
|
toggleUploadsManager,
|
|
36
|
-
|
|
37
|
-
isVisible,
|
|
38
|
-
isResumableUploadsEnabled,
|
|
39
|
-
isDragging,
|
|
41
|
+
view,
|
|
40
42
|
}: Props) => {
|
|
41
43
|
/**
|
|
42
44
|
* Keydown handler for progress bar
|
|
@@ -98,6 +100,7 @@ const UploadsManager = ({
|
|
|
98
100
|
items={items}
|
|
99
101
|
onClick={onItemActionClick}
|
|
100
102
|
onRemoveClick={onRemoveActionClick}
|
|
103
|
+
onUpgradeCTAClick={onUpgradeCTAClick}
|
|
101
104
|
view={view}
|
|
102
105
|
/>
|
|
103
106
|
</div>
|
|
@@ -2,7 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import noop from 'lodash/noop';
|
|
3
3
|
import { shallow } from 'enzyme';
|
|
4
4
|
import { ItemActionForTesting as ItemAction } from '../ItemAction';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ERROR_CODE_UPLOAD_FILE_SIZE_LIMIT_EXCEEDED,
|
|
7
|
+
STATUS_PENDING,
|
|
8
|
+
STATUS_IN_PROGRESS,
|
|
9
|
+
STATUS_COMPLETE,
|
|
10
|
+
STATUS_STAGED,
|
|
11
|
+
STATUS_ERROR,
|
|
12
|
+
} from '../../../constants';
|
|
6
13
|
|
|
7
14
|
describe('elements/content-uploader/ItemAction', () => {
|
|
8
15
|
const getWrapper = props =>
|
|
@@ -58,4 +65,15 @@ describe('elements/content-uploader/ItemAction', () => {
|
|
|
58
65
|
|
|
59
66
|
expect(wrapper).toMatchSnapshot();
|
|
60
67
|
});
|
|
68
|
+
|
|
69
|
+
test('should render PrimaryButton with STATUS_ERROR and upload file size exceeded', () => {
|
|
70
|
+
const wrapper = getWrapper({
|
|
71
|
+
status: STATUS_ERROR,
|
|
72
|
+
error: { code: ERROR_CODE_UPLOAD_FILE_SIZE_LIMIT_EXCEEDED },
|
|
73
|
+
onUpgradeCTAClick: () => {},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
expect(wrapper.exists('PrimaryButton')).toBe(true);
|
|
77
|
+
expect(wrapper.exists('PlainButton')).toBe(false);
|
|
78
|
+
});
|
|
61
79
|
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
|
|
4
|
+
import { ERROR_CODE_UPLOAD_FILE_SIZE_LIMIT_EXCEEDED, STATUS_COMPLETE, STATUS_ERROR } from '../../../constants';
|
|
5
|
+
import ItemList from '../ItemList';
|
|
6
|
+
|
|
7
|
+
jest.mock('@box/react-virtualized/dist/es/AutoSizer', () => ({ children }) => children({ height: 600, width: 600 }));
|
|
8
|
+
|
|
9
|
+
describe('elements/content-uploader/ItemList', () => {
|
|
10
|
+
const renderComponent = props => mount(<ItemList items={[]} onClick={() => {}} {...props} />);
|
|
11
|
+
|
|
12
|
+
describe('render()', () => {
|
|
13
|
+
test('should render default component', () => {
|
|
14
|
+
const wrapper = renderComponent();
|
|
15
|
+
|
|
16
|
+
expect(wrapper.find('Table').length).toBe(1);
|
|
17
|
+
expect(wrapper.find('Table.bcu-item-list').length).toBe(1);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('should render component with correct number of items', () => {
|
|
21
|
+
const items = [
|
|
22
|
+
{ id: '1', name: 'item1', status: STATUS_COMPLETE },
|
|
23
|
+
{ id: '2', name: 'item2', status: STATUS_COMPLETE },
|
|
24
|
+
{ id: '3', name: 'item3', status: STATUS_COMPLETE },
|
|
25
|
+
];
|
|
26
|
+
const wrapper = renderComponent({ items });
|
|
27
|
+
expect(wrapper.find('div.bcu-item-row').length).toBe(3);
|
|
28
|
+
const actionColumnStyle = wrapper
|
|
29
|
+
.find('.bcu-item-list-action-column')
|
|
30
|
+
.first()
|
|
31
|
+
.prop('style');
|
|
32
|
+
expect(actionColumnStyle.flex).toEqual('0 0 25px');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('should render action column with correct width for upgrade cta', () => {
|
|
36
|
+
const items = [
|
|
37
|
+
{ id: '1', name: 'item1', status: STATUS_ERROR, code: ERROR_CODE_UPLOAD_FILE_SIZE_LIMIT_EXCEEDED },
|
|
38
|
+
];
|
|
39
|
+
const wrapper = renderComponent({ items, onUpgradeCTAClick: () => {} });
|
|
40
|
+
expect(wrapper.find('div.bcu-item-row').length).toBe(1);
|
|
41
|
+
const actionColumnStyle = wrapper.find('.bcu-item-list-action-column').prop('style');
|
|
42
|
+
expect(actionColumnStyle.flex).toEqual('0 0 100px');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -11,6 +11,13 @@ type Props = {
|
|
|
11
11
|
rowData: UploadItem,
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export default (isResumableUploadsEnabled: boolean, onClick: Function
|
|
15
|
-
|
|
14
|
+
export default (isResumableUploadsEnabled: boolean, onClick: Function, onUpgradeCTAClick?: Function) => ({
|
|
15
|
+
rowData,
|
|
16
|
+
}: Props) => (
|
|
17
|
+
<ItemAction
|
|
18
|
+
{...rowData}
|
|
19
|
+
isResumableUploadsEnabled={isResumableUploadsEnabled}
|
|
20
|
+
onClick={() => onClick(rowData)}
|
|
21
|
+
onUpgradeCTAClick={onUpgradeCTAClick}
|
|
22
|
+
/>
|
|
16
23
|
);
|
|
@@ -35,11 +35,14 @@ type Props = {
|
|
|
35
35
|
* @param {string} [itemName]
|
|
36
36
|
* @returns {FormattedMessage}
|
|
37
37
|
*/
|
|
38
|
-
const getErrorMessage = (errorCode: ?string, itemName: ?string) => {
|
|
38
|
+
const getErrorMessage = (errorCode: ?string, itemName: ?string, shouldShowUpgradeCTAMessage?: boolean) => {
|
|
39
39
|
switch (errorCode) {
|
|
40
40
|
case ERROR_CODE_UPLOAD_CHILD_FOLDER_FAILED:
|
|
41
41
|
return <FormattedMessage {...messages.uploadsOneOrMoreChildFoldersFailedToUploadMessage} />;
|
|
42
42
|
case ERROR_CODE_UPLOAD_FILE_SIZE_LIMIT_EXCEEDED:
|
|
43
|
+
if (shouldShowUpgradeCTAMessage) {
|
|
44
|
+
return <FormattedMessage {...messages.uploadsFileSizeLimitExceededErrorMessageForUpgradeCta} />;
|
|
45
|
+
}
|
|
43
46
|
return <FormattedMessage {...messages.uploadsFileSizeLimitExceededErrorMessage} />;
|
|
44
47
|
case ERROR_CODE_ITEM_NAME_IN_USE:
|
|
45
48
|
return <FormattedMessage {...messages.uploadsItemNameInUseErrorMessage} />;
|
|
@@ -58,7 +61,7 @@ const getErrorMessage = (errorCode: ?string, itemName: ?string) => {
|
|
|
58
61
|
}
|
|
59
62
|
};
|
|
60
63
|
|
|
61
|
-
export default () => ({ rowData }: Props) => {
|
|
64
|
+
export default (shouldShowUpgradeCTAMessage?: boolean) => ({ rowData }: Props) => {
|
|
62
65
|
const { status, error = {}, name, isFolder, file } = rowData;
|
|
63
66
|
const { code } = error;
|
|
64
67
|
|
|
@@ -74,7 +77,7 @@ export default () => ({ rowData }: Props) => {
|
|
|
74
77
|
if (Browser.isSafari() && code === ERROR_CODE_UPLOAD_BAD_DIGEST && file.name.indexOf('.zip') !== -1) {
|
|
75
78
|
return getErrorMessage(ERROR_CODE_UPLOAD_FAILED_PACKAGE, file.name);
|
|
76
79
|
}
|
|
77
|
-
return getErrorMessage(code, name);
|
|
80
|
+
return getErrorMessage(code, name, shouldShowUpgradeCTAMessage);
|
|
78
81
|
default:
|
|
79
82
|
return null;
|
|
80
83
|
}
|