Commit 8d2ba695 authored by Sean McGivern's avatar Sean McGivern

Merge branch '239130-package-presenter-conan' into 'master'

Use conan recipe as name in package presenter

See merge request gitlab-org/gitlab!44294
parents 59ff37b8 2f163a92
......@@ -2,7 +2,6 @@
import { GlLink, GlSprintf } from '@gitlab/ui';
import { s__ } from '~/locale';
import DetailsRow from '~/vue_shared/components/registry/details_row.vue';
import { generateConanRecipe } from '../utils';
import { PackageType } from '../../shared/constants';
export default {
......@@ -25,9 +24,6 @@ export default {
},
},
computed: {
conanRecipe() {
return generateConanRecipe(this.packageEntity);
},
showMetadata() {
const visibilityConditions = {
[PackageType.NUGET]: this.packageEntity.nuget_metadatum,
......@@ -73,7 +69,7 @@ export default {
data-testid="conan-recipe"
>
<gl-sprintf :message="$options.i18n.recipeText">
<template #recipe>{{ conanRecipe }}</template>
<template #recipe>{{ packageEntity.name }}</template>
</gl-sprintf>
</details-row>
......
import { generateConanRecipe } from '../utils';
import { PackageType } from '../../shared/constants';
import { getPackageTypeLabel } from '../../shared/utils';
import { NpmManager } from '../constants';
......@@ -20,10 +19,8 @@ export const packageIcon = ({ packageEntity }) => {
};
export const conanInstallationCommand = ({ packageEntity }) => {
const recipe = generateConanRecipe(packageEntity);
// eslint-disable-next-line @gitlab/require-i18n-strings
return `conan install ${recipe} --remote=gitlab`;
return `conan install ${packageEntity.name} --remote=gitlab`;
};
export const conanSetupCommand = ({ conanPath }) =>
......
......@@ -8,16 +8,3 @@ export const trackInstallationTabChange = {
},
},
};
export function generateConanRecipe(packageEntity = {}) {
const {
name = '',
version = '',
conan_metadatum: {
package_username: packageUsername = '',
package_channel: packageChannel = '',
} = {},
} = packageEntity;
return `${name}/${version}@${packageUsername}/${packageChannel}`;
}
......@@ -8,10 +8,13 @@ module Packages
end
def detail_view
name = @package.name
name = @package.conan_recipe if @package.conan?
package_detail = {
id: @package.id,
created_at: @package.created_at,
name: @package.name,
name: name,
package_files: @package.package_files.map { |pf| build_package_file_view(pf) },
package_type: @package.package_type,
project_id: @package.project_id,
......@@ -20,6 +23,7 @@ module Packages
version: @package.version
}
package_detail[:conan_package_name] = @package.name if @package.conan?
package_detail[:maven_metadatum] = @package.maven_metadatum if @package.maven_metadatum
package_detail[:nuget_metadatum] = @package.nuget_metadatum if @package.nuget_metadatum
package_detail[:composer_metadatum] = @package.composer_metadatum if @package.composer_metadatum
......
---
title: Display conan recipe as package name on package detail page
merge_request: 44294
author:
type: changed
......@@ -31,7 +31,6 @@ import {
registryUrl,
pypiSetupCommandStr,
} from '../mock_data';
import { generateConanRecipe } from '~/packages/details/utils';
import { NpmManager } from '~/packages/details/constants';
describe('Getters PackageDetails Store', () => {
......@@ -53,8 +52,7 @@ describe('Getters PackageDetails Store', () => {
};
};
const recipe = generateConanRecipe(conanPackage);
const conanInstallationCommandStr = `conan install ${recipe} --remote=gitlab`;
const conanInstallationCommandStr = `conan install ${conanPackage.name} --remote=gitlab`;
const conanSetupCommandStr = `conan remote add gitlab ${registryUrl}`;
const mavenCommandStr = generateMavenCommand(packageWithoutBuildInfo.maven_metadatum);
......
import { generateConanRecipe } from '~/packages/details/utils';
import { conanPackage } from '../mock_data';
describe('Package detail utils', () => {
describe('generateConanRecipe', () => {
it('correctly generates the conan recipe', () => {
const recipe = generateConanRecipe(conanPackage);
expect(recipe).toEqual(conanPackage.recipe);
});
it('returns an empty recipe when no information is supplied', () => {
const recipe = generateConanRecipe({});
expect(recipe).toEqual('/@/');
});
it('recipe returns empty strings for missing metadata', () => {
const recipe = generateConanRecipe({ name: 'foo', version: '0.0.1' });
expect(recipe).toBe('foo/0.0.1@/');
});
});
});
......@@ -84,15 +84,15 @@ export const conanPackage = {
package_channel: 'stable',
package_username: 'conan+conan-package',
},
conan_package_name: 'conan-package',
created_at: '2015-12-10',
id: 3,
name: 'conan-package',
name: 'conan-package/1.0.0@conan+conan-package/stable',
project_path: 'foo/bar/baz',
projectPathName: 'foo/bar/baz',
package_files: [],
package_type: 'conan',
project_id: 1,
recipe: 'conan-package/1.0.0@conan+conan-package/stable',
updated_at: '2015-12-10',
version: '1.0.0',
_links,
......
......@@ -76,7 +76,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
context 'with conan metadata' do
let(:package) { create(:conan_package, project: project) }
let(:expected_package_details) { super().merge(conan_metadatum: package.conan_metadatum) }
let(:expected_package_details) { super().merge(conan_metadatum: package.conan_metadatum, conan_package_name: package.name, name: package.conan_recipe) }
it 'returns conan_metadatum' do
expect(presenter.detail_view).to eq expected_package_details
......
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