aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src/files_views
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/src/files_views')
-rw-r--r--apps/files_sharing/src/files_views/publicFileDrop.ts7
-rw-r--r--apps/files_sharing/src/files_views/shares.spec.ts25
-rw-r--r--apps/files_sharing/src/files_views/shares.ts35
3 files changed, 48 insertions, 19 deletions
diff --git a/apps/files_sharing/src/files_views/publicFileDrop.ts b/apps/files_sharing/src/files_views/publicFileDrop.ts
index 0d782d48fc7..65756e83c74 100644
--- a/apps/files_sharing/src/files_views/publicFileDrop.ts
+++ b/apps/files_sharing/src/files_views/publicFileDrop.ts
@@ -4,7 +4,8 @@
*/
import type { VueConstructor } from 'vue'
-import { Folder, Permission, View, davRemoteURL, davRootPath, getNavigation } from '@nextcloud/files'
+import { Folder, Permission, View, getNavigation } from '@nextcloud/files'
+import { defaultRemoteURL, defaultRootPath } from '@nextcloud/files/dav'
import { loadState } from '@nextcloud/initial-state'
import { translate as t } from '@nextcloud/l10n'
import svgCloudUpload from '@mdi/svg/svg/cloud-upload.svg?raw'
@@ -45,8 +46,8 @@ export default () => {
// Fake a writeonly folder as root
folder: new Folder({
id: 0,
- source: `${davRemoteURL}${davRootPath}`,
- root: davRootPath,
+ source: `${defaultRemoteURL}${defaultRootPath}`,
+ root: defaultRootPath,
owner: null,
permissions: Permission.CREATE,
}),
diff --git a/apps/files_sharing/src/files_views/shares.spec.ts b/apps/files_sharing/src/files_views/shares.spec.ts
index 79ef2a09843..7e5b59e0ad9 100644
--- a/apps/files_sharing/src/files_views/shares.spec.ts
+++ b/apps/files_sharing/src/files_views/shares.spec.ts
@@ -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'
@@ -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', () => {
diff --git a/apps/files_sharing/src/files_views/shares.ts b/apps/files_sharing/src/files_views/shares.ts
index 7aec0dbeafb..fd5e908638c 100644
--- a/apps/files_sharing/src/files_views/shares.ts
+++ b/apps/files_sharing/src/files_views/shares.ts
@@ -6,14 +6,15 @@ import { translate as t } from '@nextcloud/l10n'
import { View, getNavigation } from '@nextcloud/files'
import { ShareType } from '@nextcloud/sharing'
import AccountClockSvg from '@mdi/svg/svg/account-clock.svg?raw'
-import AccountGroupSvg from '@mdi/svg/svg/account-group.svg?raw'
-import AccountPlusSvg from '@mdi/svg/svg/account-plus.svg?raw'
+import AccountGroupSvg from '@mdi/svg/svg/account-group-outline.svg?raw'
+import AccountPlusSvg from '@mdi/svg/svg/account-plus-outline.svg?raw'
import AccountSvg from '@mdi/svg/svg/account.svg?raw'
import DeleteSvg from '@mdi/svg/svg/delete.svg?raw'
-import FileUploadSvg from '@mdi/svg/svg/file-upload.svg?raw'
+import FileUploadSvg from '@mdi/svg/svg/file-upload-outline.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'
@@ -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,