Commit a7a96a69 authored by David Fernandez's avatar David Fernandez

Merge branch 'fix/packages-nuget-metadata' into 'master'

Fix detail page of NuGet package with missing metadata

See merge request gitlab-org/gitlab!72013
parents 66037d4e 412acd19
...@@ -24,7 +24,13 @@ export default { ...@@ -24,7 +24,13 @@ export default {
<template> <template>
<div> <div>
<details-row icon="project" padding="gl-p-4" dashed data-testid="nuget-source"> <details-row
v-if="packageEntity.metadata.projectUrl"
icon="project"
padding="gl-p-4"
dashed
data-testid="nuget-source"
>
<gl-sprintf :message="$options.i18n.sourceText"> <gl-sprintf :message="$options.i18n.sourceText">
<template #link> <template #link>
<gl-link :href="packageEntity.metadata.projectUrl" target="_blank">{{ <gl-link :href="packageEntity.metadata.projectUrl" target="_blank">{{
...@@ -33,7 +39,12 @@ export default { ...@@ -33,7 +39,12 @@ export default {
</template> </template>
</gl-sprintf> </gl-sprintf>
</details-row> </details-row>
<details-row icon="license" padding="gl-p-4" data-testid="nuget-license"> <details-row
v-if="packageEntity.metadata.licenseUrl"
icon="license"
padding="gl-p-4"
data-testid="nuget-license"
>
<gl-sprintf :message="$options.i18n.licenseText"> <gl-sprintf :message="$options.i18n.licenseText">
<template #link> <template #link>
<gl-link :href="packageEntity.metadata.licenseUrl" target="_blank">{{ <gl-link :href="packageEntity.metadata.licenseUrl" target="_blank">{{
......
...@@ -10,9 +10,9 @@ module Types ...@@ -10,9 +10,9 @@ module Types
authorize :read_package authorize :read_package
field :id, ::Types::GlobalIDType[::Packages::Nuget::Metadatum], null: false, description: 'ID of the metadatum.' field :id, ::Types::GlobalIDType[::Packages::Nuget::Metadatum], null: false, description: 'ID of the metadatum.'
field :license_url, GraphQL::Types::String, null: false, description: 'License URL of the Nuget package.' field :license_url, GraphQL::Types::String, null: true, description: 'License URL of the Nuget package.'
field :project_url, GraphQL::Types::String, null: false, description: 'Project URL of the Nuget package.' field :project_url, GraphQL::Types::String, null: true, description: 'Project URL of the Nuget package.'
field :icon_url, GraphQL::Types::String, null: false, description: 'Icon URL of the Nuget package.' field :icon_url, GraphQL::Types::String, null: true, description: 'Icon URL of the Nuget package.'
end end
end end
end end
......
...@@ -12148,10 +12148,10 @@ Nuget metadata. ...@@ -12148,10 +12148,10 @@ Nuget metadata.
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| <a id="nugetmetadataiconurl"></a>`iconUrl` | [`String!`](#string) | Icon URL of the Nuget package. | | <a id="nugetmetadataiconurl"></a>`iconUrl` | [`String`](#string) | Icon URL of the Nuget package. |
| <a id="nugetmetadataid"></a>`id` | [`PackagesNugetMetadatumID!`](#packagesnugetmetadatumid) | ID of the metadatum. | | <a id="nugetmetadataid"></a>`id` | [`PackagesNugetMetadatumID!`](#packagesnugetmetadatumid) | ID of the metadatum. |
| <a id="nugetmetadatalicenseurl"></a>`licenseUrl` | [`String!`](#string) | License URL of the Nuget package. | | <a id="nugetmetadatalicenseurl"></a>`licenseUrl` | [`String`](#string) | License URL of the Nuget package. |
| <a id="nugetmetadataprojecturl"></a>`projectUrl` | [`String!`](#string) | Project URL of the Nuget package. | | <a id="nugetmetadataprojecturl"></a>`projectUrl` | [`String`](#string) | Project URL of the Nuget package. |
### `OncallParticipantType` ### `OncallParticipantType`
......
...@@ -9,9 +9,8 @@ import { PACKAGE_TYPE_NUGET } from '~/packages_and_registries/package_registry/c ...@@ -9,9 +9,8 @@ import { PACKAGE_TYPE_NUGET } from '~/packages_and_registries/package_registry/c
import DetailsRow from '~/vue_shared/components/registry/details_row.vue'; import DetailsRow from '~/vue_shared/components/registry/details_row.vue';
const nugetPackage = { packageType: PACKAGE_TYPE_NUGET, metadata: nugetMetadata() };
describe('Nuget Metadata', () => { describe('Nuget Metadata', () => {
let nugetPackage = { packageType: PACKAGE_TYPE_NUGET, metadata: nugetMetadata() };
let wrapper; let wrapper;
const mountComponent = () => { const mountComponent = () => {
...@@ -52,4 +51,30 @@ describe('Nuget Metadata', () => { ...@@ -52,4 +51,30 @@ describe('Nuget Metadata', () => {
expect(element.props('icon')).toBe(icon); expect(element.props('icon')).toBe(icon);
expect(findElementLink(element).attributes('href')).toBe(nugetPackage.metadata[link]); expect(findElementLink(element).attributes('href')).toBe(nugetPackage.metadata[link]);
}); });
describe('without source', () => {
beforeAll(() => {
nugetPackage = {
packageType: PACKAGE_TYPE_NUGET,
metadata: { iconUrl: 'iconUrl', licenseUrl: 'licenseUrl' },
};
});
it('does not show additional metadata', () => {
expect(findNugetSource().exists()).toBe(false);
});
});
describe('without license', () => {
beforeAll(() => {
nugetPackage = {
packageType: PACKAGE_TYPE_NUGET,
metadata: { iconUrl: 'iconUrl', projectUrl: 'projectUrl' },
};
});
it('does not show additional metadata', () => {
expect(findNugetLicense().exists()).toBe(false);
});
});
}); });
...@@ -10,4 +10,10 @@ RSpec.describe GitlabSchema.types['NugetMetadata'] do ...@@ -10,4 +10,10 @@ RSpec.describe GitlabSchema.types['NugetMetadata'] do
expect(described_class).to include_graphql_fields(*expected_fields) expect(described_class).to include_graphql_fields(*expected_fields)
end end
%w[projectUrl licenseUrl iconUrl].each do |optional_field|
it "#{optional_field} can be null" do
expect(described_class.fields[optional_field].type).to be_nullable
end
end
end end
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