All files / app/assets/javascripts/packages_and_registries/package_registry utils.js

94.44% Statements 17/18
92.31% Branches 12/13
100% Functions 4/4
93.75% Lines 15/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 38 39 40 41 42 43 44 45 46 47 48 49                                  7x 68x   2x   2x   52x   5x   1x   1x   2x       1x   1x   1x       10x   7x 60x  
import { capitalize } from 'lodash';
import { s__ } from '~/locale';
import {
  PACKAGE_TYPE_CONAN,
  PACKAGE_TYPE_MAVEN,
  PACKAGE_TYPE_NPM,
  PACKAGE_TYPE_NUGET,
  PACKAGE_TYPE_PYPI,
  PACKAGE_TYPE_COMPOSER,
  PACKAGE_TYPE_RUBYGEMS,
  PACKAGE_TYPE_GENERIC,
  PACKAGE_TYPE_DEBIAN,
  PACKAGE_TYPE_HELM,
  LIST_KEY_PROJECT,
  SORT_FIELDS,
} from './constants';
 
export const getPackageTypeLabel = (packageType) => {
  switch (packageType) {
    case PACKAGE_TYPE_CONAN:
      return s__('PackageRegistry|Conan');
    case PACKAGE_TYPE_MAVEN:
      return s__('PackageRegistry|Maven');
    case PACKAGE_TYPE_NPM:
      return s__('PackageRegistry|npm');
    case PACKAGE_TYPE_NUGET:
      return s__('PackageRegistry|NuGet');
    case PACKAGE_TYPE_PYPI:
      return s__('PackageRegistry|PyPI');
    case PACKAGE_TYPE_RUBYGEMS:
      return s__('PackageRegistry|RubyGems');
    case PACKAGE_TYPE_COMPOSER:
      return s__('PackageRegistry|Composer');
    case PACKAGE_TYPE_GENERIC:
      return s__('PackageRegistry|Generic');
    case PACKAGE_TYPE_DEBIAN:
      return s__('PackageRegistry|Debian');
    case PACKAGE_TYPE_HELM:
      return s__('PackageRegistry|Helm');
    default:
      return null;
  }
};
 
export const packageTypeToTrackCategory = (type) => `UI::${capitalize(type)}Packages`;
 
export const sortableFields = (isGroupPage) =>
  SORT_FIELDS.filter((f) => f.orderBy !== LIST_KEY_PROJECT || isGroupPage);