mirror of
https://github.com/transloadit/uppy.git
synced 2026-01-23 02:25:07 +00:00
Merge branch 'master' of https://github.com/transloadit/uppy
This commit is contained in:
commit
f51ab0fd2f
11 changed files with 126 additions and 68 deletions
|
|
@ -354,14 +354,6 @@ module.exports = class AwsS3Multipart extends Plugin {
|
|||
return Promise.all(promises)
|
||||
}
|
||||
|
||||
addResumableUploadsCapabilityFlag () {
|
||||
this.uppy.setState({
|
||||
capabilities: Object.assign({}, this.uppy.getState().capabilities, {
|
||||
resumableUploads: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
onFileRemove (fileID, cb) {
|
||||
this.uploaderEvents[fileID].on('file-removed', (file) => {
|
||||
if (fileID === file.id) cb(file.id)
|
||||
|
|
@ -414,11 +406,20 @@ module.exports = class AwsS3Multipart extends Plugin {
|
|||
}
|
||||
|
||||
install () {
|
||||
this.addResumableUploadsCapabilityFlag()
|
||||
this.uppy.setState({
|
||||
capabilities: Object.assign({}, this.uppy.getState().capabilities, {
|
||||
resumableUploads: true
|
||||
})
|
||||
})
|
||||
this.uppy.addUploader(this.upload)
|
||||
}
|
||||
|
||||
uninstall () {
|
||||
this.uppy.setState({
|
||||
capabilities: Object.assign({}, this.uppy.getState().capabilities, {
|
||||
resumableUploads: false
|
||||
})
|
||||
})
|
||||
this.uppy.removeUploader(this.upload)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,41 @@ const { iconEdit, iconCopy, iconRetry } = require('./icons')
|
|||
const classNames = require('classnames')
|
||||
const { h } = require('preact')
|
||||
|
||||
const FileItemProgressWrapper = (props) => {
|
||||
if (props.hideRetryButton && props.error) {
|
||||
return
|
||||
}
|
||||
|
||||
if (props.isUploaded ||
|
||||
props.bundled ||
|
||||
(props.hidePauseResumeCancelButtons && !props.error)) {
|
||||
return <div class="uppy-DashboardItem-progressIndicator">
|
||||
<FileItemProgress
|
||||
progress={props.file.progress.percentage}
|
||||
fileID={props.file.id}
|
||||
hidePauseResumeCancelButtons={props.hidePauseResumeCancelButtons}
|
||||
bundled={props.bundled}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
|
||||
return <button
|
||||
class="uppy-DashboardItem-progressIndicator"
|
||||
type="button"
|
||||
aria-label={props.progressIndicatorTitle}
|
||||
title={props.progressIndicatorTitle}
|
||||
onclick={props.onPauseResumeCancelRetry}>
|
||||
{props.error
|
||||
? props.hideRetryButton ? null : iconRetry()
|
||||
: <FileItemProgress
|
||||
progress={props.file.progress.percentage}
|
||||
fileID={props.file.id}
|
||||
hidePauseResumeCancelButtons={props.hidePauseResumeCancelButtons}
|
||||
/>
|
||||
}
|
||||
</button>
|
||||
}
|
||||
|
||||
module.exports = function fileItem (props) {
|
||||
const file = props.file
|
||||
const acquirers = props.acquirers
|
||||
|
|
@ -25,13 +60,19 @@ module.exports = function fileItem (props) {
|
|||
|
||||
const onPauseResumeCancelRetry = (ev) => {
|
||||
if (isUploaded) return
|
||||
|
||||
if (error && !props.hideRetryButton) {
|
||||
props.retryUpload(file.id)
|
||||
return
|
||||
}
|
||||
|
||||
if (props.hidePauseResumeCancelButtons) {
|
||||
return
|
||||
}
|
||||
|
||||
if (props.resumableUploads) {
|
||||
props.pauseUpload(file.id)
|
||||
} else if (!props.hideCancelButton) {
|
||||
} else {
|
||||
props.cancelUpload(file.id)
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +84,8 @@ module.exports = function fileItem (props) {
|
|||
{ 'is-complete': isUploaded },
|
||||
{ 'is-paused': isPaused },
|
||||
{ 'is-error': error },
|
||||
{ 'is-resumable': props.resumableUploads }
|
||||
{ 'is-resumable': props.resumableUploads },
|
||||
{ 'is-bundled': props.bundledUpload }
|
||||
)
|
||||
|
||||
const progressIndicatorTitle = isUploaded
|
||||
|
|
@ -66,28 +108,12 @@ module.exports = function fileItem (props) {
|
|||
<FilePreview file={file} />
|
||||
</div>
|
||||
<div class="uppy-DashboardItem-progress">
|
||||
{isUploaded
|
||||
? <div class="uppy-DashboardItem-progressIndicator">
|
||||
{FileItemProgress({
|
||||
progress: file.progress.percentage,
|
||||
fileID: file.id
|
||||
})}
|
||||
</div>
|
||||
: <button class="uppy-DashboardItem-progressIndicator"
|
||||
type="button"
|
||||
aria-label={progressIndicatorTitle}
|
||||
title={progressIndicatorTitle}
|
||||
onclick={onPauseResumeCancelRetry}>
|
||||
{error
|
||||
? props.hideCancelButton ? null : iconRetry()
|
||||
: FileItemProgress({
|
||||
progress: file.progress.percentage,
|
||||
fileID: file.id,
|
||||
hideCancelButton: props.hideCancelButton
|
||||
})
|
||||
}
|
||||
</button>
|
||||
}
|
||||
<FileItemProgressWrapper
|
||||
progressIndicatorTitle={progressIndicatorTitle}
|
||||
onPauseResumeCancelRetry={onPauseResumeCancelRetry}
|
||||
file={file}
|
||||
error={error}
|
||||
{...props} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="uppy-DashboardItem-info">
|
||||
|
|
|
|||
|
|
@ -13,21 +13,24 @@ module.exports = (props) => {
|
|||
return (
|
||||
<svg width="70" height="70" viewBox="0 0 36 36" class="UppyIcon UppyIcon-progressCircle">
|
||||
<g class="progress-group">
|
||||
<circle r="15" cx="18" cy="18" stroke-width="2" fill="none" class="bg" />
|
||||
<circle r="15" cx="18" cy="18" transform="rotate(-90, 18, 18)" stroke-width="2" fill="none" class="progress"
|
||||
<circle class="bg" r="15" cx="18" cy="18" stroke-width="2" fill="none" />
|
||||
<circle class="progress" r="15" cx="18" cy="18" transform="rotate(-90, 18, 18)" stroke-width="2" fill="none"
|
||||
stroke-dasharray={circleLength}
|
||||
stroke-dashoffset={circleLength - (circleLength / 100 * props.progress)}
|
||||
/>
|
||||
</g>
|
||||
<polygon transform="translate(3, 3)" points="12 20 12 10 20 15" class="play" />
|
||||
<g transform="translate(14.5, 13)" class="pause">
|
||||
<rect x="0" y="0" width="2" height="10" rx="0" />
|
||||
<rect x="5" y="0" width="2" height="10" rx="0" />
|
||||
</g>
|
||||
<polygon transform="translate(2, 3)" points="14 22.5 7 15.2457065 8.99985857 13.1732815 14 18.3547104 22.9729883 9 25 11.1005634" class="check" />
|
||||
{props.hideCancelButton ? null
|
||||
: <polygon class="cancel" transform="translate(2, 2)" points="19.8856516 11.0625 16 14.9481516 12.1019737 11.0625 11.0625 12.1143484 14.9481516 16 11.0625 19.8980263 12.1019737 20.9375 16 17.0518484 19.8856516 20.9375 20.9375 19.8980263 17.0518484 16 20.9375 12" />
|
||||
{!props.hidePauseResumeCancelButtons && !props.bundled ? (
|
||||
<g>
|
||||
<polygon class="play" transform="translate(3, 3)" points="12 20 12 10 20 15" />
|
||||
<g class="pause" transform="translate(14.5, 13)">
|
||||
<rect x="0" y="0" width="2" height="10" rx="0" />
|
||||
<rect x="5" y="0" width="2" height="10" rx="0" />
|
||||
</g>
|
||||
<polygon class="cancel" transform="translate(2, 2)" points="19.8856516 11.0625 16 14.9481516 12.1019737 11.0625 11.0625 12.1143484 14.9481516 16 11.0625 19.8980263 12.1019737 20.9375 16 17.0518484 19.8856516 20.9375 20.9375 19.8980263 17.0518484 16 20.9375 12" />
|
||||
</g>
|
||||
) : null
|
||||
}
|
||||
<polygon class="check" transform="translate(2, 3)" points="14 22.5 7 15.2457065 8.99985857 13.1732815 14 18.3547104 22.9729883 9 25 11.1005634" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,9 +40,10 @@ module.exports = (props) => {
|
|||
pauseUpload={props.pauseUpload}
|
||||
cancelUpload={props.cancelUpload}
|
||||
retryUpload={props.retryUpload}
|
||||
hideCancelButton={props.hideCancelButton}
|
||||
hidePauseResumeCancelButtons={props.hidePauseResumeCancelButtons}
|
||||
hideRetryButton={props.hideRetryButton}
|
||||
resumableUploads={props.resumableUploads}
|
||||
bundled={props.bundled}
|
||||
isWide={props.isWide}
|
||||
showLinkToFileUploadResult={props.showLinkToFileUploadResult}
|
||||
metaFields={props.metaFields}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ module.exports = class Dashboard extends Plugin {
|
|||
showProgressDetails: false,
|
||||
hideUploadButton: false,
|
||||
hideRetryButton: false,
|
||||
hideCancelButton: false,
|
||||
hidePauseResumeCancelButtons: false,
|
||||
hideProgressAfterFinish: false,
|
||||
note: null,
|
||||
closeModalOnClickOutside: false,
|
||||
|
|
@ -491,7 +491,7 @@ module.exports = class Dashboard extends Plugin {
|
|||
autoProceed: this.uppy.opts.autoProceed,
|
||||
hideUploadButton: this.opts.hideUploadButton,
|
||||
hideRetryButton: this.opts.hideRetryButton,
|
||||
hideCancelButton: this.opts.hideCancelButton,
|
||||
hidePauseResumeCancelButtons: this.opts.hidePauseResumeCancelButtons,
|
||||
id: this.id,
|
||||
closeModal: this.requestCloseModal,
|
||||
handleClickOutside: this.handleClickOutside,
|
||||
|
|
@ -509,6 +509,7 @@ module.exports = class Dashboard extends Plugin {
|
|||
note: this.opts.note,
|
||||
metaFields: pluginState.metaFields,
|
||||
resumableUploads: capabilities.resumableUploads || false,
|
||||
bundled: capabilities.bundled || false,
|
||||
startUpload: startUpload,
|
||||
pauseUpload: this.uppy.pauseResume,
|
||||
retryUpload: this.uppy.retryUpload,
|
||||
|
|
@ -564,7 +565,7 @@ module.exports = class Dashboard extends Plugin {
|
|||
target: this,
|
||||
hideUploadButton: this.opts.hideUploadButton,
|
||||
hideRetryButton: this.opts.hideRetryButton,
|
||||
hideCancelButton: this.opts.hideCancelButton,
|
||||
hidePauseResumeCancelButtons: this.opts.hidePauseResumeCancelButtons,
|
||||
showProgressDetails: this.opts.showProgressDetails,
|
||||
hideAfterFinish: this.opts.hideProgressAfterFinish,
|
||||
locale: this.opts.locale
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ module.exports = (props) => {
|
|||
<div class="uppy-StatusBar-actions">
|
||||
{ props.newFiles && !props.hideUploadButton ? <UploadBtn {...props} uploadState={uploadState} /> : null }
|
||||
{ props.error && !props.hideRetryButton ? <RetryBtn {...props} /> : null }
|
||||
{ !props.hideCancelButton && uploadState !== statusBarStates.STATE_WAITING && uploadState !== statusBarStates.STATE_COMPLETE
|
||||
{ !props.hidePauseResumeCancelButtons && uploadState !== statusBarStates.STATE_WAITING && uploadState !== statusBarStates.STATE_COMPLETE
|
||||
? <CancelBtn {...props} />
|
||||
: null
|
||||
}
|
||||
|
|
@ -116,7 +116,6 @@ const UploadBtn = (props) => {
|
|||
'uppy-StatusBar-actionBtn',
|
||||
'uppy-StatusBar-actionBtn--upload',
|
||||
{ 'uppy-c-btn-primary': props.uploadState === statusBarStates.STATE_WAITING }
|
||||
// { 'uppy-StatusBar-actionBtn uppy-StatusBar-actionBtn--upload': props.uploadState !== statusBarStates.STATE_WAITING }
|
||||
)
|
||||
|
||||
return <button type="button"
|
||||
|
|
@ -161,7 +160,7 @@ const PauseResumeButtons = (props) => {
|
|||
: <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>
|
||||
: props.hideCancelButton ? null : <svg aria-hidden="true" class="UppyIcon" width="16px" height="16px" viewBox="0 0 19 19">
|
||||
: <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" />
|
||||
</svg>
|
||||
}
|
||||
|
|
@ -192,11 +191,13 @@ const ProgressBarUploading = (props) => {
|
|||
return null
|
||||
}
|
||||
|
||||
const title = props.isAllPaused ? props.i18n('paused') : props.i18n('uploading')
|
||||
|
||||
return (
|
||||
<div class="uppy-StatusBar-content" title={props.isAllPaused ? props.i18n('paused') : props.i18n('uploading')}>
|
||||
{ <PauseResumeButtons {...props} /> }
|
||||
<div class="uppy-StatusBar-content" aria-label={title} title={title}>
|
||||
{ !props.hidePauseResumeCancelButtons && <PauseResumeButtons {...props} /> }
|
||||
<div class="uppy-StatusBar-status">
|
||||
<span class="uppy-StatusBar-statusPrimary">{ props.isAllPaused ? props.i18n('paused') : props.i18n('uploading') }: {props.totalProgress}%</span>
|
||||
<span class="uppy-StatusBar-statusPrimary">{title}: {props.totalProgress}%</span>
|
||||
<br />
|
||||
{ !props.isAllPaused && <ThrottledProgressDetails {...props} /> }
|
||||
</div>
|
||||
|
|
@ -215,11 +216,11 @@ const ProgressBarComplete = ({ totalProgress, i18n }) => {
|
|||
)
|
||||
}
|
||||
|
||||
const ProgressBarError = ({ error, retryAll, i18n }) => {
|
||||
const ProgressBarError = ({ error, retryAll, hideRetryButton, i18n }) => {
|
||||
return (
|
||||
<div class="uppy-StatusBar-content" role="alert">
|
||||
<strong class="uppy-StatusBar-contentPadding">{i18n('uploadFailed')}.</strong>
|
||||
<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"
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ module.exports = class StatusBar extends Plugin {
|
|||
target: 'body',
|
||||
hideUploadButton: false,
|
||||
hideRetryButton: false,
|
||||
hideCancelButton: false,
|
||||
hidePauseResumeCancelButtons: false,
|
||||
showProgressDetails: false,
|
||||
locale: defaultLocale,
|
||||
hideAfterFinish: true
|
||||
|
|
@ -220,7 +220,7 @@ module.exports = class StatusBar extends Plugin {
|
|||
showProgressDetails: this.opts.showProgressDetails,
|
||||
hideUploadButton: this.opts.hideUploadButton,
|
||||
hideRetryButton: this.opts.hideRetryButton,
|
||||
hideCancelButton: this.opts.hideCancelButton,
|
||||
hidePauseResumeCancelButtons: this.opts.hidePauseResumeCancelButtons,
|
||||
hideAfterFinish: this.opts.hideAfterFinish
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -451,16 +451,12 @@ module.exports = class Tus extends Plugin {
|
|||
.then(() => null)
|
||||
}
|
||||
|
||||
addResumableUploadsCapabilityFlag () {
|
||||
const newCapabilities = Object.assign({}, this.uppy.getState().capabilities)
|
||||
newCapabilities.resumableUploads = true
|
||||
this.uppy.setState({
|
||||
capabilities: newCapabilities
|
||||
})
|
||||
}
|
||||
|
||||
install () {
|
||||
this.addResumableUploadsCapabilityFlag()
|
||||
this.uppy.setState({
|
||||
capabilities: Object.assign({}, this.uppy.getState().capabilities, {
|
||||
resumableUploads: true
|
||||
})
|
||||
})
|
||||
this.uppy.addUploader(this.handleUpload)
|
||||
|
||||
this.uppy.on('reset-progress', this.handleResetProgress)
|
||||
|
|
@ -471,6 +467,11 @@ module.exports = class Tus extends Plugin {
|
|||
}
|
||||
|
||||
uninstall () {
|
||||
this.uppy.setState({
|
||||
capabilities: Object.assign({}, this.uppy.getState().capabilities, {
|
||||
resumableUploads: false
|
||||
})
|
||||
})
|
||||
this.uppy.removeUploader(this.handleUpload)
|
||||
|
||||
if (this.opts.autoRetry) {
|
||||
|
|
|
|||
|
|
@ -489,10 +489,26 @@ module.exports = class XHRUpload extends Plugin {
|
|||
}
|
||||
|
||||
install () {
|
||||
if (this.opts.bundle) {
|
||||
this.uppy.setState({
|
||||
capabilities: Object.assign({}, this.uppy.getState().capabilities, {
|
||||
bundled: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
this.uppy.addUploader(this.handleUpload)
|
||||
}
|
||||
|
||||
uninstall () {
|
||||
if (this.opts.bundle) {
|
||||
this.uppy.setState({
|
||||
capabilities: Object.assign({}, this.uppy.getState().capabilities, {
|
||||
bundled: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
this.uppy.removeUploader(this.handleUpload)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -784,10 +784,10 @@
|
|||
|
||||
.uppy-DashboardItem-progressIndicator {
|
||||
@include reset-button;
|
||||
display: inline-block;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
opacity: 0.9;
|
||||
cursor: pointer;
|
||||
transition: all .35s ease;
|
||||
|
||||
.uppy-Dashboard--wide & {
|
||||
|
|
@ -796,6 +796,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
button.uppy-DashboardItem-progressIndicator {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.uppy-DashboardItem.is-error .uppy-DashboardItem-progressIndicator {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
|
|
|
|||
|
|
@ -189,8 +189,12 @@
|
|||
top: -1px;
|
||||
left: 6px;
|
||||
font-size: 10px;
|
||||
// margin-left: -1px;
|
||||
text-align: center;
|
||||
cursor: help;
|
||||
|
||||
&:hover {
|
||||
cursor: help;
|
||||
}
|
||||
}
|
||||
|
||||
.uppy-StatusBar-details:after {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue