Merge pull request #12598 from nextcloud/stable14-12577-fix-rendering-of-the-sidebar-in-files-app

[stable14] Fix rendering of the sidebar in Files app
This commit is contained in:
Morris Jobke 2018-11-23 08:51:22 +01:00 committed by GitHub
commit c6232291a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 204 additions and 11 deletions

View File

@ -117,16 +117,6 @@
* Renders this details view * Renders this details view
*/ */
render: function() { render: function() {
// remove old instances
var $appSidebar = $('#app-sidebar');
if ($appSidebar.length === 0) {
this.$el.insertAfter($('#app-content'));
} else {
if ($appSidebar[0] !== this.el) {
$appSidebar.replaceWith(this.$el)
}
}
var templateVars = { var templateVars = {
closeLabel: t('files', 'Close') closeLabel: t('files', 'Close')
}; };

View File

@ -568,11 +568,35 @@
} }
this._currentFileModel = model; this._currentFileModel = model;
this._replaceDetailsViewElementIfNeeded();
this._detailsView.setFileInfo(model); this._detailsView.setFileInfo(model);
this._detailsView.render();
this._detailsView.$el.scrollTop(0); this._detailsView.$el.scrollTop(0);
}, },
/**
* Replaces the current details view element with the details view
* element of this file list.
*
* Each file list has its own DetailsView object, and each one has its
* own root element, but there can be just one details view/sidebar
* element in the document. This helper method replaces the current
* details view/sidebar element in the document with the element from
* the DetailsView object of this file list.
*/
_replaceDetailsViewElementIfNeeded: function() {
var $appSidebar = $('#app-sidebar');
if ($appSidebar.length === 0) {
this._detailsView.$el.insertAfter($('#app-content'));
} else if ($appSidebar[0] !== this._detailsView.el) {
// "replaceWith()" can not be used here, as it removes the old
// element instead of just detaching it.
this._detailsView.$el.insertBefore($appSidebar);
$appSidebar.detach();
}
},
/** /**
* Event handler for when the window size changed * Event handler for when the window size changed
*/ */

View File

@ -6,3 +6,26 @@ Feature: app-comments
And I open the "Comments" tab in the details view And I open the "Comments" tab in the details view
When I create a new comment with "Hello world" as message When I create a new comment with "Hello world" as message
Then I see a comment with "Hello world" as message Then I see a comment with "Hello world" as message
Scenario: open the comments for a different file
Given I am logged in
And I create a new folder named "Folder"
And I open the details view for "welcome.txt"
And I open the "Comments" tab in the details view
And I create a new comment with "Hello world" as message
And I see a comment with "Hello world" as message
When I open the details view for "Folder"
# The "Comments" tab should already be opened
Then I see that there are no comments
Scenario: write a comment in a file right after writing a comment in another file
Given I am logged in
And I create a new folder named "Folder"
And I open the details view for "Folder"
And I open the "Comments" tab in the details view
And I create a new comment with "Comment in Folder" as message
And I open the details view for "welcome.txt"
# The "Comments" tab should already be opened
When I create a new comment with "Comment in welcome.txt" as message
Then I see a comment with "Comment in welcome.txt" as message
And I see that there is no comment with "Comment in Folder" as message

View File

@ -8,6 +8,17 @@ Feature: app-files-tags
When I open the input field for tags in the details view When I open the input field for tags in the details view
Then I see that the input field for tags in the details view is shown Then I see that the input field for tags in the details view is shown
Scenario: show the input field for tags in the details view after closing and opening the details view again
Given I am logged in
And I open the details view for "welcome.txt"
And I see that the details view is open
And I close the details view
And I see that the details view is closed
And I open the details view for "welcome.txt"
And I see that the details view is open
When I open the input field for tags in the details view
Then I see that the input field for tags in the details view is shown
Scenario: show the input field for tags in the details view after the sharing tab has loaded Scenario: show the input field for tags in the details view after the sharing tab has loaded
Given I am logged in Given I am logged in
And I open the details view for "welcome.txt" And I open the details view for "welcome.txt"

