-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shown images and commits and tags for components
- Loading branch information
Showing
5 changed files
with
98 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,79 @@ | ||
import { Typography } from '@equinor/eds-core-react'; | ||
import { upperFirst } from 'lodash'; | ||
import * as PropTypes from 'prop-types'; | ||
|
||
import { buildComponentMap } from '../../utils/build-component-map'; | ||
import { ComponentSummary } from '../../store/radix-api'; | ||
import { GitCommitTags } from '../component/git-commit-tags'; | ||
import { DeploymentSummary } from '../../store/radix-api'; | ||
import { DockerImage } from '../docker-image'; | ||
import { GitCommitTags } from '../component/git-commit-tags'; | ||
import { List, Typography } from '@equinor/eds-core-react'; | ||
import { Link } from 'react-router-dom'; | ||
import { routeWithParams } from '../../utils/string'; | ||
import { routes } from '../../routes'; | ||
|
||
type Props = { | ||
components: Array<ComponentSummary>; | ||
appName: string; | ||
deployments: DeploymentSummary[]; | ||
repository: string; | ||
commonCommitID: string; | ||
}; | ||
|
||
export const ComponentList = ({ | ||
components, | ||
repository, | ||
commonCommitID, | ||
}: Props) => { | ||
const compMap = buildComponentMap(components); | ||
export const ComponentList = ({ appName, deployments, repository }: Props) => { | ||
return ( | ||
<> | ||
{Object.keys(compMap).map((type: ComponentSummary['type']) => | ||
compMap[type].map((component) => ( | ||
<Typography key={`${type}-${component.name}`}> | ||
{upperFirst(type)} <strong>{component.name}</strong> | ||
{' image '} | ||
<DockerImage path={component.image} /> | ||
{commonCommitID && | ||
(component.skipDeployment || | ||
component.commitID !== commonCommitID) && ( | ||
{deployments.some((value) => value.components?.length > 0) && ( | ||
<> | ||
<Typography variant="h4">Components</Typography> | ||
<List> | ||
{deployments.map((deployment) => ( | ||
<List.Item key={deployment.name}> | ||
<Typography> | ||
Environment <strong>{deployment.environment}</strong> | ||
</Typography> | ||
<> | ||
<> from past deployment</> | ||
<GitCommitTags | ||
commitID={component.commitID} | ||
gitTags={component.gitTags} | ||
repository={repository} | ||
/> | ||
{deployment.components ? ( | ||
<List className="o-indent-list"> | ||
{deployment.components.map((component) => ( | ||
<List.Item key={`${deployment.name}-${component.name}`}> | ||
<Typography | ||
as={Link} | ||
to={routeWithParams(routes.appComponent, { | ||
appName, | ||
deploymentName: deployment.name, | ||
componentName: component.name, | ||
})} | ||
link | ||
> | ||
{component.name} | ||
</Typography>{' '} | ||
{' image '} | ||
<DockerImage path={component.image} /> | ||
{(component.skipDeployment || | ||
component.commitID !== | ||
deployment.gitCommitHash) && ( | ||
<> | ||
<> from past deployment</> | ||
<GitCommitTags | ||
commitID={component.commitID} | ||
gitTags={component.gitTags} | ||
repository={repository} | ||
/> | ||
</> | ||
)} | ||
</List.Item> | ||
))} | ||
</List> | ||
) : ( | ||
<>No components</> | ||
)} | ||
</> | ||
)} | ||
</Typography> | ||
)) | ||
</List.Item> | ||
))} | ||
</List> | ||
</> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
ComponentList.propTypes = { | ||
components: PropTypes.arrayOf( | ||
PropTypes.object as PropTypes.Validator<ComponentSummary> | ||
deployments: PropTypes.arrayOf( | ||
PropTypes.object as PropTypes.Validator<Array<DeploymentSummary>> | ||
).isRequired, | ||
}; |
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