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

utils.js « shared « packages « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d34372e89b627bd88b096953b0b1220d6d71bfc3 (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
31
32
33
34
35
36
37
import { s__ } from '~/locale';
import { PackageType, TrackingCategories } from './constants';

export const packageTypeToTrackCategory = (type) =>
  // eslint-disable-next-line @gitlab/require-i18n-strings
  `UI::${TrackingCategories[type]}`;

export const beautifyPath = (path) => (path ? path.split('/').join(' / ') : '');

export const getPackageTypeLabel = (packageType) => {
  switch (packageType) {
    case PackageType.CONAN:
      return s__('PackageType|Conan');
    case PackageType.MAVEN:
      return s__('PackageType|Maven');
    case PackageType.NPM:
      return s__('PackageType|npm');
    case PackageType.NUGET:
      return s__('PackageType|NuGet');
    case PackageType.PYPI:
      return s__('PackageType|PyPI');
    case PackageType.COMPOSER:
      return s__('PackageType|Composer');
    case PackageType.GENERIC:
      return s__('PackageType|Generic');
    default:
      return null;
  }
};

export const getCommitLink = ({ project_path: projectPath, pipeline = {} }, isGroup = false) => {
  if (isGroup) {
    return `/${projectPath}/commit/${pipeline.sha}`;
  }

  return `../commit/${pipeline.sha}`;
};