Merge pull request #21574 from nextcloud/backport/21379/stable19
[stable19] Fix share permission checkboxes enabled when permissions can not be set
This commit is contained in:
commit
62f71a04d2
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -40,7 +40,7 @@
|
|||
ref="canEdit"
|
||||
:checked.sync="canEdit"
|
||||
:value="permissionsEdit"
|
||||
:disabled="saving">
|
||||
:disabled="saving || !canSetEdit">
|
||||
{{ t('files_sharing', 'Allow editing') }}
|
||||
</ActionCheckbox>
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
|||
ref="canCreate"
|
||||
:checked.sync="canCreate"
|
||||
:value="permissionsCreate"
|
||||
:disabled="saving">
|
||||
:disabled="saving || !canSetCreate">
|
||||
{{ t('files_sharing', 'Allow creating') }}
|
||||
</ActionCheckbox>
|
||||
|
||||
|
@ -60,7 +60,7 @@
|
|||
ref="canDelete"
|
||||
:checked.sync="canDelete"
|
||||
:value="permissionsDelete"
|
||||
:disabled="saving">
|
||||
:disabled="saving || !canSetDelete">
|
||||
{{ t('files_sharing', 'Allow deleting') }}
|
||||
</ActionCheckbox>
|
||||
|
||||
|
@ -69,7 +69,7 @@
|
|||
ref="canReshare"
|
||||
:checked.sync="canReshare"
|
||||
:value="permissionsShare"
|
||||
:disabled="saving">
|
||||
:disabled="saving || !canSetReshare">
|
||||
{{ t('files_sharing', 'Allow resharing') }}
|
||||
</ActionCheckbox>
|
||||
|
||||
|
@ -216,6 +216,54 @@ export default {
|
|||
&& this.share.type !== this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP
|
||||
},
|
||||
|
||||
/**
|
||||
* Can the sharer set whether the sharee can edit the file ?
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
canSetEdit() {
|
||||
// If the owner revoked the permission after the resharer granted it
|
||||
// the share still has the permission, and the resharer is still
|
||||
// allowed to revoke it too (but not to grant it again).
|
||||
return (this.fileInfo.sharePermissions & OC.PERMISSION_UPDATE) || this.canEdit
|
||||
},
|
||||
|
||||
/**
|
||||
* Can the sharer set whether the sharee can create the file ?
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
canSetCreate() {
|
||||
// If the owner revoked the permission after the resharer granted it
|
||||
// the share still has the permission, and the resharer is still
|
||||
// allowed to revoke it too (but not to grant it again).
|
||||
return (this.fileInfo.sharePermissions & OC.PERMISSION_CREATE) || this.canCreate
|
||||
},
|
||||
|
||||
/**
|
||||
* Can the sharer set whether the sharee can delete the file ?
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
canSetDelete() {
|
||||
// If the owner revoked the permission after the resharer granted it
|
||||
// the share still has the permission, and the resharer is still
|
||||
// allowed to revoke it too (but not to grant it again).
|
||||
return (this.fileInfo.sharePermissions & OC.PERMISSION_DELETE) || this.canDelete
|
||||
},
|
||||
|
||||
/**
|
||||
* Can the sharer set whether the sharee can reshare the file ?
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
canSetReshare() {
|
||||
// If the owner revoked the permission after the resharer granted it
|
||||
// the share still has the permission, and the resharer is still
|
||||
// allowed to revoke it too (but not to grant it again).
|
||||
return (this.fileInfo.sharePermissions & OC.PERMISSION_SHARE) || this.canReshare
|
||||
},
|
||||
|
||||
/**
|
||||
* Can the sharee edit the shared file ?
|
||||
*/
|
||||
|
|
|
@ -294,3 +294,86 @@ Feature: app-files-sharing
|
|||
And I open the "Sharing" tab in the details view
|
||||
And I see that the "Sharing" tab in the details view is eventually loaded
|
||||
And I see that resharing the file is not allowed
|
||||
|
||||
Scenario: sharee can not reshare a file with edit permission if the sharer disables it
|
||||
Given I act as John
|
||||
And I am logged in as the admin
|
||||
And I act as Jane
|
||||
And I am logged in
|
||||
And I act as John
|
||||
And I rename "welcome.txt" to "farewell.txt"
|
||||
And I see that the file list contains a file named "farewell.txt"
|
||||
And I share "farewell.txt" with "user0"
|
||||
And I see that the file is shared with "user0"
|
||||
And I set the share with "user0" as not editable
|
||||
And I see that "user0" can not edit the share
|
||||
When I act as Jane
|
||||
# The Files app is open again to reload the file list
|
||||
And I open the Files app
|
||||
And I share "farewell.txt" with "user1"
|
||||
Then I see that the file is shared with "user1"
|
||||
And I see that "user1" can not edit the share
|
||||
And I see that "user1" can not be allowed to edit the share
|
||||
|
||||
Scenario: sharee can not reshare a folder with create permission if the sharer disables it
|
||||
Given I act as John
|
||||
And I am logged in as the admin
|
||||
And I act as Jane
|
||||
And I am logged in
|
||||
And I act as John
|
||||
And I create a new folder named "Shared folder"
|
||||
And I see that the file list contains a file named "Shared folder"
|
||||
And I share "Shared folder" with "user0"
|
||||
And I see that the file is shared with "user0"
|
||||
And I set the share with "user0" as not creatable
|
||||
And I see that "user0" can not create in the share
|
||||
When I act as Jane
|
||||
# The Files app is open again to reload the file list
|
||||
And I open the Files app
|
||||
And I share "Shared folder" with "user1"
|
||||
Then I see that the file is shared with "user1"
|
||||
And I see that "user1" can not create in the share
|
||||
And I see that "user1" can not be allowed to create in the share
|
||||
|
||||
Scenario: sharee can revoke create permission from reshare after the sharer disabled it
|
||||
Given I act as John
|
||||
And I am logged in as the admin
|
||||
And I act as Jane
|
||||
And I am logged in
|
||||
And I act as Jim
|
||||
And I am logged in as "user1"
|
||||
And I act as John
|
||||
And I create a new folder named "Shared folder"
|
||||
And I see that the file list contains a file named "Shared folder"
|
||||
And I share "Shared folder" with "user0"
|
||||
And I see that the file is shared with "user0"
|
||||
And I act as Jane
|
||||
# The Files app is open again to reload the file list
|
||||
And I open the Files app
|
||||
And I share "Shared folder" with "user1"
|
||||
And I see that the file is shared with "user1"
|
||||
And I act as John
|
||||
And I set the share with "user0" as not creatable
|
||||
And I see that "user0" can not create in the share
|
||||
And I act as Jim
|
||||
# The Files app is open again to reload the file list
|
||||
And I open the Files app
|
||||
And I enter in the folder named "Shared folder"
|
||||
# Creation is still allowed in already created reshares
|
||||
And I create a new folder named "Subfolder"
|
||||
And I see that the file list contains a file named "Subfolder"
|
||||
When I act as Jane
|
||||
# The Files app is open again to reload the file list
|
||||
And I open the Files app
|
||||
And I open the details view for "Shared folder"
|
||||
And I see that the details view is open
|
||||
And I open the "Sharing" tab in the details view
|
||||
And I see that the "Sharing" tab in the details view is eventually loaded
|
||||
And I set the share with "user1" as not creatable
|
||||
Then I see that "user1" can not create in the share
|
||||
And I see that "user1" can not be allowed to create in the share
|
||||
And I act as Jim
|
||||
# The Files app is open again to reload the file list
|
||||
And I open the Files app
|
||||
And I enter in the folder named "Shared folder"
|
||||
And I see that it is not possible to create new files
|
||||
|
|
|
@ -103,22 +103,64 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
|
|||
/**
|
||||
* @return Locator
|
||||
*/
|
||||
public static function canReshareCheckbox($sharedWithName) {
|
||||
// forThe()->checkbox("Can reshare") can not be used here; that would
|
||||
// return the checkbox itself, but the element that the user interacts
|
||||
// with is the label.
|
||||
return Locator::forThe()->xpath("//label[normalize-space() = 'Allow resharing']")->
|
||||
public static function permissionCheckboxFor($sharedWithName, $itemText) {
|
||||
// forThe()->checkbox($itemText) can not be used here; that would return
|
||||
// the checkbox itself, but the element that the user interacts with is
|
||||
// the label.
|
||||
return Locator::forThe()->xpath("//label[normalize-space() = '$itemText']")->
|
||||
descendantOf(self::shareWithMenu($sharedWithName))->
|
||||
describedAs("Allow resharing checkbox in the share with $sharedWithName menu in the details view in Files app");
|
||||
describedAs("$itemText checkbox in the share with $sharedWithName menu in the details view in Files app");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Locator
|
||||
*/
|
||||
public static function permissionCheckboxInputFor($sharedWithName, $itemText) {
|
||||
return Locator::forThe()->checkbox($itemText)->
|
||||
descendantOf(self::shareWithMenu($sharedWithName))->
|
||||
describedAs("$itemText checkbox input in the share with $sharedWithName menu in the details view in Files app");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Locator
|
||||
*/
|
||||
public static function canEditCheckbox($sharedWithName) {
|
||||
return self::permissionCheckboxFor($sharedWithName, 'Allow editing');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Locator
|
||||
*/
|
||||
public static function canEditCheckboxInput($sharedWithName) {
|
||||
return self::permissionCheckboxInputFor($sharedWithName, 'Allow editing');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Locator
|
||||
*/
|
||||
public static function canCreateCheckbox($sharedWithName) {
|
||||
return self::permissionCheckboxFor($sharedWithName, 'Allow creating');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Locator
|
||||
*/
|
||||
public static function canCreateCheckboxInput($sharedWithName) {
|
||||
return self::permissionCheckboxInputFor($sharedWithName, 'Allow creating');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Locator
|
||||
*/
|
||||
public static function canReshareCheckbox($sharedWithName) {
|
||||
return self::permissionCheckboxFor($sharedWithName, 'Allow resharing');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Locator
|
||||
*/
|
||||
public static function canReshareCheckboxInput($sharedWithName) {
|
||||
return Locator::forThe()->checkbox("Allow resharing")->
|
||||
descendantOf(self::shareWithMenu($sharedWithName))->
|
||||
describedAs("Allow resharing checkbox input in the share with $sharedWithName menu in the details view in Files app");
|
||||
return self::permissionCheckboxInputFor($sharedWithName, 'Allow resharing');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -358,6 +400,28 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
|
|||
$this->actor->find(self::passwordProtectByTalkCheckbox(), 2)->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I set the share with :shareWithName as not editable
|
||||
*/
|
||||
public function iSetTheShareWithAsNotEditable($shareWithName) {
|
||||
$this->showShareWithMenuIfNeeded($shareWithName);
|
||||
|
||||
$this->iSeeThatCanEditTheShare($shareWithName);
|
||||
|
||||
$this->actor->find(self::canEditCheckbox($shareWithName), 2)->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I set the share with :shareWithName as not creatable
|
||||
*/
|
||||
public function iSetTheShareWithAsNotCreatable($shareWithName) {
|
||||
$this->showShareWithMenuIfNeeded($shareWithName);
|
||||
|
||||
$this->iSeeThatCanCreateInTheShare($shareWithName);
|
||||
|
||||
$this->actor->find(self::canCreateCheckbox($shareWithName), 2)->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I set the share with :shareWithName as not reshareable
|
||||
*/
|
||||
|
@ -395,6 +459,66 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
|
|||
$this->actor->find(self::shareWithInput(), 10)->getWrappedElement()->getAttribute("placeholder"), "Resharing is not allowed");
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I see that :sharedWithName can not be allowed to edit the share
|
||||
*/
|
||||
public function iSeeThatCanNotBeAllowedToEditTheShare($sharedWithName) {
|
||||
$this->showShareWithMenuIfNeeded($sharedWithName);
|
||||
|
||||
PHPUnit_Framework_Assert::assertEquals(
|
||||
$this->actor->find(self::canEditCheckboxInput($sharedWithName), 10)->getWrappedElement()->getAttribute("disabled"), "disabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I see that :sharedWithName can edit the share
|
||||
*/
|
||||
public function iSeeThatCanEditTheShare($sharedWithName) {
|
||||
$this->showShareWithMenuIfNeeded($sharedWithName);
|
||||
|
||||
PHPUnit_Framework_Assert::assertTrue(
|
||||
$this->actor->find(self::canEditCheckboxInput($sharedWithName), 10)->isChecked());
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I see that :sharedWithName can not edit the share
|
||||
*/
|
||||
public function iSeeThatCanNotEditTheShare($sharedWithName) {
|
||||
$this->showShareWithMenuIfNeeded($sharedWithName);
|
||||
|
||||
PHPUnit_Framework_Assert::assertFalse(
|
||||
$this->actor->find(self::canEditCheckboxInput($sharedWithName), 10)->isChecked());
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I see that :sharedWithName can not be allowed to create in the share
|
||||
*/
|
||||
public function iSeeThatCanNotBeAllowedToCreateInTheShare($sharedWithName) {
|
||||
$this->showShareWithMenuIfNeeded($sharedWithName);
|
||||
|
||||
PHPUnit_Framework_Assert::assertEquals(
|
||||
$this->actor->find(self::canCreateCheckboxInput($sharedWithName), 10)->getWrappedElement()->getAttribute("disabled"), "disabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I see that :sharedWithName can create in the share
|
||||
*/
|
||||
public function iSeeThatCanCreateInTheShare($sharedWithName) {
|
||||
$this->showShareWithMenuIfNeeded($sharedWithName);
|
||||
|
||||
PHPUnit_Framework_Assert::assertTrue(
|
||||
$this->actor->find(self::canCreateCheckboxInput($sharedWithName), 10)->isChecked());
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I see that :sharedWithName can not create in the share
|
||||
*/
|
||||
public function iSeeThatCanNotCreateInTheShare($sharedWithName) {
|
||||
$this->showShareWithMenuIfNeeded($sharedWithName);
|
||||
|
||||
PHPUnit_Framework_Assert::assertFalse(
|
||||
$this->actor->find(self::canCreateCheckboxInput($sharedWithName), 10)->isChecked());
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I see that :sharedWithName can reshare the share
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue