UNPKG

@websolutespa/payload-plugin-bowl

Version:

Bowl PayloadCms plugin of the BOM Repository

27 lines (26 loc) 743 B
import { deepMerge } from '@websolutespa/payload-utils'; import { options } from '../../options'; import { isAdmin } from '../access'; export const UserRolesDefaults = { name: 'roles', type: 'select', hasMany: true, options: [], required: true, access: { create: isAdmin, update: isAdmin } }; export const withRoles = ({ roles, ...fieldOptions } = {})=>{ const field = UserRolesDefaults; roles = roles || options.rolesList; field.options = Object.entries(options.roles).filter(([k, v])=>{ return roles.includes(v); }).map(([k, v])=>({ value: v, label: k })); return deepMerge(field, fieldOptions); }; //# sourceMappingURL=withRoles.js.map