-
Notifications
You must be signed in to change notification settings - Fork 350
feat(uploads-manager): add upload progress and time left to uploads manager #4720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4f626cc
ef49ccd
76e7c3b
ec3cac5
947c8ae
55cdac9
6fb355a
283edea
bf4a3e9
71f4dc3
bdaa777
158e721
fafd921
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ import Footer from './Footer'; | |
| import ModernizedUploadsManagerDropZone from './ModernizedUploadsManagerDropZone'; | ||
| import UploadsManager from './UploadsManager'; | ||
| import { getUploadItemKey, mapToModernizedUploadItems } from './utils/mapToModernizedUploadItem'; | ||
| import { updateEta, getRemainingMs, type EtaState } from './utils/uploadEta'; | ||
| import './ModernizedUploadsManagerPanel.scss'; | ||
| import API from '../../api'; | ||
| import Browser from '../../utils/Browser'; | ||
|
|
@@ -116,6 +117,7 @@ export interface ContentUploaderProps { | |
| uploadHost: string; | ||
| useUploadsManager?: boolean; | ||
| enableModernizedUploads?: boolean; | ||
| isUploadEtaEnabled?: boolean; | ||
| isUpgradeModalEnabled?: boolean; | ||
| isExpanded?: boolean; | ||
| onToggle?: (isExpanded: boolean) => void; | ||
|
|
@@ -171,6 +173,8 @@ class ContentUploader extends Component<ContentUploaderProps, State> { | |
|
|
||
| itemIdsRef: React.MutableRefObject<Object>; | ||
|
|
||
| etaByItem: WeakMap<UploadItem, EtaState> = new WeakMap(); | ||
|
|
||
| static defaultProps = { | ||
| apiHost: DEFAULT_HOSTNAME_API, | ||
| chunked: true, | ||
|
|
@@ -203,6 +207,7 @@ class ContentUploader extends Component<ContentUploaderProps, State> { | |
| uploadHost: DEFAULT_HOSTNAME_UPLOAD, | ||
| useUploadsManager: false, | ||
| enableModernizedUploads: false, | ||
| isUploadEtaEnabled: false, | ||
| isUpgradeModalEnabled: false, | ||
| modernizedDismissDelayMs: HIDE_MODERNIZED_UPLOAD_MANAGER_DELAY_MS, | ||
| }; | ||
|
|
@@ -1017,6 +1022,11 @@ class ContentUploader extends Component<ContentUploaderProps, State> { | |
| item.status = STATUS_PENDING; | ||
| delete item.error; | ||
|
|
||
| // Drop byte/ETA progress from the previous attempt | ||
| item.bytesUploaded = 0; | ||
| item.remainingMs = undefined; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to clear
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. totalBytes is the file's size, which doesn't change across retries, unlike the per-attempt bytesUploaded/remainingMs we reset here. |
||
| this.etaByItem.delete(item); | ||
|
|
||
| const updatedItems = [...this.itemsRef.current]; | ||
| updatedItems[this.itemsRef.current.indexOf(item)] = item; | ||
|
|
||
|
|
@@ -1260,6 +1270,13 @@ class ContentUploader extends Component<ContentUploaderProps, State> { | |
| item.progress = Math.min(Math.round((event.loaded / event.total) * 100), 100); | ||
| item.status = item.progress === 100 ? STATUS_STAGED : STATUS_IN_PROGRESS; | ||
|
|
||
| // Track byte-level progress and a smoothed ETA for the modernized manager. | ||
| const nextEta = updateEta(this.etaByItem.get(item), event.loaded, event.total, Date.now()); | ||
| this.etaByItem.set(item, nextEta); | ||
| item.bytesUploaded = event.loaded; | ||
| item.totalBytes = event.total; | ||
| item.remainingMs = getRemainingMs(nextEta); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| const { onProgress } = this.props; | ||
| onProgress(item); | ||
|
|
||
|
|
@@ -1826,6 +1843,7 @@ class ContentUploader extends Component<ContentUploaderProps, State> { | |
| className, | ||
| canDropOnUploadsManager, | ||
| enableModernizedUploads, | ||
| isUploadEtaEnabled, | ||
| fileLimit, | ||
| isDraggingItemsToUploadsManager = false, | ||
| isFolderUploadEnabled, | ||
|
|
@@ -1896,7 +1914,11 @@ class ContentUploader extends Component<ContentUploaderProps, State> { | |
| onMouseLeave={this.handleModernizedMouseLeave} | ||
| > | ||
| <UploadsManagerBP | ||
| items={mapToModernizedUploadItems(uploadsManagerItems, rootFolderId)} | ||
| items={mapToModernizedUploadItems( | ||
| uploadsManagerItems, | ||
| rootFolderId, | ||
| isUploadEtaEnabled, | ||
| )} | ||
| isExpanded={isUploadsManagerExpanded} | ||
| onToggle={this.toggleUploadsManager} | ||
| onItemCancel={this.handleUploadsManagerItemCancel} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for updating 👍