Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/files/src/views/personal-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ import { View, getNavigation } from '@nextcloud/files'

import { getContents } from '../services/PersonalFiles'
import AccountIcon from '@mdi/svg/svg/account.svg?raw'
import { loadState } from '@nextcloud/initial-state'

export default () => {
// Don't show this view if the user has no storage quota
const storageStats = loadState('files', 'storageStats', { quota: -1 })
if (storageStats.quota === 0) {
return
}

const Navigation = getNavigation()
Navigation.register(new View({
id: 'personal',
Expand Down
25 changes: 24 additions & 1 deletion apps/files_sharing/src/files_views/shares.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
/* eslint-disable n/no-extraneous-import */
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { OCSResponse } from '@nextcloud/typings/ocs'
import { Folder, Navigation, View, getNavigation } from '@nextcloud/files'

import { beforeEach, describe, expect, test, vi } from 'vitest'
import { Folder, Navigation, View, getNavigation } from '@nextcloud/files'
import * as ncInitialState from '@nextcloud/initial-state'
import axios from '@nextcloud/axios'

import '../main'
Expand Down Expand Up @@ -72,6 +74,27 @@ describe('Sharing views definition', () => {
expect(view?.getContents).toBeDefined()
})
})

test('Shared with others view is not registered if user has no storage quota', () => {
vi.spyOn(Navigation, 'register')
const spy = vi.spyOn(ncInitialState, 'loadState').mockImplementationOnce(() => ({ quota: 0 }))

expect(Navigation.views.length).toBe(0)
registerSharingViews()
expect(Navigation.register).toHaveBeenCalledTimes(6)
expect(Navigation.views.length).toBe(6)

const shareOverviewView = Navigation.views.find(view => view.id === 'shareoverview') as View
const sharesChildViews = Navigation.views.filter(view => view.parent === 'shareoverview') as View[]
expect(shareOverviewView).toBeDefined()
expect(sharesChildViews.length).toBe(5)

expect(spy).toHaveBeenCalled()
expect(spy).toHaveBeenCalledWith('files', 'storageStats', { quota: -1 })

const sharedWithOthersView = Navigation.views.find(view => view.id === 'sharingout')
expect(sharedWithOthersView).toBeUndefined()
})
})

describe('Sharing views contents', () => {
Expand Down
29 changes: 17 additions & 12 deletions apps/files_sharing/src/files_views/shares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import FileUploadSvg from '@mdi/svg/svg/file-upload.svg?raw'
import LinkSvg from '@mdi/svg/svg/link.svg?raw'

import { getContents, isFileRequest } from '../services/SharingService'
import { loadState } from '@nextcloud/initial-state'

export const sharesViewId = 'shareoverview'
export const sharedWithYouViewId = 'sharingin'
Expand Down Expand Up @@ -58,22 +59,26 @@ export default () => {
getContents: () => getContents(true, false, false, false),
}))

Navigation.register(new View({
id: sharedWithOthersViewId,
name: t('files_sharing', 'Shared with others'),
caption: t('files_sharing', 'List of files that you shared with others.'),
// Don't show this view if the user has no storage quota
const storageStats = loadState('files', 'storageStats', { quota: -1 })
if (storageStats.quota !== 0) {
Navigation.register(new View({
id: sharedWithOthersViewId,
name: t('files_sharing', 'Shared with others'),
caption: t('files_sharing', 'List of files that you shared with others.'),

emptyTitle: t('files_sharing', 'Nothing shared yet'),
emptyCaption: t('files_sharing', 'Files and folders you shared will show up here'),
emptyTitle: t('files_sharing', 'Nothing shared yet'),
emptyCaption: t('files_sharing', 'Files and folders you shared will show up here'),

icon: AccountGroupSvg,
order: 2,
parent: sharesViewId,
icon: AccountGroupSvg,
order: 2,
parent: sharesViewId,

columns: [],
columns: [],

getContents: () => getContents(false, true, false, false),
}))
getContents: () => getContents(false, true, false, false),
}))
}

Navigation.register(new View({
id: sharingByLinksViewId,
Expand Down
4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-init.js.map

Large diffs are not rendered by default.

Loading