Skip to content

Commit 71b96b9

Browse files
author
Mark DeMaria
committed
Add checkbox
Change format to single select dropdown containing all available combinations
1 parent 269c025 commit 71b96b9

File tree

4 files changed

+133
-132
lines changed

4 files changed

+133
-132
lines changed

app/index.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<meta name="msapplication-TileImage" content="images/mstile-144x144.png">
1616
<!-- build:css(.) styles/vendor.css -->
1717
<!-- bower:css -->
18+
<link rel="stylesheet" href="bower_components/bootstrap-touchspin/src/jquery.bootstrap-touchspin.css" />
1819
<link rel="stylesheet" href="bower_components/angular-patternfly/dist/styles/angular-patternfly.css" />
1920
<link rel="stylesheet" href="bower_components/messenger/build/css/messenger-theme-flat.css" />
2021
<link rel="stylesheet" href="bower_components/kubernetes-label-selector/labelFilter.css" />
@@ -98,17 +99,18 @@ <h1>JavaScript Required</h1>
9899
<script src="bower_components/lodash/lodash.js"></script>
99100
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
100101
<script src="bower_components/bootstrap-combobox/js/bootstrap-combobox.js"></script>
101-
<script src="bower_components/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
102+
<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
102103
<script src="bower_components/bootstrap-select/dist/js/bootstrap-select.js"></script>
103104
<script src="bower_components/bootstrap-switch/dist/js/bootstrap-switch.js"></script>
104-
<script src="bower_components/bootstrap-treeview/dist/bootstrap-treeview.min.js"></script>
105+
<script src="bower_components/bootstrap-touchspin/src/jquery.bootstrap-touchspin.js"></script>
105106
<script src="bower_components/d3/d3.js"></script>
106107
<script src="bower_components/c3/c3.js"></script>
107108
<script src="bower_components/datatables/media/js/jquery.dataTables.js"></script>
108109
<script src="bower_components/datatables-colreorder/js/dataTables.colReorder.js"></script>
109110
<script src="bower_components/datatables-colvis/js/dataTables.colVis.js"></script>
110-
<script src="bower_components/matchHeight/jquery.matchHeight-min.js"></script>
111+
<script src="bower_components/matchHeight/dist/jquery.matchHeight.js"></script>
111112
<script src="bower_components/moment/moment.js"></script>
113+
<script src="bower_components/patternfly-bootstrap-treeview/dist/bootstrap-treeview.min.js"></script>
112114
<script src="bower_components/patternfly/dist/js/patternfly.js"></script>
113115
<script src="bower_components/angular-patternfly/dist/angular-patternfly.js"></script>
114116
<script src="bower_components/uri.js/src/URI.js"></script>

app/scripts/constants.js

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ window.OPENSHIFT_CONSTANTS = {
3838
"roles": "https://docs.openshift.org/latest/architecture/additional_concepts/authorization.html#roles",
3939
"service_accounts": "https://docs.openshift.org/latest/dev_guide/service_accounts.html",
4040
"users_and_groups": "https://docs.openshift.org/latest/architecture/additional_concepts/authentication.html#users-and-groups",
41+
"build-hooks": "https://docs.openshift.org/latest/dev_guide/builds.html#build-hooks",
4142
// default should remain last, add new links above
4243
"default": "https://docs.openshift.org/latest/welcome/index.html"
4344
},

app/scripts/controllers/edit/buildConfig.js

+68-42
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ angular.module('openshiftConsole')
4242
"title": "Inline"
4343
}];
4444
$scope.view = {
45-
advancedOptions: false
45+
advancedOptions: false,
46+
hasHooks: false
4647
};
4748
$scope.breadcrumbs = [
4849
{
@@ -104,52 +105,76 @@ angular.module('openshiftConsole')
104105
"SerialLatestOnly"
105106
];
106107

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+
}];
114124

115-
$scope.buildHookSelection = {};
125+
$scope.buildHookSelection = {
126+
"type": {}
127+
};
116128

