Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort collaborators column, deduplicate public #3171

Merged
merged 1 commit into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 38 additions & 5 deletions apps/files/src/components/Collaborators/SharedFilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@
key="shared-with-cell"
class="uk-visible@s uk-text-meta uk-text-nowrap uk-text-truncate uk-width-medium uk-flex file-row-collaborators uk-flex-right"
>
<span
v-for="share in item.shares"
:key="share.id"
class="uk-margin-small-left 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 @@ -117,6 +113,7 @@ import FileList from '../FileList.vue'
import NoContentMessage from '../NoContentMessage.vue'
import SortableColumnHeader from '../FilesLists/SortableColumnHeader.vue'
import { shareTypes } from '../../helpers/shareTypes'
import { textUtils } from '../../helpers/textUtils'

export default {
name: 'SharedFilesList',
Expand Down Expand Up @@ -169,6 +166,42 @@ export default {
methods: {
...mapActions('Files', ['loadFolderSharedFromMe', 'loadFolderSharedWithMe', 'setFilterTerm', 'pendingShare']),

/**
* Prepare the given collaboratoes list for display.
* Sorts first by share type (user, group, link, remote)
* and then by the collaborator's display name using natural
* sort. Public links entries are deduplicated into a single
* one in order to only show "Public" once even when
* there are multiple link shares.
*
* @param {Array.<Object>} shares shares to sort
* @return {Array.<Object>} sorted shares
*/
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, link, remote
return s1.shareType - s2.shareType
}
if (!s1.collaborator) {
return 0
}
return textUtils.naturalSortCompare(s1.collaborator.displayName, s2.collaborator.displayName)
})
},

$_shareTypeIcon (type) {
switch (type) {
case shareTypes.user: return 'person'
Expand Down
10 changes: 10 additions & 0 deletions changelog/unreleased/3137
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Bugfix: Sorted collaborators column, deduplicate public entry

The collaborators column that appears in the "shared with others"
section are now sorted: first by share type (user, group, link, remote) 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
https://github.com/owncloud/phoenix/pull/3171
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