Skip to content

Commit

Permalink
Merge pull request #3060 from owncloud/feature/current-user-in-collab…
Browse files Browse the repository at this point in the history
…orators

Display current user in collaborators list
  • Loading branch information
Vincent Petry authored Feb 20, 2020
2 parents 1c90c16 + 9556412 commit 00768e4
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 20 deletions.
7 changes: 7 additions & 0 deletions apps/files/src/components/Collaborators/Collaborator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
<div class="oc-text">
<span class="files-collaborators-collaborator-name uk-text-bold">{{ collaborator.displayName }}</span>
<span v-if="$_shareType === shareTypes.user && collaborator.info.share_with_additional_info.length > 0" class="uk-text-meta files-collaborators-collaborator-additional-info">({{ collaborator.info.share_with_additional_info }})</span>
<translate
v-if="collaborator.name === user.id"
translate-comment="Indicator for current user in collaborators list"
class="uk-text-meta files-collaborators-collaborator-additional-info"
>
(me)
</translate>
</div>
<span class="oc-text"><span class="files-collaborators-collaborator-role">{{ originalRole.label }}</span><template v-if="collaborator.expires"> | <translate :translate-params="{expires: formDateFromNow(collaborator.expires)}">Expires: %{expires}</translate></template></span>
<span class="uk-text-meta files-collaborators-collaborator-share-type" v-text="$_ocCollaborators_collaboratorType(collaborator.info.share_type)" />
Expand Down
51 changes: 43 additions & 8 deletions apps/files/src/components/FileSharingSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@
v-else
v-text="noResharePermsMessage"
/>
<section v-if="$_ownerAndResharers.length > 0">
<section>
<ul class="uk-list uk-list-divider uk-overflow-hidden uk-margin-remove">
<li v-for="collaborator in $_ownerAndResharers" :key="collaborator.key">
<collaborator :collaborator="collaborator"/>
<template v-if="$_ownerAndResharers.length > 0">
<li v-for="collaborator in $_ownerAndResharers" :key="collaborator.key">
<collaborator :collaborator="collaborator"/>
</li>
</template>
<li>
<collaborator :collaborator="currentUserAsCollaborator"/>
</li>
</ul>
<hr class="uk-margin-small-top uk-margin-small-bottom" v-if="$_directOutgoingShares.length > 0 || $_indirectOutgoingShares.length > 0" />
Expand All @@ -41,9 +46,6 @@
</li>
</ul>
</section>
<div v-if="$_noCollaborators" key="oc-collaborators-no-results">
<translate>No collaborators</translate>
</div>
</template>
</div>
<div v-if="visiblePanel === PANEL_NEW" :key="PANEL_NEW">
Expand Down Expand Up @@ -73,6 +75,7 @@ import Mixins from '../mixins/collaborators'
import { textUtils } from '../helpers/textUtils'
import { shareTypes, userShareTypes } from '../helpers/shareTypes'
import { getParentPaths } from '../helpers/path'
import { bitmaskToRole, permissionsBitmask } from '../helpers/collaborators'
const NewCollaborator = _ => import('./Collaborators/NewCollaborator.vue')
const EditCollaborator = _ => import('./Collaborators/EditCollaborator.vue')
const Collaborator = _ => import('./Collaborators/Collaborator.vue')
Expand Down Expand Up @@ -128,8 +131,26 @@ export default {
return this.currentFileOutgoingSharesLoading && this.incomingSharesLoading
},
$_noCollaborators () {
return (this.$_ownerAndResharers.length + this.$_directOutgoingShares.length + this.$_indirectOutgoingShares.length) === 0
currentUserAsCollaborator () {
const permissions = this.currentUsersPermissions
const isFolder = this.highlightedFile.type === 'folder'
let role = { name: '' }
if (permissions > 0) {
role = bitmaskToRole(permissions, isFolder)
} else {
role.name = 'owner'
}
return {
name: this.user.id,
displayName: this.user.displayname,
info: {
share_type: 0,
share_with_additional_info: {}
},
role
}
},
$_ownerAndResharers () {
Expand Down Expand Up @@ -259,6 +280,20 @@ export default {
noResharePermsMessage () {
const translated = this.$gettext('You don\'t have permission to share this %{type}.')
return this.$gettextInterpolate(translated, { type: this.highlightedFile.type }, false)
},
currentUsersPermissions () {
if (this.incomingShares.length > 0) {
let permissions = permissionsBitmask.read
for (const share of this.incomingShares) {
permissions |= share.permissions
}
return permissions
}
return null
}
},
watch: {
Expand Down
6 changes: 6 additions & 0 deletions changelog/unreleased/3808
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Current user entry in collaborators list in sidebar

We've added a new entry into the collaborators list in sidebar which contains current user.

https://github.com/owncloud/phoenix/issues/3808
https://github.com/owncloud/phoenix/pull/3060
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Feature: Resharing shared files with different permissions
When the user shares folder "simple-folder (2)" with user "User Three" as "Advanced permissions" with permissions "share, delete" using the webUI
And the user re-logs in as "user3" using the webUI
And the user opens the share dialog for folder "simple-folder (2)" using the webUI
Then the current collaborators list should have order "User Two,User One"
Then the current collaborators list should have order "User Two,User One,User Three"
And user "User Two" should be listed as "Owner" in the collaborators list on the webUI
And user "User One" should be listed as "Resharer" in the collaborators list on the webUI
And user "user3" should have received a share with these details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ Feature: Sharing files with internal groups with permissions
| file_target | /lorem (2).txt |
| item_type | file |
| permissions | <actual-permissions> |
But user "User One" should not be listed in the collaborators list on the webUI
And group "grp1" should not be listed in the collaborators list on the webUI
But group "grp1" should not be listed in the collaborators list on the webUI
And as "user1" file "lorem (2).txt" should not exist
Examples:
| role | displayed-role | extra-permissions | displayed-permissions | actual-permissions |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ Feature: Sharing folders with internal groups with role as advanced permissions
| file_target | /simple-folder (2) |
| item_type | folder |
| permissions | <actual-permissions> |
But user "User One" should not be listed in the collaborators list on the webUI
And group "grp1" should not be listed in the collaborators list on the webUI
But group "grp1" should not be listed in the collaborators list on the webUI
And as "user1" folder "simple-folder (2)" should not exist
Examples:
| role | displayed-role | extra-permissions | displayed-permissions | actual-permissions |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ Feature: Sharing folders with internal groups with different roles and permissio
| file_target | /simple-folder (2) |
| item_type | folder |
| permissions | <actual-permissions> |
But user "User One" should not be listed in the collaborators list on the webUI
And group "grp1" should not be listed in the collaborators list on the webUI
But group "grp1" should not be listed in the collaborators list on the webUI
And as "user1" folder "simple-folder (2)" should not exist
Examples:
| role | displayed-role | extra-permissions | displayed-permissions | actual-permissions |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Feature: Sharing files and folders with internal groups
And the user shares folder "simple-folder" with user "User Two" as "Viewer" using the webUI
And the user shares folder "simple-folder" with group "grp1" as "Viewer" using the webUI
And the user shares folder "simple-folder" with user "User One" as "Viewer" using the webUI
Then the current collaborators list should have order "grp1,grp11,User One,User Two"
Then the current collaborators list should have order "User Three,grp1,grp11,User One,User Two"

Scenario Outline: share a file & folder with another internal user
Given user "user3" has logged in using the webUI
Expand Down Expand Up @@ -338,4 +338,4 @@ Feature: Sharing files and folders with internal groups
When the user opens the share dialog for folder "simple-empty-folder" using the webUI
Then user "User One" should be listed as "Owner" via "simple-folder (2)" in the collaborators list on the webUI
And user "User Two" should be listed as "Resharer" via "simple-folder (2)" in the collaborators list on the webUI
And the current collaborators list should have order "User One,User Two"
And the current collaborators list should have order "User One,User Two,User Three"
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ Feature: Sharing files and folders with internal users
When the user opens the share dialog for folder "simple-folder (2)" using the webUI
Then user "User One" should be listed as "Owner" in the collaborators list on the webUI
And user "User Two" should be listed as "Resharer" in the collaborators list on the webUI
And the current collaborators list should have order "User One,User Two"
And the current collaborators list should have order "User One,User Two,User Three"

@issue-2898
Scenario: see resource owner of parent shares in collaborators list
Expand All @@ -526,7 +526,7 @@ Feature: Sharing files and folders with internal users
When the user opens the share dialog for folder "simple-empty-folder" using the webUI
Then user "User One" should be listed as "Owner" via "simple-folder (2)" in the collaborators list on the webUI
And user "User Two" should be listed as "Resharer" via "simple-folder (2)" in the collaborators list on the webUI
And the current collaborators list should have order "User One,User Two"
And the current collaborators list should have order "User One,User Two,User Three"

@issue-2898
Scenario: see resource owner for direct shares in "shared with me"
Expand Down Expand Up @@ -563,3 +563,22 @@ Feature: Sharing files and folders with internal users
And the user opens the share dialog for folder "simple-folder" using the webUI
Then user "User Two" should be listed without additional info in the collaborators list on the webUI

Scenario: collaborators list contains the current user when they are an owner
Given user "user1" has shared folder "simple-folder" with user "user2"
When user "user1" has logged in using the webUI
And the user opens the share dialog for folder "simple-folder" using the webUI
Then user "User One" should be listed with additional info "(me)" in the collaborators list on the webUI

Scenario: collaborators list contains the current user when they are a receiver of the resource
Given user "user1" has shared folder "simple-folder" with user "user2"
When user "user2" has logged in using the webUI
And the user opens the share dialog for folder "simple-folder (2)" using the webUI
Then user "User Two" should be listed with additional info "(me)" in the collaborators list on the webUI

Scenario: current user should see the highest role in their entry in collaborators list
Given group "grp1" has been created
And user "user2" has been added to group "grp1"
And user "user1" has shared folder "simple-folder" with user "user2" with "read" permission
And user "user1" has shared folder "simple-folder" with group "grp1" with "read,update,create,delete" permissions
When user "user2" has logged in using the webUI
Then user "User Two" should be listed as "Editor" in the collaborators list for folder "simple-folder (2)" on the webUI
7 changes: 6 additions & 1 deletion tests/acceptance/stepDefinitions/sharingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ Given('the user has shared file/folder {string} with user {string}', function (e
})

Given(
'user {string} has shared file/folder {string} with user {string} with {string} permissions',
'user {string} has shared file/folder {string} with user {string} with {string} permission/permissions',
function (sharer, elementToShare, receiver, permissions) {
return shareFileFolder(elementToShare, sharer, receiver, SHARE_TYPES.user, permissions)
}
Expand All @@ -366,6 +366,11 @@ Given('user {string} has shared file/folder {string} with group {string}', funct
return shareFileFolder(elementToShare, sharer, receiver, SHARE_TYPES.group)
})

Given('user {string} has shared file/folder {string} with group {string} with {string} permission/permissions',
function (sharer, elementToShare, receiver, permissions) {
return shareFileFolder(elementToShare, sharer, receiver, SHARE_TYPES.group, permissions)
})

Given(
'user {string} has shared file/folder {string} with link with {string} permissions',
function (sharer, elementToShare, permissions) {
Expand Down

0 comments on commit 00768e4

Please sign in to comment.