117129
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";
128142
} else {
129-
$scope.buildHookSelection.type = "Shell Script";
143+
$scope.buildHookSelection.type.id = "command";
130144
}
145+
146+
$scope.buildHookSelection.type.label = _.find($scope.buildHookTypes, {'id': $scope.buildHookSelection.type.id}).label;
131147
};
132148

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 = "";
153178
}
154179
};
155180

@@ -458,7 +483,7 @@ angular.module('openshiftConsole')
458483

459484
$scope.save = function() {
460485
$scope.disableInputs = true;
461-
clearIncompatibleBuildHookFields($scope.buildHookSelection.type);
486+
clearIncompatibleBuildHookFields($scope.buildHookSelection.type.id);
462487
// Update Configuration
463488
buildStrategy($scope.updatedBuildConfig).forcePull = $scope.options.forcePull;
464489

@@ -503,7 +528,8 @@ angular.module('openshiftConsole')
503528
// Update envVars
504529
buildStrategy($scope.updatedBuildConfig).env = keyValueEditorUtils.compactEntries($scope.envVars);
505530

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);
507533

508534
// Update secrets
509535
updateSecrets($scope.updatedBuildConfig.spec.source, _.head($scope.secrets.picked.gitSecret), "sourceSecret");

app/views/edit/build-config.html

+59-87
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@ <h3 class="with-divider">Run Policy
525525
{{type | sentenceCase}}
526526
</ui-select-choices>
527527
</ui-select>
528-
529528
</div>
529+
530530
<div ng-switch="updatedBuildConfig.spec.runPolicy">
531531
<div class="help-block" ng-switch-when="Serial">Builds triggered from this Build Configuration will run one at the time, in the order they have been triggered.</div>
532532
<div class="help-block" ng-switch-when="Parallel">Builds triggered from this Build Configuration will run all at the same time. The order in which they will finish is not guaranteed.</div>
@@ -535,95 +535,67 @@ <h3 class="with-divider">Run Policy
535535
</div>
536536
</div>
537537

538-
<div class="section" ng-if="view.advancedOptions">
539-
<div ng-if="!(updatedBuildConfig | isJenkinsPipelineStrategy)" class="section">
540-
<h3 class="with-divider">Build Hooks
541-
<span class="help action-inline">
542-
<a href>
543-
<i class="pficon pficon-help" data-toggle="tooltip" aria-hidden="true" data-original-title="Build hooks allow behavior to be injected into the build process."></i>
544-
</a>
545-
</span>
546-
</h3>
538+
<div ng-if="view.advancedOptions && !(updatedBuildConfig | isJenkinsPipelineStrategy)" class="section">
539+
<h3 class="with-divider">Build Hooks
540+
<span class="help action-inline">
541+
<a href="{{'build-hooks' | helpLink}}" aria-hidden="true" target="_blank"><span class="learn-more-inline">Learn more&nbsp;<i class="fa fa-external-link"></i></span></a>
542+
</span>
543+
</h3>
547544

548-
<div>
549-
<div class="form-group">
550-
<h4>Hook Types</h4>
551-
<ui-select required
552-
ng-model="buildHookSelection.type"
553-
title="Choose a Build Hook type to edit">
554-
<ui-select-match>{{$select.selected | sentenceCase}}</ui-select-match>
555-
<ui-select-choices repeat="type in buildHookTypes">
556-
{{type | sentenceCase }}
557-
</ui-select-choices>
558-
</ui-select>
559-
</div>
545+
<div class="checkbox">
546+
<label>
547+
<input type="checkbox" ng-model="view.hasHooks" id="enable-build-hooks">
548+
Run build hooks after image is built
549+
</label>
550+
<div class="help-block">
551+
Build hooks allow you to run commands at the end of the build to verify the image.
552+
</div>
553+
</div>
560554

