box-ui-elements 23.4.0-beta.13 → 23.4.0-beta.15
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/es/api/Metadata.js +0 -1
- package/es/api/Metadata.js.flow +1 -1
- package/es/api/Metadata.js.map +1 -1
- package/es/elements/common/upload-dialog/UploadDialog.js +1 -0
- package/es/elements/common/upload-dialog/UploadDialog.js.flow +1 -0
- package/es/elements/common/upload-dialog/UploadDialog.js.map +1 -1
- package/es/elements/index.js +1 -0
- package/es/elements/index.js.flow +1 -0
- package/es/elements/index.js.map +1 -1
- package/es/elements/wrappers/ContentUploader.js +2 -0
- package/es/elements/wrappers/ContentUploader.js.flow +2 -0
- package/es/elements/wrappers/ContentUploader.js.map +1 -1
- package/i18n/ja-JP.js +2 -2
- package/i18n/ja-JP.properties +2 -2
- package/package.json +1 -1
- package/src/api/Metadata.js +1 -1
- package/src/elements/common/upload-dialog/UploadDialog.js +1 -0
- package/src/elements/index.js +1 -0
- package/src/elements/wrappers/ContentUploader.js +2 -0
- package/es/elements/content-uploader/ContentUploader.js.flow +0 -1322
- package/es/elements/content-uploader/ContentUploaderPopup.js.flow +0 -11
- package/es/elements/content-uploader/DroppableContent.js.flow +0 -82
- package/es/elements/content-uploader/Footer.js.flow +0 -63
- package/es/elements/content-uploader/IconName.js.flow +0 -45
- package/es/elements/content-uploader/ItemAction.js.flow +0 -128
- package/es/elements/content-uploader/ItemList.js.flow +0 -79
- package/es/elements/content-uploader/ItemRemove.js.flow +0 -51
- package/es/elements/content-uploader/OverallUploadsProgressBar.js.flow +0 -111
- package/es/elements/content-uploader/ProgressBar.js.flow +0 -65
- package/es/elements/content-uploader/UploadInput.js.flow +0 -50
- package/es/elements/content-uploader/UploadState.js.flow +0 -114
- package/es/elements/content-uploader/UploadStateContent.js.flow +0 -71
- package/es/elements/content-uploader/UploadsManager.js.flow +0 -111
- package/es/elements/content-uploader/UploadsManagerAction.js.flow +0 -36
- package/es/elements/content-uploader/actionCellRenderer.js.flow +0 -18
- package/es/elements/content-uploader/index.js.flow +0 -4
- package/es/elements/content-uploader/nameCellRenderer.js.flow +0 -13
- package/es/elements/content-uploader/progressCellRenderer.js.flow +0 -81
- package/es/elements/content-uploader/removeCellRenderer.js.flow +0 -16
- package/src/elements/content-uploader/ContentUploader.js.flow +0 -1322
- package/src/elements/content-uploader/ContentUploaderPopup.js.flow +0 -11
- package/src/elements/content-uploader/DroppableContent.js.flow +0 -82
- package/src/elements/content-uploader/Footer.js.flow +0 -63
- package/src/elements/content-uploader/IconName.js.flow +0 -45
- package/src/elements/content-uploader/ItemAction.js.flow +0 -128
- package/src/elements/content-uploader/ItemList.js.flow +0 -79
- package/src/elements/content-uploader/ItemRemove.js.flow +0 -51
- package/src/elements/content-uploader/OverallUploadsProgressBar.js.flow +0 -111
- package/src/elements/content-uploader/ProgressBar.js.flow +0 -65
- package/src/elements/content-uploader/UploadInput.js.flow +0 -50
- package/src/elements/content-uploader/UploadState.js.flow +0 -114
- package/src/elements/content-uploader/UploadStateContent.js.flow +0 -71
- package/src/elements/content-uploader/UploadsManager.js.flow +0 -111
- package/src/elements/content-uploader/UploadsManagerAction.js.flow +0 -36
- package/src/elements/content-uploader/actionCellRenderer.js.flow +0 -18
- package/src/elements/content-uploader/index.js.flow +0 -4
- package/src/elements/content-uploader/nameCellRenderer.js.flow +0 -13
- package/src/elements/content-uploader/progressCellRenderer.js.flow +0 -81
- package/src/elements/content-uploader/removeCellRenderer.js.flow +0 -16
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import { useIntl, FormattedMessage } from 'react-intl';
|
|
4
|
-
import { HatWand } from '@box/blueprint-web-assets/illustrations/Medium';
|
|
5
|
-
|
|
6
|
-
import UploadEmptyState from '../../icons/states/UploadEmptyState';
|
|
7
|
-
import UploadSuccessState from '../../icons/states/UploadSuccessState';
|
|
8
|
-
import UploadStateContent from './UploadStateContent';
|
|
9
|
-
import type { View } from '../../common/types/core';
|
|
10
|
-
|
|
11
|
-
import { VIEW_ERROR, VIEW_UPLOAD_EMPTY, VIEW_UPLOAD_IN_PROGRESS, VIEW_UPLOAD_SUCCESS } from '../../constants';
|
|
12
|
-
|
|
13
|
-
import messages from '../common/messages';
|
|
14
|
-
|
|
15
|
-
import './UploadState.scss';
|
|
16
|
-
|
|
17
|
-
type Props = {
|
|
18
|
-
canDrop: boolean,
|
|
19
|
-
hasItems: boolean,
|
|
20
|
-
isFolderUploadEnabled: boolean,
|
|
21
|
-
isOver: boolean,
|
|
22
|
-
isTouch: boolean,
|
|
23
|
-
onSelect: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
24
|
-
view: View
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const UploadState = ({
|
|
28
|
-
canDrop,
|
|
29
|
-
hasItems,
|
|
30
|
-
isOver,
|
|
31
|
-
isTouch,
|
|
32
|
-
view,
|
|
33
|
-
onSelect,
|
|
34
|
-
isFolderUploadEnabled,
|
|
35
|
-
}: Props) => {
|
|
36
|
-
const intl = useIntl();
|
|
37
|
-
let icon;
|
|
38
|
-
let content;
|
|
39
|
-
switch (view) {
|
|
40
|
-
case VIEW_ERROR:
|
|
41
|
-
icon = <HatWand aria-label={intl.formatMessage(messages.uploadErrorState)} height={126} width={130} />;
|
|
42
|
-
content = <UploadStateContent message={<FormattedMessage {...messages.uploadError} />} />;
|
|
43
|
-
break;
|
|
44
|
-
case VIEW_UPLOAD_EMPTY:
|
|
45
|
-
icon = <UploadEmptyState title={<FormattedMessage {...messages.uploadEmptyState} />} />;
|
|
46
|
-
/* eslint-disable no-nested-ternary */
|
|
47
|
-
content =
|
|
48
|
-
canDrop && hasItems ? (
|
|
49
|
-
<UploadStateContent message={<FormattedMessage {...messages.uploadInProgress} />} />
|
|
50
|
-
) : isTouch ? (
|
|
51
|
-
<UploadStateContent
|
|
52
|
-
fileInputLabel={<FormattedMessage {...messages.uploadNoDragDrop} />}
|
|
53
|
-
onChange={onSelect}
|
|
54
|
-
useButton
|
|
55
|
-
/>
|
|
56
|
-
) : (
|
|
57
|
-
<UploadStateContent
|
|
58
|
-
fileInputLabel={<FormattedMessage {...messages.uploadEmptyFileInput} />}
|
|
59
|
-
folderInputLabel={
|
|
60
|
-
isFolderUploadEnabled && <FormattedMessage {...messages.uploadEmptyFolderInput} />
|
|
61
|
-
}
|
|
62
|
-
message={
|
|
63
|
-
isFolderUploadEnabled ? (
|
|
64
|
-
<FormattedMessage {...messages.uploadEmptyWithFolderUploadEnabled} />
|
|
65
|
-
) : (
|
|
66
|
-
<FormattedMessage {...messages.uploadEmptyWithFolderUploadDisabled} />
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
onChange={onSelect}
|
|
70
|
-
/>
|
|
71
|
-
);
|
|
72
|
-
/* eslint-enable no-nested-ternary */
|
|
73
|
-
break;
|
|
74
|
-
case VIEW_UPLOAD_IN_PROGRESS:
|
|
75
|
-
icon = <UploadEmptyState title={<FormattedMessage {...messages.uploadEmptyState} />} />;
|
|
76
|
-
content = <UploadStateContent message={<FormattedMessage {...messages.uploadInProgress} />} />;
|
|
77
|
-
break;
|
|
78
|
-
case VIEW_UPLOAD_SUCCESS:
|
|
79
|
-
icon = <UploadSuccessState title={<FormattedMessage {...messages.uploadSuccessState} />} />;
|
|
80
|
-
content = (
|
|
81
|
-
<UploadStateContent
|
|
82
|
-
fileInputLabel={<FormattedMessage {...messages.uploadSuccessFileInput} />}
|
|
83
|
-
folderInputLabel={
|
|
84
|
-
isFolderUploadEnabled && <FormattedMessage {...messages.uploadSuccessFolderInput} />
|
|
85
|
-
}
|
|
86
|
-
message={<FormattedMessage {...messages.uploadSuccess} />}
|
|
87
|
-
onChange={onSelect}
|
|
88
|
-
useButton={isTouch}
|
|
89
|
-
/>
|
|
90
|
-
);
|
|
91
|
-
break;
|
|
92
|
-
default:
|
|
93
|
-
break;
|
|
94
|
-
/* eslint-enable jsx-a11y/label-has-for */
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const className = classNames('bcu-upload-state', {
|
|
98
|
-
'bcu-is-droppable': isOver && canDrop,
|
|
99
|
-
'bcu-is-not-droppable': isOver && !canDrop,
|
|
100
|
-
'bcu-has-items': hasItems,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<div className={className}>
|
|
105
|
-
<div>
|
|
106
|
-
{icon}
|
|
107
|
-
{content}
|
|
108
|
-
</div>
|
|
109
|
-
<div className="bcu-drag-drop-overlay" />
|
|
110
|
-
</div>
|
|
111
|
-
);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export default UploadState;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @flow
|
|
3
|
-
* @file Upload state content component
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import * as React from 'react';
|
|
7
|
-
import { FormattedMessage } from 'react-intl';
|
|
8
|
-
import messages from '../common/messages';
|
|
9
|
-
import UploadInput from './UploadInput';
|
|
10
|
-
|
|
11
|
-
type Props = {
|
|
12
|
-
fileInputLabel?: React.Node,
|
|
13
|
-
folderInputLabel?: React.Node,
|
|
14
|
-
message?: React.Node,
|
|
15
|
-
onChange?: Function,
|
|
16
|
-
useButton?: boolean,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const UploadStateContent = ({ fileInputLabel, folderInputLabel, message, onChange, useButton = false }: Props) => {
|
|
20
|
-
const messageContent = message ? <div className="bcu-upload-state-message">{message}</div> : null;
|
|
21
|
-
const inputLabelClass = useButton ? 'btn btn-primary be-input-btn' : 'be-input-link';
|
|
22
|
-
const shouldShowFolderUploadInput = !useButton && !!folderInputLabel;
|
|
23
|
-
|
|
24
|
-
const handleChange = (event: SyntheticInputEvent<HTMLInputElement>) => {
|
|
25
|
-
if (!onChange) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
onChange(event);
|
|
30
|
-
|
|
31
|
-
const currentTarget = (event.currentTarget: HTMLInputElement);
|
|
32
|
-
// resets the file input selection
|
|
33
|
-
currentTarget.value = '';
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const fileInputContent = (
|
|
37
|
-
<UploadInput handleChange={handleChange} inputLabel={fileInputLabel} inputLabelClass={inputLabelClass} />
|
|
38
|
-
);
|
|
39
|
-
const folderInputContent = shouldShowFolderUploadInput ? (
|
|
40
|
-
<UploadInput
|
|
41
|
-
handleChange={handleChange}
|
|
42
|
-
inputLabel={folderInputLabel}
|
|
43
|
-
inputLabelClass={inputLabelClass}
|
|
44
|
-
isFolderUpload
|
|
45
|
-
/>
|
|
46
|
-
) : null;
|
|
47
|
-
|
|
48
|
-
let inputsContent;
|
|
49
|
-
if (fileInputContent && folderInputContent) {
|
|
50
|
-
inputsContent = (
|
|
51
|
-
<FormattedMessage
|
|
52
|
-
{...messages.uploadOptions}
|
|
53
|
-
values={{
|
|
54
|
-
option1: fileInputContent,
|
|
55
|
-
option2: folderInputContent,
|
|
56
|
-
}}
|
|
57
|
-
/>
|
|
58
|
-
);
|
|
59
|
-
} else if (fileInputContent) {
|
|
60
|
-
inputsContent = fileInputContent;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<div>
|
|
65
|
-
{messageContent}
|
|
66
|
-
{inputsContent && <div className="bcu-upload-input-container">{inputsContent}</div>}
|
|
67
|
-
</div>
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export default UploadStateContent;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @flow
|
|
3
|
-
* @file Uploads manager
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import * as React from 'react';
|
|
7
|
-
import classNames from 'classnames';
|
|
8
|
-
import ItemList from './ItemList';
|
|
9
|
-
import OverallUploadsProgressBar from './OverallUploadsProgressBar';
|
|
10
|
-
import { STATUS_ERROR } from '../../constants';
|
|
11
|
-
import type { UploadItem } from '../../common/types/upload';
|
|
12
|
-
import type { View } from '../../common/types/core';
|
|
13
|
-
|
|
14
|
-
import './UploadsManager.scss';
|
|
15
|
-
|
|
16
|
-
type Props = {
|
|
17
|
-
isDragging: boolean,
|
|
18
|
-
isExpanded: boolean,
|
|
19
|
-
isResumableUploadsEnabled: boolean,
|
|
20
|
-
isVisible: boolean,
|
|
21
|
-
items: UploadItem[],
|
|
22
|
-
onItemActionClick: Function,
|
|
23
|
-
onRemoveActionClick: (item: UploadItem) => void,
|
|
24
|
-
onUpgradeCTAClick?: Function,
|
|
25
|
-
onUploadsManagerActionClick: Function,
|
|
26
|
-
toggleUploadsManager: Function,
|
|
27
|
-
view: View,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const UploadsManager = ({
|
|
31
|
-
isExpanded,
|
|
32
|
-
isVisible,
|
|
33
|
-
isResumableUploadsEnabled,
|
|
34
|
-
isDragging,
|
|
35
|
-
items,
|
|
36
|
-
onItemActionClick,
|
|
37
|
-
onRemoveActionClick,
|
|
38
|
-
onUpgradeCTAClick,
|
|
39
|
-
onUploadsManagerActionClick,
|
|
40
|
-
toggleUploadsManager,
|
|
41
|
-
view,
|
|
42
|
-
}: Props) => {
|
|
43
|
-
/**
|
|
44
|
-
* Keydown handler for progress bar
|
|
45
|
-
*
|
|
46
|
-
* @param {SyntheticKeyboardEvent} event
|
|
47
|
-
* @return {void}
|
|
48
|
-
*/
|
|
49
|
-
const handleProgressBarKeyDown = (event: SyntheticKeyboardEvent<*>): void => {
|
|
50
|
-
switch (event.key) {
|
|
51
|
-
case 'Enter':
|
|
52
|
-
case 'Space':
|
|
53
|
-
toggleUploadsManager();
|
|
54
|
-
break;
|
|
55
|
-
default:
|
|
56
|
-
// noop
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
let numFailedUploads = 0;
|
|
61
|
-
let totalSize = 0;
|
|
62
|
-
let totalUploaded = 0;
|
|
63
|
-
items.forEach(item => {
|
|
64
|
-
if (item.status !== STATUS_ERROR && !item.isFolder) {
|
|
65
|
-
totalSize += item.size;
|
|
66
|
-
totalUploaded += (item.size * item.progress) / 100.0;
|
|
67
|
-
} else if (item.status === STATUS_ERROR) {
|
|
68
|
-
numFailedUploads += 1;
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const percent = (totalUploaded / totalSize) * 100;
|
|
73
|
-
const isResumeVisible = isResumableUploadsEnabled && numFailedUploads > 0;
|
|
74
|
-
const hasMultipleFailedUploads = numFailedUploads > 1;
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<div
|
|
78
|
-
data-resin-component="uploadsmanager"
|
|
79
|
-
data-resin-feature="uploads"
|
|
80
|
-
className={classNames('be bcu-uploads-manager-container', {
|
|
81
|
-
'bcu-is-expanded': isExpanded,
|
|
82
|
-
'bcu-is-visible': isVisible,
|
|
83
|
-
})}
|
|
84
|
-
>
|
|
85
|
-
<OverallUploadsProgressBar
|
|
86
|
-
isDragging={isDragging}
|
|
87
|
-
isExpanded={isExpanded}
|
|
88
|
-
isResumeVisible={isResumeVisible}
|
|
89
|
-
isVisible={isVisible}
|
|
90
|
-
hasMultipleFailedUploads={hasMultipleFailedUploads}
|
|
91
|
-
onClick={toggleUploadsManager}
|
|
92
|
-
onKeyDown={handleProgressBarKeyDown}
|
|
93
|
-
onUploadsManagerActionClick={onUploadsManagerActionClick}
|
|
94
|
-
percent={percent}
|
|
95
|
-
view={view}
|
|
96
|
-
/>
|
|
97
|
-
<div className="bcu-uploads-manager-item-list">
|
|
98
|
-
<ItemList
|
|
99
|
-
isResumableUploadsEnabled={isResumableUploadsEnabled}
|
|
100
|
-
items={items}
|
|
101
|
-
onClick={onItemActionClick}
|
|
102
|
-
onRemoveClick={onRemoveActionClick}
|
|
103
|
-
onUpgradeCTAClick={onUpgradeCTAClick}
|
|
104
|
-
view={view}
|
|
105
|
-
/>
|
|
106
|
-
</div>
|
|
107
|
-
</div>
|
|
108
|
-
);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export default UploadsManager;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useIntl } from 'react-intl';
|
|
3
|
-
import { Button } from '@box/blueprint-web';
|
|
4
|
-
|
|
5
|
-
import { RESIN_TAG_TARGET } from '../../common/variables';
|
|
6
|
-
import { STATUS_ERROR } from '../../constants';
|
|
7
|
-
|
|
8
|
-
import messages from '../common/messages';
|
|
9
|
-
import type { UploadStatus } from '../../common/types/upload';
|
|
10
|
-
|
|
11
|
-
import './UploadsManagerAction.scss';
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
hasMultipleFailedUploads: boolean;
|
|
15
|
-
onClick: (status: UploadStatus) => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const UploadsManagerAction = ({ hasMultipleFailedUploads, onClick }: Props) => {
|
|
19
|
-
const handleResumeClick = event => {
|
|
20
|
-
event.stopPropagation();
|
|
21
|
-
onClick(STATUS_ERROR);
|
|
22
|
-
};
|
|
23
|
-
const intl = useIntl();
|
|
24
|
-
const resumeMessage = hasMultipleFailedUploads ? messages.resumeAll : messages.resume;
|
|
25
|
-
const resin = { [RESIN_TAG_TARGET]: 'uploadresumeheader' };
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<div className="bcu-uploads-manager-action">
|
|
29
|
-
<Button onClick={handleResumeClick} size="small" variant="primary" {...resin}>
|
|
30
|
-
{intl.formatMessage(resumeMessage)}
|
|
31
|
-
</Button>
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default UploadsManagerAction;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import ItemAction from './ItemAction';
|
|
3
|
-
import type { UploadItem } from '../../common/types/upload';
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
rowData: UploadItem
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default (isResumableUploadsEnabled: boolean, onClick: any, onUpgradeCTAClick?: any) => ({
|
|
10
|
-
rowData,
|
|
11
|
-
}: Props) => (
|
|
12
|
-
<ItemAction
|
|
13
|
-
{...rowData}
|
|
14
|
-
isResumableUploadsEnabled={isResumableUploadsEnabled}
|
|
15
|
-
onClick={() => onClick(rowData)}
|
|
16
|
-
onUpgradeCTAClick={onUpgradeCTAClick}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import IconName from './IconName';
|
|
3
|
-
import type { UploadItem } from '../../common/types/upload';
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
rowData: UploadItem
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default (isResumableUploadsEnabled: boolean) => ({
|
|
10
|
-
rowData,
|
|
11
|
-
}: Props) => (
|
|
12
|
-
<IconName isResumableUploadsEnabled={isResumableUploadsEnabled} {...rowData} />
|
|
13
|
-
);
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { FormattedMessage } from 'react-intl';
|
|
3
|
-
import Browser from '../../utils/Browser';
|
|
4
|
-
import messages from '../common/messages';
|
|
5
|
-
import ItemProgress from './ItemProgress';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
ERROR_CODE_UPLOAD_FILE_SIZE_LIMIT_EXCEEDED,
|
|
9
|
-
ERROR_CODE_ITEM_NAME_IN_USE,
|
|
10
|
-
ERROR_CODE_ITEM_NAME_INVALID,
|
|
11
|
-
ERROR_CODE_UPLOAD_PENDING_APP_FOLDER_SIZE_LIMIT,
|
|
12
|
-
ERROR_CODE_UPLOAD_STORAGE_LIMIT_EXCEEDED,
|
|
13
|
-
ERROR_CODE_UPLOAD_CHILD_FOLDER_FAILED,
|
|
14
|
-
ERROR_CODE_UPLOAD_BAD_DIGEST,
|
|
15
|
-
ERROR_CODE_UPLOAD_FAILED_PACKAGE,
|
|
16
|
-
STATUS_IN_PROGRESS,
|
|
17
|
-
STATUS_STAGED,
|
|
18
|
-
STATUS_ERROR,
|
|
19
|
-
} from '../../constants';
|
|
20
|
-
import type { UploadItem } from '../../common/types/upload';
|
|
21
|
-
|
|
22
|
-
type Props = {
|
|
23
|
-
rowData: UploadItem
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Get error message for a specific error code
|
|
28
|
-
*
|
|
29
|
-
* @param {string} [errorCode]
|
|
30
|
-
* @param {string} [itemName]
|
|
31
|
-
* @returns {FormattedMessage}
|
|
32
|
-
*/
|
|
33
|
-
const getErrorMessage = (errorCode?: string | null, itemName?: string | null, shouldShowUpgradeCTAMessage?: boolean) => {
|
|
34
|
-
switch (errorCode) {
|
|
35
|
-
case ERROR_CODE_UPLOAD_CHILD_FOLDER_FAILED:
|
|
36
|
-
return <FormattedMessage {...messages.uploadsOneOrMoreChildFoldersFailedToUploadMessage} />;
|
|
37
|
-
case ERROR_CODE_UPLOAD_FILE_SIZE_LIMIT_EXCEEDED:
|
|
38
|
-
if (shouldShowUpgradeCTAMessage) {
|
|
39
|
-
return <FormattedMessage {...messages.uploadsFileSizeLimitExceededErrorMessageForUpgradeCta} />;
|
|
40
|
-
}
|
|
41
|
-
return <FormattedMessage {...messages.uploadsFileSizeLimitExceededErrorMessage} />;
|
|
42
|
-
case ERROR_CODE_ITEM_NAME_IN_USE:
|
|
43
|
-
return <FormattedMessage {...messages.uploadsItemNameInUseErrorMessage} />;
|
|
44
|
-
case ERROR_CODE_ITEM_NAME_INVALID:
|
|
45
|
-
return (
|
|
46
|
-
<FormattedMessage {...messages.uploadsProvidedFolderNameInvalidMessage} values={{ name: itemName }} />
|
|
47
|
-
);
|
|
48
|
-
case ERROR_CODE_UPLOAD_STORAGE_LIMIT_EXCEEDED:
|
|
49
|
-
return <FormattedMessage {...messages.uploadsStorageLimitErrorMessage} />;
|
|
50
|
-
case ERROR_CODE_UPLOAD_PENDING_APP_FOLDER_SIZE_LIMIT:
|
|
51
|
-
return <FormattedMessage {...messages.uploadsPendingFolderSizeLimitErrorMessage} />;
|
|
52
|
-
case ERROR_CODE_UPLOAD_FAILED_PACKAGE:
|
|
53
|
-
return <FormattedMessage {...messages.uploadsPackageUploadErrorMessage} />;
|
|
54
|
-
default:
|
|
55
|
-
return <FormattedMessage {...messages.uploadsDefaultErrorMessage} />;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export default (shouldShowUpgradeCTAMessage?: boolean) => ({
|
|
60
|
-
rowData,
|
|
61
|
-
}: Props) => {
|
|
62
|
-
const { status, error = {}, name, isFolder, file } = rowData;
|
|
63
|
-
const { code } = error;
|
|
64
|
-
|
|
65
|
-
if (isFolder && status !== STATUS_ERROR) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
switch (status) {
|
|
70
|
-
case STATUS_IN_PROGRESS:
|
|
71
|
-
case STATUS_STAGED:
|
|
72
|
-
return <ItemProgress {...rowData} />;
|
|
73
|
-
case STATUS_ERROR:
|
|
74
|
-
if (Browser.isSafari() && code === ERROR_CODE_UPLOAD_BAD_DIGEST && file.name.indexOf('.zip') !== -1) {
|
|
75
|
-
return getErrorMessage(ERROR_CODE_UPLOAD_FAILED_PACKAGE, file.name);
|
|
76
|
-
}
|
|
77
|
-
return getErrorMessage(code, name, shouldShowUpgradeCTAMessage);
|
|
78
|
-
default:
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import ItemRemove from './ItemRemove';
|
|
3
|
-
import type { UploadItem } from '../../common/types/upload';
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
rowData: UploadItem
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default (onClick: (item: UploadItem) => void) => ({
|
|
10
|
-
rowData,
|
|
11
|
-
}: Props) => {
|
|
12
|
-
if (rowData.isFolder) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
return <ItemRemove status={rowData.status} onClick={() => onClick(rowData)} />;
|
|
16
|
-
};
|