Commit 56c03d33 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera Committed by Natalia Tepluhina

Move packages/shared to packages_and_registries/shared

parent bead17ae
import { s__ } from '~/locale';
export const PackageType = {
CONAN: 'conan',
MAVEN: 'maven',
NPM: 'npm',
NUGET: 'nuget',
PYPI: 'pypi',
COMPOSER: 'composer',
RUBYGEMS: 'rubygems',
GENERIC: 'generic',
DEBIAN: 'debian',
HELM: 'helm',
};
// we want this separated from the main dictionary to avoid it being pulled in the search of package
export const TERRAFORM_PACKAGE_TYPE = 'terraform_module';
export const TrackingActions = {
DELETE_PACKAGE: 'delete_package',
REQUEST_DELETE_PACKAGE: 'request_delete_package',
CANCEL_DELETE_PACKAGE: 'cancel_delete_package',
PULL_PACKAGE: 'pull_package',
DELETE_PACKAGE_FILE: 'delete_package_file',
REQUEST_DELETE_PACKAGE_FILE: 'request_delete_package_file',
CANCEL_DELETE_PACKAGE_FILE: 'cancel_delete_package_file',
};
export const TrackingCategories = {
[PackageType.MAVEN]: 'MavenPackages',
[PackageType.NPM]: 'NpmPackages',
[PackageType.CONAN]: 'ConanPackages',
};
export const SHOW_DELETE_SUCCESS_ALERT = 'showSuccessDeleteAlert';
export const DELETE_PACKAGE_ERROR_MESSAGE = s__(
'PackageRegistry|Something went wrong while deleting the package.',
);
export const DELETE_PACKAGE_FILE_ERROR_MESSAGE = s__(
'PackageRegistry|Something went wrong while deleting the package file.',
);
export const DELETE_PACKAGE_FILE_SUCCESS_MESSAGE = s__(
'PackageRegistry|Package file deleted successfully',
);
export const PACKAGE_ERROR_STATUS = 'error';
export const PACKAGE_DEFAULT_STATUS = 'default';
export const PACKAGE_HIDDEN_STATUS = 'hidden';
export const PACKAGE_PROCESSING_STATUS = 'processing';
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__('PackageRegistry|Conan');
case PackageType.MAVEN:
return s__('PackageRegistry|Maven');
case PackageType.NPM:
return s__('PackageRegistry|npm');
case PackageType.NUGET:
return s__('PackageRegistry|NuGet');
case PackageType.PYPI:
return s__('PackageRegistry|PyPI');
case PackageType.RUBYGEMS:
return s__('PackageRegistry|RubyGems');
case PackageType.COMPOSER:
return s__('PackageRegistry|Composer');
case PackageType.GENERIC:
return s__('PackageRegistry|Generic');
case PackageType.DEBIAN:
return s__('PackageRegistry|Debian');
case PackageType.HELM:
return s__('PackageRegistry|Helm');
default:
return null;
}
};
export const getCommitLink = ({ project_path: projectPath, pipeline = {} }, isGroup = false) => {
if (isGroup) {
return `/${projectPath}/commit/${pipeline.sha}`;
}
return `../commit/${pipeline.sha}`;
};
...@@ -17,9 +17,12 @@ import TerraformTitle from '~/packages_and_registries/infrastructure_registry/de ...@@ -17,9 +17,12 @@ import TerraformTitle from '~/packages_and_registries/infrastructure_registry/de
import TerraformInstallation from '~/packages_and_registries/infrastructure_registry/details/components/terraform_installation.vue'; import TerraformInstallation from '~/packages_and_registries/infrastructure_registry/details/components/terraform_installation.vue';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import PackageListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue'; import PackageListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue';
import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue'; import PackagesListLoader from '~/packages_and_registries/shared/components/packages_list_loader.vue';
import { TrackingActions, SHOW_DELETE_SUCCESS_ALERT } from '~/packages/shared/constants'; import {
import { packageTypeToTrackCategory } from '~/packages/shared/utils'; TRACKING_ACTIONS,
SHOW_DELETE_SUCCESS_ALERT,
} from '~/packages_and_registries/shared/constants';
import { TRACK_CATEGORY } from '~/packages_and_registries/infrastructure_registry/shared/constants';
import PackageFiles from './package_files.vue'; import PackageFiles from './package_files.vue';
import PackageHistory from './package_history.vue'; import PackageHistory from './package_history.vue';
...@@ -44,7 +47,7 @@ export default { ...@@ -44,7 +47,7 @@ export default {
GlModal: GlModalDirective, GlModal: GlModalDirective,
}, },
mixins: [Tracking.mixin()], mixins: [Tracking.mixin()],
trackingActions: { ...TrackingActions }, trackingActions: { ...TRACKING_ACTIONS },
data() { data() {
return { return {
fileToDelete: null, fileToDelete: null,
...@@ -68,7 +71,7 @@ export default { ...@@ -68,7 +71,7 @@ export default {
}, },
tracking() { tracking() {
return { return {
category: packageTypeToTrackCategory(this.packageEntity.package_type), category: TRACK_CATEGORY,
}; };
}, },
hasVersions() { hasVersions() {
...@@ -86,7 +89,7 @@ export default { ...@@ -86,7 +89,7 @@ export default {
} }
}, },
async confirmPackageDeletion() { async confirmPackageDeletion() {
this.track(TrackingActions.DELETE_PACKAGE); this.track(TRACKING_ACTIONS.DELETE_PACKAGE);
await this.deletePackage(); await this.deletePackage();
const returnTo = const returnTo =
!this.groupListUrl || document.referrer.includes(this.projectName) !this.groupListUrl || document.referrer.includes(this.projectName)
...@@ -96,12 +99,12 @@ export default { ...@@ -96,12 +99,12 @@ export default {
window.location.replace(`${returnTo}?${modalQuery}`); window.location.replace(`${returnTo}?${modalQuery}`);
}, },
handleFileDelete(file) { handleFileDelete(file) {
this.track(TrackingActions.REQUEST_DELETE_PACKAGE_FILE); this.track(TRACKING_ACTIONS.REQUEST_DELETE_PACKAGE_FILE);
this.fileToDelete = { ...file }; this.fileToDelete = { ...file };
this.$refs.deleteFileModal.show(); this.$refs.deleteFileModal.show();
}, },
confirmFileDelete() { confirmFileDelete() {
this.track(TrackingActions.DELETE_PACKAGE_FILE); this.track(TRACKING_ACTIONS.DELETE_PACKAGE_FILE);
this.deletePackageFile(this.fileToDelete.id); this.deletePackageFile(this.fileToDelete.id);
this.fileToDelete = null; this.fileToDelete = null;
}, },
......
...@@ -4,7 +4,7 @@ import { ...@@ -4,7 +4,7 @@ import {
DELETE_PACKAGE_ERROR_MESSAGE, DELETE_PACKAGE_ERROR_MESSAGE,
DELETE_PACKAGE_FILE_ERROR_MESSAGE, DELETE_PACKAGE_FILE_ERROR_MESSAGE,
DELETE_PACKAGE_FILE_SUCCESS_MESSAGE, DELETE_PACKAGE_FILE_SUCCESS_MESSAGE,
} from '~/packages/shared/constants'; } from '~/packages_and_registries/shared/constants';
import { FETCH_PACKAGE_VERSIONS_ERROR } from '../constants'; import { FETCH_PACKAGE_VERSIONS_ERROR } from '../constants';
import * as types from './mutation_types'; import * as types from './mutation_types';
......
...@@ -4,9 +4,9 @@ import { mapState, mapGetters } from 'vuex'; ...@@ -4,9 +4,9 @@ import { mapState, mapGetters } from 'vuex';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import PackagesListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue'; import PackagesListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue';
import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue'; import PackagesListLoader from '~/packages_and_registries/shared/components/packages_list_loader.vue';
import { TrackingActions } from '~/packages/shared/constants'; import { TRACKING_ACTIONS } from '~/packages_and_registries/shared/constants';
import { packageTypeToTrackCategory } from '~/packages/shared/utils'; import { TRACK_CATEGORY } from '~/packages_and_registries/infrastructure_registry/shared/constants';
export default { export default {
components: { components: {
...@@ -49,27 +49,24 @@ export default { ...@@ -49,27 +49,24 @@ export default {
return this.itemToBeDeleted?.name ?? ''; return this.itemToBeDeleted?.name ?? '';
}, },
tracking() { tracking() {
const category = this.itemToBeDeleted
? packageTypeToTrackCategory(this.itemToBeDeleted.package_type)
: undefined;
return { return {
category, category: TRACK_CATEGORY,
}; };
}, },
}, },
methods: { methods: {
setItemToBeDeleted(item) { setItemToBeDeleted(item) {
this.itemToBeDeleted = { ...item }; this.itemToBeDeleted = { ...item };
this.track(TrackingActions.REQUEST_DELETE_PACKAGE); this.track(TRACKING_ACTIONS.REQUEST_DELETE_PACKAGE);
this.$refs.packageListDeleteModal.show(); this.$refs.packageListDeleteModal.show();
}, },
deleteItemConfirmation() { deleteItemConfirmation() {
this.$emit('package:delete', this.itemToBeDeleted); this.$emit('package:delete', this.itemToBeDeleted);
this.track(TrackingActions.DELETE_PACKAGE); this.track(TRACKING_ACTIONS.DELETE_PACKAGE);
this.itemToBeDeleted = null; this.itemToBeDeleted = null;
}, },
deleteItemCanceled() { deleteItemCanceled() {
this.track(TrackingActions.CANCEL_DELETE_PACKAGE); this.track(TRACKING_ACTIONS.CANCEL_DELETE_PACKAGE);
this.itemToBeDeleted = null; this.itemToBeDeleted = null;
}, },
}, },
......
...@@ -4,8 +4,11 @@ import { mapActions, mapState } from 'vuex'; ...@@ -4,8 +4,11 @@ import { mapActions, mapState } from 'vuex';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { historyReplaceState } from '~/lib/utils/common_utils'; import { historyReplaceState } from '~/lib/utils/common_utils';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { SHOW_DELETE_SUCCESS_ALERT } from '~/packages/shared/constants'; import {
import { FILTERED_SEARCH_TERM } from '~/packages_and_registries/shared/constants'; SHOW_DELETE_SUCCESS_ALERT,
FILTERED_SEARCH_TERM,
} from '~/packages_and_registries/shared/constants';
import { getQueryParams, extractFilterAndSorting } from '~/packages_and_registries/shared/utils'; import { getQueryParams, extractFilterAndSorting } from '~/packages_and_registries/shared/utils';
import InfrastructureTitle from '~/packages_and_registries/infrastructure_registry/list/components/infrastructure_title.vue'; import InfrastructureTitle from '~/packages_and_registries/infrastructure_registry/list/components/infrastructure_title.vue';
import InfrastructureSearch from '~/packages_and_registries/infrastructure_registry/list/components/infrastructure_search.vue'; import InfrastructureSearch from '~/packages_and_registries/infrastructure_registry/list/components/infrastructure_search.vue';
......
import Api from '~/api'; import Api from '~/api';
import createFlash from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { DELETE_PACKAGE_ERROR_MESSAGE } from '~/packages/shared/constants'; import { DELETE_PACKAGE_ERROR_MESSAGE } from '~/packages_and_registries/shared/constants';
import { import {
FETCH_PACKAGES_LIST_ERROR_MESSAGE, FETCH_PACKAGES_LIST_ERROR_MESSAGE,
DELETE_PACKAGE_SUCCESS_MESSAGE, DELETE_PACKAGE_SUCCESS_MESSAGE,
......
import { beautifyPath } from '~/packages/shared/utils'; import { beautifyPath } from '~/packages_and_registries/shared/utils';
import { LIST_KEY_PROJECT } from '../constants'; import { LIST_KEY_PROJECT } from '../constants';
export default (state) => export default (state) =>
......
...@@ -3,11 +3,13 @@ import { GlButton, GlLink, GlSprintf, GlTooltipDirective, GlTruncate } from '@gi ...@@ -3,11 +3,13 @@ import { GlButton, GlLink, GlSprintf, GlTooltipDirective, GlTruncate } from '@gi
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import ListItem from '~/vue_shared/components/registry/list_item.vue'; import ListItem from '~/vue_shared/components/registry/list_item.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago'; import timeagoMixin from '~/vue_shared/mixins/timeago';
import { PACKAGE_ERROR_STATUS, PACKAGE_DEFAULT_STATUS } from '~/packages/shared/constants'; import {
import { getPackageTypeLabel } from '~/packages/shared/utils'; PACKAGE_ERROR_STATUS,
import PackagePath from '~/packages/shared/components/package_path.vue'; PACKAGE_DEFAULT_STATUS,
import PackageTags from '~/packages/shared/components/package_tags.vue'; } from '~/packages_and_registries/shared/constants';
import PublishMethod from '~/packages/shared/components/publish_method.vue'; import PackagePath from '~/packages_and_registries/shared/components/package_path.vue';
import PackageTags from '~/packages_and_registries/shared/components/package_tags.vue';
import PublishMethod from '~/packages_and_registries/shared/components/publish_method.vue';
import InfrastructureIconAndName from '~/packages_and_registries/infrastructure_registry/shared/infrastructure_icon_and_name.vue'; import InfrastructureIconAndName from '~/packages_and_registries/infrastructure_registry/shared/infrastructure_icon_and_name.vue';
export default { export default {
...@@ -53,9 +55,6 @@ export default { ...@@ -53,9 +55,6 @@ export default {
}, },
}, },
computed: { computed: {
packageType() {
return getPackageTypeLabel(this.packageEntity.package_type);
},
hasPipeline() { hasPipeline() {
return Boolean(this.packageEntity.pipeline); return Boolean(this.packageEntity.pipeline);
}, },
...@@ -120,9 +119,7 @@ export default { ...@@ -120,9 +119,7 @@ export default {
</gl-sprintf> </gl-sprintf>
</div> </div>
<infrastructure-icon-and-name v-if="showPackageType"> <infrastructure-icon-and-name v-if="showPackageType" />
{{ packageType }}
</infrastructure-icon-and-name>
<package-path <package-path
v-if="hasProjectLink" v-if="hasProjectLink"
......
...@@ -15,7 +15,7 @@ import { convertToGraphQLId } from '~/graphql_shared/utils'; ...@@ -15,7 +15,7 @@ import { convertToGraphQLId } from '~/graphql_shared/utils';
import { numberToHumanSize } from '~/lib/utils/number_utils'; import { numberToHumanSize } from '~/lib/utils/number_utils';
import { objectToQuery } from '~/lib/utils/url_utility'; import { objectToQuery } from '~/lib/utils/url_utility';
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
import { packageTypeToTrackCategory } from '~/packages/shared/utils'; import { packageTypeToTrackCategory } from '~/packages_and_registries/package_registry/utils';
import AdditionalMetadata from '~/packages_and_registries/package_registry/components/details/additional_metadata.vue'; import AdditionalMetadata from '~/packages_and_registries/package_registry/components/details/additional_metadata.vue';
import DependencyRow from '~/packages_and_registries/package_registry/components/details/dependency_row.vue'; import DependencyRow from '~/packages_and_registries/package_registry/components/details/dependency_row.vue';
import InstallationCommands from '~/packages_and_registries/package_registry/components/details/installation_commands.vue'; import InstallationCommands from '~/packages_and_registries/package_registry/components/details/installation_commands.vue';
......
...@@ -3,7 +3,7 @@ import { GlIcon, GlSprintf, GlBadge, GlResizeObserverDirective } from '@gitlab/u ...@@ -3,7 +3,7 @@ import { GlIcon, GlSprintf, GlBadge, GlResizeObserverDirective } from '@gitlab/u
import { GlBreakpointInstance } from '@gitlab/ui/dist/utils'; import { GlBreakpointInstance } from '@gitlab/ui/dist/utils';
import { numberToHumanSize } from '~/lib/utils/number_utils'; import { numberToHumanSize } from '~/lib/utils/number_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
import PackageTags from '~/packages/shared/components/package_tags.vue'; import PackageTags from '~/packages_and_registries/shared/components/package_tags.vue';
import { PACKAGE_TYPE_NUGET } from '~/packages_and_registries/package_registry/constants'; import { PACKAGE_TYPE_NUGET } from '~/packages_and_registries/package_registry/constants';
import { getPackageTypeLabel } from '~/packages_and_registries/package_registry/utils'; import { getPackageTypeLabel } from '~/packages_and_registries/package_registry/utils';
import MetadataItem from '~/vue_shared/components/registry/metadata_item.vue'; import MetadataItem from '~/vue_shared/components/registry/metadata_item.vue';
......
<script> <script>
import { GlLink, GlSprintf, GlTruncate } from '@gitlab/ui'; import { GlLink, GlSprintf, GlTruncate } from '@gitlab/ui';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import PackageTags from '~/packages/shared/components/package_tags.vue'; import PackageTags from '~/packages_and_registries/shared/components/package_tags.vue';
import PublishMethod from '~/packages/shared/components/publish_method.vue'; import PublishMethod from '~/packages_and_registries/shared/components/publish_method.vue';
import ListItem from '~/vue_shared/components/registry/list_item.vue'; import ListItem from '~/vue_shared/components/registry/list_item.vue';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import { PACKAGE_DEFAULT_STATUS } from '../../constants'; import { PACKAGE_DEFAULT_STATUS } from '../../constants';
......
...@@ -3,7 +3,7 @@ import { GlEmptyState, GlLink, GlSprintf } from '@gitlab/ui'; ...@@ -3,7 +3,7 @@ import { GlEmptyState, GlLink, GlSprintf } from '@gitlab/ui';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { historyReplaceState } from '~/lib/utils/common_utils'; import { historyReplaceState } from '~/lib/utils/common_utils';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { SHOW_DELETE_SUCCESS_ALERT } from '~/packages/shared/constants'; import { SHOW_DELETE_SUCCESS_ALERT } from '~/packages_and_registries/shared/constants';
import { import {
PROJECT_RESOURCE_TYPE, PROJECT_RESOURCE_TYPE,
GROUP_RESOURCE_TYPE, GROUP_RESOURCE_TYPE,
......
...@@ -6,11 +6,11 @@ import { ...@@ -6,11 +6,11 @@ import {
PACKAGE_ERROR_STATUS, PACKAGE_ERROR_STATUS,
PACKAGE_DEFAULT_STATUS, PACKAGE_DEFAULT_STATUS,
} from '~/packages_and_registries/package_registry/constants'; } from '~/packages_and_registries/package_registry/constants';
import { getPackageTypeLabel } from '~/packages/shared/utils'; import { getPackageTypeLabel } from '~/packages_and_registries/package_registry/utils';
import PackagePath from '~/packages/shared/components/package_path.vue'; import PackagePath from '~/packages_and_registries/shared/components/package_path.vue';
import PackageTags from '~/packages/shared/components/package_tags.vue'; import PackageTags from '~/packages_and_registries/shared/components/package_tags.vue';
import PublishMethod from '~/packages_and_registries/package_registry/components/list/publish_method.vue'; import PublishMethod from '~/packages_and_registries/package_registry/components/list/publish_method.vue';
import PackageIconAndName from '~/packages/shared/components/package_icon_and_name.vue'; import PackageIconAndName from '~/packages_and_registries/shared/components/package_icon_and_name.vue';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
...@@ -40,7 +40,7 @@ export default { ...@@ -40,7 +40,7 @@ export default {
}, },
computed: { computed: {
packageType() { packageType() {
return getPackageTypeLabel(this.packageEntity.packageType.toLowerCase()); return getPackageTypeLabel(this.packageEntity.packageType);
}, },
packageLink() { packageLink() {
const { project, id } = this.packageEntity; const { project, id } = this.packageEntity;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { GlModal, GlSprintf, GlKeysetPagination } from '@gitlab/ui'; import { GlModal, GlSprintf, GlKeysetPagination } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import PackagesListRow from '~/packages_and_registries/package_registry/components/list/package_list_row.vue'; import PackagesListRow from '~/packages_and_registries/package_registry/components/list/package_list_row.vue';
import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue'; import PackagesListLoader from '~/packages_and_registries/shared/components/packages_list_loader.vue';
import { import {
DELETE_PACKAGE_TRACKING_ACTION, DELETE_PACKAGE_TRACKING_ACTION,
REQUEST_DELETE_PACKAGE_TRACKING_ACTION, REQUEST_DELETE_PACKAGE_TRACKING_ACTION,
......
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
export {
DELETE_PACKAGE_TRACKING_ACTION,
REQUEST_DELETE_PACKAGE_TRACKING_ACTION,
CANCEL_DELETE_PACKAGE_TRACKING_ACTION,
PULL_PACKAGE_TRACKING_ACTION,
DELETE_PACKAGE_FILE_TRACKING_ACTION,
REQUEST_DELETE_PACKAGE_FILE_TRACKING_ACTION,
CANCEL_DELETE_PACKAGE_FILE_TRACKING_ACTION,
} from '~/packages_and_registries/shared/constants';
export const PACKAGE_TYPE_CONAN = 'CONAN'; export const PACKAGE_TYPE_CONAN = 'CONAN';
export const PACKAGE_TYPE_MAVEN = 'MAVEN'; export const PACKAGE_TYPE_MAVEN = 'MAVEN';
export const PACKAGE_TYPE_NPM = 'NPM'; export const PACKAGE_TYPE_NPM = 'NPM';
...@@ -11,14 +21,6 @@ export const PACKAGE_TYPE_GENERIC = 'GENERIC'; ...@@ -11,14 +21,6 @@ export const PACKAGE_TYPE_GENERIC = 'GENERIC';
export const PACKAGE_TYPE_DEBIAN = 'DEBIAN'; export const PACKAGE_TYPE_DEBIAN = 'DEBIAN';
export const PACKAGE_TYPE_HELM = 'HELM'; export const PACKAGE_TYPE_HELM = 'HELM';
export const DELETE_PACKAGE_TRACKING_ACTION = 'delete_package';
export const REQUEST_DELETE_PACKAGE_TRACKING_ACTION = 'request_delete_package';
export const CANCEL_DELETE_PACKAGE_TRACKING_ACTION = 'cancel_delete_package';
export const PULL_PACKAGE_TRACKING_ACTION = 'pull_package';
export const DELETE_PACKAGE_FILE_TRACKING_ACTION = 'delete_package_file';
export const REQUEST_DELETE_PACKAGE_FILE_TRACKING_ACTION = 'request_delete_package_file';
export const CANCEL_DELETE_PACKAGE_FILE_TRACKING_ACTION = 'cancel_delete_package_file';
export const TRACKING_LABEL_CODE_INSTRUCTION = 'code_instruction'; export const TRACKING_LABEL_CODE_INSTRUCTION = 'code_instruction';
export const TRACKING_LABEL_CONAN_INSTALLATION = 'conan_installation'; export const TRACKING_LABEL_CONAN_INSTALLATION = 'conan_installation';
export const TRACKING_LABEL_MAVEN_INSTALLATION = 'maven_installation'; export const TRACKING_LABEL_MAVEN_INSTALLATION = 'maven_installation';
......
import { s__ } from '~/locale';
export const FILTERED_SEARCH_TERM = 'filtered-search-term'; export const FILTERED_SEARCH_TERM = 'filtered-search-term';
export const FILTERED_SEARCH_TYPE = 'type'; export const FILTERED_SEARCH_TYPE = 'type';
export const HISTORY_PIPELINES_LIMIT = 5; export const HISTORY_PIPELINES_LIMIT = 5;
export const DELETE_PACKAGE_TRACKING_ACTION = 'delete_package';
export const REQUEST_DELETE_PACKAGE_TRACKING_ACTION = 'request_delete_package';
export const CANCEL_DELETE_PACKAGE_TRACKING_ACTION = 'cancel_delete_package';
export const PULL_PACKAGE_TRACKING_ACTION = 'pull_package';
export const DELETE_PACKAGE_FILE_TRACKING_ACTION = 'delete_package_file';
export const REQUEST_DELETE_PACKAGE_FILE_TRACKING_ACTION = 'request_delete_package_file';
export const CANCEL_DELETE_PACKAGE_FILE_TRACKING_ACTION = 'cancel_delete_package_file';
export const TRACKING_ACTIONS = {
DELETE_PACKAGE: DELETE_PACKAGE_TRACKING_ACTION,
REQUEST_DELETE_PACKAGE: REQUEST_DELETE_PACKAGE_TRACKING_ACTION,
CANCEL_DELETE_PACKAGE: CANCEL_DELETE_PACKAGE_TRACKING_ACTION,
PULL_PACKAGE: PULL_PACKAGE_TRACKING_ACTION,
DELETE_PACKAGE_FILE: DELETE_PACKAGE_FILE_TRACKING_ACTION,
REQUEST_DELETE_PACKAGE_FILE: REQUEST_DELETE_PACKAGE_FILE_TRACKING_ACTION,
CANCEL_DELETE_PACKAGE_FILE: CANCEL_DELETE_PACKAGE_FILE_TRACKING_ACTION,
};
export const SHOW_DELETE_SUCCESS_ALERT = 'showSuccessDeleteAlert';
export const DELETE_PACKAGE_ERROR_MESSAGE = s__(
'PackageRegistry|Something went wrong while deleting the package.',
);
export const DELETE_PACKAGE_FILE_ERROR_MESSAGE = s__(
'PackageRegistry|Something went wrong while deleting the package file.',
);
export const DELETE_PACKAGE_FILE_SUCCESS_MESSAGE = s__(
'PackageRegistry|Package file deleted successfully',
);
export const PACKAGE_ERROR_STATUS = 'error';
export const PACKAGE_DEFAULT_STATUS = 'default';
export const PACKAGE_HIDDEN_STATUS = 'hidden';
export const PACKAGE_PROCESSING_STATUS = 'processing';
...@@ -28,3 +28,13 @@ export const extractFilterAndSorting = (queryObject) => { ...@@ -28,3 +28,13 @@ export const extractFilterAndSorting = (queryObject) => {
} }
return { filters, sorting }; return { filters, sorting };
}; };
export const beautifyPath = (path) => (path ? path.split('/').join(' / ') : '');
export const getCommitLink = ({ project_path: projectPath, pipeline = {} }, isGroup = false) => {
if (isGroup) {
return `/${projectPath}/commit/${pipeline.sha}`;
}
return `../commit/${pipeline.sha}`;
};
import { PackageType, TrackingCategories } from '~/packages/shared/constants';
import {
packageTypeToTrackCategory,
beautifyPath,
getPackageTypeLabel,
getCommitLink,
} from '~/packages/shared/utils';
import { packageList } from 'jest/packages_and_registries/infrastructure_registry/components/mock_data';
describe('Packages shared utils', () => {
describe('packageTypeToTrackCategory', () => {
it('prepend UI to package category', () => {
expect(packageTypeToTrackCategory()).toMatchInlineSnapshot(`"UI::undefined"`);
});
it.each(Object.keys(PackageType))('returns a correct category string for %s', (packageKey) => {
const packageName = PackageType[packageKey];
expect(packageTypeToTrackCategory(packageName)).toBe(
`UI::${TrackingCategories[packageName]}`,
);
});
});
describe('beautifyPath', () => {
it('returns a string with spaces around /', () => {
expect(beautifyPath('foo/bar')).toBe('foo / bar');
});
it('does not fail for empty string', () => {
expect(beautifyPath()).toBe('');
});
});
describe('getPackageTypeLabel', () => {
describe.each`
packageType | expectedResult
${'conan'} | ${'Conan'}
${'maven'} | ${'Maven'}
${'npm'} | ${'npm'}
${'nuget'} | ${'NuGet'}
${'pypi'} | ${'PyPI'}
${'rubygems'} | ${'RubyGems'}
${'composer'} | ${'Composer'}
${'debian'} | ${'Debian'}
${'helm'} | ${'Helm'}
${'foo'} | ${null}
`(`package type`, ({ packageType, expectedResult }) => {
it(`${packageType} should show as ${expectedResult}`, () => {
expect(getPackageTypeLabel(packageType)).toBe(expectedResult);
});
});
});
describe('getCommitLink', () => {
it('returns a relative link when isGroup is false', () => {
const link = getCommitLink(packageList[0], false);
expect(link).toContain('../commit');
});
describe('when isGroup is true', () => {
it('returns an absolute link matching project path', () => {
const mavenPackage = packageList[0];
const link = getCommitLink(mavenPackage, true);
expect(link).toContain(`/${mavenPackage.project_path}/commit`);
});
});
});
});
...@@ -10,9 +10,9 @@ import PackageFiles from '~/packages_and_registries/infrastructure_registry/deta ...@@ -10,9 +10,9 @@ import PackageFiles from '~/packages_and_registries/infrastructure_registry/deta
import PackageHistory from '~/packages_and_registries/infrastructure_registry/details/components/package_history.vue'; import PackageHistory from '~/packages_and_registries/infrastructure_registry/details/components/package_history.vue';
import * as getters from '~/packages_and_registries/infrastructure_registry/details/store/getters'; import * as getters from '~/packages_and_registries/infrastructure_registry/details/store/getters';
import PackageListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue'; import PackageListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue';
import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue'; import PackagesListLoader from '~/packages_and_registries/shared/components/packages_list_loader.vue';
import { TrackingActions } from '~/packages/shared/constants'; import { TRACKING_ACTIONS } from '~/packages_and_registries/shared/constants';
import * as SharedUtils from '~/packages/shared/utils'; import { TRACK_CATEGORY } from '~/packages_and_registries/infrastructure_registry/shared/constants';
import TerraformTitle from '~/packages_and_registries/infrastructure_registry/details/components/details_title.vue'; import TerraformTitle from '~/packages_and_registries/infrastructure_registry/details/components/details_title.vue';
import TerraformInstallation from '~/packages_and_registries/infrastructure_registry/details/components/terraform_installation.vue'; import TerraformInstallation from '~/packages_and_registries/infrastructure_registry/details/components/terraform_installation.vue';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
...@@ -232,87 +232,78 @@ describe('PackagesApp', () => { ...@@ -232,87 +232,78 @@ describe('PackagesApp', () => {
describe('tracking', () => { describe('tracking', () => {
let eventSpy; let eventSpy;
let utilSpy;
const category = 'foo';
beforeEach(() => { beforeEach(() => {
eventSpy = jest.spyOn(Tracking, 'event'); eventSpy = jest.spyOn(Tracking, 'event');
utilSpy = jest.spyOn(SharedUtils, 'packageTypeToTrackCategory').mockReturnValue(category);
}); });
it('tracking category calls packageTypeToTrackCategory', () => { it(`delete button on delete modal call event with ${TRACKING_ACTIONS.DELETE_PACKAGE}`, () => {
createComponent({ packageEntity: npmPackage });
expect(wrapper.vm.tracking.category).toBe(category);
expect(utilSpy).toHaveBeenCalledWith('npm');
});
it(`delete button on delete modal call event with ${TrackingActions.DELETE_PACKAGE}`, () => {
createComponent({ packageEntity: npmPackage }); createComponent({ packageEntity: npmPackage });
findDeleteModal().vm.$emit('primary'); findDeleteModal().vm.$emit('primary');
expect(eventSpy).toHaveBeenCalledWith( expect(eventSpy).toHaveBeenCalledWith(
category, TRACK_CATEGORY,
TrackingActions.DELETE_PACKAGE, TRACKING_ACTIONS.DELETE_PACKAGE,
expect.any(Object), expect.any(Object),
); );
}); });
it(`canceling a package deletion tracks ${TrackingActions.CANCEL_DELETE_PACKAGE}`, () => { it(`canceling a package deletion tracks ${TRACKING_ACTIONS.CANCEL_DELETE_PACKAGE}`, () => {
createComponent({ packageEntity: npmPackage }); createComponent({ packageEntity: npmPackage });
findDeleteModal().vm.$emit('canceled'); findDeleteModal().vm.$emit('canceled');
expect(eventSpy).toHaveBeenCalledWith( expect(eventSpy).toHaveBeenCalledWith(
category, TRACK_CATEGORY,
TrackingActions.CANCEL_DELETE_PACKAGE, TRACKING_ACTIONS.CANCEL_DELETE_PACKAGE,
expect.any(Object), expect.any(Object),
); );
}); });
it(`request a file deletion tracks ${TrackingActions.REQUEST_DELETE_PACKAGE_FILE}`, () => { it(`request a file deletion tracks ${TRACKING_ACTIONS.REQUEST_DELETE_PACKAGE_FILE}`, () => {
createComponent({ packageEntity: npmPackage }); createComponent({ packageEntity: npmPackage });
findPackageFiles().vm.$emit('delete-file', mavenFiles[0]); findPackageFiles().vm.$emit('delete-file', mavenFiles[0]);
expect(eventSpy).toHaveBeenCalledWith( expect(eventSpy).toHaveBeenCalledWith(
category, TRACK_CATEGORY,
TrackingActions.REQUEST_DELETE_PACKAGE_FILE, TRACKING_ACTIONS.REQUEST_DELETE_PACKAGE_FILE,
expect.any(Object), expect.any(Object),
); );
}); });
it(`confirming a file deletion tracks ${TrackingActions.DELETE_PACKAGE_FILE}`, () => { it(`confirming a file deletion tracks ${TRACKING_ACTIONS.DELETE_PACKAGE_FILE}`, () => {
createComponent({ packageEntity: npmPackage }); createComponent({ packageEntity: npmPackage });
findPackageFiles().vm.$emit('delete-file', npmPackage); findPackageFiles().vm.$emit('delete-file', npmPackage);
findDeleteFileModal().vm.$emit('primary'); findDeleteFileModal().vm.$emit('primary');
expect(eventSpy).toHaveBeenCalledWith( expect(eventSpy).toHaveBeenCalledWith(
category, TRACK_CATEGORY,
TrackingActions.REQUEST_DELETE_PACKAGE_FILE, TRACKING_ACTIONS.REQUEST_DELETE_PACKAGE_FILE,
expect.any(Object), expect.any(Object),
); );
}); });
it(`canceling a file deletion tracks ${TrackingActions.CANCEL_DELETE_PACKAGE_FILE}`, () => { it(`canceling a file deletion tracks ${TRACKING_ACTIONS.CANCEL_DELETE_PACKAGE_FILE}`, () => {
createComponent({ packageEntity: npmPackage }); createComponent({ packageEntity: npmPackage });
findPackageFiles().vm.$emit('delete-file', npmPackage); findPackageFiles().vm.$emit('delete-file', npmPackage);
findDeleteFileModal().vm.$emit('canceled'); findDeleteFileModal().vm.$emit('canceled');
expect(eventSpy).toHaveBeenCalledWith( expect(eventSpy).toHaveBeenCalledWith(
category, TRACK_CATEGORY,
TrackingActions.CANCEL_DELETE_PACKAGE_FILE, TRACKING_ACTIONS.CANCEL_DELETE_PACKAGE_FILE,
expect.any(Object), expect.any(Object),
); );
}); });
it(`file download link call event with ${TrackingActions.PULL_PACKAGE}`, () => { it(`file download link call event with ${TRACKING_ACTIONS.PULL_PACKAGE}`, () => {
createComponent({ packageEntity: npmPackage }); createComponent({ packageEntity: npmPackage });
findPackageFiles().vm.$emit('download-file'); findPackageFiles().vm.$emit('download-file');
expect(eventSpy).toHaveBeenCalledWith( expect(eventSpy).toHaveBeenCalledWith(
category, TRACK_CATEGORY,
TrackingActions.PULL_PACKAGE, TRACKING_ACTIONS.PULL_PACKAGE,
expect.any(Object), expect.any(Object),
); );
}); });
......
...@@ -12,7 +12,7 @@ import { ...@@ -12,7 +12,7 @@ import {
DELETE_PACKAGE_ERROR_MESSAGE, DELETE_PACKAGE_ERROR_MESSAGE,
DELETE_PACKAGE_FILE_ERROR_MESSAGE, DELETE_PACKAGE_FILE_ERROR_MESSAGE,
DELETE_PACKAGE_FILE_SUCCESS_MESSAGE, DELETE_PACKAGE_FILE_SUCCESS_MESSAGE,
} from '~/packages/shared/constants'; } from '~/packages_and_registries/shared/constants';
import { npmPackage as packageEntity } from '../../mock_data'; import { npmPackage as packageEntity } from '../../mock_data';
jest.mock('~/flash.js'); jest.mock('~/flash.js');
......
...@@ -6,8 +6,11 @@ import createFlash from '~/flash'; ...@@ -6,8 +6,11 @@ import createFlash from '~/flash';
import * as commonUtils from '~/lib/utils/common_utils'; import * as commonUtils from '~/lib/utils/common_utils';
import PackageListApp from '~/packages_and_registries/infrastructure_registry/list/components/packages_list_app.vue'; import PackageListApp from '~/packages_and_registries/infrastructure_registry/list/components/packages_list_app.vue';
import { DELETE_PACKAGE_SUCCESS_MESSAGE } from '~/packages_and_registries/infrastructure_registry/list/constants'; import { DELETE_PACKAGE_SUCCESS_MESSAGE } from '~/packages_and_registries/infrastructure_registry/list/constants';
import { SHOW_DELETE_SUCCESS_ALERT } from '~/packages/shared/constants'; import {
import { FILTERED_SEARCH_TERM } from '~/packages_and_registries/shared/constants'; SHOW_DELETE_SUCCESS_ALERT,
FILTERED_SEARCH_TERM,
} from '~/packages_and_registries/shared/constants';
import * as packageUtils from '~/packages_and_registries/shared/utils'; import * as packageUtils from '~/packages_and_registries/shared/utils';
import InfrastructureSearch from '~/packages_and_registries/infrastructure_registry/list/components/infrastructure_search.vue'; import InfrastructureSearch from '~/packages_and_registries/infrastructure_registry/list/components/infrastructure_search.vue';
......
...@@ -5,9 +5,9 @@ import Vuex from 'vuex'; ...@@ -5,9 +5,9 @@ import Vuex from 'vuex';
import stubChildren from 'helpers/stub_children'; import stubChildren from 'helpers/stub_children';
import PackagesList from '~/packages_and_registries/infrastructure_registry/list/components/packages_list.vue'; import PackagesList from '~/packages_and_registries/infrastructure_registry/list/components/packages_list.vue';
import PackagesListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue'; import PackagesListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue';
import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue'; import PackagesListLoader from '~/packages_and_registries/shared/components/packages_list_loader.vue';
import { TrackingActions } from '~/packages/shared/constants'; import { TRACKING_ACTIONS } from '~/packages_and_registries/shared/constants';
import * as SharedUtils from '~/packages/shared/utils'; import { TRACK_CATEGORY } from '~/packages_and_registries/infrastructure_registry/shared/constants';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import { packageList } from '../../mock_data'; import { packageList } from '../../mock_data';
...@@ -190,26 +190,18 @@ describe('packages_list', () => { ...@@ -190,26 +190,18 @@ describe('packages_list', () => {
describe('tracking', () => { describe('tracking', () => {
let eventSpy; let eventSpy;
let utilSpy;
const category = 'foo';
beforeEach(() => { beforeEach(() => {
mountComponent(); mountComponent();
eventSpy = jest.spyOn(Tracking, 'event'); eventSpy = jest.spyOn(Tracking, 'event');
utilSpy = jest.spyOn(SharedUtils, 'packageTypeToTrackCategory').mockReturnValue(category);
wrapper.setData({ itemToBeDeleted: { package_type: 'conan' } }); wrapper.setData({ itemToBeDeleted: { package_type: 'conan' } });
}); });
it('tracking category calls packageTypeToTrackCategory', () => {
expect(wrapper.vm.tracking.category).toBe(category);
expect(utilSpy).toHaveBeenCalledWith('conan');
});
it('deleteItemConfirmation calls event', () => { it('deleteItemConfirmation calls event', () => {
wrapper.vm.deleteItemConfirmation(); wrapper.vm.deleteItemConfirmation();
expect(eventSpy).toHaveBeenCalledWith( expect(eventSpy).toHaveBeenCalledWith(
category, TRACK_CATEGORY,
TrackingActions.DELETE_PACKAGE, TRACKING_ACTIONS.DELETE_PACKAGE,
expect.any(Object), expect.any(Object),
); );
}); });
......
...@@ -6,7 +6,7 @@ import createFlash from '~/flash'; ...@@ -6,7 +6,7 @@ import createFlash from '~/flash';
import { MISSING_DELETE_PATH_ERROR } from '~/packages_and_registries/infrastructure_registry/list/constants'; import { MISSING_DELETE_PATH_ERROR } from '~/packages_and_registries/infrastructure_registry/list/constants';
import * as actions from '~/packages_and_registries/infrastructure_registry/list/stores/actions'; import * as actions from '~/packages_and_registries/infrastructure_registry/list/stores/actions';
import * as types from '~/packages_and_registries/infrastructure_registry/list/stores/mutation_types'; import * as types from '~/packages_and_registries/infrastructure_registry/list/stores/mutation_types';
import { DELETE_PACKAGE_ERROR_MESSAGE } from '~/packages/shared/constants'; import { DELETE_PACKAGE_ERROR_MESSAGE } from '~/packages_and_registries/shared/constants';
jest.mock('~/flash.js'); jest.mock('~/flash.js');
jest.mock('~/api.js'); jest.mock('~/api.js');
......
...@@ -3,9 +3,9 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; ...@@ -3,9 +3,9 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import PackagesListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue'; import PackagesListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue';
import PackagePath from '~/packages/shared/components/package_path.vue'; import PackagePath from '~/packages_and_registries/shared/components/package_path.vue';
import PackageTags from '~/packages/shared/components/package_tags.vue'; import PackageTags from '~/packages_and_registries/shared/components/package_tags.vue';
import { PACKAGE_ERROR_STATUS } from '~/packages/shared/constants'; import { PACKAGE_ERROR_STATUS } from '~/packages_and_registries/shared/constants';
import ListItem from '~/vue_shared/components/registry/list_item.vue'; import ListItem from '~/vue_shared/components/registry/list_item.vue';
import { packageList } from '../mock_data'; import { packageList } from '../mock_data';
......
...@@ -2,7 +2,7 @@ import { GlIcon, GlSprintf } from '@gitlab/ui'; ...@@ -2,7 +2,7 @@ import { GlIcon, GlSprintf } from '@gitlab/ui';
import { GlBreakpointInstance } from '@gitlab/ui/dist/utils'; import { GlBreakpointInstance } from '@gitlab/ui/dist/utils';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import PackageTags from '~/packages/shared/components/package_tags.vue'; import PackageTags from '~/packages_and_registries/shared/components/package_tags.vue';
import PackageTitle from '~/packages_and_registries/package_registry/components/details/package_title.vue'; import PackageTitle from '~/packages_and_registries/package_registry/components/details/package_title.vue';
import { import {
PACKAGE_TYPE_CONAN, PACKAGE_TYPE_CONAN,
......
import { GlLink, GlSprintf, GlTruncate } from '@gitlab/ui'; import { GlLink, GlSprintf, GlTruncate } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import PackageTags from '~/packages/shared/components/package_tags.vue'; import PackageTags from '~/packages_and_registries/shared/components/package_tags.vue';
import PublishMethod from '~/packages/shared/components/publish_method.vue'; import PublishMethod from '~/packages_and_registries/shared/components/publish_method.vue';
import VersionRow from '~/packages_and_registries/package_registry/components/details/version_row.vue'; import VersionRow from '~/packages_and_registries/package_registry/components/details/version_row.vue';
import ListItem from '~/vue_shared/components/registry/list_item.vue'; import ListItem from '~/vue_shared/components/registry/list_item.vue';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
......
...@@ -3,9 +3,9 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; ...@@ -3,9 +3,9 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import PackagesListRow from '~/packages_and_registries/package_registry/components/list/package_list_row.vue'; import PackagesListRow from '~/packages_and_registries/package_registry/components/list/package_list_row.vue';
import PackagePath from '~/packages/shared/components/package_path.vue'; import PackagePath from '~/packages_and_registries/shared/components/package_path.vue';
import PackageTags from '~/packages/shared/components/package_tags.vue'; import PackageTags from '~/packages_and_registries/shared/components/package_tags.vue';
import PackageIconAndName from '~/packages/shared/components/package_icon_and_name.vue'; import PackageIconAndName from '~/packages_and_registries/shared/components/package_icon_and_name.vue';
import PublishMethod from '~/packages_and_registries/package_registry/components/list/publish_method.vue'; import PublishMethod from '~/packages_and_registries/package_registry/components/list/publish_method.vue';
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import { PACKAGE_ERROR_STATUS } from '~/packages_and_registries/package_registry/constants'; import { PACKAGE_ERROR_STATUS } from '~/packages_and_registries/package_registry/constants';
......
...@@ -2,7 +2,7 @@ import { GlKeysetPagination, GlModal, GlSprintf } from '@gitlab/ui'; ...@@ -2,7 +2,7 @@ import { GlKeysetPagination, GlModal, GlSprintf } from '@gitlab/ui';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import PackagesListRow from '~/packages_and_registries/package_registry/components/list/package_list_row.vue'; import PackagesListRow from '~/packages_and_registries/package_registry/components/list/package_list_row.vue';
import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue'; import PackagesListLoader from '~/packages_and_registries/shared/components/packages_list_loader.vue';
import { import {
DELETE_PACKAGE_TRACKING_ACTION, DELETE_PACKAGE_TRACKING_ACTION,
REQUEST_DELETE_PACKAGE_TRACKING_ACTION, REQUEST_DELETE_PACKAGE_TRACKING_ACTION,
......
import { GlIcon } from '@gitlab/ui'; import { GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import PackageIconAndName from '~/packages/shared/components/package_icon_and_name.vue'; import PackageIconAndName from '~/packages_and_registries/shared/components/package_icon_and_name.vue';
describe('PackageIconAndName', () => { describe('PackageIconAndName', () => {
let wrapper; let wrapper;
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import PackagePath from '~/packages/shared/components/package_path.vue'; import PackagePath from '~/packages_and_registries/shared/components/package_path.vue';
describe('PackagePath', () => { describe('PackagePath', () => {
let wrapper; let wrapper;
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import PackageTags from '~/packages/shared/components/package_tags.vue'; import PackageTags from '~/packages_and_registries/shared/components/package_tags.vue';
import { mockTags } from 'jest/packages_and_registries/infrastructure_registry/components/mock_data'; import { mockTags } from 'jest/packages_and_registries/infrastructure_registry/components/mock_data';
describe('PackageTags', () => { describe('PackageTags', () => {
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue'; import PackagesListLoader from '~/packages_and_registries/shared/components/packages_list_loader.vue';
describe('PackagesListLoader', () => { describe('PackagesListLoader', () => {
let wrapper; let wrapper;
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import PublishMethod from '~/packages/shared/components/publish_method.vue'; import PublishMethod from '~/packages_and_registries/shared/components/publish_method.vue';
import { packageList } from 'jest/packages_and_registries/infrastructure_registry/components/mock_data'; import { packageList } from 'jest/packages_and_registries/infrastructure_registry/components/mock_data';
describe('publish_method', () => { describe('publish_method', () => {
......
...@@ -4,8 +4,12 @@ import { ...@@ -4,8 +4,12 @@ import {
keyValueToFilterToken, keyValueToFilterToken,
searchArrayToFilterTokens, searchArrayToFilterTokens,
extractFilterAndSorting, extractFilterAndSorting,
beautifyPath,
getCommitLink,
} from '~/packages_and_registries/shared/utils'; } from '~/packages_and_registries/shared/utils';
import { packageList } from 'jest/packages_and_registries/infrastructure_registry/components/mock_data';
describe('Packages And Registries shared utils', () => { describe('Packages And Registries shared utils', () => {
describe('getQueryParams', () => { describe('getQueryParams', () => {
it('returns an object from a query string, with arrays', () => { it('returns an object from a query string, with arrays', () => {
...@@ -56,4 +60,30 @@ describe('Packages And Registries shared utils', () => { ...@@ -56,4 +60,30 @@ describe('Packages And Registries shared utils', () => {
}, },
); );
}); });
describe('beautifyPath', () => {
it('returns a string with spaces around /', () => {
expect(beautifyPath('foo/bar')).toBe('foo / bar');
});
it('does not fail for empty string', () => {
expect(beautifyPath()).toBe('');
});
});
describe('getCommitLink', () => {
it('returns a relative link when isGroup is false', () => {
const link = getCommitLink(packageList[0], false);
expect(link).toContain('../commit');
});
describe('when isGroup is true', () => {
it('returns an absolute link matching project path', () => {
const mavenPackage = packageList[0];
const link = getCommitLink(mavenPackage, true);
expect(link).toContain(`/${mavenPackage.project_path}/commit`);
});
});
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment