Welcome to mirror list, hosted at ThFree Co, Russian Federation.

utils.js « user_deletion_obstacles « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 502302a1ef2d3c4895cb7c53d635513f659931b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { OBSTACLE_TYPES } from './constants';

const addTypeToObstacles = (obstacles, type) => {
  if (!obstacles) return [];

  return obstacles?.map((obstacle) => ({ type, ...obstacle }));
};

// For use with user objects formatted via internal REST API.
// If the removal/deletion of a user could cause critical
// problems, return a single array containing all affected
// associations including their type.
export const parseUserDeletionObstacles = (user) => {
  if (!user) return [];

  return Object.keys(OBSTACLE_TYPES).flatMap((type) => {
    return addTypeToObstacles(user[type], OBSTACLE_TYPES[type]);
  });
};