diff --git a/src/app/applications/components/application-deployment-history/application-deployment-history.tsx b/src/app/applications/components/application-deployment-history/application-deployment-history.tsx index bf505115c5930..9d001170ac82d 100644 --- a/src/app/applications/components/application-deployment-history/application-deployment-history.tsx +++ b/src/app/applications/components/application-deployment-history/application-deployment-history.tsx @@ -4,6 +4,8 @@ import * as React from 'react'; import * as models from '../../../shared/models'; +import { getParamsWithOverridesInfo } from '../utils'; + require('./application-deployment-history.scss'); export const ApplicationDeploymentHistory = ({ @@ -19,10 +21,14 @@ export const ApplicationDeploymentHistory = ({ }) => { const deployments = (app.status.history || []).slice().reverse(); const recentDeployments = deployments.map((info, i) => { - const params = info.params || []; const nextDeployedAt = i === 0 ? null : deployments[i - 1].deployedAt; const runEnd = nextDeployedAt ? moment(nextDeployedAt) : moment(); - return {...info, nextDeployedAt, durationMs: runEnd.diff(moment(info.deployedAt)) / 1000, params: selectedRollbackDeploymentIndex === i ? params : params.slice(0, 3)}; + let params = info.params || []; + if (selectedRollbackDeploymentIndex !== i) { + params = params.slice(0, 3); + } + const componentParams = getParamsWithOverridesInfo(params, info.componentParameterOverrides || []); + return {...info, componentParams, nextDeployedAt, durationMs: runEnd.diff(moment(info.deployedAt)) / 1000}; }); return ( @@ -51,15 +57,20 @@ export const ApplicationDeploymentHistory = ({ - {info.params.map((param, i) => ( -
-
- {param.component}.{param.name}: -
-
- {param.value} + {Array.from(info.componentParams.keys()).map((component) => ( + info.componentParams.get(component).map((param) => ( +
+
+ {param.component}.{param.name}: +
+
+ + {param.original && } + {param.value} + +
-
+ )) ))}
diff --git a/src/app/applications/components/parameters-panel/parameters-panel.tsx b/src/app/applications/components/parameters-panel/parameters-panel.tsx index d4e9dcf958622..5d6356c7a0570 100644 --- a/src/app/applications/components/parameters-panel/parameters-panel.tsx +++ b/src/app/applications/components/parameters-panel/parameters-panel.tsx @@ -2,21 +2,10 @@ import * as React from 'react'; import * as models from '../../../shared/models'; +import { getParamsWithOverridesInfo } from '../utils'; + export const ParametersPanel = (props: { params: models.ComponentParameter[], overrides?: models.ComponentParameter[]}) => { - const componentParams = new Map(); - (props.params || []).map((param) => { - const override = (props.overrides || []).find((item) => item.component === param.component && item.name === param.name); - const res = {...param, original: ''}; - if (override) { - res.original = res.value; - res.value = override.value; - } - return res; - }).forEach((param) => { - const params = componentParams.get(param.component) || []; - params.push(param); - componentParams.set(param.component, params); - }); + const componentParams = getParamsWithOverridesInfo(props.params, props.overrides); return (
diff --git a/src/app/applications/components/utils.tsx b/src/app/applications/components/utils.tsx index 063066d24c48a..215d096a40a88 100644 --- a/src/app/applications/components/utils.tsx +++ b/src/app/applications/components/utils.tsx @@ -6,6 +6,24 @@ import { AppContext } from '../../shared/context'; import * as appModels from '../../shared/models'; import { services } from '../../shared/services'; +export function getParamsWithOverridesInfo(params: appModels.ComponentParameter[], overrides: appModels.ComponentParameter[]) { + const componentParams = new Map(); + (params || []).map((param) => { + const override = (overrides || []).find((item) => item.component === param.component && item.name === param.name); + const res = {...param, original: ''}; + if (override) { + res.original = res.value; + res.value = override.value; + } + return res; + }).forEach((param) => { + const items = componentParams.get(param.component) || []; + items.push(param); + componentParams.set(param.component, items); + }); + return componentParams; +} + export async function syncApplication(appName: string, revision: string, prune: boolean, context: AppContext) { try { await services.applications.sync(appName, revision, prune);