Commit ffa1d139 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '337468-display-available-metadata-for-pypi' into 'master'

Display available metadata for PyPI

See merge request gitlab-org/gitlab!69967
parents cbc14bb5 94f5de02
...@@ -6,6 +6,7 @@ import { ...@@ -6,6 +6,7 @@ import {
PACKAGE_TYPE_CONAN, PACKAGE_TYPE_CONAN,
PACKAGE_TYPE_MAVEN, PACKAGE_TYPE_MAVEN,
PACKAGE_TYPE_COMPOSER, PACKAGE_TYPE_COMPOSER,
PACKAGE_TYPE_PYPI,
} from '~/packages_and_registries/package_registry/constants'; } from '~/packages_and_registries/package_registry/constants';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import DetailsRow from '~/vue_shared/components/registry/details_row.vue'; import DetailsRow from '~/vue_shared/components/registry/details_row.vue';
...@@ -22,6 +23,7 @@ export default { ...@@ -22,6 +23,7 @@ export default {
composerJson: s__( composerJson: s__(
'PackageRegistry|Composer.json with license: %{license} and version: %{version}', 'PackageRegistry|Composer.json with license: %{license} and version: %{version}',
), ),
requiredPython: s__('PackageRegistry|Required Python: %{pythonVersion}'),
}, },
components: { components: {
DetailsRow, DetailsRow,
...@@ -43,6 +45,7 @@ export default { ...@@ -43,6 +45,7 @@ export default {
PACKAGE_TYPE_CONAN, PACKAGE_TYPE_CONAN,
PACKAGE_TYPE_MAVEN, PACKAGE_TYPE_MAVEN,
PACKAGE_TYPE_COMPOSER, PACKAGE_TYPE_COMPOSER,
PACKAGE_TYPE_PYPI,
].includes(this.packageEntity.packageType) && this.packageEntity.metadata ].includes(this.packageEntity.packageType) && this.packageEntity.metadata
); );
}, },
...@@ -58,6 +61,9 @@ export default { ...@@ -58,6 +61,9 @@ export default {
showComposerMetadata() { showComposerMetadata() {
return this.packageEntity.packageType === PACKAGE_TYPE_COMPOSER; return this.packageEntity.packageType === PACKAGE_TYPE_COMPOSER;
}, },
showPypiMetadata() {
return this.packageEntity.packageType === PACKAGE_TYPE_PYPI;
},
}, },
}; };
</script> </script>
...@@ -141,6 +147,19 @@ export default { ...@@ -141,6 +147,19 @@ export default {
</gl-sprintf> </gl-sprintf>
</details-row> </details-row>
</template> </template>
<details-row
v-else-if="showPypiMetadata"
icon="information-o"
padding="gl-p-4"
data-testid="pypi-required-python"
>
<gl-sprintf :message="$options.i18n.requiredPython">
<template #pythonVersion>
<strong>{{ packageEntity.metadata.requiredPython }}</strong>
</template>
</gl-sprintf>
</details-row>
</div> </div>
</div> </div>
</template> </template>
...@@ -24043,6 +24043,9 @@ msgstr "" ...@@ -24043,6 +24043,9 @@ msgstr ""
msgid "PackageRegistry|Remove package" msgid "PackageRegistry|Remove package"
msgstr "" msgstr ""
msgid "PackageRegistry|Required Python: %{pythonVersion}"
msgstr ""
msgid "PackageRegistry|RubyGems" msgid "PackageRegistry|RubyGems"
msgstr "" msgstr ""
......
...@@ -6,6 +6,7 @@ import { ...@@ -6,6 +6,7 @@ import {
nugetMetadata, nugetMetadata,
packageData, packageData,
composerMetadata, composerMetadata,
pypiMetadata,
} from 'jest/packages_and_registries/package_registry/mock_data'; } from 'jest/packages_and_registries/package_registry/mock_data';
import component from '~/packages_and_registries/package_registry/components/details/additional_metadata.vue'; import component from '~/packages_and_registries/package_registry/components/details/additional_metadata.vue';
import { import {
...@@ -14,6 +15,7 @@ import { ...@@ -14,6 +15,7 @@ import {
PACKAGE_TYPE_MAVEN, PACKAGE_TYPE_MAVEN,
PACKAGE_TYPE_NPM, PACKAGE_TYPE_NPM,
PACKAGE_TYPE_COMPOSER, PACKAGE_TYPE_COMPOSER,
PACKAGE_TYPE_PYPI,
} from '~/packages_and_registries/package_registry/constants'; } from '~/packages_and_registries/package_registry/constants';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import DetailsRow from '~/vue_shared/components/registry/details_row.vue'; import DetailsRow from '~/vue_shared/components/registry/details_row.vue';
...@@ -22,6 +24,7 @@ const mavenPackage = { packageType: PACKAGE_TYPE_MAVEN, metadata: mavenMetadata( ...@@ -22,6 +24,7 @@ const mavenPackage = { packageType: PACKAGE_TYPE_MAVEN, metadata: mavenMetadata(
const conanPackage = { packageType: PACKAGE_TYPE_CONAN, metadata: conanMetadata() }; const conanPackage = { packageType: PACKAGE_TYPE_CONAN, metadata: conanMetadata() };
const nugetPackage = { packageType: PACKAGE_TYPE_NUGET, metadata: nugetMetadata() }; const nugetPackage = { packageType: PACKAGE_TYPE_NUGET, metadata: nugetMetadata() };
const composerPackage = { packageType: PACKAGE_TYPE_COMPOSER, metadata: composerMetadata() }; const composerPackage = { packageType: PACKAGE_TYPE_COMPOSER, metadata: composerMetadata() };
const pypiPackage = { packageType: PACKAGE_TYPE_PYPI, metadata: pypiMetadata() };
const npmPackage = { packageType: PACKAGE_TYPE_NPM, metadata: {} }; const npmPackage = { packageType: PACKAGE_TYPE_NPM, metadata: {} };
describe('Package Additional Metadata', () => { describe('Package Additional Metadata', () => {
...@@ -58,6 +61,7 @@ describe('Package Additional Metadata', () => { ...@@ -58,6 +61,7 @@ describe('Package Additional Metadata', () => {
const findComposerTargetSha = () => wrapper.findByTestId('composer-target-sha'); const findComposerTargetSha = () => wrapper.findByTestId('composer-target-sha');
const findComposerTargetShaCopyButton = () => wrapper.findComponent(ClipboardButton); const findComposerTargetShaCopyButton = () => wrapper.findComponent(ClipboardButton);
const findComposerJson = () => wrapper.findByTestId('composer-json'); const findComposerJson = () => wrapper.findByTestId('composer-json');
const findPypiRequiredPython = () => wrapper.findByTestId('pypi-required-python');
it('has the correct title', () => { it('has the correct title', () => {
mountComponent(); mountComponent();
...@@ -74,6 +78,7 @@ describe('Package Additional Metadata', () => { ...@@ -74,6 +78,7 @@ describe('Package Additional Metadata', () => {
${conanPackage} | ${true} | ${PACKAGE_TYPE_CONAN} ${conanPackage} | ${true} | ${PACKAGE_TYPE_CONAN}
${nugetPackage} | ${true} | ${PACKAGE_TYPE_NUGET} ${nugetPackage} | ${true} | ${PACKAGE_TYPE_NUGET}
${composerPackage} | ${true} | ${PACKAGE_TYPE_COMPOSER} ${composerPackage} | ${true} | ${PACKAGE_TYPE_COMPOSER}
${pypiPackage} | ${true} | ${PACKAGE_TYPE_PYPI}
${npmPackage} | ${false} | ${PACKAGE_TYPE_NPM} ${npmPackage} | ${false} | ${PACKAGE_TYPE_NPM}
`( `(
`It is $visible that the component is visible when the package is $packageType`, `It is $visible that the component is visible when the package is $packageType`,
...@@ -160,4 +165,20 @@ describe('Package Additional Metadata', () => { ...@@ -160,4 +165,20 @@ describe('Package Additional Metadata', () => {
}); });
}); });
}); });
describe('pypi metadata', () => {
beforeEach(() => {
mountComponent({ packageEntity: pypiPackage });
});
it.each`
name | finderFunction | text | icon
${'pypi-required-python'} | ${findPypiRequiredPython} | ${'Required Python: 1.0.0'} | ${'information-o'}
`('$name element', ({ finderFunction, text, icon }) => {
const element = finderFunction();
expect(element.exists()).toBe(true);
expect(element.text()).toBe(text);
expect(element.props('icon')).toBe(icon);
});
});
}); });
...@@ -133,7 +133,7 @@ export const composerMetadata = () => ({ ...@@ -133,7 +133,7 @@ export const composerMetadata = () => ({
}, },
}); });
export const pypyMetadata = () => ({ export const pypiMetadata = () => ({
requiredPython: '1.0.0', requiredPython: '1.0.0',
}); });
...@@ -157,7 +157,7 @@ export const packageDetailsQuery = (extendPackage) => ({ ...@@ -157,7 +157,7 @@ export const packageDetailsQuery = (extendPackage) => ({
metadata: { metadata: {
...conanMetadata(), ...conanMetadata(),
...composerMetadata(), ...composerMetadata(),
...pypyMetadata(), ...pypiMetadata(),
...mavenMetadata(), ...mavenMetadata(),
...nugetMetadata(), ...nugetMetadata(),
}, },
......
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