From 6456c90cd8c57add97b46781d196956600092c13 Mon Sep 17 00:00:00 2001 From: Samir Jha Date: Wed, 7 Feb 2024 17:29:33 +0000 Subject: [PATCH] Fixes #36988 - CV version should display Container manifest list count --- .../ContentViews/ContentViewsConstants.js | 3 ++ .../Details/ContentViewDetailActions.js | 24 ++++++++++- .../Details/ContentViewDetailSelectors.js | 20 +++++++++- .../Compare/CVVersionCompareConfig.js | 40 +++++++++++++++++-- .../Versions/ContentViewVersionContent.js | 12 +++++- .../ContentViewVersionDetailConfig.js | 36 ++++++++++++++--- 6 files changed, 123 insertions(+), 12 deletions(-) diff --git a/webpack/scenes/ContentViews/ContentViewsConstants.js b/webpack/scenes/ContentViews/ContentViewsConstants.js index d7ce073215f..f1c1e653957 100644 --- a/webpack/scenes/ContentViews/ContentViewsConstants.js +++ b/webpack/scenes/ContentViews/ContentViewsConstants.js @@ -9,6 +9,7 @@ const MODULE_STREAMS_KEY = 'MODULE_STREAMS'; const DEB_PACKAGES_KEY = 'DEB_PACKAGES'; const DOCKER_TAGS_KEY = 'DOCKER_TAGS'; const FILES_KEY = 'FILES'; +const CONTAINER_MANIFEST_LISTS_KEY = 'CONTAINER_MANIFEST_LISTS'; export const CREATE_CONTENT_VIEW_KEY = 'CONTENT_VIEW_CREATE'; export const COPY_CONTENT_VIEW_KEY = 'CONTENT_VIEW_COPY'; export const CREATE_CONTENT_VIEW_FILTER_KEY = 'CONTENT_VIEW_FILTER_CREATE'; @@ -31,6 +32,7 @@ export const RPM_PACKAGE_GROUPS_CONTENT = 'RPM_PACKAGE_GROUPS_CONTENT'; export const REPOSITORY_CONTENT = 'REPOSITORY_CONTENT'; export const ERRATA_CONTENT = 'ERRATA_CONTENT'; export const DOCKER_TAGS_CONTENT = 'DOCKER_TAGS_CONTENT'; +export const CONTAINER_MANIFEST_LIST_CONTENT = 'CONTAINER_MANIFEST_LIST_CONTENT'; export const MODULE_STREAMS_CONTENT = 'MODULE_STREAMS_CONTENT'; export const DEB_PACKAGES_CONTENT = 'DEB_PACKAGES_CONTENT'; export const RPM_PACKAGES_CONTENT = 'RPM_PACKAGES_CONTENT'; @@ -72,6 +74,7 @@ export const cvErrataCompareKey = (versionOne, versionTwo, viewBy) => `${ERRATA_ export const cvModuleStreamsCompareKey = (versionOne, versionTwo, viewBy) => `${MODULE_STREAMS_KEY}_COMPARE_${versionOne}_${versionTwo}_VIEW_BY_${toUpper(viewBy)}`; export const cvDebPackagesCompareKey = (versionOne, versionTwo, viewBy) => `${DEB_PACKAGES_KEY}_COMPARE_${versionOne}_${versionTwo}_VIEW_BY_${toUpper(viewBy)}`; export const cvDockerTagsCompareKey = (versionOne, versionTwo, viewBy) => `${DOCKER_TAGS_KEY}_COMPARE_${versionOne}_${versionTwo}_VIEW_BY_${toUpper(viewBy)}`; +export const cvContainerManifestListsCompareKey = (versionOne, versionTwo, viewBy) => `${CONTAINER_MANIFEST_LISTS_KEY}_COMPARE_${versionOne}_${versionTwo}_VIEW_BY_${toUpper(viewBy)}`; export const filesCompareKey = (versionOne, versionTwo, viewBy) => `${FILES_KEY}_COMPARE_${versionOne}_${versionTwo}_VIEW_BY_${toUpper(viewBy)}`; // Repo added to content view status display and key export const ADDED = __('Added'); diff --git a/webpack/scenes/ContentViews/Details/ContentViewDetailActions.js b/webpack/scenes/ContentViews/Details/ContentViewDetailActions.js index 1d282434a33..81a5eaa1c6f 100644 --- a/webpack/scenes/ContentViews/Details/ContentViewDetailActions.js +++ b/webpack/scenes/ContentViews/Details/ContentViewDetailActions.js @@ -47,6 +47,7 @@ import { MODULE_STREAMS_CONTENT, DEB_PACKAGES_CONTENT, DOCKER_TAGS_CONTENT, + CONTAINER_MANIFEST_LIST_CONTENT, generatedContentKey, STATUS_TRANSLATIONS_ENUM, bulkRemoveVersionKey, @@ -58,7 +59,7 @@ import { cvDebPackagesCompareKey, filesCompareKey, genericContentCompareKey, - cvRepositoriesCompareKey, + cvRepositoriesCompareKey, cvContainerManifestListsCompareKey, } from '../ContentViewsConstants'; import api, { foremanApi, orgId } from '../../../services/api'; import { getResponseErrorMsgs } from '../../../utils/helpers'; @@ -179,6 +180,19 @@ export const getDockerTagsComparison = (versionOne, versionTwo, viewBy, params) }); }; +export const getContainerManifestListsComparison = (versionOne, versionTwo, viewBy, params) => { + const versions = { content_view_version_ids: [versionOne, versionTwo] }; + const restrictComparison = { restrict_comparison: viewBy }; + const apiParams = { ...versions, ...restrictComparison, ...params }; + const apiUrl = '/docker_manifest_lists/compare'; + return get({ + key: cvContainerManifestListsCompareKey(versionOne, versionTwo, viewBy), + params: apiParams, + errorToast: error => __(`Something went wrong while retrieving the container tags! ${getResponseErrorMsgs(error.response)}`), + url: api.getApiUrl(apiUrl), + }); +}; + export const getFilesComparison = (versionOne, versionTwo, viewBy, params) => { const versions = { content_view_version_ids: [versionOne, versionTwo] }; const restrictComparison = { restrict_comparison: viewBy }; @@ -268,6 +282,14 @@ export const getDockerTags = params => get({ errorToast: error => __(`Something went wrong while getting container tags! ${getResponseErrorMsgs(error.response)}`), }); +export const getContainerManifestLists = params => get({ + type: API_OPERATIONS.GET, + key: CONTAINER_MANIFEST_LIST_CONTENT, + url: api.getApiUrl('/docker_manifest_lists'), + params, + errorToast: error => __(`Something went wrong while getting container manifest lists! ${getResponseErrorMsgs(error.response)}`), +}); + export const getErrata = params => get({ type: API_OPERATIONS.GET, key: ERRATA_CONTENT, diff --git a/webpack/scenes/ContentViews/Details/ContentViewDetailSelectors.js b/webpack/scenes/ContentViews/Details/ContentViewDetailSelectors.js index 26e9ce40783..67f0d550b5a 100644 --- a/webpack/scenes/ContentViews/Details/ContentViewDetailSelectors.js +++ b/webpack/scenes/ContentViews/Details/ContentViewDetailSelectors.js @@ -44,7 +44,10 @@ import { cvDockerTagsCompareKey, cvDebPackagesCompareKey, filesCompareKey, - genericContentCompareKey, cvRepositoriesCompareKey, + genericContentCompareKey, + cvRepositoriesCompareKey, + CONTAINER_MANIFEST_LIST_CONTENT, + cvContainerManifestListsCompareKey, } from '../ContentViewsConstants'; export const selectCVDetails = (state, cvId) => @@ -191,6 +194,15 @@ export const selectDockerTagsComparisonStatus = (state, versionOne, versionTwo, export const selectDockerTagsComparisonError = (state, versionOne, versionTwo, viewBy) => selectAPIError(state, cvDockerTagsCompareKey(versionOne, versionTwo, viewBy)); +export const selectContainerManifestListsComparison = (state, versionOne, versionTwo, viewBy) => + selectAPIResponse(state, cvContainerManifestListsCompareKey(versionOne, versionTwo, viewBy)) + || {}; + +export const selectContainerManifestListsComparisonStatus = + (state, versionOne, versionTwo, viewBy) => + selectAPIStatus(state, cvContainerManifestListsCompareKey(versionOne, versionTwo, viewBy)) + || STATUS.PENDING; + export const selectDebPackagesComparison = (state, versionOne, versionTwo, viewBy) => selectAPIResponse(state, cvDebPackagesCompareKey(versionOne, versionTwo, viewBy)) || {}; @@ -243,6 +255,12 @@ export const selectDockerTags = state => export const selectDockerTagsStatus = state => selectAPIStatus(state, DOCKER_TAGS_CONTENT) || STATUS.PENDING; +export const selectContainerManifestLists = state => + selectAPIResponse(state, CONTAINER_MANIFEST_LIST_CONTENT); + +export const selectContainerManifestListsStatus = state => + selectAPIStatus(state, CONTAINER_MANIFEST_LIST_CONTENT) || STATUS.PENDING; + export const selectRepositories = state => selectAPIResponse(state, REPOSITORY_CONTENT); diff --git a/webpack/scenes/ContentViews/Details/Versions/Compare/CVVersionCompareConfig.js b/webpack/scenes/ContentViews/Details/Versions/Compare/CVVersionCompareConfig.js index 9ed79ca9cbb..ad6bb7903b2 100644 --- a/webpack/scenes/ContentViews/Details/Versions/Compare/CVVersionCompareConfig.js +++ b/webpack/scenes/ContentViews/Details/Versions/Compare/CVVersionCompareConfig.js @@ -21,6 +21,8 @@ import { selectDebPackagesComparisonStatus, selectDockerTagsComparison, selectDockerTagsComparisonStatus, + selectContainerManifestListsComparison, + selectContainerManifestListsComparisonStatus, selectGenericContentComparison, selectGenericContentComparisonStatus, selectRepositoriesComparison, @@ -34,6 +36,7 @@ import { getModuleStreamsComparison, getDebPackagesComparison, getDockerTagsComparison, + getContainerManifestListsComparison, getGenericContentComparison, getRepositoriesComparison, } from '../../ContentViewDetailActions'; @@ -361,10 +364,10 @@ export default ({ ), }, { - title: __('Available Schema Versions'), + title: __('Available schema versions'), getProperty: (item) => { - if (item?.manifest_schema1) return __('Schema Version 1'); - return __('Schema Version 2'); + if (item?.manifest_schema1) return __('Schema version 1'); + return __('Schema version 2'); }, }, { @@ -382,6 +385,37 @@ export default ({ [__('Name')]: 'name', }, }, + { + name: __('Container manifest lists'), + getCountKey: (itemVersionOne, itemVersionTwo) => + itemVersionOne?.docker_manifest_list_count || itemVersionTwo?.docker_manifest_list_count, + responseSelector: state => + selectContainerManifestListsComparison(state, versionOneId, versionTwoId, viewBy), + statusSelector: state => + selectContainerManifestListsComparisonStatus(state, versionOneId, versionTwoId, viewBy), + autocompleteEndpoint: '/katello/api/v2/docker_manifest_lists', + bookmarkController: 'katello_content_view_components', + fetchItems: params => + getContainerManifestListsComparison(versionOneId, versionTwoId, viewBy, params), + columnHeaders: [ + { + title: __('Digest'), + getProperty: item => item?.digest, + }, + { + title: __('Available schema versions'), + getProperty: (item) => { + if (item?.manifest_schema1) return __('Schema version 1'); + return __('Schema version 2'); + }, + }, + { title: __(`Version ${versionOne}`), getProperty: item => compareContent(item, versionOneId) }, + { title: __(`Version ${versionTwo}`), getProperty: item => compareContent(item, versionTwoId) }, + ], + sortConfig: { + [__('Digest')]: 'digest', + }, + }, ...ContentConfig.filter(config => !(config.names.pluralLabel === 'ostree_refs')).map(({ names: { pluralLowercase, pluralLabel, singularLabel }, columnHeaders, diff --git a/webpack/scenes/ContentViews/Details/Versions/ContentViewVersionContent.js b/webpack/scenes/ContentViews/Details/Versions/ContentViewVersionContent.js index e90598fd826..140d8e0842d 100644 --- a/webpack/scenes/ContentViews/Details/Versions/ContentViewVersionContent.js +++ b/webpack/scenes/ContentViews/Details/Versions/ContentViewVersionContent.js @@ -11,13 +11,13 @@ const ContentViewVersionContent = ({ cvId, versionId, cvVersion }) => { const { deb_count: debCount = 0, docker_manifest_count: dockerManifestCount = 0, + docker_manifest_list_count: dockerManifestListCount = 0, docker_tag_count: dockerTagCount = 0, file_count: fileCount = 0, module_stream_count: moduleStreamCount = 0, ansible_collection_count: ansibleCollectionCount = 0, } = cvVersion; - const contentConfigTypes = ContentConfig.filter(({ names: { singularLabel } }) => !!cvVersion[`${singularLabel}_count`]) .map(({ @@ -37,7 +37,7 @@ const ContentViewVersionContent = ({ cvId, versionId, cvVersion }) => { const noCounts = !Number(debCount) && !Number(dockerManifestCount) && !Number(dockerTagCount) && !Number(fileCount) && !Number(moduleStreamCount) && !Number(ansibleCollectionCount) && - !contentConfigTypes?.length; + !Number(dockerManifestListCount) && !contentConfigTypes?.length; if (noCounts) { return ; @@ -67,6 +67,13 @@ const ContentViewVersionContent = ({ cvId, versionId, cvVersion }) => { {`${dockerManifestCount} Container manifests`}
} + {dockerManifestListCount > 0 && + <> + + {`${dockerManifestListCount} Container manifest lists`} +
+ + } {fileCount > 0 && <> {`${fileCount} Files`}
@@ -90,6 +97,7 @@ ContentViewVersionContent.propTypes = { cvVersion: PropTypes.shape({ deb_count: PropTypes.number, docker_manifest_count: PropTypes.number, + docker_manifest_list_count: PropTypes.number, docker_tag_count: PropTypes.number, file_count: PropTypes.number, module_stream_count: PropTypes.number, diff --git a/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetailConfig.js b/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetailConfig.js index 998c4903883..64c48d2c0e9 100644 --- a/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetailConfig.js +++ b/webpack/scenes/ContentViews/Details/Versions/VersionDetails/ContentViewVersionDetailConfig.js @@ -20,7 +20,7 @@ import { getPackageGroups, getRepositories, getRPMPackages, - getContent, + getContent, getContainerManifestLists, } from '../../ContentViewDetailActions'; import { selectCVVersions, @@ -42,7 +42,7 @@ import { selectRPMPackages, selectRPMPackagesStatus, selectContent, - selectContentStatus, + selectContentStatus, selectContainerManifestLists, selectContainerManifestListsStatus, } from '../../ContentViewDetailSelectors'; import ContentViewVersionRepositoryCell from './ContentViewVersionRepositoryCell'; import ContentConfig from '../../../../Content/ContentConfig'; @@ -324,10 +324,10 @@ export default ({ cvId, versionId }) => [ ), }, { - title: __('Available Schema Versions'), + title: __('Available schema versions'), getProperty: (item) => { - if (item?.manifest_schema1) return __('Schema Version 1'); - return __('Schema Version 2'); + if (item?.manifest_schema1) return __('Schema version 1'); + return __('Schema version 2'); }, }, { @@ -340,6 +340,32 @@ export default ({ cvId, versionId }) => [ { title: __('Image'), getProperty: item => item?.upstream_name }, ], }, + { + name: __('Container manifest lists'), + route: 'dockerManifestList', + repoType: 'docker', + getCountKey: item => item?.docker_manifest_list_count, + responseSelector: state => selectContainerManifestLists(state), + statusSelector: state => selectContainerManifestListsStatus(state), + autocompleteEndpoint: '/katello/api/v2/docker_manifest_lists', + autocompleteQueryParams: { content_view_version_id: versionId }, + bookmarkController: 'katello_content_view_components', + fetchItems: params => + getContainerManifestLists({ content_view_version_id: versionId, ...params }), + columnHeaders: [ + { + title: __('Digest'), + getProperty: item => item?.digest, + }, + { + title: __('Available schema versions'), + getProperty: (item) => { + if (item?.manifest_schema1) return __('Schema version 1'); + return __('Schema version 2'); + }, + }, + ], + }, ...ContentConfig.map(({ names: { pluralTitle, pluralLabel, singularLabel }, columnHeaders,