Skip to content

Commit

Permalink
Display current user in collaborators list
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasHirt committed Feb 18, 2020
1 parent f59ab0d commit c78f71f
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 9 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 } 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 = 1
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 @@ -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 he is 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 he is 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 his 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 @@ -355,7 +355,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 @@ -365,6 +365,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 c78f71f

Please sign in to comment.