Skip to content

Commit 1102b9d

Browse files
committed
fix: the account files filter should also work in trashbin
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent bc2321d commit 1102b9d

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

apps/files/src/components/FileListFilter/FileListFilter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ defineEmits<{
4040

4141
<style scoped>
4242
.files-list-filter__clear-button :deep(.action-button__text) {
43-
color: var(--color-error-text);
43+
color: var(--color-text-error, var(--color-error-text));
4444
}
4545
4646
:deep(.button-vue) {

apps/files_sharing/src/files_filters/AccountFilter.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Vue from 'vue'
1111

1212
import FileListFilterAccount from '../components/FileListFilterAccount.vue'
1313
import { isPublicShare } from '@nextcloud/sharing/public'
14+
import { TRASHBIN_VIEW_ID } from '../../../files_trashbin/src/files_views/trashbinView'
1415

1516
export interface IAccountData {
1617
uid: string
@@ -62,19 +63,30 @@ class AccountFilter extends FileListFilter {
6263
const userIds = this.filterAccounts.map(({ uid }) => uid)
6364
// Filter if the owner of the node is in the list of filtered accounts
6465
return nodes.filter((node) => {
65-
const sharees = node.attributes.sharees?.sharee as { id: string }[] | undefined
66-
// If the node provides no information lets keep it
67-
if (!node.owner && !sharees) {
68-
return true
66+
if (window.OCP.Files.Router.params.view === TRASHBIN_VIEW_ID) {
67+
const deletedBy = node.attributes?.['trashbin-deleted-by-id']
68+
if (deletedBy && userIds.includes(deletedBy)) {
69+
return true
70+
}
71+
return false
6972
}
73+
7074
// if the owner matches
7175
if (node.owner && userIds.includes(node.owner)) {
7276
return true
7377
}
78+
7479
// Or any of the sharees (if only one share this will be an object, otherwise an array. So using `.flat()` to make it always an array)
80+
const sharees = node.attributes.sharees?.sharee as { id: string }[] | undefined
7581
if (sharees && [sharees].flat().some(({ id }) => userIds.includes(id))) {
7682
return true
7783
}
84+
85+
// If the node provides no information lets keep it
86+
if (!node.owner && !sharees) {
87+
return true
88+
}
89+
7890
// Not a valid node for the current filter
7991
return false
8092
})
@@ -139,6 +151,15 @@ class AccountFilter extends FileListFilter {
139151
})
140152
}
141153
}
154+
155+
// lets also handle trashbin
156+
const deletedBy = node.attributes?.['trashbin-deleted-by-id']
157+
if (deletedBy) {
158+
available.set(deletedBy, {
159+
uid: deletedBy,
160+
displayName: node.attributes?.['trashbin-deleted-by-display-name'] || deletedBy,
161+
})
162+
}
142163
}
143164

144165
this.availableAccounts = [...available.values()]

0 commit comments

Comments
 (0)