Skip to content

Commit

Permalink
Sort collaborators column, deduplicate public
Browse files Browse the repository at this point in the history
Sort the collaborators by share type (user, group, remote, link) and by
display name.
Deduplicate the public link entry so it only appears once in the column.
  • Loading branch information
Vincent Petry committed Mar 11, 2020
1 parent 3d4a264 commit 539434f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
28 changes: 27 additions & 1 deletion apps/files/src/components/Collaborators/SharedFilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</div>
<div><!-- indicators column --></div>
<div key="shared-with-cell" v-if="!$_isSharedWithMe" class="uk-visible@s uk-text-meta uk-text-nowrap uk-text-truncate uk-width-medium uk-flex file-row-collaborators">
<span v-for="share in item.shares" :key="share.id" class="uk-margin-small-right uk-flex uk-flex-middle">
<span v-for="share in prepareCollaborators(item.shares)" :key="share.id" class="uk-margin-small-right uk-flex uk-flex-middle">
<avatar-image :key="'avatar-' + share.id" v-if="share.shareType === shareTypes.user && share.collaborator" class="uk-margin-xsmall-right" :width="24" :userid="share.collaborator.name" :userName="share.collaborator.displayName" />
<oc-icon
v-else
Expand Down Expand Up @@ -84,6 +84,7 @@ import FileList from '../FileList.vue'
import NoContentMessage from '../NoContentMessage.vue'
import SortableColumnHeader from '../FilesLists/SortableColumnHeader.vue'
import { shareTypes } from '../../helpers/shareTypes'
import { naturalSortCompare } from '../../helpers/textUtils'
export default {
name: 'SharedFilesList',
Expand Down Expand Up @@ -136,6 +137,31 @@ export default {
methods: {
...mapActions('Files', ['loadFolderSharedFromMe', 'loadFolderSharedWithMe', 'setFilterTerm', 'pendingShare']),
prepareCollaborators (shares) {
let hasLink = false
const results = []
shares.forEach(share => {
if (share.shareType === shareTypes.link) {
if (!hasLink) {
results.push(share)
hasLink = true
}
} else {
results.push(share)
}
})
return results.sort((s1, s2) => {
if (s1.shareType !== s2.shareType) {
// sort by share type: user, group, remote, link
return s1.shareType - s2.shareType
}
if (!s1.collaborator) {
return 0
}
return naturalSortCompare(s1.collaborator.displayName, s2.collaborator.displayName)
})
},
$_shareTypeIcon (type) {
switch (type) {
case shareTypes.user: return 'person'
Expand Down
9 changes: 9 additions & 0 deletions changelog/unreleased/3137
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Bugfix: Sorted collaborators column, deduplicate public entry

The collaborators appears a the column in the "shared with others"
section are now sorted: first by share type (user, group, remote, link) and then by
display name using natural sort.
Additionally, if there is more than one public link for the resource, the text "Public"
only appears once in the collaborators column.

https://github.com/owncloud/phoenix/issues/3137
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,13 @@ Feature: Share by public link
Scenario: user shares a file through public link and then it appears in a shared-with-others page
Given the setting "shareapi_allow_public_notification" of app "core" has been set to "yes"
And user "user1" has shared folder "simple-folder" with link with "read, update, create, delete" permissions
And user "user1" has shared folder "simple-folder" with link with "read" permissions
And user "user1" has logged in using the webUI
When the user browses to the shared-with-others page
Then folder "simple-folder" should be listed on the webUI
And the following resources should have the following collaborators
| fileName | expectedCollaborators |
| simple-folder | Public |

Scenario: user edits the password of an already existing public link
Given user "user1" has shared folder "simple-folder" with link with "read, update, create, delete" permissions and password "pass123"
Expand Down

0 comments on commit 539434f

Please sign in to comment.