Skip to content

Commit

Permalink
correct endpoint params, update docs
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Borysenko <[email protected]>
  • Loading branch information
andrey18106 committed May 7, 2024
1 parent 687bcf4 commit d39366e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
26 changes: 9 additions & 17 deletions docs/tech_details/api/fileactionsmenu.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ AppAPI takes responsibility to register FileActionsMenu, ExApps needs only to re
Register
^^^^^^^^

.. note::

With AppAPI 2.6.0 there is a new v2 OCS endpoint with redirect to ExApp UI support:
OCS endpoint: ``POST /apps/app_api/api/v2/ui/files-actions-menu``.
Old v1 is marked as deprecated.

OCS endpoint: ``POST /apps/app_api/api/v1/ui/files-actions-menu``


Params
******

Expand All @@ -31,12 +38,10 @@ Complete list of params (including optional):
"icon": "img/icon.svg",
"permissions": "permissions",
"order": "order_in_file_actions_menu",
"version": "1.0"
}
.. note:: Urls ``icon`` and ``actionHandler`` are relative to the ExApp root, starting slash is not required.


Optional params
***************

Expand Down Expand Up @@ -95,22 +100,9 @@ Redirect to ExApp UI page (top menu)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. note::
Supported in Nextcloud 28+.

If you want to open some file in ExApp UI, you need to set ``version`` to ``2.0``` in the FileActionsMenu registration.

.. code-block:: json
Supported only for Nextcloud 28+.

{
"name": "unique_name_of_file_actions_menu",
"display_name": "Display name (for UI listing)",
"action_handler": "/action_handler_route"
"mime": "mime of files where to display action menu",
"icon": "img/icon.svg",
"permissions": "permissions",
"order": "order_in_file_actions_menu",
"version": "2.0"
}
If you want to open some files in ExApp UI, your FileActionsMenu have to be registered using OCS v2 version (``/apps/app_api/api/v2/ui/files-actions-menu``).

After that, AppAPI will expect in the JSON response of the ExApp ``action_handler``
the ``redirect_handler`` - a relative path on the ExApp Top Menu page,
Expand Down
8 changes: 4 additions & 4 deletions lib/Controller/OCSUiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public function __construct(
#[NoCSRFRequired]
public function registerFileActionMenu(string $name, string $displayName, string $actionHandler,
string $icon = "", string $mime = "file", int $permissions = 31,
int $order = 0, string $version = '1.0'): DataResponse {
int $order = 0): DataResponse {
$result = $this->filesActionsMenuService->registerFileActionMenu(
$this->request->getHeader('EX-APP-ID'), $name, $displayName, $actionHandler, $icon, $mime, $permissions, $order, $version);
$this->request->getHeader('EX-APP-ID'), $name, $displayName, $actionHandler, $icon, $mime, $permissions, $order, '1.0');
if (!$result) {
throw new OCSBadRequestException("File Action Menu entry could not be registered");
}
Expand All @@ -63,9 +63,9 @@ public function registerFileActionMenu(string $name, string $displayName, string
#[NoCSRFRequired]
public function registerFileActionMenuV2(string $name, string $displayName, string $actionHandler,
string $icon = "", string $mime = "file", int $permissions = 31,
int $order = 0, string $version = '2.0'): DataResponse {
int $order = 0): DataResponse {
$result = $this->filesActionsMenuService->registerFileActionMenu(
$this->request->getHeader('EX-APP-ID'), $name, $displayName, $actionHandler, $icon, $mime, $permissions, $order, $version);
$this->request->getHeader('EX-APP-ID'), $name, $displayName, $actionHandler, $icon, $mime, $permissions, $order, '2.0');
if (!$result) {
throw new OCSBadRequestException("File Action Menu entry could not be registered");
}
Expand Down

0 comments on commit d39366e

Please sign in to comment.