Skip to content

Commit acf8054

Browse files
authored
feat: Dashboard now displaying name, specRef and weight in the experimental step. (argoproj#1863)
feat: Dashboard now displaying name, specRef and weight in the experimental step. (argoproj#1863) Signed-off-by: Alexander Matyushentsev <[email protected]>
1 parent 4d95f6a commit acf8054

File tree

3 files changed

+102
-3
lines changed

3 files changed

+102
-3
lines changed

ui/src/app/components/rollout/rollout.scss

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,49 @@
7676
border: 2px solid $sherbert;
7777
}
7878

79+
&-title {
80+
padding-left: 16px;
81+
padding-right: 16px;
82+
margin: 0 -16px;
83+
&--experiment {
84+
padding-bottom: 8px;
85+
border-bottom: 1px solid $argo-color-gray-6;
86+
}
87+
}
88+
89+
&__content {
90+
margin-left: -16px;
91+
margin-right: -16px;
92+
max-height: 160px;
93+
overflow-y: auto;
94+
95+
&-body {
96+
padding: 8px 16px;
97+
}
98+
99+
&-header {
100+
display: flex;
101+
align-items: center;
102+
justify-content: space-between;
103+
}
104+
105+
&-title {
106+
padding-top: 8px;
107+
padding-bottom: 4px;
108+
font-size: 14px;
109+
}
110+
111+
&-value {
112+
font-weight: 600;
113+
padding-bottom: 4px;
114+
border-bottom: 1px solid $argo-color-gray-4;
115+
&:last-child {
116+
padding-bottom: -8px;
117+
border-bottom: none;
118+
}
119+
}
120+
}
121+
79122
&:hover > &__background {
80123
transform: scale(1.02);
81124
}

ui/src/app/components/rollout/rollout.tsx

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import * as React from 'react';
33
import {Helmet} from 'react-helmet';
44
import {Key, KeybindingContext} from 'react-keyhooks';
55
import {useHistory, useParams} from 'react-router-dom';
6-
import {GithubComArgoprojArgoRolloutsPkgApisRolloutsV1alpha1CanaryStep, RolloutReplicaSetInfo, RolloutRolloutInfo, RolloutServiceApi} from '../../../models/rollout/generated';
6+
import {
7+
GithubComArgoprojArgoRolloutsPkgApisRolloutsV1alpha1CanaryStep,
8+
GithubComArgoprojArgoRolloutsPkgApisRolloutsV1alpha1RolloutExperimentTemplate,
9+
RolloutReplicaSetInfo,
10+
RolloutRolloutInfo,
11+
RolloutServiceApi,
12+
} from '../../../models/rollout/generated';
713
import {RolloutInfo} from '../../../models/rollout/rollout';
814
import {NamespaceContext, RolloutAPIContext} from '../../shared/context/api';
915
import {useWatchRollout} from '../../shared/services/rollout';
@@ -12,6 +18,7 @@ import {RolloutStatus, StatusIcon} from '../status-icon/status-icon';
1218
import {ContainersWidget} from './containers';
1319
import {Revision, RevisionWidget} from './revision';
1420
import './rollout.scss';
21+
import {Fragment} from 'react';
1522

1623
const RolloutActions = React.lazy(() => import('../rollout-actions/rollout-actions'));
1724
export interface ImageInfo {
@@ -266,6 +273,7 @@ const parseDuration = (duration: string): string => {
266273
};
267274

268275
const Step = (props: {step: GithubComArgoprojArgoRolloutsPkgApisRolloutsV1alpha1CanaryStep; complete?: boolean; current?: boolean; last?: boolean}) => {
276+
const [openedTemplate, setOpenedTemplate] = React.useState('');
269277
let icon: string;
270278
let content = '';
271279
let unit = '';
@@ -297,10 +305,52 @@ const Step = (props: {step: GithubComArgoprojArgoRolloutsPkgApisRolloutsV1alpha1
297305
return (
298306
<React.Fragment>
299307
<EffectDiv className={`steps__step ${props.complete ? 'steps__step--complete' : ''} ${props.current ? 'steps__step--current' : ''}`}>
300-
<i className={`fa ${icon}`} /> {content}
301-
{unit}
308+
<div className={`steps__step-title ${props.step.experiment ? 'steps__step-title--experiment' : ''}`}>
309+
<i className={`fa ${icon}`} /> {content}
310+
{unit}
311+
</div>
312+
{props.step.experiment?.templates && (
313+
<div className='steps__step__content'>
314+
{props.step.experiment?.templates.map((template) => {
315+
return <ExperimentWidget key={template.name} template={template} opened={openedTemplate === template.name} onToggle={setOpenedTemplate} />;
316+
})}
317+
</div>
318+
)}
302319
</EffectDiv>
303320
{!props.last && <ThemeDiv className='steps__connector' />}
304321
</React.Fragment>
305322
);
306323
};
324+
325+
const ExperimentWidget = ({
326+
template,
327+
opened,
328+
onToggle,
329+
}: {
330+
template: GithubComArgoprojArgoRolloutsPkgApisRolloutsV1alpha1RolloutExperimentTemplate;
331+
opened: boolean;
332+
onToggle: (name: string) => void;
333+
}) => {
334+
const icon = opened ? 'fa-chevron-circle-up' : 'fa-chevron-circle-down';
335+
return (
336+
<EffectDiv className='steps__step__content-body'>
337+
<ThemeDiv className={`steps__step__content-header ${opened ? 'steps__step__content-value' : ''}`}>
338+
{template.name}
339+
<ThemeDiv onClick={() => onToggle(opened ? '' : template.name)}>
340+
<i className={`fa ${icon}`} />
341+
</ThemeDiv>
342+
</ThemeDiv>
343+
{opened && (
344+
<EffectDiv>
345+
<div className='steps__step__content-title'>SPECREF</div>
346+
<div className='steps__step__content-value'>{template.specRef}</div>
347+
{template.weight && (
348+
<Fragment>
349+
<div className='steps__step__content-title'>WEIGHT</div> <div className='steps__step__content-value'>{template.weight}</div>
350+
</Fragment>
351+
)}
352+
</EffectDiv>
353+
)}
354+
</EffectDiv>
355+
);
356+
};

ui/src/models/rollout/generated/api.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,12 @@ export interface GithubComArgoprojArgoRolloutsPkgApisRolloutsV1alpha1RolloutExpe
867867
* @memberof GithubComArgoprojArgoRolloutsPkgApisRolloutsV1alpha1RolloutExperimentTemplate
868868
*/
869869
replicas?: number;
870+
/**
871+
*
872+
* @type {number}
873+
* @memberof GithubComArgoprojArgoRolloutsPkgApisRolloutsV1alpha1RolloutExperimentTemplate
874+
*/
875+
weight?: number;
870876
/**
871877
*
872878
* @type {GithubComArgoprojArgoRolloutsPkgApisRolloutsV1alpha1PodTemplateMetadata}

0 commit comments

Comments
 (0)