|
| 1 | +.. _FilesAPI: |
| 2 | + |
| 3 | +===== |
| 4 | +Files |
| 5 | +===== |
| 6 | + |
| 7 | +.. sectionauthor:: John Molakvoæ <skjnldsv@protonmail.com> |
| 8 | + |
| 9 | +Since Nextcloud 27, the files app has been rewritten to use new standards |
| 10 | +and frameworks. This means that the old documentation is no longer valid. |
| 11 | +We will update and document the new files app APIs and methods here. |
| 12 | + |
| 13 | +.. note:: Some external libraries offers in-depth technical documentation. |
| 14 | + Please have a look at the following: |
| 15 | + |
| 16 | + * https://github.com/nextcloud/nextcloud-files (`documentation <https://nextcloud.github.io/nextcloud-files/>`_) |
| 17 | + * https://github.com/nextcloud/nextcloud-upload |
| 18 | + |
| 19 | + |
| 20 | +Router |
| 21 | +^^^^^^ |
| 22 | + |
| 23 | +To change views and parameters of the current Files app, we expose the router. |
| 24 | +This directly maps to the Vue router. You can check their own `documentation <https://router.vuejs.org/guide/essentials/navigation.html#navigate-to-a-different-location>`_ to |
| 25 | +better understand the methods. |
| 26 | + |
| 27 | +.. code-block:: ts |
| 28 | +
|
| 29 | + /** |
| 30 | + * Trigger a route change on the files app |
| 31 | + * |
| 32 | + * @param path the url path, eg: '/trashbin?dir=/Deleted' |
| 33 | + * @param replace replace the current history |
| 34 | + * @see https://router.vuejs.org/guide/essentials/navigation.html#navigate-to-a-different-location |
| 35 | + */ |
| 36 | + goTo(path: string, replace: boolean = false): Promise<Route> |
| 37 | +
|
| 38 | + /** |
| 39 | + * Trigger a route change on the files App |
| 40 | + * |
| 41 | + * @param name the route name |
| 42 | + * @param params the route parameters |
| 43 | + * @param query the url query parameters |
| 44 | + * @param replace replace the current history |
| 45 | + * @see https://router.vuejs.org/guide/essentials/navigation.html#navigate-to-a-different-location |
| 46 | + */ |
| 47 | + goToRoute( |
| 48 | + name?: string, |
| 49 | + params?: Dictionary<string>, |
| 50 | + query?: Dictionary<string | (string | null)[] | null | undefined>, |
| 51 | + replace?: boolean, |
| 52 | + ): Promise<Route> |
| 53 | +
|
| 54 | +
|
| 55 | +Examples |
| 56 | +-------- |
| 57 | + |
| 58 | +.. code-block:: js |
| 59 | +
|
| 60 | + OCP.Files.Router.goTo('/trashbin?dir=/Unsplash.d1680193199') |
| 61 | + OCP.Files.Router.goToRoute('fileslist', { view: 'files' }, { dir: '/Folders/Group folder' }) |
0 commit comments