561-
<fieldset>
562-
<div ng-show="buildHookSelection.type === 'Shell Script'">
563-
<h4>Script</h4>
564-
<div
565-
ui-ace="{
566-
mode: 'yaml',
567-
theme: 'eclipse',
568-
onLoad: aceLoaded,
569-
rendererOptions: {
570-
fadeFoldWidgets: true,
571-
showPrintMargin: false
572-
}
573-
}"
574-
ng-model="buildConfig.spec.postCommit.script"
575-
class="ace-bordered ace-read-only ace-inline dockerfile-mode mar-top-md">
576-
</div>
577-
</div>
578-
<div ng-show="buildHookSelection.type === 'Command'">
579-
<h4>Command</h4>
580-
<edit-command
581-
args="buildConfig.spec.postCommit.command"
582-
isRequired="true">
583-
</edit-command>
584-
</div>
585-
<div ng-show="buildHookSelection.type === 'Arguments to Default Image Entry Point'">
586-
<h4>Arguments to Default Image Entry Point</h4>
587-
<edit-command
588-
args="buildConfig.spec.postCommit.args"
589-
isRequired="true">
590-
</edit-command>
591-
</div>
592-
<div ng-show="buildHookSelection.type === 'Shell Script with Arguments'">
593-
<h4>Shell Script with Arguments</h4>
594-
<div
595-
ui-ace="{
596-
mode: 'yaml',
597-
theme: 'eclipse',
598-
onLoad: aceLoaded,
599-
rendererOptions: {
600-
fadeFoldWidgets: true,
601-
showPrintMargin: false
602-
}
603-
}"
604-
ng-model="buildConfig.spec.postCommit.script"
605-
class="ace-bordered ace-read-only ace-inline dockerfile-mode mar-top-md">
606-
</div>
607-
<h4>Arguments</h4>
608-
<edit-command
609-
args="buildConfig.spec.postCommit.args"
610-
isRequired="false">
611-
</edit-command>
612-
</div>
613-
<div ng-show="buildHookSelection.type === 'Command with Arguments'">
614-
<h4>Command</h4>
615-
<edit-command
616-
args="buildConfig.spec.postCommit.command"
617-
isRequired="true">
618-
</edit-command>
619-
<h4 class="mar-top-xl">Arguments</h4>
620-
<edit-command
621-
args="buildConfig.spec.postCommit.args"
622-
isRequired="true">
623-
</edit-command>
624-
</div>
625-
</fieldset>
555+
<div ng-show="view.hasHooks">
556+
<div class="form-group">
557+
<h4>Hook Types</h4>
558+
<ui-select
559+
ng-model="buildHookSelection.type"
560+
title="Choose a type of build hook">
561+
<ui-select-match>{{$select.selected.label}}</ui-select-match>
562+
<ui-select-choices repeat="type in buildHookTypes">
563+
{{type.label}}
564+
</ui-select-choices>
565+
</ui-select>
626566
</div>
567+
568+
<fieldset>
569+
<div ng-show="buildHookSelection.type.id === 'script' || buildHookSelection.type.id === 'scriptArgs'">
570+
<h4>Script</h4>
571+
<div
572+
ui-ace="{
573+
mode: 'sh',
574+
theme: 'eclipse',
575+
rendererOptions: {
576+
fadeFoldWidgets: true,
577+
showPrintMargin: false
578+
}
579+
}"
580+
ng-model="updatedBuildConfig.spec.postCommit.script"
581+
class="ace-bordered ace-inline mar-top-md">
582+
</div>
583+
</div>
584+
585+
<div ng-show="buildHookSelection.type.id === 'command' || buildHookSelection.type.id === 'commandArgs'">
586+
<h4>Command</h4>
587+
<edit-command
588+
args="updatedBuildConfig.spec.postCommit.command">
589+
</edit-command>
590+
</div>
591+
592+
<div ng-show="buildHookSelection.type.id === 'args' || buildHookSelection.type.id === 'commandArgs' || buildHookSelection.type.id === 'scriptArgs' ">
593+
<h4>Arguments</h4>
594+
<edit-command
595+
args="updatedBuildConfig.spec.postCommit.args">
596+
</edit-command>
597+
</div>
598+
</fieldset>
627599
</div>
628600
</div>
629601

0 commit comments

Comments
 (0)