View File

@ -1,5 +1,42 @@
Feature: app-files Feature: app-files
Scenario: open and close the details view
Given I am logged in
When I open the details view for "welcome.txt"
And I see that the details view is open
And I close the details view
Then I see that the details view is closed
Scenario: open and close the details view twice
Given I am logged in
And I open the details view for "welcome.txt"
And I see that the details view is open
And I close the details view
And I see that the details view is closed
When I open the details view for "welcome.txt"
And I see that the details view is open
And I close the details view
Then I see that the details view is closed
Scenario: open and close the details view again after coming back from a different section
Given I am logged in
And I open the details view for "welcome.txt"
And I see that the details view is open
And I close the details view
And I see that the details view is closed
And I open the "Recent" section
And I see that the current section is "Recent"
And I open the details view for "welcome.txt"
And I see that the details view is open
And I close the details view
And I see that the details view is closed
When I open the "All files" section
And I see that the current section is "All files"
And I open the details view for "welcome.txt"
And I see that the details view is open
And I close the details view
Then I see that the details view is closed
Scenario: viewing a favorite file in its folder shows the correct sidebar view Scenario: viewing a favorite file in its folder shows the correct sidebar view
Given I am logged in Given I am logged in
And I create a new folder named "other" And I create a new folder named "other"
@ -262,3 +299,22 @@ Feature: app-files
When I unmark "welcome.txt" as favorite When I unmark "welcome.txt" as favorite
Then I see that "welcome.txt" is not marked as favorite Then I see that "welcome.txt" is not marked as favorite
And I see that "A name alphabetically lower than welcome.txt" precedes "welcome.txt" in the file list And I see that "A name alphabetically lower than welcome.txt" precedes "welcome.txt" in the file list
Scenario: mark a file as favorite in the details view
Given I am logged in
And I open the details view for "welcome.txt"
And I see that the details view is open
When I mark the file as favorite in the details view
Then I see that "welcome.txt" is marked as favorite
And I see that the file is marked as favorite in the details view
Scenario: unmark a file as favorite in the details view
Given I am logged in
And I open the details view for "welcome.txt"
And I see that the details view is open
And I mark the file as favorite in the details view
And I see that "welcome.txt" is marked as favorite
And I see that the file is marked as favorite in the details view
When I unmark the file as favorite in the details view
Then I see that "welcome.txt" is not marked as favorite
And I see that the file is not marked as favorite in the details view

View File

@ -62,6 +62,15 @@ class CommentsAppContext implements Context, ActorAwareInterface {
describedAs("Comment with text \"$text\" in details view in Files app"); describedAs("Comment with text \"$text\" in details view in Files app");
} }
/**
* @return Locator
*/
public static function emptyContent() {
return Locator::forThe()->css(".emptycontent")->
descendantOf(FilesAppContext::detailsView())->
describedAs("Empty content in details view in Files app");
}
/** /**
* @When /^I create a new comment with "([^"]*)" as message$/ * @When /^I create a new comment with "([^"]*)" as message$/
*/ */
@ -70,6 +79,14 @@ class CommentsAppContext implements Context, ActorAwareInterface {
$this->actor->find(self::submitNewCommentButton())->click(); $this->actor->find(self::submitNewCommentButton())->click();
} }
/**
* @Then /^I see that there are no comments$/
*/
public function iSeeThatThereAreNoComments() {
PHPUnit_Framework_Assert::assertTrue(
$this->actor->find(self::emptyContent(), 10)->isVisible());
}
/** /**
* @Then /^I see a comment with "([^"]*)" as message$/ * @Then /^I see a comment with "([^"]*)" as message$/
*/ */
@ -77,4 +94,15 @@ class CommentsAppContext implements Context, ActorAwareInterface {
PHPUnit_Framework_Assert::assertTrue( PHPUnit_Framework_Assert::assertTrue(
$this->actor->find(self::commentWithText($commentText), 10)->isVisible()); $this->actor->find(self::commentWithText($commentText), 10)->isVisible());
} }
/**
* @Then /^I see that there is no comment with "([^"]*)" as message$/
*/
public function iSeeThatThereIsNoCommentWithAsMessage($commentText) {
try {
PHPUnit_Framework_Assert::assertFalse(
$this->actor->find(self::commentWithText($commentText))->isVisible());
} catch (NoSuchElementException $exception) {
}
}
} }

