box-ui-elements 23.4.0-beta.13 → 23.4.0-beta.14
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/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/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,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @flow
|
|
3
|
-
* @file Content Uploader Popup Component
|
|
4
|
-
* @author Box
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import makePopup from '../common/makePopup';
|
|
8
|
-
import ContentUploader from './ContentUploader';
|
|
9
|
-
import { CLIENT_NAME_CONTENT_UPLOADER } from '../../constants';
|
|
10
|
-
|
|
11
|
-
export default makePopup(CLIENT_NAME_CONTENT_UPLOADER)(ContentUploader);
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import ItemList from './ItemList';
|
|
4
|
-
import UploadState from './UploadState';
|
|
5
|
-
|
|
6
|
-
import makeDroppable from '../common/droppable';
|
|
7
|
-
import type { UploadFile, UploadFileWithAPIOptions, UploadItem } from '../../common/types/upload';
|
|
8
|
-
import type { DOMStringList, View } from '../../common/types/core';
|
|
9
|
-
|
|
10
|
-
import './DroppableContent.scss';
|
|
11
|
-
|
|
12
|
-
type Props = {
|
|
13
|
-
addDataTransferItemsToUploadQueue: (droppedItems: DataTransfer) => void,
|
|
14
|
-
addFiles: (files?: Array<UploadFileWithAPIOptions | UploadFile>) => void,
|
|
15
|
-
allowedTypes: Array<string>;
|
|
16
|
-
canDrop: boolean,
|
|
17
|
-
isFolderUploadEnabled: boolean,
|
|
18
|
-
isOver: boolean,
|
|
19
|
-
isTouch: boolean,
|
|
20
|
-
items: UploadItem[],
|
|
21
|
-
onClick: (item: UploadItem) => void,
|
|
22
|
-
view: View,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Definition for drag and drop behavior.
|
|
27
|
-
*/
|
|
28
|
-
const dropDefinition = {
|
|
29
|
-
/**
|
|
30
|
-
* Validates whether a file can be dropped or not.
|
|
31
|
-
*/
|
|
32
|
-
dropValidator: (
|
|
33
|
-
{ allowedTypes }: { allowedTypes: Array<string> },
|
|
34
|
-
{ types }: { types: Array<string> | DOMStringList },
|
|
35
|
-
) => {
|
|
36
|
-
if (types instanceof Array) {
|
|
37
|
-
return Array.from(types).some(type => allowedTypes.indexOf(type) > -1);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const allowedList = allowedTypes.filter(allowed => types.contains(allowed));
|
|
41
|
-
return allowedList.length > 0;
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Determines what happens after a file is dropped
|
|
46
|
-
*/
|
|
47
|
-
onDrop: (event, { addDataTransferItemsToUploadQueue }: Props) => {
|
|
48
|
-
const { dataTransfer } = event;
|
|
49
|
-
addDataTransferItemsToUploadQueue(dataTransfer);
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const DroppableContent = makeDroppable(dropDefinition)(({
|
|
54
|
-
addFiles,
|
|
55
|
-
canDrop,
|
|
56
|
-
isFolderUploadEnabled,
|
|
57
|
-
isOver,
|
|
58
|
-
isTouch,
|
|
59
|
-
items,
|
|
60
|
-
onClick,
|
|
61
|
-
view,
|
|
62
|
-
}: Props) => {
|
|
63
|
-
const handleSelectFiles = ({ target: { files } }: any) => addFiles(files);
|
|
64
|
-
const hasItems = items.length > 0;
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<div className="bcu-droppable-content">
|
|
68
|
-
<ItemList items={items} onClick={onClick} />
|
|
69
|
-
<UploadState
|
|
70
|
-
canDrop={canDrop}
|
|
71
|
-
hasItems={hasItems}
|
|
72
|
-
isFolderUploadEnabled={isFolderUploadEnabled}
|
|
73
|
-
isOver={isOver}
|
|
74
|
-
isTouch={isTouch}
|
|
75
|
-
onSelect={handleSelectFiles}
|
|
76
|
-
view={view}
|
|
77
|
-
/>
|
|
78
|
-
</div>
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
export default DroppableContent;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { FormattedMessage, useIntl } from 'react-intl';
|
|
3
|
-
import { Button } from '@box/blueprint-web';
|
|
4
|
-
import messages from '../common/messages';
|
|
5
|
-
import { ERROR_CODE_UPLOAD_FILE_LIMIT } from '../../constants';
|
|
6
|
-
import './Footer.scss';
|
|
7
|
-
|
|
8
|
-
type Props = {
|
|
9
|
-
errorCode?: string,
|
|
10
|
-
fileLimit: number,
|
|
11
|
-
hasFiles: boolean,
|
|
12
|
-
isDone: boolean,
|
|
13
|
-
isLoading: boolean,
|
|
14
|
-
onCancel: any,
|
|
15
|
-
onClose?: any,
|
|
16
|
-
onUpload: any,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const Footer = ({ isLoading, hasFiles, errorCode, onCancel, onClose, onUpload, fileLimit, isDone }: Props) => {
|
|
20
|
-
const intl = useIntl();
|
|
21
|
-
const isCloseButtonDisabled = hasFiles;
|
|
22
|
-
const isCancelButtonDisabled = !hasFiles || isDone;
|
|
23
|
-
const isUploadButtonDisabled = !hasFiles;
|
|
24
|
-
|
|
25
|
-
let message;
|
|
26
|
-
switch (errorCode) {
|
|
27
|
-
case ERROR_CODE_UPLOAD_FILE_LIMIT:
|
|
28
|
-
message = <FormattedMessage {...messages.uploadErrorTooManyFiles} values={{ fileLimit }} />;
|
|
29
|
-
break;
|
|
30
|
-
default:
|
|
31
|
-
// ignore
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div className="bcu-footer">
|
|
36
|
-
<div className="bcu-footer-left">
|
|
37
|
-
{onClose ? (
|
|
38
|
-
<Button disabled={isCloseButtonDisabled} onClick={onClose} size="large" variant="secondary">
|
|
39
|
-
{intl.formatMessage(messages.close)}
|
|
40
|
-
</Button>
|
|
41
|
-
) : null}
|
|
42
|
-
</div>
|
|
43
|
-
{message && <div className="bcu-footer-message">{message}</div>}
|
|
44
|
-
<div className="bcu-footer-right">
|
|
45
|
-
<Button disabled={isCancelButtonDisabled} onClick={onCancel} size="large" variant="secondary">
|
|
46
|
-
{intl.formatMessage(messages.cancel)}
|
|
47
|
-
</Button>
|
|
48
|
-
<Button
|
|
49
|
-
disabled={isUploadButtonDisabled}
|
|
50
|
-
loading={isLoading}
|
|
51
|
-
loadingAriaLabel={intl.formatMessage(messages.loading)}
|
|
52
|
-
onClick={onUpload}
|
|
53
|
-
size="large"
|
|
54
|
-
variant="primary"
|
|
55
|
-
>
|
|
56
|
-
{intl.formatMessage(messages.upload)}
|
|
57
|
-
</Button>
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export default Footer;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @flow
|
|
3
|
-
* @file Component for file icon and name
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import * as React from 'react';
|
|
7
|
-
import Badgeable from '../../components/badgeable';
|
|
8
|
-
import FileIcon from '../../icons/file-icon/FileIcon';
|
|
9
|
-
import IconAlertDefault from '../../icons/general/IconAlertDefault';
|
|
10
|
-
import IconFolderPersonal from '../../icons/folder/IconFolderPersonal';
|
|
11
|
-
import ItemName from './ItemName';
|
|
12
|
-
import { STATUS_ERROR } from '../../constants';
|
|
13
|
-
import type { UploadStatus } from '../../common/types/upload';
|
|
14
|
-
import './IconName.scss';
|
|
15
|
-
|
|
16
|
-
type Props = {
|
|
17
|
-
extension: string,
|
|
18
|
-
isFolder?: boolean,
|
|
19
|
-
isResumableUploadsEnabled: boolean,
|
|
20
|
-
name: string,
|
|
21
|
-
status: UploadStatus,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const IconName = ({ name, extension, isFolder = false, isResumableUploadsEnabled, status }: Props) => {
|
|
25
|
-
let icon = isFolder ? <IconFolderPersonal /> : <FileIcon extension={extension} />;
|
|
26
|
-
|
|
27
|
-
if (isResumableUploadsEnabled && status === STATUS_ERROR) {
|
|
28
|
-
icon = (
|
|
29
|
-
<Badgeable className="bcu-icon-badge" bottomRight={<IconAlertDefault height={18} width={18} />}>
|
|
30
|
-
{icon}
|
|
31
|
-
</Badgeable>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<div className="bcu-item-icon-name">
|
|
37
|
-
<div className="bcu-item-icon">{icon}</div>
|
|
38
|
-
<div className="bcu-item-name">
|
|
39
|
-
<ItemName name={name} />
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export default IconName;
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { injectIntl } from 'react-intl';
|
|
3
|
-
import type { IntlShape } from 'react-intl';
|
|
4
|
-
import { Button, IconButton, LoadingIndicator } from '@box/blueprint-web';
|
|
5
|
-
import { ArrowCurveForward, Checkmark } from '@box/blueprint-web-assets/icons/Line';
|
|
6
|
-
import { EllipsisBadge, XMark } from '@box/blueprint-web-assets/icons/Fill';
|
|
7
|
-
|
|
8
|
-
import Tooltip, { TooltipPosition } from '../../components/tooltip';
|
|
9
|
-
import {
|
|
10
|
-
ERROR_CODE_UPLOAD_FILE_SIZE_LIMIT_EXCEEDED,
|
|
11
|
-
STATUS_PENDING,
|
|
12
|
-
STATUS_IN_PROGRESS,
|
|
13
|
-
STATUS_STAGED,
|
|
14
|
-
STATUS_COMPLETE,
|
|
15
|
-
STATUS_ERROR,
|
|
16
|
-
} from '../../constants';
|
|
17
|
-
|
|
18
|
-
import messages from '../common/messages';
|
|
19
|
-
|
|
20
|
-
import type { UploadStatus } from '../../common/types/upload';
|
|
21
|
-
|
|
22
|
-
import './ItemAction.scss';
|
|
23
|
-
import { Size5, SurfaceStatusSurfaceSuccess } from '@box/blueprint-web-assets/tokens/tokens';
|
|
24
|
-
|
|
25
|
-
type ItemActionProps = {
|
|
26
|
-
error?: any,
|
|
27
|
-
intl: IntlShape,
|
|
28
|
-
isFolder?: boolean,
|
|
29
|
-
isResumableUploadsEnabled: boolean,
|
|
30
|
-
onClick: any,
|
|
31
|
-
onUpgradeCTAClick?: any,
|
|
32
|
-
status: UploadStatus,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const getIconWithTooltip = (
|
|
36
|
-
icon: React.ReactNode,
|
|
37
|
-
isDisabled: boolean,
|
|
38
|
-
isLoading: boolean,
|
|
39
|
-
onClick: any,
|
|
40
|
-
tooltip: boolean,
|
|
41
|
-
tooltipText: string,
|
|
42
|
-
) => {
|
|
43
|
-
if (isLoading) {
|
|
44
|
-
return <LoadingIndicator aria-label="loading" />;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (tooltip) {
|
|
48
|
-
return (
|
|
49
|
-
<Tooltip position={TooltipPosition.TOP_LEFT} text={tooltipText}>
|
|
50
|
-
<IconButton aria-label={tooltipText} disabled={isDisabled} onClick={onClick} icon={() => icon} />
|
|
51
|
-
</Tooltip>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return <>{icon}</>;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const ItemAction = ({
|
|
59
|
-
error,
|
|
60
|
-
intl,
|
|
61
|
-
isFolder = false,
|
|
62
|
-
isResumableUploadsEnabled,
|
|
63
|
-
onClick,
|
|
64
|
-
onUpgradeCTAClick,
|
|
65
|
-
status,
|
|
66
|
-
}: ItemActionProps) => {
|
|
67
|
-
let icon: React.ReactNode = <XMark color="black" height={Size5} width={Size5} />;
|
|
68
|
-
let tooltip;
|
|
69
|
-
let isLoading = false;
|
|
70
|
-
const { code } = error || {};
|
|
71
|
-
const { formatMessage } = intl;
|
|
72
|
-
|
|
73
|
-
if (isFolder && status !== STATUS_PENDING) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
switch (status) {
|
|
78
|
-
case STATUS_COMPLETE:
|
|
79
|
-
icon = <Checkmark aria-label="complete" color={SurfaceStatusSurfaceSuccess} height={Size5} width={Size5} />;
|
|
80
|
-
if (!isResumableUploadsEnabled) {
|
|
81
|
-
tooltip = messages.remove;
|
|
82
|
-
}
|
|
83
|
-
break;
|
|
84
|
-
case STATUS_ERROR:
|
|
85
|
-
icon = <ArrowCurveForward aria-label="error" color="black" height={Size5} width={Size5} />;
|
|
86
|
-
tooltip = isResumableUploadsEnabled ? messages.resume : messages.retry;
|
|
87
|
-
break;
|
|
88
|
-
case STATUS_IN_PROGRESS:
|
|
89
|
-
case STATUS_STAGED:
|
|
90
|
-
if (isResumableUploadsEnabled) {
|
|
91
|
-
isLoading = true;
|
|
92
|
-
} else {
|
|
93
|
-
icon = <EllipsisBadge aria-label="staged" color="black" height={Size5} width={Size5} />;
|
|
94
|
-
tooltip = messages.uploadsCancelButtonTooltip;
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
case STATUS_PENDING:
|
|
98
|
-
default:
|
|
99
|
-
if (isResumableUploadsEnabled) {
|
|
100
|
-
isLoading = true;
|
|
101
|
-
} else {
|
|
102
|
-
tooltip = messages.uploadsCancelButtonTooltip;
|
|
103
|
-
}
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (status === STATUS_ERROR && code === ERROR_CODE_UPLOAD_FILE_SIZE_LIMIT_EXCEEDED && !!onUpgradeCTAClick) {
|
|
108
|
-
return (
|
|
109
|
-
<Button
|
|
110
|
-
onClick={onUpgradeCTAClick}
|
|
111
|
-
data-resin-target="large_version_error_inline_upgrade_cta"
|
|
112
|
-
variant="primary"
|
|
113
|
-
>
|
|
114
|
-
{intl.formatMessage(messages.uploadsFileSizeLimitExceededUpgradeMessageForUpgradeCta)}
|
|
115
|
-
</Button>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
const isDisabled = status === STATUS_STAGED;
|
|
119
|
-
const tooltipText = tooltip && formatMessage(tooltip);
|
|
120
|
-
|
|
121
|
-
return (
|
|
122
|
-
<div className="bcu-item-action">
|
|
123
|
-
{getIconWithTooltip(icon, isDisabled, isLoading, onClick, tooltip, tooltipText)}
|
|
124
|
-
</div>
|
|
125
|
-
);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export default injectIntl(ItemAction);
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import noop from 'lodash/noop';
|
|
3
|
-
import { Table, Column } from '@box/react-virtualized/dist/es/Table';
|
|
4
|
-
import AutoSizer from '@box/react-virtualized/dist/es/AutoSizer';
|
|
5
|
-
import nameCellRenderer from './nameCellRenderer';
|
|
6
|
-
import progressCellRenderer from './progressCellRenderer';
|
|
7
|
-
import actionCellRenderer from './actionCellRenderer';
|
|
8
|
-
import removeCellRenderer from './removeCellRenderer';
|
|
9
|
-
import type { UploadItem } from '../../common/types/upload';
|
|
10
|
-
import '@box/react-virtualized/styles.css';
|
|
11
|
-
import './ItemList.scss';
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
isResumableUploadsEnabled?: boolean,
|
|
15
|
-
items: UploadItem[],
|
|
16
|
-
onClick: any,
|
|
17
|
-
onRemoveClick?: (item: UploadItem) => void,
|
|
18
|
-
onUpgradeCTAClick?: any
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const ItemList = ({
|
|
22
|
-
isResumableUploadsEnabled = false,
|
|
23
|
-
items,
|
|
24
|
-
onClick,
|
|
25
|
-
onRemoveClick = noop,
|
|
26
|
-
onUpgradeCTAClick,
|
|
27
|
-
}: Props) => (
|
|
28
|
-
<AutoSizer>
|
|
29
|
-
{({ width, height }) => {
|
|
30
|
-
const nameCell = nameCellRenderer(isResumableUploadsEnabled);
|
|
31
|
-
const progressCell = progressCellRenderer(!!onUpgradeCTAClick);
|
|
32
|
-
const actionCell = actionCellRenderer(isResumableUploadsEnabled, onClick, onUpgradeCTAClick);
|
|
33
|
-
const removeCell = removeCellRenderer(onRemoveClick);
|
|
34
|
-
const baseIconWidth = 32;
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<Table
|
|
38
|
-
className="bcu-item-list"
|
|
39
|
-
disableHeader
|
|
40
|
-
headerHeight={0}
|
|
41
|
-
height={height}
|
|
42
|
-
rowClassName="bcu-item-row"
|
|
43
|
-
rowCount={items.length}
|
|
44
|
-
rowGetter={({ index }) => items[index]}
|
|
45
|
-
rowHeight={50}
|
|
46
|
-
width={width}
|
|
47
|
-
>
|
|
48
|
-
<Column cellRenderer={nameCell} dataKey="name" flexGrow={1} flexShrink={1} width={300} />
|
|
49
|
-
<Column
|
|
50
|
-
cellRenderer={progressCell}
|
|
51
|
-
dataKey="progress"
|
|
52
|
-
flexGrow={1}
|
|
53
|
-
flexShrink={1}
|
|
54
|
-
style={{ textAlign: 'right' }}
|
|
55
|
-
width={300}
|
|
56
|
-
/>
|
|
57
|
-
<Column
|
|
58
|
-
className={isResumableUploadsEnabled ? '' : 'bcu-item-list-action-column'}
|
|
59
|
-
cellRenderer={actionCell}
|
|
60
|
-
dataKey="status"
|
|
61
|
-
flexShrink={0}
|
|
62
|
-
width={onUpgradeCTAClick ? 100 : baseIconWidth}
|
|
63
|
-
/>
|
|
64
|
-
{isResumableUploadsEnabled && (
|
|
65
|
-
<Column
|
|
66
|
-
className="bcu-item-list-action-column"
|
|
67
|
-
cellRenderer={removeCell}
|
|
68
|
-
dataKey="remove"
|
|
69
|
-
flexShrink={0}
|
|
70
|
-
width={baseIconWidth}
|
|
71
|
-
/>
|
|
72
|
-
)}
|
|
73
|
-
</Table>
|
|
74
|
-
);
|
|
75
|
-
}}
|
|
76
|
-
</AutoSizer>
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
export default ItemList;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useIntl } from 'react-intl';
|
|
3
|
-
import { IconButton, Tooltip } from '@box/blueprint-web';
|
|
4
|
-
import { GrayBlack, Size5 } from '@box/blueprint-web-assets/tokens/tokens';
|
|
5
|
-
import { XMark } from '@box/blueprint-web-assets/icons/Fill';
|
|
6
|
-
|
|
7
|
-
import type { UploadItem, UploadStatus } from '../../common/types/upload';
|
|
8
|
-
|
|
9
|
-
import { STATUS_ERROR, STATUS_IN_PROGRESS, STATUS_STAGED } from '../../constants';
|
|
10
|
-
|
|
11
|
-
import messages from '../common/messages';
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
onClick: (item: UploadItem) => void;
|
|
15
|
-
status: UploadStatus;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const ItemRemove = ({ onClick, status }: Props) => {
|
|
19
|
-
const resin: Record<string, string> = {};
|
|
20
|
-
let target = null;
|
|
21
|
-
|
|
22
|
-
if (status === STATUS_IN_PROGRESS) {
|
|
23
|
-
target = 'uploadcancel';
|
|
24
|
-
} else if (status === STATUS_ERROR) {
|
|
25
|
-
target = 'remove-failed';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (target) {
|
|
29
|
-
resin['data-resin-target'] = target;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const intl = useIntl();
|
|
33
|
-
const isDisabled = status === STATUS_STAGED;
|
|
34
|
-
const tooltipText = intl.formatMessage(messages.remove);
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<div className="bcu-item-action">
|
|
38
|
-
<Tooltip content={tooltipText} variant="standard">
|
|
39
|
-
<IconButton
|
|
40
|
-
aria-label={tooltipText}
|
|
41
|
-
disabled={isDisabled}
|
|
42
|
-
onClick={onClick}
|
|
43
|
-
icon={() => <XMark color={GrayBlack} height={Size5} width={Size5} />}
|
|
44
|
-
{...resin}
|
|
45
|
-
/>
|
|
46
|
-
</Tooltip>
|
|
47
|
-
</div>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export default ItemRemove;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { FormattedMessage } from 'react-intl';
|
|
3
|
-
import messages from '../common/messages';
|
|
4
|
-
import ProgressBar from './ProgressBar';
|
|
5
|
-
import UploadsManagerItemAction from './UploadsManagerAction';
|
|
6
|
-
import { VIEW_UPLOAD_IN_PROGRESS, VIEW_UPLOAD_SUCCESS, VIEW_ERROR, VIEW_UPLOAD_EMPTY } from '../../constants';
|
|
7
|
-
import type { View } from '../../common/types/core';
|
|
8
|
-
|
|
9
|
-
import './OverallUploadsProgressBar.scss';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Get upload status
|
|
13
|
-
*
|
|
14
|
-
* @param {View} view
|
|
15
|
-
* @return {FormattedMessage|string}
|
|
16
|
-
*/
|
|
17
|
-
const getUploadStatus = (view: string) => {
|
|
18
|
-
switch (view) {
|
|
19
|
-
case VIEW_UPLOAD_IN_PROGRESS:
|
|
20
|
-
return <FormattedMessage {...messages.uploadsManagerUploadInProgress} />;
|
|
21
|
-
case VIEW_UPLOAD_SUCCESS:
|
|
22
|
-
return <FormattedMessage {...messages.uploadsManagerUploadComplete} />;
|
|
23
|
-
case VIEW_UPLOAD_EMPTY:
|
|
24
|
-
return <FormattedMessage {...messages.uploadsManagerUploadPrompt} />;
|
|
25
|
-
case VIEW_ERROR:
|
|
26
|
-
return <FormattedMessage {...messages.uploadsManagerUploadFailed} />;
|
|
27
|
-
default:
|
|
28
|
-
return '';
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Get overall upload progress percentage
|
|
34
|
-
*
|
|
35
|
-
* @param {string} view
|
|
36
|
-
* @param {number} percent
|
|
37
|
-
*/
|
|
38
|
-
const getPercent = (view: string, percent: number): number => {
|
|
39
|
-
switch (view) {
|
|
40
|
-
case VIEW_UPLOAD_SUCCESS:
|
|
41
|
-
return 100;
|
|
42
|
-
case VIEW_UPLOAD_EMPTY:
|
|
43
|
-
case VIEW_ERROR:
|
|
44
|
-
return 0;
|
|
45
|
-
default:
|
|
46
|
-
return percent;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
type Props = {
|
|
51
|
-
customPrompt?: {
|
|
52
|
-
defaultMessage: string,
|
|
53
|
-
description: string,
|
|
54
|
-
id: string
|
|
55
|
-
},
|
|
56
|
-
hasMultipleFailedUploads: boolean,
|
|
57
|
-
isDragging: boolean,
|
|
58
|
-
isExpanded: boolean,
|
|
59
|
-
isResumeVisible: boolean,
|
|
60
|
-
isVisible: boolean,
|
|
61
|
-
onClick: any,
|
|
62
|
-
onKeyDown: any,
|
|
63
|
-
onUploadsManagerActionClick: any,
|
|
64
|
-
percent: number,
|
|
65
|
-
view: View
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const OverallUploadsProgressBar = ({
|
|
69
|
-
customPrompt,
|
|
70
|
-
hasMultipleFailedUploads,
|
|
71
|
-
isDragging,
|
|
72
|
-
isExpanded,
|
|
73
|
-
isResumeVisible,
|
|
74
|
-
isVisible,
|
|
75
|
-
onClick,
|
|
76
|
-
onKeyDown,
|
|
77
|
-
onUploadsManagerActionClick,
|
|
78
|
-
percent,
|
|
79
|
-
view,
|
|
80
|
-
}: Props) => {
|
|
81
|
-
// Show the upload prompt and set progress to 0 when the uploads manager
|
|
82
|
-
// is invisible or is having files dragged to it
|
|
83
|
-
const shouldShowPrompt = isDragging || !isVisible;
|
|
84
|
-
const message = customPrompt || messages.uploadsManagerUploadPrompt;
|
|
85
|
-
const status = shouldShowPrompt ? <FormattedMessage {...message} /> : getUploadStatus(view);
|
|
86
|
-
const updatedPercent = shouldShowPrompt ? 0 : getPercent(view, percent);
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<div
|
|
90
|
-
aria-hidden={!isVisible}
|
|
91
|
-
className="bcu-overall-progress-bar"
|
|
92
|
-
data-resin-target={isExpanded ? 'uploadcollapse' : 'uploadexpand'}
|
|
93
|
-
onClick={onClick}
|
|
94
|
-
onKeyDown={onKeyDown}
|
|
95
|
-
role="button"
|
|
96
|
-
tabIndex={isVisible ? '0' : '-1'}
|
|
97
|
-
>
|
|
98
|
-
<span className="bcu-upload-status">{status}</span>
|
|
99
|
-
<ProgressBar percent={updatedPercent} />
|
|
100
|
-
{isResumeVisible && (
|
|
101
|
-
<UploadsManagerItemAction
|
|
102
|
-
hasMultipleFailedUploads={hasMultipleFailedUploads}
|
|
103
|
-
onClick={onUploadsManagerActionClick}
|
|
104
|
-
/>
|
|
105
|
-
)}
|
|
106
|
-
<span className="bcu-uploads-manager-toggle" />
|
|
107
|
-
</div>
|
|
108
|
-
);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export default OverallUploadsProgressBar;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @flow
|
|
3
|
-
* @file Component for a progress bar
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React, { PureComponent } from 'react';
|
|
7
|
-
import './ProgressBar.scss';
|
|
8
|
-
|
|
9
|
-
type Props = {
|
|
10
|
-
percent: number,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type State = {
|
|
14
|
-
percent: number,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
class ProgressBar extends PureComponent<Props, State> {
|
|
18
|
-
props: Props;
|
|
19
|
-
|
|
20
|
-
state: State;
|
|
21
|
-
|
|
22
|
-
static defaultProps = {
|
|
23
|
-
percent: 0,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
static getDerivedStateFromProps({ percent }: Props, state: State): any {
|
|
27
|
-
if (percent !== state.percent) {
|
|
28
|
-
return {
|
|
29
|
-
percent,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* [constructor]
|
|
38
|
-
*
|
|
39
|
-
* @return {ProgressBar}
|
|
40
|
-
*/
|
|
41
|
-
constructor(props: Props) {
|
|
42
|
-
super(props);
|
|
43
|
-
const { percent } = props;
|
|
44
|
-
this.state = { percent };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Renders the progress bar
|
|
49
|
-
*
|
|
50
|
-
* @return {void}
|
|
51
|
-
*/
|
|
52
|
-
render() {
|
|
53
|
-
const { percent } = this.state;
|
|
54
|
-
const containerStyle = {
|
|
55
|
-
transitionDelay: percent > 0 && percent < 100 ? '0' : '0.4s',
|
|
56
|
-
};
|
|
57
|
-
return (
|
|
58
|
-
<div className="bcu-progress-container" style={containerStyle}>
|
|
59
|
-
<div className="bcu-progress" style={{ width: `${percent}%` }} />
|
|
60
|
-
</div>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default ProgressBar;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @flow
|
|
3
|
-
* @file Input element for folder/file upload
|
|
4
|
-
* @author Box
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/* eslint-disable */
|
|
8
|
-
import * as React from 'react';
|
|
9
|
-
|
|
10
|
-
type Props = {
|
|
11
|
-
handleChange: Function,
|
|
12
|
-
inputLabel?: React.Node,
|
|
13
|
-
inputLabelClass?: string,
|
|
14
|
-
isFolderUpload?: boolean,
|
|
15
|
-
isMultiple?: boolean,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const UploadInput = ({
|
|
19
|
-
handleChange,
|
|
20
|
-
inputLabel,
|
|
21
|
-
inputLabelClass = '',
|
|
22
|
-
isFolderUpload = false,
|
|
23
|
-
isMultiple = true,
|
|
24
|
-
}: Props) => {
|
|
25
|
-
const inputRef = React.useRef(null);
|
|
26
|
-
|
|
27
|
-
const onKeyDown = e => {
|
|
28
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
29
|
-
if (inputRef.current) {
|
|
30
|
-
inputRef.current.click();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
return inputLabel ? (
|
|
36
|
-
<label className={inputLabelClass} onKeyDown={onKeyDown} tabIndex={0}>
|
|
37
|
-
{inputLabel}
|
|
38
|
-
<input
|
|
39
|
-
data-testid="upload-input"
|
|
40
|
-
directory={isFolderUpload ? '' : undefined}
|
|
41
|
-
multiple={isMultiple}
|
|
42
|
-
onChange={handleChange}
|
|
43
|
-
ref={inputRef}
|
|
44
|
-
type="file"
|
|
45
|
-
webkitdirectory={isFolderUpload ? '' : undefined}
|
|
46
|
-
/>
|
|
47
|
-
</label>
|
|
48
|
-
) : null;
|
|
49
|
-
};
|
|
50
|
-
export default UploadInput;
|