debian-mirror-gitlab/app/assets/javascripts/projects/settings/utils.js
2023-04-23 21:23:45 +05:30

17 lines
556 B
JavaScript

export const getAccessLevels = (accessLevels = {}) => {
const total = accessLevels.edges?.length;
const accessLevelTypes = { total, users: [], groups: [], roles: [] };
accessLevels.edges?.forEach(({ node }) => {
if (node.user) {
const src = node.user.avatarUrl;
accessLevelTypes.users.push({ src, ...node.user });
} else if (node.group) {
accessLevelTypes.groups.push(node);
} else {
accessLevelTypes.roles.push({ accessLevelDescription: node.accessLevelDescription });
}
});
return accessLevelTypes;
};