@@ -17,6 +17,7 @@ import {
1717} from 'kubernetes/v2/manifest/manifestCommandBuilder.service' ;
1818
1919import { IManifestBindArtifact } from './ManifestBindArtifactsSelector' ;
20+ import { yamlDocumentsToString } from '../../../manifest/editor/yaml/yamlEditorUtils' ;
2021
2122export class KubernetesV2DeployManifestConfigCtrl implements IController {
2223 public state = {
@@ -29,6 +30,7 @@ export class KubernetesV2DeployManifestConfigCtrl implements IController {
2930 public manifestArtifactDelegate : NgGenericArtifactDelegate ;
3031 public manifestArtifactController : ExpectedArtifactSelectorViewController ;
3132 public sources = [ this . textSource , this . artifactSource ] ;
33+ public rawManifest : string ;
3234
3335 public static $inject = [ '$scope' ] ;
3436
@@ -63,6 +65,9 @@ export class KubernetesV2DeployManifestConfigCtrl implements IController {
6365 this . state . loaded = true ;
6466 this . manifestArtifactDelegate . setAccounts ( get ( this , [ 'metadata' , 'backingData' , 'artifactAccounts' ] , [ ] ) ) ;
6567 this . manifestArtifactController . updateAccounts ( this . manifestArtifactDelegate . getSelectedExpectedArtifact ( ) ) ;
68+ if ( stage . source === this . textSource ) {
69+ this . initRawManifest ( ) ;
70+ }
6671 } ) ;
6772 }
6873
@@ -97,11 +102,26 @@ export class KubernetesV2DeployManifestConfigCtrl implements IController {
97102
98103 public handleCopy = ( manifest : IManifest ) => {
99104 this . $scope . stage . manifests = [ manifest ] ;
105+ this . initRawManifest ( ) ;
100106 // This method is called from a React component.
101107 this . $scope . $applyAsync ( ) ;
102108 } ;
103109
104110 public checkFeatureFlag ( flag : string ) : boolean {
105111 return ! ! SETTINGS . feature [ flag ] ;
106112 }
113+
114+ // If we have more than one manifest, render as a
115+ // list of manifests. Otherwise, hide the fact
116+ // that the underlying model is a list.
117+ public initRawManifest = ( ) : void => {
118+ this . rawManifest = yamlDocumentsToString ( this . $scope . stage . manifests ) ;
119+ } ;
120+
121+ public handleRawManifestChange = ( rawManifest : string , manifests : any ) : void => {
122+ this . rawManifest = rawManifest ;
123+ this . $scope . stage . manifests = manifests ;
124+ // This method is called from a React component.
125+ this . $scope . $applyAsync ( ) ;
126+ } ;
107127}
0 commit comments