@@ -5,15 +5,17 @@ import { ref, onMounted } from 'vue';
55import { BucketConfigForm , BucketSidebar , BucketTable } from ' @/components/bucket' ;
66import { Button , Dialog , Message } from ' @/lib/primevue' ;
77import { useAuthStore , useBucketStore , useConfigStore , usePermissionStore } from ' @/store' ;
8- import { BucketConfig } from ' @/utils/constants' ;
8+ import { bucketService } from ' @/services' ;
9+
10+ import { BucketConfig , Permissions } from ' @/utils/constants' ;
911import { onDialogHide } from ' @/utils/utils' ;
1012
1113import type { Ref } from ' vue' ;
1214import type { Bucket } from ' @/types' ;
1315
1416// Store
1517const bucketStore = useBucketStore ();
16- const { getUserId } = storeToRefs (useAuthStore ());
18+ const { getProfile, getUserId } = storeToRefs (useAuthStore ());
1719const { getConfig } = storeToRefs (useConfigStore ());
1820
1921// State
@@ -43,17 +45,31 @@ const closeBucketConfig = () => {
4345};
4446
4547onMounted (async () => {
48+ // fetch buckets with current user's READ permission (enforced by COMS privacy mode)
4649 const buckets = await bucketStore .fetchBuckets ({
4750 userId: getUserId .value ,
4851 objectPerms: true
4952 });
50- // get IDP permissions for labelling in table
53+ // get all subfolders of each bucket based on current users IDP
54+ // so they shpw up in the folder tree
5155 if (buckets && buckets .length > 0 && usePermissionStore ().isUserElevatedRights ()) {
52- await usePermissionStore ().fetchBucketIdpPermissions ({
53- // limit to 1000 folders
54- bucketId: buckets .slice (0 , 1000 ).map ((b ) => b .bucketId ),
55- idp: ' idir' ,
56- objectPerms: true
56+ const uniqueBuckets = buckets .filter (
57+ (b , i , arr ) => arr .findIndex ((item ) => item .bucket === b .bucket && item .endpoint === b .endpoint ) === i
58+ );
59+ uniqueBuckets .forEach (async (bucket ) => {
60+ const allFolders = (
61+ await bucketService .searchBuckets ({
62+ endpoint: bucket .endpoint ,
63+ bucket: bucket .bucket
64+ })
65+ ).data ;
66+ await bucketStore .fetchBuckets ({
67+ bucketId: allFolders .slice (0 , 1000 ).map ((b : any ) => b .bucketId ),
68+ userId: getUserId .value ,
69+ idp: (getProfile .value as any )?.identity_provider ,
70+ permCode: Permissions .READ ,
71+ objectPerms: true
72+ });
5773 });
5874 }
5975});
0 commit comments