Skip to content

Commit

Permalink
Merge pull request #17 from alexmt/402-deployment-override-history
Browse files Browse the repository at this point in the history
Issue #402 - App deployment history don't display parameter overrides
  • Loading branch information
alexmt authored Jul 13, 2018
2 parents af88064 + 658a16f commit 71b02e3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ({
Expand All @@ -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 (
Expand Down Expand Up @@ -51,15 +57,20 @@ export const ApplicationDeploymentHistory = ({
</div>
</div>
</div>
{info.params.map((param, i) => (
<div className='row' key={i}>
<div className='columns small-2 application-deployment-history__param-name'>
<span>{param.component}.{param.name}:</span>
</div>
<div className='columns small-10'>
{param.value}
{Array.from(info.componentParams.keys()).map((component) => (
info.componentParams.get(component).map((param) => (
<div className='row' key={component + param.name}>
<div className='columns small-2 application-deployment-history__param-name'>
<span>{param.component}.{param.name}:</span>
</div>
<div className='columns small-10'>
<span title={param.value}>
{param.original && <span className='fa fa-exclamation-triangle' title={`Original value: ${param.original}`}/>}
{param.value}
</span>
</div>
</div>
</div>
))
))}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, (models.ComponentParameter & {original: string})[]>();
(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 (
<div className='white-box'>
<div className='white-box__details'>
Expand Down
18 changes: 18 additions & 0 deletions src/app/applications/components/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, (appModels.ComponentParameter & {original: string})[]>();
(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);
Expand Down

0 comments on commit 71b02e3

Please sign in to comment.