Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | 140x 398x 398x 398x 398x 398x 398x 398x 398x 398x 398x 398x | import RESOURCE_BASE, { OPERATIONS } from "@constants/permissions";
import {
composePermission,
useAccessControl,
} from "features/Permissions/AccessControl";
const useTeamPermissions = () => {
const isListAllowed = useAccessControl({
resource: RESOURCE_BASE.MEMBER,
operation: OPERATIONS.LIST,
withPortal: true,
});
const isReadAllowed = useAccessControl({
resource: RESOURCE_BASE.MEMBER,
operation: OPERATIONS.READ,
withPortal: true,
});
const isAddAllowed = useAccessControl({
resource: RESOURCE_BASE.MEMBER,
operation: OPERATIONS.CREATE,
withPortal: true,
});
const isEditAllowed = useAccessControl({
resource: RESOURCE_BASE.MEMBER,
operation: OPERATIONS.UPDATE,
withPortal: true,
});
const isDeleteAllowed = useAccessControl({
resource: RESOURCE_BASE.MEMBER,
operation: OPERATIONS.DELETE,
withPortal: true,
});
const isDeleteOwnerAllowed = useAccessControl({
resource: RESOURCE_BASE.OWNER,
operation: OPERATIONS.DELETE,
withPortal: true,
});
const isInviteAllowed = useAccessControl({
resource: RESOURCE_BASE.INVITE,
operation: OPERATIONS.CREATE,
withPortal: true,
});
const isListAccessPoliciesAllowed = useAccessControl({
resource: composePermission(
RESOURCE_BASE.MEMBER,
RESOURCE_BASE.ACCESS_POLICIES,
),
operation: OPERATIONS.LIST,
withPortal: true,
});
/**
* `member:access-policy update` — the gate on a member's assigned-events set
* (`PATCH /accounts/{id}/members/{id}/products`), seeded as "Edit Merchant
* Team Member Permissions". Assigning an event to a host writes that set, so
* the Assign Host modal's actions carry this rather than `member:update`.
*/
const isUpdateAccessPolicyAllowed = useAccessControl({
resource: composePermission(
RESOURCE_BASE.MEMBER,
RESOURCE_BASE.ACCESS_POLICIES,
),
operation: OPERATIONS.UPDATE,
withPortal: true,
});
const isAttachAccessPolicyAllowed = useAccessControl({
resource: composePermission(
RESOURCE_BASE.MEMBER,
RESOURCE_BASE.ACCESS_POLICIES,
),
operation: OPERATIONS.ATTACH,
withPortal: true,
});
return {
isAddAllowed,
isEditAllowed,
isDeleteAllowed,
isInviteAllowed,
isListAllowed,
isListAccessPoliciesAllowed,
isDeleteOwnerAllowed,
isAttachAccessPolicyAllowed,
isUpdateAccessPolicyAllowed,
isReadAllowed,
};
};
export default useTeamPermissions;
|