Skip to content
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

fix(files): Show correct quota size (file size base 2) #40787

Merged
merged 2 commits into from Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/files/src/components/FileEntry.vue
Expand Up @@ -261,7 +261,7 @@ export default Vue.extend({
if (typeof size !== 'number' || size < 0) {
return this.t('files', 'Pending')
}
return formatFileSize(size, true)
return formatFileSize(size, true, true).replace('iB', 'B')
},
sizeOpacity() {
const size = parseInt(this.source.size, 10) || 0
Expand Down
4 changes: 2 additions & 2 deletions apps/files/src/components/FilesListFooter.vue
Expand Up @@ -127,11 +127,11 @@ export default Vue.extend({
totalSize() {
// If we have the size already, let's use it
if (this.currentFolder?.size) {
return formatFileSize(this.currentFolder.size, true)
return formatFileSize(this.currentFolder.size, true, true).replace('iB', 'B')
}

// Otherwise let's compute it
return formatFileSize(this.nodes.reduce((total, node) => total + node.size || 0, 0), true)
return formatFileSize(this.nodes.reduce((total, node) => total + node.size || 0, 0), true, true).replace('iB', 'B')
},
},

Expand Down
4 changes: 2 additions & 2 deletions apps/files/src/components/NavigationQuota.vue
Expand Up @@ -51,8 +51,8 @@ export default {

computed: {
storageStatsTitle() {
const usedQuotaByte = formatFileSize(this.storageStats?.used)
const quotaByte = formatFileSize(this.storageStats?.quota)
const usedQuotaByte = formatFileSize(this.storageStats?.used, false, true).replace('iB', 'B')
const quotaByte = formatFileSize(this.storageStats?.quota, false, true).replace('iB', 'B')

// If no quota set
if (this.storageStats?.quota < 0) {
Expand Down
27 changes: 15 additions & 12 deletions apps/files/src/views/Navigation.cy.ts
@@ -1,21 +1,24 @@
import * as InitialState from '@nextcloud/initial-state'
import * as L10n from '@nextcloud/l10n'
import FolderSvg from '@mdi/svg/svg/folder.svg'
import ShareSvg from '@mdi/svg/svg/share-variant.svg'
// eslint-disable-next-line import/no-unresolved
import FolderSvg from '@mdi/svg/svg/folder.svg?raw'
// eslint-disable-next-line import/no-unresolved
import ShareSvg from '@mdi/svg/svg/share-variant.svg?raw'
import { createTestingPinia } from '@pinia/testing'

import NavigationService from '../services/Navigation.ts'
import NavigationService from '../services/Navigation'
import NavigationView from './Navigation.vue'
import router from '../router/router.js'
import { useViewConfigStore } from '../store/viewConfig'
import { Folder } from '@nextcloud/files'

describe('Navigation renders', () => {
const Navigation = new NavigationService() as NavigationService

before(() => {
cy.stub(InitialState, 'loadState')
.returns({
used: 1000 * 1000 * 1000,
used: 1024 * 1024 * 1024,
quota: -1,
})
})
Expand Down Expand Up @@ -72,7 +75,7 @@ describe('Navigation API', () => {
Navigation.register({
id: 'sharing',
name: 'Sharing',
getContents: () => Promise.resolve(),
getContents: () => Promise.resolve({ contents: [], folder: new Folder({ owner: 'admin', source: 'source' }) }),
icon: ShareSvg,
order: 2,
})
Expand All @@ -99,7 +102,7 @@ describe('Navigation API', () => {
Navigation.register({
id: 'sharingin',
name: 'Shared with me',
getContents: () => Promise.resolve(),
getContents: () => Promise.resolve({ contents: [], folder: new Folder({ owner: 'admin', source: 'source' }) }),
parent: 'sharing',
icon: ShareSvg,
order: 1,
Expand Down Expand Up @@ -146,7 +149,7 @@ describe('Navigation API', () => {
Navigation.register({
id: 'files',
name: 'Files',
getContents: () => Promise.resolve(),
getContents: () => Promise.resolve({ contents: [], folder: new Folder({ owner: 'admin', source: 'source' }) }),
icon: FolderSvg,
order: 1,
})
Expand Down Expand Up @@ -191,7 +194,7 @@ describe('Quota rendering', () => {
cy.stub(InitialState, 'loadState')
.as('loadStateStats')
.returns({
used: 1000 * 1000 * 1000,
used: 1024 * 1024 * 1024,
quota: -1,
})

Expand All @@ -215,8 +218,8 @@ describe('Quota rendering', () => {
cy.stub(InitialState, 'loadState')
.as('loadStateStats')
.returns({
used: 1000 * 1000 * 1000,
quota: 5 * 1000 * 1000 * 1000,
used: 1024 * 1024 * 1024,
quota: 5 * 1024 * 1024 * 1024,
relative: 20, // percent
})

Expand All @@ -241,8 +244,8 @@ describe('Quota rendering', () => {
cy.stub(InitialState, 'loadState')
.as('loadStateStats')
.returns({
used: 5 * 1000 * 1000 * 1000,
quota: 1000 * 1000 * 1000,
used: 5 * 1024 * 1024 * 1024,
quota: 1024 * 1024 * 1024,
relative: 500, // percent
})

Expand Down
4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.