text icon indicating copy to clipboard operation
text copied to clipboard

Redirect to files app when opening direct editing from desktop client

Open juliusknorr opened this issue 5 years ago • 4 comments

This is a challenging https://github.com/nextcloud/text/labels/good%20first%20issue if you...

  • want to learn how the desktop client integrates with the text app
  • have some basic knowledge of php

If you would like some guidance ping @max-nextcloud or join the public text channel.

Problem

Direct editing is a mechanism we use so that from clients (mobile and desktop) you can open a file with a context menu click in your browser so you can collaborate using apps that support it instead of opening the file locally.

This works fine however in cases where the user is already logged in to an instance and has access to the file we want to redirect them to the files app directly. Direct editing has some technical limitations as it is stripped down to also work with only a one time token, so in case possible the forward will result in a better user experience and more functionality.

Here would be a few pointers, to make testing easier one can use the following curl statement to generate a link that the desktop client would open in the browser:

curl --request POST \
  --url 'https://admin:[email protected]/ocs/v2.php/apps/files/api/v1/directEditing/open?editorId=text&creatorId=textdocument&format=json' \
  --header 'Content-Type: multipart/form-data' \
  --header 'OCS-APIRequest: true' \
  --form path=/test.md

The goal would be to check if the user is logged in and has access to the requested file. In this case it may not open the existing "direct editing" UI, but instead just redirect using the internal file link (e.g. /index.php/f/12345 for the file id 12345)

Note the implementation of this is likely better suited in the server repository.

Code pointers

https://github.com/nextcloud/server/blob/master/apps/files/lib/Controller/DirectEditingViewController.php#L42-L48 is the entrypoint of the URL that is opened in the browser then, which triggers https://github.com/nextcloud/text/blob/8cdb2d22fc42c60e03f480b1ddecfe328dbaaf42/lib/DirectEditing/TextDirectEditor.php#L151 for the text app.

Additional Context

This would go well together with #3819 if you also want to work with the client side.

juliusknorr avatar Jan 18 '20 13:01 juliusknorr

@juliushaertl Is this still relevant nowadays?

julien-nc avatar Oct 17 '22 16:10 julien-nc

Yep, still relevant. The redirect could happen in a similar way like https://github.com/nextcloud/richdocuments/pull/2419/files#diff-f6848853e94bfe83f31f5a03e8e8c1d086eb07a4ba5c6646b2c5001e05a18da2R424-R455 which could be added to the direct editor rendering bits:

https://github.com/nextcloud/text/blob/8cdb2d22fc42c60e03f480b1ddecfe328dbaaf42/lib/DirectEditing/TextDirectEditor.php#L151

In addition if on desktop we should just hide the close button and share icon from here (as then there is noone taking care of those post messages emitted): https://github.com/nextcloud/text/blob/ba1bc2cb2eef697252fa98b89b8d8321beda91d4/src/views/DirectEditing.vue#L33

juliusknorr avatar Nov 16 '22 11:11 juliusknorr

In order to make sure this https://github.com/nextcloud/text/labels/good%20first%20issue is easy to parse I tried to provide all information needed in the issue description above.

If some aspects of it are still unclear please ask so i can clarify further.

If you think this should be done differently please open a new issue describing your solution. Let's keep this issue focused on the proposed solution to provide clarity for whoever wants to tackle it.

max-nextcloud avatar Feb 21 '23 13:02 max-nextcloud

Updated with some more details

juliusknorr avatar May 09 '25 13:05 juliusknorr