From 6c8565a3c18156aa8f07b59a578445fe3039485f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Fri, 6 Oct 2023 10:57:50 +0200 Subject: [PATCH] feat(developer_manual): 28 files-to-vue upgrade guide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ Signed-off-by: John Molakvoæ --- .../app_upgrade_guide/upgrade_to_28.rst | 13 ++++++++- developer_manual/client_apis/files.rst | 29 +++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_28.rst b/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_28.rst index 5e50a4ce789..4dedd91121b 100644 --- a/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_28.rst +++ b/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_28.rst @@ -22,7 +22,17 @@ Front-end changes Added APIs ^^^^^^^^^^ -* tbd +* File actions: to register file actions, please use the dedicated API from https://npmjs.org/@nextcloud/files or + https://nextcloud-libraries.github.io/nextcloud-files/functions/registerFileAction.html +* New file menu: to register entries in the new file menu, please use the dedicated API from https://npmjs.org/@nextcloud/files or + https://nextcloud-libraries.github.io/nextcloud-files/functions/addNewFileMenuEntry.html +* Reminder from 27, to interact with the Files app router, use ``OCP.Files.Router``. See :ref:`FilesAPI` +* To Interact with the Files app data, please use the following events. All of them have a `Node object `_ as main parameter. + + * ``files:node:created``: the node has been created + * ``files:node:deleted``: the node has been deleted + * ``files:node:moved``: the node has been moved (and its data is already updated) + * ``files:node:updated``: the node data has been updated Changed APIs ^^^^^^^^^^^^ @@ -39,6 +49,7 @@ Removed APIs * ``OC.loadScript`` and ``OC.loadStyle``: Use ``OCP.Loader`` instead. * ``OC.appSettings``: There is no replacement. +* ``OCA.Files``: Everything removed but Sidebar and Settings. See the Added API section for replacements. Back-end changes ---------------- diff --git a/developer_manual/client_apis/files.rst b/developer_manual/client_apis/files.rst index e7281fcb4eb..e02451b02e7 100644 --- a/developer_manual/client_apis/files.rst +++ b/developer_manual/client_apis/files.rst @@ -14,8 +14,33 @@ We will update and document the new files app APIs and methods here. .. note:: Some external libraries offers in-depth technical documentation. Please have a look at the following: - * https://github.com/nextcloud/nextcloud-files (`documentation `__) - * https://github.com/nextcloud/nextcloud-upload + * https://github.com/nextcloud-libraries/nextcloud-event-bus (`documentation `__) + * https://github.com/nextcloud-libraries/nextcloud-files (`documentation `__) + * https://github.com/nextcloud-libraries/nextcloud-upload (`documentation `__) + + +Events +^^^^^^ + +To listen to files or folder changes or to trigger changes, you need to use +the ``event-bus`` and use the following events: + + * ``files:node:created``: the node has been created + * ``files:node:deleted``: the node has been deleted + * ``files:node:moved``: the node has been moved (and its data is already updated) + * ``files:node:updated``: the node data has been updated + +Example +------- + +.. code-block:: ts + + import type { Node } from '@nextcloud/files' + import { subscribe } from '@nextcloud/event-bus' + + subscribe('files:node:created', (node: Node) => { + console.log('Node created', node) + }) Router