View File

@ -86,6 +86,33 @@ class FilesAppContext implements Context, ActorAwareInterface {
describedAs("File name in details view in Files app"); describedAs("File name in details view in Files app");
} }
/**
* @return Locator
*/
public static function favoriteActionInFileDetailsInDetailsView() {
return Locator::forThe()->css(".action-favorite")->
descendantOf(self::fileDetailsInDetailsView())->
describedAs("Favorite action in file details in details view in Files app");
}
/**
* @return Locator
*/
public static function notFavoritedStateIconInFileDetailsInDetailsView() {
return Locator::forThe()->css(".icon-star")->
descendantOf(self::favoriteActionInFileDetailsInDetailsView())->
describedAs("Not favorited state icon in file details in details view in Files app");
}
/**
* @return Locator
*/
public static function favoritedStateIconInFileDetailsInDetailsView() {
return Locator::forThe()->css(".icon-starred")->
descendantOf(self::favoriteActionInFileDetailsInDetailsView())->
describedAs("Favorited state icon in file details in details view in Files app");
}
/** /**
* @return Locator * @return Locator
*/ */
@ -316,6 +343,24 @@ class FilesAppContext implements Context, ActorAwareInterface {
$this->actor->getSharedNotebook()["shared link"] = $this->actor->find(self::copyUrlMenuItem(), 2)->getWrappedElement()->getAttribute("data-clipboard-text"); $this->actor->getSharedNotebook()["shared link"] = $this->actor->find(self::copyUrlMenuItem(), 2)->getWrappedElement()->getAttribute("data-clipboard-text");
} }
/**
* @When I mark the file as favorite in the details view
*/
public function iMarkTheFileAsFavoriteInTheDetailsView() {
$this->iSeeThatTheFileIsNotMarkedAsFavoriteInTheDetailsView();
$this->actor->find(self::favoriteActionInFileDetailsInDetailsView(), 10)->click();
}
/**
* @When I unmark the file as favorite in the details view
*/
public function iUnmarkTheFileAsFavoriteInTheDetailsView() {
$this->iSeeThatTheFileIsMarkedAsFavoriteInTheDetailsView();
$this->actor->find(self::favoriteActionInFileDetailsInDetailsView(), 10)->click();
}
/** /**
* @When I check the tag :tag in the dropdown for tags in the details view * @When I check the tag :tag in the dropdown for tags in the details view
*/ */
@ -400,6 +445,22 @@ class FilesAppContext implements Context, ActorAwareInterface {
$this->actor->find(self::fileNameInDetailsView(), 10)->getText(), $fileName); $this->actor->find(self::fileNameInDetailsView(), 10)->getText(), $fileName);
} }
/**
* @Then I see that the file is marked as favorite in the details view
*/
public function iSeeThatTheFileIsMarkedAsFavoriteInTheDetailsView() {
PHPUnit_Framework_Assert::assertNotNull(
$this->actor->find(self::favoritedStateIconInFileDetailsInDetailsView(), 10));
}
/**
* @Then I see that the file is not marked as favorite in the details view
*/
public function iSeeThatTheFileIsNotMarkedAsFavoriteInTheDetailsView() {
PHPUnit_Framework_Assert::assertNotNull(
$this->actor->find(self::notFavoritedStateIconInFileDetailsInDetailsView(), 10));
}
/** /**
* @Then I see that the input field for tags in the details view is shown * @Then I see that the input field for tags in the details view is shown
*/ */