Skip to content

Permalinks - #24434

Merged
LukasReschke merged 5 commits into
masterfrom
permalinks
May 10, 2016
Merged

LukasReschke merged 5 commits into
masterfrom
permalinks

Conversation

@PVince81

@PVince81 PVince81 commented May 4, 2016 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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

@PVince81

PVince81 commented May 4, 2016

Copy link
Copy Markdown
Contributor Author

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

PVince81 commented May 4, 2016 •

Copy link
Copy Markdown
Contributor Author
  • if fileid in trash, redirect to trash instead to be done separately

@PVince81

PVince81 commented May 4, 2016 •

Copy link
Copy Markdown
Contributor Author

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

PVince81 commented May 4, 2016

Copy link
Copy Markdown
Contributor Author

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

@PVince81

PVince81 commented May 4, 2016 •

Copy link
Copy Markdown
Contributor Author
  • TODO: fallback if fileid not accessible, fallback to using dir

@PVince81

PVince81 commented May 4, 2016 •

Copy link
Copy Markdown
Contributor Author
  • prevent opening fileid outside of "/$user/files" (except "files_trashbin")

@PVince81

PVince81 commented May 4, 2016

Copy link
Copy Markdown
Contributor Author

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

PVince81 commented May 6, 2016 •

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

@PVince81

PVince81 commented May 6, 2016 •

Copy link
Copy Markdown
Contributor Author
  • TEST: make sure activity links still work (due to URL rewriting)

@PVince81

PVince81 commented May 6, 2016

Copy link
Copy Markdown
Contributor Author

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

@PVince81

PVince81 commented May 6, 2016

Copy link
Copy Markdown
Contributor Author

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

PVince81 commented May 6, 2016

Copy link
Copy Markdown
Contributor Author

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

PVince81 commented May 6, 2016

Copy link
Copy Markdown
Contributor Author

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

PVince81 commented May 6, 2016

Copy link
Copy Markdown
Contributor Author

Comment thread lib/private/Share/MailNotifications.php Outdated

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

@PVince81

PVince81 commented May 6, 2016

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor

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

That's fine :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@return missing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missing @return

@PVince81

PVince81 commented May 6, 2016 •

Copy link
Copy Markdown
Contributor Author
  • BUG: back button goes to root folder after going into 2 subdirs

@rullzer

rullzer commented May 6, 2016

Copy link
Copy Markdown
Contributor

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

@PVince81

PVince81 commented May 6, 2016

Copy link
Copy Markdown
Contributor Author

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

@rullzer

rullzer commented May 6, 2016

Copy link
Copy Markdown
Contributor

Aaaah ok then never mind :)

@PVince81

PVince81 commented May 6, 2016

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
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
Copy Markdown
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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

PVince81 commented May 6, 2016

Copy link
Copy Markdown
Contributor Author

@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

PVince81 commented May 6, 2016 •

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

@PVince81

PVince81 commented May 6, 2016

Copy link
Copy Markdown
Contributor Author

Fixed back button and unit test.

@rullzer

rullzer commented May 10, 2016

Copy link
Copy Markdown
Contributor

👍 very very cool stuff!

@LiamHD

LiamHD commented Jul 13, 2016

Copy link
Copy Markdown

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

@georgehrke

Copy link
Copy Markdown
Contributor

@LiamHD This feature will be released with ownCloud 9.1

@lock

lock Bot commented Aug 5, 2019

Copy link
Copy Markdown

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