const { h } = require('preact')
function onPauseResumeCancelRetry (props) {
console.log(props.uppy)
if (props.isUploaded) return
if (props.error && !props.hideRetryButton) {
props.uppy.retryUpload(props.file.id)
return
}
if (props.resumableUploads && !props.hidePauseResumeButton) {
props.uppy.pauseResume(props.file.id)
} else if (props.individualCancellation && !props.hideCancelButton) {
props.uppy.removeFile(props.file.id)
}
}
function progressIndicatorTitle (props) {
if (props.isUploaded) {
return props.i18n('uploadComplete')
}
if (props.error) {
return props.i18n('retryUpload')
}
if (props.resumableUploads) {
if (props.file.isPaused) {
return props.i18n('resumeUpload')
}
return props.i18n('pauseUpload')
} if (props.individualCancellation) {
return props.i18n('cancelUpload')
}
return ''
}
function ProgressIndicatorButton (props) {
return (
)
}
function ProgressCircleContainer ({ children }) {
return (
)
}
function ProgressCircle ({ progress }) {
// circle length equals 2 * PI * R
const circleLength = 2 * Math.PI * 15
return (
)
}
module.exports = function FileProgress (props) {
// Nothing if upload has not started
if (!props.file.progress.uploadStarted) {
return null
}
// Green checkmark when complete
if (props.isUploaded) {
return (
)
}
if (props.recoveredState) {
return
}
// Retry button for error
if (props.error && !props.hideRetryButton) {
return (
)
}
// Pause/resume button for resumable uploads
if (props.resumableUploads && !props.hidePauseResumeButton) {
return (
{
props.file.isPaused
?
: (
)
}
)
}
// Cancel button for non-resumable uploads if individualCancellation is supported (not bundled)
if (!props.resumableUploads && props.individualCancellation && !props.hideCancelButton) {
return (
)
}
// Just progress when buttons are disabled
return (