Fix hidden folders/collections (#9207) (#10005)

Show parent folders/collections if user has at least one permission to child collection (#9207)
This commit is contained in:
Alisher Nazarhanov
2021-11-25 04:24:52 +06:00
committed by GitHub
parent 19906d0501
commit 05e69ecabd
2 changed files with 18 additions and 1 deletions

View File

@@ -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);
});

View File

@@ -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 = {