files_zip icon indicating copy to clipboard operation
files_zip copied to clipboard

Declarative UI: use a file/folder to create a zip file

Open tobiasKaminsky opened this issue 3 months ago • 6 comments

Related to https://github.com/nextcloud/files-clients/issues/86#issuecomment-3199249342

With Declarative UI any server app can add interactions dynamically to Files clients. This reduces code on client side and gives lots of opportunities to display simple stuff in a native way or interact in an easy way.

To have a starting set, we discussed and defined some actions. One action is to offer an menu entry in context menu to convert an audio file file to md.

To do so:

  • add info to capability like https://github.com/tobiasKaminsky/declarativetest/blob/main/lib/Capabilities.php#L29
  • create an endpoint that can receive a fileID and create a zip file out of it

tobiasKaminsky avatar Aug 20 '25 07:08 tobiasKaminsky

A few questions about this :-)

* add info to capability like https://github.com/tobiasKaminsky/declarativetest/blob/main/lib/Capabilities.php#L29

How is internationalization and localization handled for the action name?

* create an endpoint that can receive a fileID and create a zip file out of it
  • Is it expected that the fileID will be just appended to the declared endpoint? So, if the endpoint is declared as /ocs/v2.php/apps/file_zip/api/1/zip, will the client send the request, for example, to /ocs/v2.php/apps/file_zip/api/1/zip/42108? Or should it be declared with a parameter syntax like /ocs/v2.php/apps/file_zip/api/1/zip/{fileId}?
  • Is the client expected to provide the target file? If yes, how should it be declared? If not, what should be the name of the created zip file? Just the original file name with .zip? If it exists, should it just follow the typical pattern of adding (2) or (3) or (4)... until there is no previously existing file?
  • Will the endpoint be called with POST or should it be explicitly declared somehow?

danxuliu avatar Aug 24 '25 17:08 danxuliu

How is internationalization and localization handled for the action name?

Can this be translated like every other string?

  • Is it expected that the fileID will be just appended to the declared endpoint? So, if the endpoint is declared as /ocs/v2.php/apps/file_zip/api/1/zip, will the client send the request, for example, to /ocs/v2.php/apps/file_zip/api/1/zip/42108? Or should it be declared with a parameter syntax like /ocs/v2.php/apps/file_zip/api/1/zip/{fileId}?

Parameter syntax 👍

  • Is the client expected to provide the target file? If yes, how should it be declared? If not, what should be the name of the created zip file? Just the original file name with .zip? If it exists, should it just follow the typical pattern of adding (2) or (3) or (4)... until there is no previously existing file?

No. This is handled by app. And your suggestion is good 👍

  • Will the endpoint be called with POST or should it be explicitly declared somehow?

within capabilities/endpoint, you can specify "method: POST", else clients will do GET.

tobiasKaminsky avatar Sep 03 '25 13:09 tobiasKaminsky

How is internationalization and localization handled for the action name?

Can this be translated like every other string?

But could it happen that the language used in the translated capabilities does not match the language used in the client? 🤔

danxuliu avatar Sep 03 '25 14:09 danxuliu

But could it happen that the language used in the translated capabilities does not match the language used in the client? 🤔

That can already happen now, e.g: Android set to German user language on server: English

Then you see a german Android app, but any server side computed error, e.g. "password within 1 million common passwords" would then be English.

We could add a htttp language header, but so far it is more a theoritcal problem and not something user/customer complain on it.

tobiasKaminsky avatar Sep 05 '25 08:09 tobiasKaminsky

An issue that appeared while implementing this. If another file needs to be created from the fileId the fileId may not provide enough information about the original file. See the following scenario:

  • User A creates folder Folder
  • User A creates file Folder/File
  • User A shares folder Folder with user B
  • User A shares file Folder/File with user B

User B now has access to Folder/File both as Folder/File and as File. The fileId is the same in both cases. If user B now selects Compress to Zip for Folder/File in the client and only fileId is sent the app does not actually know if the user selected Folder/File or File in order to create either Folder/File.zip or File.zip.

danxuliu avatar Sep 16 '25 03:09 danxuliu

True. We can also add filePath as a variable? This way it would be like: "url": "/ocs/v2.php/apps/files_zip/api/v1/zip/{filePath}"

tobiasKaminsky avatar Sep 16 '25 06:09 tobiasKaminsky