-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #36758 - Add content counts to capsule content view UI
(cherry picked from commit ad08dad)
- Loading branch information
Showing
6 changed files
with
204 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { translate as __ } from 'foremanReact/common/I18n'; | ||
import ContentConfig from '../Content/ContentConfig'; | ||
|
||
const AdditionalCapsuleContent = ({ counts }) => { | ||
//console.log(counts); | ||
const { | ||
'deb.package': debPackageCount = 0, | ||
docker_manifest: dockerManifestCount = 0, | ||
docker_tag: dockerTagCount = 0, | ||
file: fileCount = 0, | ||
erratum: errataCount = 0, | ||
package_group: packageGroup = 0, | ||
'rpm.modulemd': moduleStreamCount = 0, | ||
} = counts; | ||
|
||
const contentConfigTypes = ContentConfig.filter(({ names: { capsuleCountLabel } }) => | ||
!!counts[`${capsuleCountLabel}`]) | ||
.map(({ | ||
names: { | ||
capsuleCountLabel, pluralLowercase, | ||
}, | ||
}) => { | ||
const countParam = `${capsuleCountLabel}`; | ||
const count = counts[countParam]; | ||
return { | ||
pluralLowercase, | ||
count, | ||
}; | ||
}); | ||
//console.log(contentConfigTypes); | ||
|
||
return ( | ||
<> | ||
{errataCount > 0 && | ||
<> | ||
{`${errataCount} Errata`}<br /> | ||
</> | ||
} | ||
{moduleStreamCount > 0 && | ||
<> | ||
{`${moduleStreamCount} Module streams`}<br /> | ||
</> | ||
} | ||
{packageGroup > 0 && | ||
<> | ||
{`${packageGroup} Package groups`}<br /> | ||
</> | ||
} | ||
{dockerTagCount > 0 && | ||
<> | ||
{`${dockerTagCount} Container tags`}<br /> | ||
</> | ||
} | ||
{dockerManifestCount > 0 && | ||
<> | ||
{`${dockerManifestCount} Container manifests`}<br /> | ||
</> | ||
} | ||
{fileCount > 0 && | ||
<> | ||
{`${fileCount} Files`}<br /> | ||
</> | ||
} | ||
{debPackageCount > 0 && | ||
<> | ||
{`${debPackageCount} Debian packages`}<br /> | ||
</>} | ||
{contentConfigTypes?.length > 0 && | ||
contentConfigTypes.map(({ count, pluralLowercase }) => ( | ||
<React.Fragment key={pluralLowercase}> | ||
{`${count} ${pluralLowercase}`}<br /> | ||
</React.Fragment>)) | ||
} | ||
</> | ||
); | ||
}; | ||
|
||
export default AdditionalCapsuleContent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
webpack/scenes/SmartProxy/ExpandedSmartProxyRepositories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { translate as __ } from 'foremanReact/common/I18n'; | ||
import {DataList, DataListItem, DataListItemRow, DataListItemCells, DataListCell} from '@patternfly/react-core'; | ||
import { CheckCircleIcon, TimesCircleIcon } from '@patternfly/react-icons'; | ||
import LongDateTime from 'foremanReact/components/common/dates/LongDateTime'; | ||
import { urlBuilder } from 'foremanReact/common/urlHelpers'; | ||
import ContentViewIcon from '../ContentViews/components/ContentViewIcon'; | ||
import AdditionalCapsuleContent from './AdditionalCapsuleContent'; | ||
import {useSet} from "../../components/Table/TableHooks"; | ||
|
||
const ExpandedSmartProxyRepositories = ({ contentCounts, repositories }) => { | ||
const getRepositoryNameById = (id) => { | ||
console.log("repos", repositories, typeof repositories); | ||
console.log("id", id, typeof id); | ||
console.log((repositories.find(repo => repo.id == id))); | ||
console.log((repositories[id] || {}).name); | ||
return (repositories.find(repo => repo.id == id) || {}).name; | ||
}; | ||
|
||
const dataListCellLists = (repo) => { | ||
var cellList= []; | ||
//console.log("contentCounts",contentCounts, typeof contentCounts); | ||
//console.log("repositories", repositories); | ||
cellList.push(<DataListCell><span>{getRepositoryNameById(repo)}</span></DataListCell>) | ||
cellList.push(<DataListCell><span>{contentCounts[repo].rpm ? contentCounts[repo].rpm + " Packages" : "N/A"}</span></DataListCell>) | ||
cellList.push(<DataListCell><AdditionalCapsuleContent counts={contentCounts[repo]} /></DataListCell>) | ||
return cellList; | ||
} | ||
return ( | ||
<DataList aria-label="Expanded repository details"> | ||
<DataListItem aria-labelledby="simple-item1"> | ||
<DataListItemRow> | ||
<DataListItemCells dataListCells={[ | ||
<DataListCell key="primary content"> | ||
<b>{__('Repositories')}</b> | ||
</DataListCell>, | ||
<DataListCell key="Packages"><b>{__('Packages')}</b></DataListCell>, | ||
<DataListCell key="Additional Content"><b>{__('Additional Content')}</b></DataListCell> | ||
]} /> | ||
</DataListItemRow> | ||
</DataListItem> | ||
{Object.keys(contentCounts).map((repo) => ( | ||
<DataListItem aria-labelledby="simple-item2"> | ||
<DataListItemRow> | ||
<DataListItemCells dataListCells={dataListCellLists(repo)} /> | ||
</DataListItemRow> | ||
</DataListItem> | ||
))} | ||
</DataList> | ||
); | ||
}; | ||
|
||
ExpandedSmartProxyRepositories.propTypes = { | ||
contentViews: PropTypes.arrayOf(PropTypes.shape({})), | ||
}; | ||
|
||
ExpandedSmartProxyRepositories.defaultProps = { | ||
contentViews: [], | ||
}; | ||
|
||
export default ExpandedSmartProxyRepositories; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters