Skip to content

Commit b6623a2

Browse files
committed
Fix idp toggle state
1 parent 50c6b7f commit b6623a2

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

frontend/src/components/bucket/BucketIdpToggle.vue

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,25 @@ onMounted(async () => {
105105
bucket: bucket.bucket
106106
})
107107
).data;
108-
// get closest parent (longest key that is a substring of current bucket key)
109-
const parent = responseArray
110-
.filter((p: any) => {
111-
return (
112-
p.key !== bucket.key && // exclude current bucket
113-
// key is parent if current bucket key starts with parent key (or parent is root with key of '/')
114-
(bucket.key.startsWith(p.key) || p.key === '/')
115-
);
116-
})
117-
.reduce((a: any, b: any) => (a.key.length > b.key.length ? a : b));
118-
// fetch bucketIdpPermissions for parent
119-
await permissionStore.fetchBucketIdpPermissions({
120-
bucketId: parent.bucketId,
121-
permCode: Permissions.READ,
122-
idp: 'idir'
108+
109+
// Filter for parent buckets
110+
const parentBuckets = responseArray.filter((p: any) => {
111+
return (
112+
p.key !== bucket.key && // exclude current bucket
113+
(bucket.key.startsWith(p.key) || p.key === '/') // is parent if current starts with it
114+
);
123115
});
124-
isParentBucketInternal.value = permissionStore.getBucketInternal(parent.bucketId);
116+
// Get closest parent by longest key match
117+
const parent = parentBuckets.sort((a: any, b: any) => b.key.length - a.key.length)[0];
118+
if (parent) {
119+
// fetch bucketIdpPermissions for parent
120+
await permissionStore.fetchBucketIdpPermissions({
121+
bucketId: parent.bucketId,
122+
permCode: Permissions.READ,
123+
idp: 'idir'
124+
});
125+
isParentBucketInternal.value = permissionStore.getBucketInternal(parent.bucketId);
126+
}
125127
}
126128
}
127129
isInternal.value = isInternalState.value;

0 commit comments

Comments
 (0)