Commit 2f163a92 authored by Steve Abrams's avatar Steve Abrams Committed by Sean McGivern

Use conan recipe as name in package presenter

Returns conan recipe as the package name attribute
Removes unneeded frontend helper that composed the
recipe.
parent f2e77c33
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import { GlLink, GlSprintf } from '@gitlab/ui'; import { GlLink, GlSprintf } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import DetailsRow from '~/vue_shared/components/registry/details_row.vue'; import DetailsRow from '~/vue_shared/components/registry/details_row.vue';
import { generateConanRecipe } from '../utils';
import { PackageType } from '../../shared/constants'; import { PackageType } from '../../shared/constants';
export default { export default {
...@@ -25,9 +24,6 @@ export default { ...@@ -25,9 +24,6 @@ export default {
}, },
}, },
computed: { computed: {
conanRecipe() {
return generateConanRecipe(this.packageEntity);
},
showMetadata() { showMetadata() {
const visibilityConditions = { const visibilityConditions = {
[PackageType.NUGET]: this.packageEntity.nuget_metadatum, [PackageType.NUGET]: this.packageEntity.nuget_metadatum,
...@@ -73,7 +69,7 @@ export default { ...@@ -73,7 +69,7 @@ export default {
data-testid="conan-recipe" data-testid="conan-recipe"
> >
<gl-sprintf :message="$options.i18n.recipeText"> <gl-sprintf :message="$options.i18n.recipeText">
<template #recipe>{{ conanRecipe }}</template> <template #recipe>{{ packageEntity.name }}</template>
</gl-sprintf> </gl-sprintf>
</details-row> </details-row>
......
import { generateConanRecipe } from '../utils';
import { PackageType } from '../../shared/constants'; import { PackageType } from '../../shared/constants';
import { getPackageTypeLabel } from '../../shared/utils'; import { getPackageTypeLabel } from '../../shared/utils';
import { NpmManager } from '../constants'; import { NpmManager } from '../constants';
...@@ -20,10 +19,8 @@ export const packageIcon = ({ packageEntity }) => { ...@@ -20,10 +19,8 @@ export const packageIcon = ({ packageEntity }) => {
}; };
export const conanInstallationCommand = ({ packageEntity }) => { export const conanInstallationCommand = ({ packageEntity }) => {
const recipe = generateConanRecipe(packageEntity);
// eslint-disable-next-line @gitlab/require-i18n-strings // 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 }) => export const conanSetupCommand = ({ conanPath }) =>
......
...@@ -8,16 +8,3 @@ export const trackInstallationTabChange = { ...@@ -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 ...@@ -8,10 +8,13 @@ module Packages
end end
def detail_view def detail_view
name = @package.name
name = @package.conan_recipe if @package.conan?
package_detail = { package_detail = {
id: @package.id, id: @package.id,
created_at: @package.created_at, created_at: @package.created_at,
name: @package.name, name: name,
package_files: @package.package_files.map { |pf| build_package_file_view(pf) }, package_files: @package.package_files.map { |pf| build_package_file_view(pf) },
package_type: @package.package_type, package_type: @package.package_type,
project_id: @package.project_id, project_id: @package.project_id,
...@@ -20,6 +23,7 @@ module Packages ...@@ -20,6 +23,7 @@ module Packages
version: @package.version 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[:maven_metadatum] = @package.maven_metadatum if @package.maven_metadatum
package_detail[:nuget_metadatum] = @package.nuget_metadatum if @package.nuget_metadatum package_detail[:nuget_metadatum] = @package.nuget_metadatum if @package.nuget_metadatum
package_detail[:composer_metadatum] = @package.composer_metadatum if @package.composer_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 { ...@@ -31,7 +31,6 @@ import {
registryUrl, registryUrl,
pypiSetupCommandStr, pypiSetupCommandStr,
} from '../mock_data'; } from '../mock_data';
import { generateConanRecipe } from '~/packages/details/utils';
import { NpmManager } from '~/packages/details/constants'; import { NpmManager } from '~/packages/details/constants';
describe('Getters PackageDetails Store', () => { describe('Getters PackageDetails Store', () => {
...@@ -53,8 +52,7 @@ describe('Getters PackageDetails Store', () => { ...@@ -53,8 +52,7 @@ describe('Getters PackageDetails Store', () => {
}; };
}; };
const recipe = generateConanRecipe(conanPackage); const conanInstallationCommandStr = `conan install ${conanPackage.name} --remote=gitlab`;
const conanInstallationCommandStr = `conan install ${recipe} --remote=gitlab`;
const conanSetupCommandStr = `conan remote add gitlab ${registryUrl}`; const conanSetupCommandStr = `conan remote add gitlab ${registryUrl}`;
const mavenCommandStr = generateMavenCommand(packageWithoutBuildInfo.maven_metadatum); 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 = { ...@@ -84,15 +84,15 @@ export const conanPackage = {
package_channel: 'stable', package_channel: 'stable',
package_username: 'conan+conan-package', package_username: 'conan+conan-package',
}, },
conan_package_name: 'conan-package',
created_at: '2015-12-10', created_at: '2015-12-10',
id: 3, id: 3,
name: 'conan-package', name: 'conan-package/1.0.0@conan+conan-package/stable',
project_path: 'foo/bar/baz', project_path: 'foo/bar/baz',
projectPathName: 'foo/bar/baz', projectPathName: 'foo/bar/baz',
package_files: [], package_files: [],
package_type: 'conan', package_type: 'conan',
project_id: 1, project_id: 1,
recipe: 'conan-package/1.0.0@conan+conan-package/stable',
updated_at: '2015-12-10', updated_at: '2015-12-10',
version: '1.0.0', version: '1.0.0',
_links, _links,
......
...@@ -76,7 +76,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do ...@@ -76,7 +76,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
context 'with conan metadata' do context 'with conan metadata' do
let(:package) { create(:conan_package, project: project) } 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 it 'returns conan_metadatum' do
expect(presenter.detail_view).to eq expected_package_details 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