Skip to content

Commit

Permalink
feat: add a button to show parameter details (#12183) (#16871)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tchoupinax authored Sep 8, 2024
1 parent 5af95b1 commit be90cc0
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

.application-deployment-history {
&__item {
cursor: pointer;
position: relative;
@include themify($themes) {
background: themed('background-2');
Expand Down Expand Up @@ -34,6 +33,10 @@
right: 1em;
}

&__show-parameter-details {
margin: 20px 0px;
}

.white-box {
margin-top: 1em;
padding: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export const ApplicationDeploymentHistory = ({
const runEnd = nextDeployedAt ? moment(nextDeployedAt) : moment();
return {...info, nextDeployedAt, durationMs: runEnd.diff(moment(info.deployedAt)) / 1000};
});

const [showParameterDetails, setShowParameterDetails] = React.useState(Boolean);

return (
<div className='application-deployment-history'>
{recentDeployments.map((info, index) => (
Expand Down Expand Up @@ -93,21 +96,30 @@ export const ApplicationDeploymentHistory = ({
index={0}
versionId={recentDeployments[index].id}
/>
<DataLoader
input={{...recentDeployments[index].source, targetRevision: recentDeployments[index].revision, appName: app.metadata.name}}
load={src => services.repos.appDetails(src, src.appName, app.spec.project, 0, recentDeployments[index].id)}>
{(details: models.RepoAppDetails) => (
<div>
<ApplicationParameters
application={{
...app,
spec: {...app.spec, source: recentDeployments[index].source}
}}
details={details}
/>
</div>
)}
</DataLoader>
<button
type='button'
className='argo-button argo-button--base application-deployment-history__show-parameter-details'
onClick={() => setShowParameterDetails(!showParameterDetails)}>
{showParameterDetails ? 'Hide details' : 'Show details'}
</button>

{showParameterDetails && (
<DataLoader
input={{...recentDeployments[index].source, targetRevision: recentDeployments[index].revision, appName: app.metadata.name}}
load={src => services.repos.appDetails(src, src.appName, app.spec.project, 0, recentDeployments[index].id)}>
{(details: models.RepoAppDetails) => (
<div>
<ApplicationParameters
application={{
...app,
spec: {...app.spec, source: recentDeployments[index].source}
}}
details={details}
/>
</div>
)}
</DataLoader>
)}
</React.Fragment>
) : (
info.sources.map((source, i) => (
Expand All @@ -128,28 +140,36 @@ export const ApplicationDeploymentHistory = ({
index={i}
versionId={recentDeployments[index].id}
/>
<button
type='button'
className='argo-button argo-button--base application-deployment-history__show-parameter-details'
onClick={() => setShowParameterDetails(!showParameterDetails)}>
{showParameterDetails ? 'Hide details' : 'Show details'}
</button>

<DataLoader
input={{
...source,
targetRevision: recentDeployments[index].revisions[i],
index: i,
versionId: recentDeployments[index].id,
appName: app.metadata.name
}}
load={src => services.repos.appDetails(src, src.appName, app.spec.project, i, recentDeployments[index].id)}>
{(details: models.RepoAppDetails) => (
<div>
<ApplicationParameters
application={{
...app,
spec: {...app.spec, source}
}}
details={details}
/>
</div>
)}
</DataLoader>
{showParameterDetails && (
<DataLoader
input={{
...source,
targetRevision: recentDeployments[index].revisions[i],
index: i,
versionId: recentDeployments[index].id,
appName: app.metadata.name
}}
load={src => services.repos.appDetails(src, src.appName, app.spec.project, i, recentDeployments[index].id)}>
{(details: models.RepoAppDetails) => (
<div>
<ApplicationParameters
application={{
...app,
spec: {...app.spec, source}
}}
details={details}
/>
</div>
)}
</DataLoader>
)}
</React.Fragment>
))
)
Expand Down

0 comments on commit be90cc0

Please sign in to comment.