aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-08-21 00:05:51 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-08-21 07:55:24 +0000
commitdd30146ce9ff24f32d23190d32adac5f8f896f76 (patch)
tree3ebc56f1f78f5b47ce163c6b738bdfbf9e2acc75 /apps/files_sharing
parent629bd67dabdfc5866e4459c7663627e911db484b (diff)
downloadnextcloud-server-dd30146ce9ff24f32d23190d32adac5f8f896f76.tar.gz
nextcloud-server-dd30146ce9ff24f32d23190d32adac5f8f896f76.zip
fix(files_sharing): Sort by correct share attribute ("share with displayname")
There is no `title` attribute, so this causes an exception. Instead sort by the "share with" displayname which will be the user or group the node is shared to. Meaning this will also be the title of the share in the UI. If this is not available or there are multiple for the same, then sort by the custom label. If also this is not set sort by the creation time. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de> [skip ci]
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/src/views/SharingTab.vue29
1 files changed, 16 insertions, 13 deletions
diff --git a/apps/files_sharing/src/views/SharingTab.vue b/apps/files_sharing/src/views/SharingTab.vue
index 0d991fa3982..318b8ca3b56 100644
--- a/apps/files_sharing/src/views/SharingTab.vue
+++ b/apps/files_sharing/src/views/SharingTab.vue
@@ -82,11 +82,12 @@
</template>
<script>
-import { CollectionList } from 'nextcloud-vue-collections'
-import { generateOcsUrl } from '@nextcloud/router'
-import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
import axios from '@nextcloud/axios'
+import { orderBy } from '@nextcloud/files'
import { loadState } from '@nextcloud/initial-state'
+import { generateOcsUrl } from '@nextcloud/router'
+import { CollectionList } from 'nextcloud-vue-collections'
+import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
import Config from '../services/ConfigService.ts'
import { shareWithTitle } from '../utils/SharedWithMe.js'
@@ -260,16 +261,18 @@ export default {
*/
processShares({ data }) {
if (data.ocs && data.ocs.data && data.ocs.data.length > 0) {
- // create Share objects and sort by title in alphabetical order and then by creation time
- const shares = data.ocs.data
- .map(share => new Share(share))
- .sort((a, b) => {
- const localCompare = a.title.localeCompare(b.title)
- if (localCompare !== 0) {
- return localCompare
- }
- return b.createdTime - a.createdTime
- })
+ const shares = orderBy(
+ data.ocs.data.map(share => new Share(share)),
+ [
+ // First order by the "share with" label
+ (share) => share.shareWithDisplayName,
+ // Then by the label
+ (share) => share.label,
+ // And last resort order by createdTime
+ (share) => share.createdTime,
+ ],
+ )
+
this.linkShares = shares.filter(share => share.type === this.SHARE_TYPES.SHARE_TYPE_LINK || share.type === this.SHARE_TYPES.SHARE_TYPE_EMAIL)
this.shares = shares.filter(share => share.type !== this.SHARE_TYPES.SHARE_TYPE_LINK && share.type !== this.SHARE_TYPES.SHARE_TYPE_EMAIL)