Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permalinks #24434

Merged
merged 5 commits into from
May 10, 2016
Merged

Permalinks #24434

merged 5 commits into from
May 10, 2016

Conversation

PVince81
Copy link
Contributor

@PVince81 PVince81 commented May 4, 2016

Fixes #11732

The following routes will redirect to the files app and display the
matching folder. If the fileid is a file, it will scroll to it.

Missing parts and challenges:

  • have the JS code append "fileid" when switching dirs and using history API
  • what if the user hits the back button and the URL contains an older fileid ? => no problem
  • have "fileid" always appear in the URL when switching dirs (and avoid infinite redirect loop)
  • fileid with other views than "All files" ?!! => not supported

@PVince81 PVince81 added this to the 9.1-current milestone May 4, 2016
@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @ChristophWurst, @LukasReschke and @tanghus to be potential reviewers

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

Note: there is no UI yet to create such links, for testing please create these manually.
You can find a fileid by inspecting the "tr" element of the file/folder row and checking "data-id"

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

  • if fileid in trash, redirect to trash instead to be done separately

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

Okay, delay aside, I found a way to replace the URL after the current folder was loaded. So if you observe the URL (when no fileid) present, it will appear without fileid until the folder is loaded, then the fileid will pop into the URL.

  • fix discrepancy between encoded slashes and non-encoded slashes (less jumpy)

The fileid will now appear in all URLs under "All files" !

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

Basically if we detect a URL change, and the only change is appending the fileid, then we use replaceState instead of pushState.

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

  • TODO: fallback if fileid not accessible, fallback to using dir

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

  • prevent opening fileid outside of "/$user/files" (except "files_trashbin")

@PVince81
Copy link
Contributor Author

PVince81 commented May 4, 2016

Okay, looks like $userFolder->getById() already enforces the limit to "files".
I'll leave the trashbin case for a separate PR as it will require some working around this.

@PVince81 PVince81 changed the title Add route to resolve fileid to files app URL Permalinks May 6, 2016
@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

  • TODO: instead of triggering the "changeDirectory" even twice, do it only once after the fileid is known?

@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

  • TEST: make sure activity links still work (due to URL rewriting)

@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

well, actually... activity app could also use the new URL format

@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

I added a section in the sidebar:
permalink-sidebar

When clicking the anchor (with title "Local link"), a new field will pop up with the link.
I wasn't sure about this, if this is too much I can also get rid of the field and expect people to right click + copy on the anchor.

This one delivers the short format link, also for files!

@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

Just added: email about internal share now uses the shortened permalink.

Would be good to get some feedback whether it works usability-wise @owncloud/designers

@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

More fixes:

  • not encoding slashes any more (no more ugly %2f in the URL)
  • added event "afterChangeDirectory" to separately append the "fileid" param in the URL when we got it

@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

  • TEST: short link http://localhost/owncloud/index.php/f/$fileid
  • TEST: long link http://localhost/owncloud/index.php/files/?dir=somedir&fileid=$fileid
  • TEST: folder file id opens the folder
  • TEST: file file id link opens the parent folder and scrolls to + highlights the file
  • TEST: email for local shares contain short link
  • TEST: copy permalink as share owner, open as recipient
  • TEST: copy permalink, rename/move folder, open permalink
  • TEST: link to file/folder on ext storage
  • TEST: link to ext storage, cross-storage move, etc
  • TEST: link to file inside a received share
  • TEST: link to file inside a received share when received parent folder was moved/renamed
  • TEST: link to deleted file gives 404 (no trashbin link for now)
  • TEST: link to inaccessible file gives 404

'files.view.index',
$args
'files.viewcontroller.showFile',
['fileId' => $items[0]['item_source']]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undefined index in the unit test :)

10:20:05 1) MailNotificationsTest::testSendInternalShareMail
10:20:05 Undefined index: item_source
10:20:05 
10:20:05 /ssd/jenkins/workspace/server-master-linux-php7-ci/database/sqlite/label/SLAVE/lib/private/Share/MailNotifications.php:124
10:20:05 /ssd/jenkins/workspace/server-master-linux-php7-ci/database/sqlite/label/SLAVE/tests/lib/share/MailNotificationsTest.php:250

@LukasReschke
Copy link
Member

Most useful feature ever. Code looks good and works. Great stuff!!!! 🚀 💘 ❤️ 🎉

@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

I think this is ready for review @MorrisJobke @nickvergessen @guruz @rullzer @icewind1991 @schiesbn @VicDeo @georgehrke @Xenopathic @blizzz @ChristophWurst

@LukasReschke mind checking the endpoint ? (disabled CSRF, etc)

@LukasReschke
Copy link
Member

@LukasReschke mind checking the endpoint ? (disabled CSRF, etc)

That's fine :)

* Redirects to the file list and highlight the given file id
*
* @param string $fileId file id to show
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@return missing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing @return

@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

  • BUG: back button goes to root folder after going into 2 subdirs

@rullzer
Copy link
Contributor

rullzer commented May 6, 2016

I love the local link thingy... but can't we just copy it to the clipboard directly?

@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

@rullzer copy to clipboard requires flash, see how Github does it with its copy link button. No flash, no button.

@rullzer
Copy link
Contributor

rullzer commented May 6, 2016

Aaaah ok then never mind :)

@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

@rullzer (else we'd probably have that button for all link fields)

* @return TemplateResponse
* @throws \OCP\Files\NotFoundException
*/
public function index($dir = '', $view = '') {
public function index($dir = '', $view = '', $fileid = null) {
if ($fileid !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So fileid always has preference if it is there. Sounds good

@georgehrke
Copy link
Contributor

You can also use Document.execCommand to copy stuff to the clipboard, but I'm not sure how good it is supported in various browsers.

There are some wrapper libs that have fallbacks like https://clipboardjs.com

$params = [];

if (!empty($files)) {
$file = current($files);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking... maybe it is good to loop over all files (if a file is shared via multiple ways)... and pick the one with the highest permission?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course harder then it sounds because which do you pick if 1 has edit and 1 has share permissions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not that common scenario...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rullzer yeah good point, possibly something for later.

Also I thought about adding a "trashbin" route in case the file is detected in trash instead, but something for later also.

@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

@georgehrke I'll make a ticket to research that. Could definitely be useful for the many link-copy locations we have: #24472

Vincent Petry added 4 commits May 6, 2016 16:46
The following routes will redirect to the files app and display the
matching folder. If the fileid is a file, it will scroll to it.
- http://localhost/owncloud/index.php/f/$fileid
- http://localhost/owncloud/index.php/files/?dir=somedir&fileid=$fileid
@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

  • TEST: file share + rename file as recipient + open permalink => correct filename used
  • TEST: browser back button after several navigations

@PVince81
Copy link
Contributor Author

PVince81 commented May 6, 2016

Fixed back button and unit test.

@rullzer
Copy link
Contributor

rullzer commented May 10, 2016

👍 very very cool stuff!

@LiamHD
Copy link

LiamHD commented Jul 13, 2016

I cannot find the permalink in the curren owncloud version. What this feature removed?

@georgehrke
Copy link
Contributor

@LiamHD This feature will be released with ownCloud 9.1

@lock
Copy link

lock bot commented Aug 5, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Permalinks for folders and files that work across internal users when sharing
6 participants