mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Show parent folders/collections if user has at least one permission to child collection (#9207)
This commit is contained in:
committed by
GitHub
parent
19906d0501
commit
05e69ecabd
@@ -195,12 +195,28 @@ export class CollectionsService {
|
||||
meta.push(...systemCollectionRows);
|
||||
|
||||
if (this.accountability && this.accountability.admin !== true) {
|
||||
const collectionsYouHavePermissionToRead: string[] = this.accountability
|
||||
const collectionsGroups: { [key: string]: string } = meta.reduce(
|
||||
(meta, item) => ({
|
||||
...meta,
|
||||
[item.collection]: item.group,
|
||||
}),
|
||||
{}
|
||||
);
|
||||
|
||||
let collectionsYouHavePermissionToRead: string[] = this.accountability
|
||||
.permissions!.filter((permission) => {
|
||||
return permission.action === 'read';
|
||||
})
|
||||
.map(({ collection }) => collection);
|
||||
|
||||
for (const collection of collectionsYouHavePermissionToRead) {
|
||||
const group = collectionsGroups[collection];
|
||||
if (group) collectionsYouHavePermissionToRead.push(group);
|
||||
delete collectionsGroups[collection];
|
||||
}
|
||||
|
||||
collectionsYouHavePermissionToRead = [...new Set([...collectionsYouHavePermissionToRead])];
|
||||
|
||||
tablesInDatabase = tablesInDatabase.filter((table) => {
|
||||
return collectionsYouHavePermissionToRead.includes(table.name);
|
||||
});
|
||||
|
||||
@@ -10,6 +10,7 @@ export type CollectionMeta = {
|
||||
translations: Record<string, string>;
|
||||
item_duplication_fields: string[] | null;
|
||||
accountability: 'all' | 'accountability' | null;
|
||||
group: string | null;
|
||||
};
|
||||
|
||||
export type Collection = {
|
||||
|
||||
Reference in New Issue
Block a user