Skip to content

Commit

Permalink
Merge pull request #32152 from owncloud/master-d1f28e5880af3e456b43e8…
Browse files Browse the repository at this point in the history
…e9dbc3fd6eff455ddd

Add url parameter which open a specific details tab right away
  • Loading branch information
DeepDiver1975 authored Jul 31, 2018
2 parents 936e58a + 058eaa3 commit 8a811f5
Show file tree
Hide file tree
Showing 10 changed files with 444 additions and 93 deletions.
1 change: 1 addition & 0 deletions apps/files/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
fileActions: fileActions,
allowLegacyActions: true,
scrollTo: urlParams.scrollto,
detailTabId: urlParams.details,
filesClient: OC.Files.getClient(),
sorting: {
mode: $('#defaultFileSorting').val(),
Expand Down
9 changes: 6 additions & 3 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@
this.$el.toggleClass('hide-hidden-files', !this._filesConfig.get('showhidden'));
}


if (_.isUndefined(options.detailsViewEnabled) || options.detailsViewEnabled) {
this._detailsView = new OCA.Files.DetailsView();
this._detailsView.$el.insertBefore(this.$el);
Expand Down Expand Up @@ -333,7 +332,7 @@

if (options.scrollTo) {
this.$fileList.one('updated', function() {
self.scrollTo(options.scrollTo);
self.scrollTo(options.scrollTo, options.detailTabId);
});
}

Expand Down Expand Up @@ -2519,10 +2518,14 @@
this.$el.find('.mask').remove();
this.$table.removeClass('hidden');
},
scrollTo:function(file) {
scrollTo:function(file, detailTabId) {
if (!_.isArray(file)) {
file = [file];
}
if (!_.isUndefined(detailTabId)) {
var filename = file[file.length - 1];
this.showDetailsView(filename, detailTabId);
}
this.highlightFiles(file, function($tr) {
$tr.addClass('searchresult');
$tr.one('hover', function() {
Expand Down
9 changes: 6 additions & 3 deletions apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ protected function getStorageInfo() {
* @param string $fileid
* @return TemplateResponse
*/
public function index($dir = '', $view = '', $fileid = null) {
public function index($dir = '', $view = '', $fileid = null, $details = null) {
$fileNotFound = false;
if ($fileid !== null) {
try {
return $this->showFile($fileid);
return $this->showFile($fileid, $details);
} catch (NotFoundException $e) {
$fileNotFound = true;
}
Expand Down Expand Up @@ -278,7 +278,7 @@ public function index($dir = '', $view = '', $fileid = null) {
* @NoCSRFRequired
* @NoAdminRequired
*/
public function showFile($fileId) {
public function showFile($fileId, $details = null) {
$uid = $this->userSession->getUser()->getUID();
$baseFolder = $this->rootFolder->get($uid . '/files/');
$files = $baseFolder->getById($fileId);
Expand Down Expand Up @@ -308,6 +308,9 @@ public function showFile($fileId) {
// and scroll to the entry
$params['scrollto'] = $file->getName();
}
if ($details !== null) {
$params['details'] = $details;
}
$webUrl = $this->urlGenerator->linkToRoute('files.view.index', $params);

$webdavUrl = $this->urlGenerator->linkTo('', 'remote.php') . '/dav/files/' . \rawurlencode($uid) . '/';
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -2103,7 +2103,7 @@ public function userDeletesEverythingInFolder($user, $folder) {
*
* @return int
*/
private function getFileIdForPath($user, $path) {
public function getFileIdForPath($user, $path) {
try {
return WebDavHelper::getFileIdForPath(
$this->getBaseUrl(),
Expand Down
91 changes: 91 additions & 0 deletions tests/acceptance/features/bootstrap/WebUIFilesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class WebUIFilesContext extends RawMinkContext implements Context {
* @var ConflictDialog
*/
private $conflictDialog;

/**
* Table of all files and folders that should have been deleted, stored so
* that other steps can use the list to check if the deletion happened correctly
Expand All @@ -97,6 +98,13 @@ class WebUIFilesContext extends RawMinkContext implements Context {
*/
private $currentFolder = "";

/**
* variable to remember with which file we are currently working
*
* @var string
*/
private $currentFile = "";

/**
*
* @var FeatureContext
Expand Down Expand Up @@ -150,6 +158,15 @@ private function getCurrentPageObject() {
return $pageObject;
}

/**
* get the current folder and file path that is being worked on
*
* @return string
*/
private function getCurrentFolderFilePath() {
return \rtrim($this->currentFolder, '/') . '/' . $this->currentFile;
}

/**
* reset any context remembered about where we are or what we have done on
* the files-like pages
Expand All @@ -158,6 +175,7 @@ private function getCurrentPageObject() {
*/
public function resetFilesContext() {
$this->currentFolder = "";
$this->currentFile = "";
$this->deletedElementsTable = null;
$this->movedElementsTable = null;
}
Expand All @@ -181,6 +199,79 @@ public function theUserBrowsesToTheFilesPage() {
}
}

/**
* @When the user browses directly to display the :tabName details of file :fileName in folder :folderName
*
* @param string $tabName
* @param string $fileName
* @param string $folderName
* @return void
* @throws Exception
*/
public function theUserBrowsesDirectlyToDetailsTabOfFileInFolder(
$tabName, $fileName, $folderName
) {
$this->currentFolder = '/' . \trim($folderName, '/');
$this->currentFile = $fileName;
$fileId = $this->featureContext->getFileIdForPath(
$this->featureContext->getCurrentUser(),
$this->getCurrentFolderFilePath()
);
$this->filesPage->browseToFileId(
$fileId, $this->currentFolder, $tabName
);
$this->filesPage->waitTillPageIsLoaded($this->getSession());
$this->filesPage->getDetailsDialog()->waitTillPageIsLoaded($this->getSession());
}

/**
* @Then the thumbnail should be visible in the details panel
*
* @return void
* @throws Exception
*/
public function theThumbnailShouldBeVisibleInTheDetailsPanel() {
$detailsDialog = $this->filesPage->getDetailsDialog();
$style = $detailsDialog->findThumbnail()->getAttribute("style");
PHPUnit_Framework_Assert::assertNotNull(
$style,
'style attribute of details thumbnail is null'
);
PHPUnit_Framework_Assert::assertContains(
$this->getCurrentFolderFilePath(),
$style
);
}

/**
* @Then the :tabName details panel should be visible
*
* @param string $tabName
*
* @return void
*/
public function theTabNameDetailsPanelShouldBeVisible($tabName) {
$detailsDialog = $this->filesPage->getDetailsDialog();
PHPUnit_Framework_Assert::assertTrue(
$detailsDialog->isDetailsPanelVisible($tabName),
"the $tabName panel is not visible in the details panel"
);
}

/**
* @Then the share-with field should be visible in the details panel
*
* @return void
* @throws Exception
*/
public function theShareWithFieldShouldBeVisibleInTheDetailsPanel() {
$sharingDialog = $this->filesPage->getSharingDialog();
PHPUnit_Framework_Assert::assertTrue(
$sharingDialog->isShareWithFieldVisible(),
'the share-with field is not visible in the details panel'
);
}

/**
* @When the user browses to the trashbin page
* @Given the user has browsed to the trashbin page
Expand Down
20 changes: 14 additions & 6 deletions tests/acceptance/features/bootstrap/WebUISharingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\RawMinkContext;
use Page\FilesPage;
use Page\FilesPageElement\SharingDialog;
use Page\PublicLinkFilesPage;
use Page\SharedWithYouPage;
use SensioLabs\Behat\PageObjectExtension\PageObject\Exception\ElementNotFoundException;
Expand Down Expand Up @@ -55,6 +56,11 @@ class WebUISharingContext extends RawMinkContext implements Context {
* @var SharedWithYouPage
*/
private $sharedWithYouPage;

/**
*
* @var SharingDialog
*/
private $sharingDialog;

/**
Expand Down Expand Up @@ -125,7 +131,7 @@ public function theUserSharesTheFileFolderWithTheUserUsingTheWebUI(
) {
$this->filesPage->waitTillPageIsloaded($this->getSession());
try {
$this->filesPage->closeSharingDialog();
$this->filesPage->closeDetailsDialog();
} catch (Exception $e) {
//we don't care
}
Expand Down Expand Up @@ -160,7 +166,7 @@ public function theUserSharesTheFileFolderWithTheGroupUsingTheWebUI(
) {
$this->filesPage->waitTillPageIsloaded($this->getSession());
try {
$this->filesPage->closeSharingDialog();
$this->filesPage->closeDetailsDialog();
} catch (Exception $e) {
//we don't care
}
Expand Down Expand Up @@ -222,7 +228,7 @@ public function theUserCreatesANewPublicLinkForUsingTheWebUIWith(
//if there is no dialog open and we try to close it
//an exception will be thrown, but we do not care
try {
$this->filesPage->closeSharingDialog();
$this->filesPage->closeDetailsDialog();
} catch (Exception $e) {
}
$this->sharingDialog = $this->filesPage->openSharingDialog(
Expand Down Expand Up @@ -274,7 +280,8 @@ public function theUserCreatesANewPublicLinkForUsingTheWebUIWith(
* @return void
*/
public function theUserClosesTheShareDialog() {
$this->sharingDialog->closeSharingDialog();
// The close button is for the whole details dialog.
$this->filesPage->closeDetailsDialog();
}

/**
Expand Down Expand Up @@ -619,7 +626,7 @@ public function theFileFolderShouldBeMarkedAsSharedBy(
//if there is no dialog open and we try to close it
//an exception will be thrown, but we do not care
try {
$this->filesPage->closeSharingDialog();
$this->filesPage->closeDetailsDialog();
} catch (Exception $e) {
}

Expand All @@ -639,9 +646,10 @@ public function theFileFolderShouldBeMarkedAsSharedBy(
"folder-shared.svg",
$row->findThumbnail()->getAttribute("style")
);
$detailsDialog = $this->filesPage->getDetailsDialog();
PHPUnit_Framework_Assert::assertContains(
"folder-shared.svg",
$sharingDialog->findThumbnail()->getAttribute("style")
$detailsDialog->findThumbnail()->getAttribute("style")
);
}
if ($sharedWithGroup !== "") {
Expand Down
57 changes: 54 additions & 3 deletions tests/acceptance/features/lib/FilesPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
namespace Page;

use Behat\Mink\Session;
use Page\FilesPageElement\DetailsDialog;
use Page\FilesPageElement\SharingDialog;
use SensioLabs\Behat\PageObjectExtension\PageObject\Exception\ElementNotFoundException;
use SensioLabs\Behat\PageObjectExtension\PageObject\Exception\UnexpectedPageException;
Expand Down Expand Up @@ -213,6 +214,26 @@ public function uploadFile(Session $session, $name) {
$this->waitForUploadProgressbarToFinish();
}

/**
* gets a details dialog object
*
* @throws ElementNotFoundException
* @return DetailsDialog
*/
public function getDetailsDialog() {
return $this->getPage("FilesPageElement\\DetailsDialog");
}

/**
* gets a sharing dialog object
*
* @throws ElementNotFoundException
* @return SharingDialog
*/
public function getSharingDialog() {
return $this->getPage("FilesPageElement\\SharingDialog");
}

/**
* opens the sharing dialog for a given file/folder name
* returns the SharingDialog Object
Expand All @@ -228,14 +249,15 @@ public function openSharingDialog($fileName, Session $session) {
}

/**
* closes an open sharing dialog
* closes an open details dialog
* the details dialog contains the comments, sharing, versions etc tabs
*
* @throws ElementNotFoundException
* if no sharing dialog is open
* @return void
*/
public function closeSharingDialog() {
$this->getPage('FilesPageElement\\SharingDialog')->closeSharingDialog();
public function closeDetailsDialog() {
$this->getDetailsDialog()->closeDetailsDialog();
}

/**
Expand Down Expand Up @@ -369,6 +391,35 @@ public function open(array $urlParameters = []) {
return $this;
}

/**
* Browse directly to a particular file within a folder.
*
* The folder should open and scroll to the requested file.
* If a details tab is specified, then the details panel for that file
* should open with the requested tab selected.
*
* @param string $fileId
* @param string $folderName
* @param string|null $detailsTab e.g. comments, sharing, versions
*
* @return FilesPage
*/
public function browseToFileId(
$fileId, $folderName = '/', $detailsTab = null
) {
$url = \rtrim($this->getUrl(), '/');
$fullUrl = $url . '/?dir=' . $folderName . '&fileid=' . $fileId;

if ($detailsTab !== null) {
$detailsDialog = $this->getDetailsDialog();
$fullUrl = $fullUrl . '&details=' . $detailsDialog->getDetailsTabId($detailsTab);
}

$this->getDriver()->visit($fullUrl);

return $this;
}

/**
* waits till the upload progressbar is not visible anymore
*
Expand Down
Loading

0 comments on commit 8a811f5

Please sign in to comment.