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

Open the sidebar on scrollTo, and directly trigger the default action from search results #27100

Closed
3 tasks
skjnldsv opened this issue May 25, 2021 · 4 comments · Fixed by #27102
Closed
3 tasks
Assignees
Labels
1. to develop Accepted and waiting to be taken care of enhancement high
Milestone

Comments

@skjnldsv
Copy link
Member

skjnldsv commented May 25, 2021

When opening a file, let's directly open the sidebar and trigger the default file action.

  • Provide a FileInfo of the desired file via initialState
  • Don't wait for the full scrollTo pagination before opening the sidebar
  • Don't wait for the full page load to triggering the default action with the https://dev.domain.com/apps/files/?dir=/&openfile=88 type url
@gary-kim
Copy link
Member

Any chance we could add the ability to scroll to a file without triggering the default action (or does that already exist)? I can see situations in which you explicit want to scroll to a file without opening it.

@skjnldsv skjnldsv changed the title Open the sidebar on scrollTo, as well as the default action from search results. Open the sidebar on scrollTo, and directly trigger the default action from search results May 27, 2021
@skjnldsv
Copy link
Member Author

Right, @artonge there is already the https://dev.domain.com/apps/files/?dir=/&openfile=88 url, so we should use that.
ScrollTo should just open the sidebar, but the openFile already open the file and trigger the action, it just doesn't work well as it's linked to the scrollTo pagination, so we should take it out and trigger the action also before it's fetched?

[
'name' => 'View#showFile',
'url' => '/f/{fileid}',
'verb' => 'GET',
'root' => '',
],

public function showFile(string $fileid = null): Response {
// This is the entry point from the `/f/{fileid}` URL which is hardcoded in the server.
try {
return $this->redirectToFile($fileid);
} catch (NotFoundException $e) {
return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
}
}

Maybe add a new route like /f/123456/open that also trigger the scrollTo but the openfile as well?

private function redirectToFile($fileId) {
$uid = $this->userSession->getUser()->getUID();
$baseFolder = $this->rootFolder->getUserFolder($uid);
$files = $baseFolder->getById($fileId);
$params = [];
if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) {
$baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/');
$files = $baseFolder->getById($fileId);
$params['view'] = 'trashbin';
}
if (!empty($files)) {
$file = current($files);
if ($file instanceof Folder) {
// set the full path to enter the folder
$params['dir'] = $baseFolder->getRelativePath($file->getPath());
} else {
// set parent path as dir
$params['dir'] = $baseFolder->getRelativePath($file->getParent()->getPath());
// and scroll to the entry
$params['scrollto'] = $file->getName();
}
return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params));
}
throw new \OCP\Files\NotFoundException();
}

@artonge
Copy link
Contributor

artonge commented May 27, 2021

Right, @artonge there is already the https://dev.domain.com/apps/files/?dir=/&openfile=88 url, so we should use that.

It makes sense indeed. We should also update the search code to use &openfile=... then.

Maybe add a new route like /f/123456/open that also trigger the scrollTo but the openfile as well?

Could the URL support two actions like &scrollTo=...&openFile=... so it just uses existing functionality instead of adding a new one.

@skjnldsv
Copy link
Member Author

I think openFile was implemented with the inclusion of the scrollTo. But needs confirmation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of enhancement high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants