diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2023-08-18 10:59:14 +0200 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2023-08-23 14:03:50 +0200 |
commit | b4e71ad0fb282fbc9981924b9783ae6659a9e4fe (patch) | |
tree | ac0a921804b87d6c5707dc87c3041938aec505a6 /apps/files_sharing | |
parent | c9a197e6dd699942b0cf36504ff1fa5f5ef26893 (diff) | |
download | nextcloud-server-b4e71ad0fb282fbc9981924b9783ae6659a9e4fe.tar.gz nextcloud-server-b4e71ad0fb282fbc9981924b9783ae6659a9e4fe.zip |
chore: use Navigation from `@nextcloud/files`
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_sharing')
10 files changed, 36 insertions, 49 deletions
diff --git a/apps/files_sharing/src/actions/acceptShareAction.spec.ts b/apps/files_sharing/src/actions/acceptShareAction.spec.ts index acef697b1aa..7ad8a42a1a6 100644 --- a/apps/files_sharing/src/actions/acceptShareAction.spec.ts +++ b/apps/files_sharing/src/actions/acceptShareAction.spec.ts @@ -21,22 +21,21 @@ */ import { action } from './acceptShareAction' import { expect } from '@jest/globals' -import { File, Permission } from '@nextcloud/files' +import { File, Permission, View } from '@nextcloud/files' import { FileAction } from '../../../files/src/services/FileAction' import * as eventBus from '@nextcloud/event-bus' import axios from '@nextcloud/axios' -import type { Navigation } from '../../../files/src/services/Navigation' import '../main' const view = { id: 'files', name: 'Files', -} as Navigation +} as View const pendingShareView = { id: 'pendingshares', name: 'Pending shares', -} as Navigation +} as View describe('Accept share action conditions tests', () => { test('Default values', () => { diff --git a/apps/files_sharing/src/actions/acceptShareAction.ts b/apps/files_sharing/src/actions/acceptShareAction.ts index 4be69633122..8bd8d6a5533 100644 --- a/apps/files_sharing/src/actions/acceptShareAction.ts +++ b/apps/files_sharing/src/actions/acceptShareAction.ts @@ -19,8 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import type { Node } from '@nextcloud/files' -import type { Navigation } from '../../../files/src/services/Navigation' +import type { Node, View } from '@nextcloud/files' import { emit } from '@nextcloud/event-bus' import { generateOcsUrl } from '@nextcloud/router' @@ -55,7 +54,7 @@ export const action = new FileAction({ return false } }, - async execBatch(nodes: Node[], view: Navigation, dir: string) { + async execBatch(nodes: Node[], view: View, dir: string) { return Promise.all(nodes.map(node => this.exec(node, view, dir))) }, diff --git a/apps/files_sharing/src/actions/openInFilesAction.spec.ts b/apps/files_sharing/src/actions/openInFilesAction.spec.ts index 49d4e192d39..2d723770ee9 100644 --- a/apps/files_sharing/src/actions/openInFilesAction.spec.ts +++ b/apps/files_sharing/src/actions/openInFilesAction.spec.ts @@ -19,10 +19,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import type { Navigation } from '../../../files/src/services/Navigation' - import { expect } from '@jest/globals' -import { File, Permission } from '@nextcloud/files' +import { File, Permission, View } from '@nextcloud/files' import '../main' import { action } from './openInFilesAction' @@ -32,19 +30,19 @@ import { deletedSharesViewId, pendingSharesViewId, sharedWithOthersViewId, share const view = { id: 'files', name: 'Files', -} as Navigation +} as View const validViews = [ sharesViewId, sharedWithYouViewId, sharedWithOthersViewId, sharingByLinksViewId, -].map(id => ({ id, name: id })) as Navigation[] +].map(id => ({ id, name: id })) as View[] const invalidViews = [ deletedSharesViewId, pendingSharesViewId, -].map(id => ({ id, name: id })) as Navigation[] +].map(id => ({ id, name: id })) as View[] describe('Open in files action conditions tests', () => { test('Default values', () => { diff --git a/apps/files_sharing/src/actions/rejectShareAction.spec.ts b/apps/files_sharing/src/actions/rejectShareAction.spec.ts index a075b45eedb..bc666b7c081 100644 --- a/apps/files_sharing/src/actions/rejectShareAction.spec.ts +++ b/apps/files_sharing/src/actions/rejectShareAction.spec.ts @@ -21,22 +21,21 @@ */ import { action } from './rejectShareAction' import { expect } from '@jest/globals' -import { File, Folder, Permission } from '@nextcloud/files' +import { File, Folder, Permission, View } from '@nextcloud/files' import { FileAction } from '../../../files/src/services/FileAction' import * as eventBus from '@nextcloud/event-bus' import axios from '@nextcloud/axios' -import type { Navigation } from '../../../files/src/services/Navigation' import '../main' const view = { id: 'files', name: 'Files', -} as Navigation +} as View const pendingShareView = { id: 'pendingshares', name: 'Pending shares', -} as Navigation +} as View describe('Reject share action conditions tests', () => { test('Default values', () => { diff --git a/apps/files_sharing/src/actions/rejectShareAction.ts b/apps/files_sharing/src/actions/rejectShareAction.ts index 44dd36abe55..7fb04d36227 100644 --- a/apps/files_sharing/src/actions/rejectShareAction.ts +++ b/apps/files_sharing/src/actions/rejectShareAction.ts @@ -19,8 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import type { Node } from '@nextcloud/files' -import type { Navigation } from '../../../files/src/services/Navigation' +import type { Node, View } from '@nextcloud/files' import { emit } from '@nextcloud/event-bus' import { generateOcsUrl } from '@nextcloud/router' @@ -72,7 +71,7 @@ export const action = new FileAction({ return false } }, - async execBatch(nodes: Node[], view: Navigation, dir: string) { + async execBatch(nodes: Node[], view: View, dir: string) { return Promise.all(nodes.map(node => this.exec(node, view, dir))) }, diff --git a/apps/files_sharing/src/actions/restoreShareAction.spec.ts b/apps/files_sharing/src/actions/restoreShareAction.spec.ts index 6b87d0549cf..2c37dd83857 100644 --- a/apps/files_sharing/src/actions/restoreShareAction.spec.ts +++ b/apps/files_sharing/src/actions/restoreShareAction.spec.ts @@ -21,22 +21,21 @@ */ import { action } from './restoreShareAction' import { expect } from '@jest/globals' -import { File, Permission } from '@nextcloud/files' +import { File, Permission, View } from '@nextcloud/files' import { FileAction } from '../../../files/src/services/FileAction' import * as eventBus from '@nextcloud/event-bus' import axios from '@nextcloud/axios' -import type { Navigation } from '../../../files/src/services/Navigation' import '../main' const view = { id: 'files', name: 'Files', -} as Navigation +} as View const deletedShareView = { id: 'deletedshares', name: 'Deleted shares', -} as Navigation +} as View describe('Restore share action conditions tests', () => { test('Default values', () => { diff --git a/apps/files_sharing/src/actions/restoreShareAction.ts b/apps/files_sharing/src/actions/restoreShareAction.ts index 6c43b0cfb37..d1b67f10b08 100644 --- a/apps/files_sharing/src/actions/restoreShareAction.ts +++ b/apps/files_sharing/src/actions/restoreShareAction.ts @@ -19,8 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import type { Node } from '@nextcloud/files' -import type { Navigation } from '../../../files/src/services/Navigation' +import type { Node, View } from '@nextcloud/files' import { emit } from '@nextcloud/event-bus' import { generateOcsUrl } from '@nextcloud/router' @@ -54,7 +53,7 @@ export const action = new FileAction({ return false } }, - async execBatch(nodes: Node[], view: Navigation, dir: string) { + async execBatch(nodes: Node[], view: View, dir: string) { return Promise.all(nodes.map(node => this.exec(node, view, dir))) }, diff --git a/apps/files_sharing/src/services/SharingService.ts b/apps/files_sharing/src/services/SharingService.ts index 5f288ce7fc5..2b5e2e0d329 100644 --- a/apps/files_sharing/src/services/SharingService.ts +++ b/apps/files_sharing/src/services/SharingService.ts @@ -21,9 +21,8 @@ */ /* eslint-disable camelcase, n/no-extraneous-import */ import type { AxiosPromise } from 'axios' -import type { ContentsWithRoot } from '../../../files/src/services/Navigation' -import { Folder, File } from '@nextcloud/files' +import { Folder, File, type ContentsWithRoot } from '@nextcloud/files' import { generateOcsUrl, generateRemoteUrl, generateUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' import axios from '@nextcloud/axios' diff --git a/apps/files_sharing/src/views/shares.spec.ts b/apps/files_sharing/src/views/shares.spec.ts index 424d3680411..4107c3154ba 100644 --- a/apps/files_sharing/src/views/shares.spec.ts +++ b/apps/files_sharing/src/views/shares.spec.ts @@ -23,19 +23,16 @@ import { expect } from '@jest/globals' import axios from '@nextcloud/axios' -import { type Navigation } from '../../../files/src/services/Navigation' import { type OCSResponse } from '../services/SharingService' -import { NavigationService } from '../../../files/src/services/Navigation' import registerSharingViews from './shares' import '../main' -import { Folder } from '@nextcloud/files' +import { Folder, getNavigation } from '@nextcloud/files' describe('Sharing views definition', () => { let Navigation beforeEach(() => { - Navigation = new NavigationService() - window.OCP = { Files: { Navigation } } + Navigation = getNavigation() }) afterAll(() => { diff --git a/apps/files_sharing/src/views/shares.ts b/apps/files_sharing/src/views/shares.ts index 74be9e7a503..e5e8df8fdb9 100644 --- a/apps/files_sharing/src/views/shares.ts +++ b/apps/files_sharing/src/views/shares.ts @@ -19,8 +19,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import type { NavigationService, Navigation } from '../../../files/src/services/Navigation' - import { translate as t } from '@nextcloud/l10n' import AccountClockSvg from '@mdi/svg/svg/account-clock.svg?raw' import AccountGroupSvg from '@mdi/svg/svg/account-group.svg?raw' @@ -30,6 +28,7 @@ import LinkSvg from '@mdi/svg/svg/link.svg?raw' import AccountPlusSvg from '@mdi/svg/svg/account-plus.svg?raw' import { getContents } from '../services/SharingService' +import { View, getNavigation } from '@nextcloud/files' export const sharesViewId = 'shareoverview' export const sharedWithYouViewId = 'sharingin' @@ -39,8 +38,8 @@ export const deletedSharesViewId = 'deletedshares' export const pendingSharesViewId = 'pendingshares' export default () => { - const Navigation = window.OCP.Files.Navigation as NavigationService - Navigation.register({ + const Navigation = getNavigation() + Navigation.register(new View({ id: sharesViewId, name: t('files_sharing', 'Shares'), caption: t('files_sharing', 'Overview of shared files.'), @@ -54,9 +53,9 @@ export default () => { columns: [], getContents: () => getContents(), - } as Navigation) + })) - Navigation.register({ + Navigation.register(new View({ id: sharedWithYouViewId, name: t('files_sharing', 'Shared with you'), caption: t('files_sharing', 'List of files that are shared with you.'), @@ -71,9 +70,9 @@ export default () => { columns: [], getContents: () => getContents(true, false, false, false), - } as Navigation) + })) - Navigation.register({ + 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.'), @@ -88,9 +87,9 @@ export default () => { columns: [], getContents: () => getContents(false, true, false, false), - } as Navigation) + })) - Navigation.register({ + Navigation.register(new View({ id: sharingByLinksViewId, name: t('files_sharing', 'Shared by link'), caption: t('files_sharing', 'List of files that are shared by link.'), @@ -105,9 +104,9 @@ export default () => { columns: [], getContents: () => getContents(false, true, false, false, [window.OC.Share.SHARE_TYPE_LINK]), - } as Navigation) + })) - Navigation.register({ + Navigation.register(new View({ id: deletedSharesViewId, name: t('files_sharing', 'Deleted shares'), caption: t('files_sharing', 'List of shares you left.'), @@ -122,9 +121,9 @@ export default () => { columns: [], getContents: () => getContents(false, false, false, true), - } as Navigation) + })) - Navigation.register({ + Navigation.register(new View({ id: pendingSharesViewId, name: t('files_sharing', 'Pending shares'), caption: t('files_sharing', 'List of unapproved shares.'), @@ -139,5 +138,5 @@ export default () => { columns: [], getContents: () => getContents(false, false, true, false), - } as Navigation) + })) } |