@@ -3,6 +3,7 @@ import * as yaml from 'yamljs';
3
3
4
4
import * as models from '../../../../models' ;
5
5
import { Utils } from '../../../shared/components' ;
6
+ import { SlideContents } from '../../../shared/components/slide-contents/slide-contents' ;
6
7
7
8
require ( './workflow-yaml-viewer.scss' ) ;
8
9
@@ -23,19 +24,64 @@ export class WorkflowYamlViewer extends React.Component<WorkflowYamlViewerProps>
23
24
}
24
25
25
26
public render ( ) {
26
- let nodeName = '' ;
27
+ const contents : JSX . Element [ ] = [ ] ;
27
28
if ( this . props . selectedNode ) {
28
- nodeName = this . normalizeNodeName ( this . props . selectedNode . displayName || this . props . selectedNode . name ) ;
29
- }
30
- const html = this . props . workflow . spec . templates . map ( ( item ) => {
31
- let itemStr = yaml . stringify ( item , 4 , 1 ) ;
32
- if ( nodeName ) {
33
- itemStr = this . highlightStep ( item , nodeName , itemStr ) ;
29
+ const parentNode = this . props . workflow . status . nodes [ this . props . selectedNode . boundaryID ] ;
30
+ if ( parentNode ) {
31
+ const parentTemplate = Utils . getResolvedTemplates ( this . props . workflow , parentNode ) ;
32
+
33
+ let nodeName = '' ;
34
+ if ( this . props . selectedNode ) {
35
+ nodeName = this . normalizeNodeName ( this . props . selectedNode . displayName || this . props . selectedNode . name ) ;
36
+ }
37
+ let parentTemplateStr = yaml . stringify ( parentTemplate , 4 , 1 ) ;
38
+ if ( nodeName ) {
39
+ parentTemplateStr = this . highlightStep ( parentTemplate , nodeName , parentTemplateStr ) ;
40
+ }
41
+ contents . push (
42
+ < div className = 'workflow-yaml-section' >
43
+ < h4 > Parent Node</ h4 >
44
+ < div dangerouslySetInnerHTML = { { __html : this . addCounterToDisplayedFiles ( parentTemplateStr ) } } />
45
+ </ div > ,
46
+ ) ;
34
47
}
35
- return this . addCounterToDisplayedFiles ( itemStr ) ;
36
- } ) . join ( '\n\n' ) ;
48
+
49
+ const template = Utils . getResolvedTemplates ( this . props . workflow , this . props . selectedNode ) ;
50
+ const templateStr = yaml . stringify ( template , 4 , 1 ) ;
51
+ contents . push (
52
+ < div className = 'workflow-yaml-section' >
53
+ < h4 > Current Node</ h4 >
54
+ < div dangerouslySetInnerHTML = { { __html : this . addCounterToDisplayedFiles ( templateStr ) } } />
55
+ </ div > ,
56
+ ) ;
57
+ }
58
+ const templates = this . props . workflow . spec . templates ;
59
+ if ( templates && Object . keys ( templates ) . length ) {
60
+ const templatesStr = yaml . stringify ( templates , 4 , 1 ) ;
61
+ contents . push ( (
62
+ < SlideContents
63
+ title = { 'Templates' }
64
+ contents = { < div dangerouslySetInnerHTML = { { __html : this . addCounterToDisplayedFiles ( templatesStr ) } } /> }
65
+ className = 'workflow-yaml-section'
66
+ />
67
+ ) ) ;
68
+ }
69
+ const storedTemplates = this . props . workflow . status . storedTemplates ;
70
+ if ( storedTemplates && Object . keys ( storedTemplates ) . length ) {
71
+ const storedTemplatesStr = yaml . stringify ( storedTemplates , 4 , 1 ) ;
72
+ contents . push ( (
73
+ < SlideContents
74
+ title = { 'Stored Templates' }
75
+ contents = { < div dangerouslySetInnerHTML = { { __html : this . addCounterToDisplayedFiles ( storedTemplatesStr ) } } /> }
76
+ className = 'workflow-yaml-section'
77
+ />
78
+ ) ) ;
79
+ }
80
+
37
81
return (
38
- < div className = 'workflow-yaml-viewer' dangerouslySetInnerHTML = { { __html : html } } ref = { ( container ) => this . container = container } />
82
+ < div className = 'workflow-yaml-viewer' ref = { ( container ) => this . container = container } >
83
+ { contents }
84
+ </ div >
39
85
) ;
40
86
}
41
87
@@ -47,7 +93,7 @@ export class WorkflowYamlViewer extends React.Component<WorkflowYamlViewerProps>
47
93
if ( item !== '' ) {
48
94
if ( item . indexOf ( '<span>' ) !== - 1 ) {
49
95
item = item . match ( / ^ < s p a n > \s * / ) [ 0 ] + item . substr ( 6 ) ;
50
- item = `<li class=" highlight" >${ item } </li>` ;
96
+ item = `<li class=' highlight' >${ item } </li>` ;
51
97
} else {
52
98
item = item . match ( / ^ \s * / ) [ 0 ] + item ;
53
99
// special treatment to beautify resource templates
0 commit comments