2020-10-24 23:57:45 +05:30
|
|
|
import { s__ } from '~/locale';
|
|
|
|
import { PackageType, TrackingCategories } from './constants';
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
export const packageTypeToTrackCategory = (type) =>
|
2020-10-24 23:57:45 +05:30
|
|
|
// eslint-disable-next-line @gitlab/require-i18n-strings
|
|
|
|
`UI::${TrackingCategories[type]}`;
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
export const beautifyPath = (path) => (path ? path.split('/').join(' / ') : '');
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
export const getPackageTypeLabel = (packageType) => {
|
2020-10-24 23:57:45 +05:30
|
|
|
switch (packageType) {
|
|
|
|
case PackageType.CONAN:
|
2021-04-29 21:17:54 +05:30
|
|
|
return s__('PackageRegistry|Conan');
|
2020-10-24 23:57:45 +05:30
|
|
|
case PackageType.MAVEN:
|
2021-04-29 21:17:54 +05:30
|
|
|
return s__('PackageRegistry|Maven');
|
2020-10-24 23:57:45 +05:30
|
|
|
case PackageType.NPM:
|
2021-04-29 21:17:54 +05:30
|
|
|
return s__('PackageRegistry|npm');
|
2020-10-24 23:57:45 +05:30
|
|
|
case PackageType.NUGET:
|
2021-04-29 21:17:54 +05:30
|
|
|
return s__('PackageRegistry|NuGet');
|
2020-10-24 23:57:45 +05:30
|
|
|
case PackageType.PYPI:
|
2021-04-29 21:17:54 +05:30
|
|
|
return s__('PackageRegistry|PyPI');
|
|
|
|
case PackageType.RUBYGEMS:
|
|
|
|
return s__('PackageRegistry|RubyGems');
|
2020-10-24 23:57:45 +05:30
|
|
|
case PackageType.COMPOSER:
|
2021-04-29 21:17:54 +05:30
|
|
|
return s__('PackageRegistry|Composer');
|
2021-02-22 17:27:13 +05:30
|
|
|
case PackageType.GENERIC:
|
2021-04-29 21:17:54 +05:30
|
|
|
return s__('PackageRegistry|Generic');
|
2020-10-24 23:57:45 +05:30
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getCommitLink = ({ project_path: projectPath, pipeline = {} }, isGroup = false) => {
|
|
|
|
if (isGroup) {
|
|
|
|
return `/${projectPath}/commit/${pipeline.sha}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
return `../commit/${pipeline.sha}`;
|
|
|
|
};
|