diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-06-04 01:25:28 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-09-06 03:38:42 +0200 |
commit | 96c827558611033ac35f6095b77ea04dca8044dd (patch) | |
tree | 9657a6d191dba82ae025c23838b2b35716c415cf /apps/files/src | |
parent | e4fa9967014e99a70fcf0f45e84b35f610cedeb6 (diff) | |
download | nextcloud-server-96c827558611033ac35f6095b77ea04dca8044dd.tar.gz nextcloud-server-96c827558611033ac35f6095b77ea04dca8044dd.zip |
feat(files_sharing): Migrate public share to use Vue files list
Co-authored-by: Ferdinand Thiessen <opensource@fthiessen.de>
Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files/src')
-rw-r--r-- | apps/files/src/main.ts | 8 | ||||
-rw-r--r-- | apps/files/src/services/Files.ts | 11 | ||||
-rw-r--r-- | apps/files/src/services/RouterService.ts | 8 | ||||
-rw-r--r-- | apps/files/src/views/Sidebar.vue | 7 |
4 files changed, 22 insertions, 12 deletions
diff --git a/apps/files/src/main.ts b/apps/files/src/main.ts index 7f3f2fe78f5..f8741fca96e 100644 --- a/apps/files/src/main.ts +++ b/apps/files/src/main.ts @@ -30,8 +30,10 @@ window.OCA.Files = window.OCA.Files ?? {} window.OCP.Files = window.OCP.Files ?? {} // Expose router -const Router = new RouterService(router) -Object.assign(window.OCP.Files, { Router }) +if (!window.OCP.Files.Router) { + const Router = new RouterService(router) + Object.assign(window.OCP.Files, { Router }) +} // Init Pinia store Vue.use(PiniaVuePlugin) @@ -48,6 +50,6 @@ Object.assign(window.OCA.Files.Settings, { Setting: SettingsModel }) const FilesAppVue = Vue.extend(FilesApp) new FilesAppVue({ - router, + router: window.OCP.Files.Router.router, pinia, }).$mount('#content') diff --git a/apps/files/src/services/Files.ts b/apps/files/src/services/Files.ts index 944c2d30678..f02b48f64f3 100644 --- a/apps/files/src/services/Files.ts +++ b/apps/files/src/services/Files.ts @@ -5,25 +5,26 @@ import type { ContentsWithRoot, File, Folder } from '@nextcloud/files' import type { FileStat, ResponseDataDetailed } from 'webdav' -import { CancelablePromise } from 'cancelable-promise' import { davGetDefaultPropfind, davResultToNode, davRootPath } from '@nextcloud/files' +import { CancelablePromise } from 'cancelable-promise' +import { join } from 'path' import { client } from './WebdavClient.ts' import logger from '../logger.ts' /** * Slim wrapper over `@nextcloud/files` `davResultToNode` to allow using the function with `Array.map` - * @param node The node returned by the webdav library + * @param stat The result returned by the webdav library */ -export const resultToNode = (node: FileStat): File | Folder => davResultToNode(node) +export const resultToNode = (stat: FileStat): File | Folder => davResultToNode(stat) export const getContents = (path = '/'): CancelablePromise<ContentsWithRoot> => { + path = join(davRootPath, path) const controller = new AbortController() const propfindPayload = davGetDefaultPropfind() - path = `${davRootPath}${path}` - return new CancelablePromise(async (resolve, reject, onCancel) => { onCancel(() => controller.abort()) + try { const contentsResponse = await client.getDirectoryContents(path, { details: true, diff --git a/apps/files/src/services/RouterService.ts b/apps/files/src/services/RouterService.ts index 84516465495..0138939b1ba 100644 --- a/apps/files/src/services/RouterService.ts +++ b/apps/files/src/services/RouterService.ts @@ -27,6 +27,14 @@ export default class RouterService { } /** + * This is a protected getter only for internal use + * @private + */ + get router() { + return this._router + } + + /** * Trigger a route change on the files app * * @param path the url path, eg: '/trashbin?dir=/Deleted' diff --git a/apps/files/src/views/Sidebar.vue b/apps/files/src/views/Sidebar.vue index 8fcfda4e6b7..5d9f2079253 100644 --- a/apps/files/src/views/Sidebar.vue +++ b/apps/files/src/views/Sidebar.vue @@ -91,9 +91,9 @@ import { getCurrentUser } from '@nextcloud/auth' import { getCapabilities } from '@nextcloud/capabilities' import { showError } from '@nextcloud/dialogs' import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus' -import { File, Folder, formatFileSize } from '@nextcloud/files' +import { File, Folder, davRemoteURL, davRootPath, formatFileSize } from '@nextcloud/files' import { encodePath } from '@nextcloud/paths' -import { generateRemoteUrl, generateUrl } from '@nextcloud/router' +import { generateUrl } from '@nextcloud/router' import { ShareType } from '@nextcloud/sharing' import { mdiStar, mdiStarOutline } from '@mdi/js' import axios from '@nextcloud/axios' @@ -187,8 +187,7 @@ export default { * @return {string} */ davPath() { - const user = this.currentUser.uid - return generateRemoteUrl(`dav/files/${user}${encodePath(this.file)}`) + return `${davRemoteURL}/${davRootPath}${encodePath(this.file)}` }, /** |