|
@@ -50,6 +50,17 @@ function togglePauseResume (props) {
|
|
|
module.exports = (props) => {
|
|
|
props = props || {}
|
|
|
|
|
|
+ const { newFiles,
|
|
|
+ allowNewUpload,
|
|
|
+ isUploadInProgress,
|
|
|
+ isAllPaused,
|
|
|
+ resumableUploads,
|
|
|
+ error,
|
|
|
+ hideUploadButton,
|
|
|
+ hidePauseResumeButton,
|
|
|
+ hideCancelButton,
|
|
|
+ hideRetryButton } = props
|
|
|
+
|
|
|
const uploadState = props.uploadState
|
|
|
|
|
|
let progressValue = props.totalProgress
|
|
@@ -78,11 +89,18 @@ module.exports = (props) => {
|
|
|
(uploadState === statusBarStates.STATE_WAITING && !props.newFiles > 0) ||
|
|
|
(uploadState === statusBarStates.STATE_COMPLETE && props.hideAfterFinish)
|
|
|
|
|
|
- const showUploadButton = props.newFiles && !props.hideUploadButton && props.allowNewUpload
|
|
|
- const showRetryButton = props.error && !props.hideRetryButton
|
|
|
- const showCancelButton = !props.hidePauseResumeCancelButtons &&
|
|
|
+ const showUploadBtn = !error && newFiles &&
|
|
|
+ !isUploadInProgress && !isAllPaused &&
|
|
|
+ allowNewUpload && !hideUploadButton
|
|
|
+ const showCancelBtn = !hideCancelButton &&
|
|
|
+ uploadState !== statusBarStates.STATE_WAITING &&
|
|
|
+ uploadState !== statusBarStates.STATE_COMPLETE
|
|
|
+ const showPauseResumeBtn = resumableUploads && !hidePauseResumeButton &&
|
|
|
uploadState !== statusBarStates.STATE_WAITING &&
|
|
|
+ uploadState !== statusBarStates.STATE_PREPROCESSING &&
|
|
|
+ uploadState !== statusBarStates.STATE_POSTPROCESSING &&
|
|
|
uploadState !== statusBarStates.STATE_COMPLETE
|
|
|
+ const showRetryBtn = error && !hideRetryButton
|
|
|
|
|
|
const progressClassNames = `uppy-StatusBar-progress
|
|
|
${progressMode ? 'is-' + progressMode : ''}`
|
|
@@ -90,8 +108,7 @@ module.exports = (props) => {
|
|
|
const statusBarClassNames = classNames(
|
|
|
{ 'uppy-Root': props.isTargetDOMEl },
|
|
|
'uppy-StatusBar',
|
|
|
- `is-${uploadState}`,
|
|
|
- { 'uppy-StatusBar--detailedProgress': props.showProgressDetails }
|
|
|
+ `is-${uploadState}`
|
|
|
)
|
|
|
|
|
|
return (
|
|
@@ -104,9 +121,10 @@ module.exports = (props) => {
|
|
|
aria-valuenow={progressValue} />
|
|
|
{progressBarContent}
|
|
|
<div class="uppy-StatusBar-actions">
|
|
|
- { showUploadButton ? <UploadBtn {...props} uploadState={uploadState} /> : null }
|
|
|
- { showRetryButton ? <RetryBtn {...props} /> : null }
|
|
|
- { showCancelButton ? <CancelBtn {...props} /> : null }
|
|
|
+ { showUploadBtn ? <UploadBtn {...props} uploadState={uploadState} /> : null }
|
|
|
+ { showRetryBtn ? <RetryBtn {...props} /> : null }
|
|
|
+ { showPauseResumeBtn ? <PauseResumeButton {...props} /> : null }
|
|
|
+ { showCancelBtn ? <CancelBtn {...props} /> : null }
|
|
|
</div>
|
|
|
</div>
|
|
|
)
|
|
@@ -125,7 +143,7 @@ const UploadBtn = (props) => {
|
|
|
class={uploadBtnClassNames}
|
|
|
aria-label={props.i18n('uploadXFiles', { smart_count: props.newFiles })}
|
|
|
onclick={props.startUpload}>
|
|
|
- {props.newFiles && props.uploadStarted
|
|
|
+ {props.newFiles && props.isUploadStarted
|
|
|
? props.i18n('uploadXNewFiles', { smart_count: props.newFiles })
|
|
|
: props.i18n('uploadXFiles', { smart_count: props.newFiles })
|
|
|
}
|
|
@@ -141,39 +159,43 @@ const RetryBtn = (props) => {
|
|
|
|
|
|
const CancelBtn = (props) => {
|
|
|
return <button type="button"
|
|
|
- class="uppy-u-reset uppy-c-btn uppy-StatusBar-actionBtn uppy-StatusBar-actionBtn--cancel"
|
|
|
+ class="uppy-u-reset uppy-StatusBar-actionCircleBtn"
|
|
|
+ title={props.i18n('cancel')}
|
|
|
aria-label={props.i18n('cancel')}
|
|
|
- onclick={props.cancelAll}>{props.i18n('cancel')}</button>
|
|
|
+ onclick={props.cancelAll}>
|
|
|
+ <svg aria-hidden="true" class="UppyIcon" width="8" height="8" viewBox="0 0 8 8" xmlns="http://www.w3.org/2000/svg">
|
|
|
+ <path d="M5.21 4.104l1.658 1.658-1.106 1.106-1.658-1.659-1.659 1.659L1.34 5.762l1.658-1.658L1.34 2.445 2.445 1.34l1.659 1.658L5.762 1.34l1.106 1.105-1.659 1.659z" fill-rule="evenodd" />
|
|
|
+ </svg>
|
|
|
+ </button>
|
|
|
}
|
|
|
|
|
|
-const PauseResumeButtons = (props) => {
|
|
|
- const { resumableUploads, isAllPaused, i18n } = props
|
|
|
- const title = resumableUploads
|
|
|
- ? isAllPaused
|
|
|
- ? i18n('resumeUpload')
|
|
|
- : i18n('pauseUpload')
|
|
|
- : i18n('cancelUpload')
|
|
|
-
|
|
|
- return <button title={title} class="uppy-u-reset uppy-StatusBar-statusIndicator" type="button" onclick={() => togglePauseResume(props)}>
|
|
|
- {resumableUploads
|
|
|
- ? isAllPaused
|
|
|
- ? <svg aria-hidden="true" class="UppyIcon" width="15" height="17" viewBox="0 0 11 13">
|
|
|
- <path d="M1.26 12.534a.67.67 0 0 1-.674.012.67.67 0 0 1-.336-.583v-11C.25.724.38.5.586.382a.658.658 0 0 1 .673.012l9.165 5.5a.66.66 0 0 1 .325.57.66.66 0 0 1-.325.573l-9.166 5.5z" />
|
|
|
- </svg>
|
|
|
- : <svg aria-hidden="true" class="UppyIcon" width="16" height="17" viewBox="0 0 12 13">
|
|
|
- <path d="M4.888.81v11.38c0 .446-.324.81-.722.81H2.722C2.324 13 2 12.636 2 12.19V.81c0-.446.324-.81.722-.81h1.444c.398 0 .722.364.722.81zM9.888.81v11.38c0 .446-.324.81-.722.81H7.722C7.324 13 7 12.636 7 12.19V.81c0-.446.324-.81.722-.81h1.444c.398 0 .722.364.722.81z" />
|
|
|
- </svg>
|
|
|
- : <svg aria-hidden="true" class="UppyIcon" width="16px" height="16px" viewBox="0 0 19 19">
|
|
|
- <path d="M17.318 17.232L9.94 9.854 9.586 9.5l-.354.354-7.378 7.378h.707l-.62-.62v.706L9.318 9.94l.354-.354-.354-.354L1.94 1.854v.707l.62-.62h-.706l7.378 7.378.354.354.354-.354 7.378-7.378h-.707l.622.62v-.706L9.854 9.232l-.354.354.354.354 7.378 7.378.708-.707-7.38-7.378v.708l7.38-7.38.353-.353-.353-.353-.622-.622-.353-.353-.354.352-7.378 7.38h.708L2.56 1.23 2.208.88l-.353.353-.622.62-.353.355.352.353 7.38 7.38v-.708l-7.38 7.38-.353.353.352.353.622.622.353.353.354-.353 7.38-7.38h-.708l7.38 7.38z" />
|
|
|
+const PauseResumeButton = (props) => {
|
|
|
+ const { isAllPaused, i18n } = props
|
|
|
+ const title = isAllPaused ? i18n('resume') : i18n('pause')
|
|
|
+
|
|
|
+ return <button title={title} class="uppy-u-reset uppy-StatusBar-actionCircleBtn" type="button" onclick={() => togglePauseResume(props)}>
|
|
|
+ {isAllPaused
|
|
|
+ ? <svg aria-hidden="true" class="UppyIcon" width="8" height="8" viewBox="0 0 8 8" xmlns="http://www.w3.org/2000/svg">
|
|
|
+ <path d="M6.736 3.852l-4.472 2.84V1.075z" fill-rule="evenodd" />
|
|
|
+ </svg>
|
|
|
+ : <svg aria-hidden="true" class="UppyIcon" width="8" height="8" viewBox="0 0 8 8" xmlns="http://www.w3.org/2000/svg">
|
|
|
+ <path d="M1 1h2v6H1zM5 1h2v6H5z" fill-rule="evenodd" />
|
|
|
</svg>
|
|
|
}
|
|
|
</button>
|
|
|
}
|
|
|
|
|
|
+const LoadingSpinner = (props) => {
|
|
|
+ return <svg class="uppy-StatusBar-spinner" width="14" height="14" xmlns="http://www.w3.org/2000/svg">
|
|
|
+ <path d="M13.983 6.547c-.12-2.509-1.64-4.893-3.939-5.936-2.48-1.127-5.488-.656-7.556 1.094C.524 3.367-.398 6.048.162 8.562c.556 2.495 2.46 4.52 4.94 5.183 2.932.784 5.61-.602 7.256-3.015-1.493 1.993-3.745 3.309-6.298 2.868-2.514-.434-4.578-2.349-5.153-4.84a6.226 6.226 0 0 1 2.98-6.778C6.34.586 9.74 1.1 11.373 3.493c.407.596.693 1.282.842 1.988.127.598.073 1.197.161 1.794.078.525.543 1.257 1.15.864.525-.341.49-1.05.456-1.592-.007-.15.02.3 0 0" fill-rule="evenodd" />
|
|
|
+ </svg>
|
|
|
+}
|
|
|
+
|
|
|
const ProgressBarProcessing = (props) => {
|
|
|
const value = Math.round(props.value * 100)
|
|
|
|
|
|
return <div class="uppy-StatusBar-content">
|
|
|
+ <LoadingSpinner {...props} />
|
|
|
{props.mode === 'determinate' ? `${value}% \u00B7 ` : ''}
|
|
|
{props.message}
|
|
|
</div>
|
|
@@ -187,6 +209,26 @@ const ProgressDetails = (props) => {
|
|
|
</div>
|
|
|
}
|
|
|
|
|
|
+const UploadNewlyAddedFiles = (props) => {
|
|
|
+ const uploadBtnClassNames = classNames(
|
|
|
+ 'uppy-u-reset',
|
|
|
+ 'uppy-c-btn',
|
|
|
+ 'uppy-StatusBar-actionBtn'
|
|
|
+ )
|
|
|
+
|
|
|
+ return <div class="uppy-StatusBar-statusSecondary">
|
|
|
+ <div class="uppy-StatusBar-statusSecondaryHint">
|
|
|
+ { props.i18n('xMoreFilesAdded', { smart_count: props.newFiles }) }
|
|
|
+ </div>
|
|
|
+ <button type="button"
|
|
|
+ class={uploadBtnClassNames}
|
|
|
+ aria-label={props.i18n('uploadXFiles', { smart_count: props.newFiles })}
|
|
|
+ onclick={props.startUpload}>
|
|
|
+ {props.i18n('upload')}
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+}
|
|
|
+
|
|
|
const ThrottledProgressDetails = throttle(ProgressDetails, 500, { leading: true, trailing: true })
|
|
|
|
|
|
const ProgressBarUploading = (props) => {
|
|
@@ -195,13 +237,18 @@ const ProgressBarUploading = (props) => {
|
|
|
}
|
|
|
|
|
|
const title = props.isAllPaused ? props.i18n('paused') : props.i18n('uploading')
|
|
|
+ const showUploadNewlyAddedFiles = props.newFiles && props.isUploadStarted
|
|
|
|
|
|
return (
|
|
|
<div class="uppy-StatusBar-content" aria-label={title} title={title}>
|
|
|
- { !props.hidePauseResumeCancelButtons && <PauseResumeButtons {...props} /> }
|
|
|
+ { !props.isAllPaused ? <LoadingSpinner {...props} /> : null }
|
|
|
<div class="uppy-StatusBar-status">
|
|
|
<div class="uppy-StatusBar-statusPrimary">{title}: {props.totalProgress}%</div>
|
|
|
- { !props.isAllPaused && <ThrottledProgressDetails {...props} /> }
|
|
|
+ { !props.isAllPaused && !showUploadNewlyAddedFiles && props.showProgressDetails
|
|
|
+ ? <ThrottledProgressDetails {...props} />
|
|
|
+ : null
|
|
|
+ }
|
|
|
+ { showUploadNewlyAddedFiles ? <UploadNewlyAddedFiles {...props} /> : null }
|
|
|
</div>
|
|
|
</div>
|
|
|
)
|
|
@@ -222,7 +269,9 @@ const ProgressBarError = ({ error, retryAll, hideRetryButton, i18n }) => {
|
|
|
return (
|
|
|
<div class="uppy-StatusBar-content" role="alert">
|
|
|
<span class="uppy-StatusBar-contentPadding">{i18n('uploadFailed')}.</span>
|
|
|
- { !hideRetryButton && <span class="uppy-StatusBar-contentPadding">{i18n('pleasePressRetry')}</span> }
|
|
|
+ {!hideRetryButton &&
|
|
|
+ <span class="uppy-StatusBar-contentPadding">{i18n('pleasePressRetry')}</span>
|
|
|
+ }
|
|
|
<span class="uppy-StatusBar-details"
|
|
|
aria-label={error}
|
|
|
data-microtip-position="top"
|