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

utils.js « ci_environments_dropdown « ci « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 093b04dab0c8b1972640472fe9e53dbdd35065ce (plain)
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
import { ALL_ENVIRONMENTS_OPTION, NO_ENVIRONMENT_OPTION } from './constants';

/**
 * This function job is to convert the * wildcard to text when applicable
 * in the UI. It uses a constants to compare the incoming value to that
 * of the * and then apply the corresponding label if applicable. If there
 * is no scope, then we return the default value as well.
 * @param {String} scope
 * @returns {String} - Converted value if applicable
 */

export const convertEnvironmentScope = (environmentScope = '') => {
  switch (environmentScope) {
    case ALL_ENVIRONMENTS_OPTION.type || '':
      return ALL_ENVIRONMENTS_OPTION.text;
    case NO_ENVIRONMENT_OPTION.type:
      return NO_ENVIRONMENT_OPTION.text;
    default:
      return environmentScope;
  }
};

/**
 * Gives us an array of all the environments by name
 * @param {Array} nodes
 * @return {Array<String>} - Array of environments strings
 */
export const mapEnvironmentNames = (nodes = []) => {
  return nodes.map((env) => env.name);
};