@@ -42,7 +42,8 @@ angular.module('openshiftConsole')
42
42
"title" : "Inline"
43
43
} ] ;
44
44
$scope . view = {
45
- advancedOptions : false
45
+ advancedOptions : false ,
46
+ hasHooks : false
46
47
} ;
47
48
$scope . breadcrumbs = [
48
49
{
@@ -104,52 +105,76 @@ angular.module('openshiftConsole')
104
105
"SerialLatestOnly"
105
106
] ;
106
107
107
- $scope . buildHookTypes = [
108
- "Shell Script" ,
109
- "Command" ,
110
- "Arguments to Default Image Entry Point" ,
111
- "Shell Script with Arguments" ,
112
- "Command with Arguments"
113
- ] ;
108
+ $scope . buildHookTypes = [ {
109
+ "id" : "script" ,
110
+ "label" : "Shell Script"
111
+ } , {
112
+ "id" : "command" ,
113
+ "label" : "Command"
114
+ } , {
115
+ "id" : "args" ,
116
+ "label" : "Arguments to Default Image Entry Point"
117
+ } , {
118
+ "id" : "scriptArgs" ,
119
+ "label" : "Shell Script with Arguments"
120
+ } , {
121
+ "id" : "commandArgs" ,
122
+ "label" : "Command with Arguments"
123
+ } ] ;
114
124
115
- $scope . buildHookSelection = { } ;
125
+ $scope . buildHookSelection = {
126
+ "type" : { }
127
+ } ;
116
128
117
129
var getInitialBuildHookSelection = function ( ) {
118
- if ( ( $scope . buildConfig . spec . postCommit . args || [ ] ) . length ) {
119
- if ( ( $scope . buildConfig . spec . postCommit . command || [ ] ) . length ) {
120
- $scope . buildHookSelection . type = "Command with Arguments" ; sdas
121
- } else if ( ( $scope . buildConfig . spec . postCommit . script || "" ) . length ) {
122
- $scope . buildHookSelection . type = "Shell Script with Arguments" ;
123
- } else {
124
- $scope . buildHookSelection . type = "Arguments to Default Image Entry Point" ;
125
- }
126
- } else if ( ( $scope . buildConfig . spec . postCommit . command || [ ] ) . length ) {
127
- $scope . buildHookSelection . type = "Command" ;
130
+ $scope . view . hasHooks = ( _ . size ( $scope . buildConfig . spec . postCommit . args ) ||
131
+ _ . size ( $scope . buildConfig . spec . postCommit . command ) ||
132
+ $scope . buildConfig . spec . postCommit . script ) ? true : false ;
133
+
134
+ if ( _ . size ( $scope . buildConfig . spec . postCommit . args ) && _ . size ( $scope . buildConfig . spec . postCommit . command ) ) {
135
+ $scope . buildHookSelection . type . id = "commandArgs" ;
136
+ } else if ( $scope . buildConfig . spec . postCommit . script && _ . size ( $scope . buildConfig . spec . postCommit . args ) ) {
137
+ $scope . buildHookSelection . type . id = "scriptArgs" ;
138
+ } else if ( _ . size ( $scope . buildConfig . spec . postCommit . args ) ) {
139
+ $scope . buildHookSelection . type . id = "args" ;
140
+ } else if ( $scope . buildConfig . spec . postCommit . script ) {
141
+ $scope . buildHookSelection . type . id = "script" ;
128
142
} else {
129
- $scope . buildHookSelection . type = "Shell Script " ;
143
+ $scope . buildHookSelection . type . id = "command " ;
130
144
}
145
+
146
+ $scope . buildHookSelection . type . label = _ . find ( $scope . buildHookTypes , { 'id' : $scope . buildHookSelection . type . id } ) . label ;
131
147
} ;
132
148
133
- var clearIncompatibleBuildHookFields = function ( selectedBuildHook ) {
134
- switch ( selectedBuildHook ) {
135
- case "Shell Script" :
136
- $scope . buildConfig . spec . postCommit . command = [ ] ;
137
- $scope . buildConfig . spec . postCommit . args = [ ] ;
138
- break ;
139
- case "Command" :
140
- $scope . buildConfig . spec . postCommit . script = "" ;
141
- $scope . buildConfig . spec . postCommit . args = [ ] ;
142
- break ;
143
- case "Arguments to Default Image Entry Point" :
144
- $scope . buildConfig . spec . postCommit . script = "" ;
145
- $scope . buildConfig . spec . postCommit . command = [ ] ;
146
- break ;
147
- case "Shell Script with Arguments" :
148
- $scope . buildConfig . spec . postCommit . command = [ ] ;
149
- break ;
150
- case "Command with Arguments" :
151
- $scope . buildConfig . spec . postCommit . script = "" ;
152
- break ;
149
+ var clearIncompatibleBuildHookFields = function ( selectedBuildHookID ) {
150
+ console . log ( "Checkbox state " , $scope . view . hasHooks ) ;
151
+ if ( $scope . view . hasHooks ) {
152
+ console . log ( "Enable editor" ) ;
153
+ switch ( selectedBuildHookID ) {
154
+ case "script" :
155
+ $scope . updatedBuildConfig . spec . postCommit . command = [ ] ;
156
+ $scope . updatedBuildConfig . spec . postCommit . args = [ ] ;
157
+ break ;
158
+ case "command" :
159
+ $scope . updatedBuildConfig . spec . postCommit . script = "" ;
160
+ $scope . updatedBuildConfig . spec . postCommit . args = [ ] ;
161
+ break ;
162
+ case "args" :
163
+ $scope . updatedBuildConfig . spec . postCommit . script = "" ;
164
+ $scope . updatedBuildConfig . spec . postCommit . command = [ ] ;
165
+ break ;
166
+ case "scriptArgs" :
167
+ $scope . updatedBuildConfig . spec . postCommit . command = [ ] ;
168
+ break ;
169
+ case "commandArgs" :
170
+ $scope . updatedBuildConfig . spec . postCommit . script = "" ;
171
+ break ;
172
+ }
173
+ } else {
174
+ console . log ( "Disable editor" ) ;
175
+ $scope . updatedBuildConfig . spec . postCommit . command = [ ] ;
176
+ $scope . updatedBuildConfig . spec . postCommit . args = [ ] ;
177
+ $scope . updatedBuildConfig . spec . postCommit . script = "" ;
153
178
}
154
179
} ;
155
180
@@ -458,7 +483,7 @@ angular.module('openshiftConsole')
458
483
459
484
$scope . save = function ( ) {
460
485
$scope . disableInputs = true ;
461
- clearIncompatibleBuildHookFields ( $scope . buildHookSelection . type ) ;
486
+ clearIncompatibleBuildHookFields ( $scope . buildHookSelection . type . id ) ;
462
487
// Update Configuration
463
488
buildStrategy ( $scope . updatedBuildConfig ) . forcePull = $scope . options . forcePull ;
464
489
@@ -503,7 +528,8 @@ angular.module('openshiftConsole')
503
528
// Update envVars
504
529
buildStrategy ( $scope . updatedBuildConfig ) . env = keyValueEditorUtils . compactEntries ( $scope . envVars ) ;
505
530
506
- $scope . updatedBuildConfig . spec . postCommit = $scope . buildConfig . spec . postCommit ;
531
+ //$scope.updatedBuildConfig.spec.postCommit = $scope.buildConfig.spec.postCommit;
532
+ console . log ( "Updated BC Spec PC: " , $scope . updatedBuildConfig . spec . postCommit ) ;
507
533
508
534
// Update secrets
509
535
updateSecrets ( $scope . updatedBuildConfig . spec . source , _ . head ( $scope . secrets . picked . gitSecret ) , "sourceSecret" ) ;
0 commit comments