sanity 6.6.0-next.36 → 6.6.0-next.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/_chunks-es/index2.js
CHANGED
|
@@ -81434,6 +81434,18 @@ const INITIAL_STATE$1 = {
|
|
|
81434
81434
|
error: null,
|
|
81435
81435
|
loading: !0
|
|
81436
81436
|
};
|
|
81437
|
+
async function hasPermissionFromAnyGrant(userId, grants, permission, documentValue) {
|
|
81438
|
+
return documentValue ? (await Promise.all(grants.map(async (grant) => {
|
|
81439
|
+
try {
|
|
81440
|
+
const {
|
|
81441
|
+
granted
|
|
81442
|
+
} = await grantsPermissionOn(userId, [grant], permission, documentValue);
|
|
81443
|
+
return granted;
|
|
81444
|
+
} catch {
|
|
81445
|
+
return !1;
|
|
81446
|
+
}
|
|
81447
|
+
}))).some(Boolean) : !0;
|
|
81448
|
+
}
|
|
81437
81449
|
function useUserListWithPermissions(opts) {
|
|
81438
81450
|
const $ = c(21), {
|
|
81439
81451
|
documentValue,
|
|
@@ -81461,9 +81473,7 @@ function useUserListWithPermissions(opts) {
|
|
|
81461
81473
|
let t42;
|
|
81462
81474
|
$[15] !== documentValue || $[16] !== permission ? (t42 = async (t52) => {
|
|
81463
81475
|
const [users_0, groups] = t52, grantPromises = users_0?.map(async (user_0) => {
|
|
81464
|
-
const flattenedGrants = [...groups.map((group2) => group2.members?.includes(user_0.id) ? group2.grants : [])].flat(),
|
|
81465
|
-
granted
|
|
81466
|
-
} = await grantsPermissionOn(user_0.id, flattenedGrants, permission, documentValue);
|
|
81476
|
+
const flattenedGrants = [...groups.map((group2) => group2.members?.includes(user_0.id) ? group2.grants : [])].flat(), granted = await hasPermissionFromAnyGrant(user_0.id, flattenedGrants, permission, documentValue);
|
|
81467
81477
|
return {
|
|
81468
81478
|
...user_0,
|
|
81469
81479
|
granted
|