Skip to content

Commit

Permalink
Address code review (formatFileSize, , changelog item)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed Feb 7, 2023
1 parent 2391142 commit 6115c7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion changelog/unreleased/enhancement-show-upload-speed
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Show upload speed
Enhancement: Show upload speed

We have added a tooltip that shows the current upload speed and
absolute vs processed filesize for the current upload.
Expand Down
20 changes: 12 additions & 8 deletions packages/web-runtime/src/components/UploadInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div
class="upload-info-title oc-flex oc-flex-between oc-flex-middle oc-px-m oc-py-s oc-rounded-top"
>
<p class="oc-my-xs" v-oc-tooltip="uploadDetails" v-text="uploadInfoTitle" />
<p v-oc-tooltip="uploadDetails" class="oc-my-xs" v-text="uploadInfoTitle" />
<oc-button
v-if="!filesInProgressCount"
id="close-upload-info-btn"
Expand Down Expand Up @@ -142,11 +142,11 @@ import { defineComponent } from 'vue'
import { mapGetters } from 'vuex'
import { isUndefined } from 'lodash-es'
import getSpeed from '@uppy/utils/lib/getSpeed'
import filesize from 'filesize'
import { urlJoin } from 'web-client/src/utils'
import { configurationManager } from 'web-pkg/src/configuration'
import { useCapabilityShareJailEnabled } from 'web-pkg/src/composables'
import { formatFileSize } from 'web-pkg/src/helpers'
import { UppyResource } from '../composables/upload'
export default defineComponent({
Expand Down Expand Up @@ -179,14 +179,18 @@ export default defineComponent({
...mapGetters(['configuration']),
uploadDetails() {
if (this.uploadSpeed === 0) {
if (!this.uploadSpeed || !this.runningUploads) {
return ''
}
const uploadedBytes = filesize(this.bytesUploaded)
const totalBytes = filesize(this.bytesTotal)
const currentUploadSpeed = filesize(this.uploadSpeed)
// needs $gettext interpolation
return `${uploadedBytes} of ${totalBytes} (${currentUploadSpeed}/s)`
const uploadedBytes = formatFileSize(this.bytesUploaded, this.$language.current)
const totalBytes = formatFileSize(this.bytesTotal, this.$language.current)
const currentUploadSpeed = formatFileSize(this.uploadSpeed, this.$language.current)
return this.$gettext('%{uploadedBytes} of %{totalBytes} (%{currentUploadSpeed}/s)', {
uploadedBytes,
totalBytes,
currentUploadSpeed
})
},
uploadInfoTitle() {
if (this.inFinalization) {
Expand Down

0 comments on commit 6115c7b

Please sign in to comment.