Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show post commit hooks for builds and build configs #1139

Merged
merged 1 commit into from
Jan 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ <h1>JavaScript Required</h1>
<script src="scripts/directives/deployImage.js"></script>
<script src="scripts/directives/selector.js"></script>
<script src="scripts/directives/selectContainers.js"></script>
<script src="scripts/directives/buildHooks.js"></script>
<script src="scripts/filters/date.js"></script>
<script src="scripts/filters/resources.js"></script>
<script src="scripts/filters/canI.js"></script>
Expand Down
14 changes: 14 additions & 0 deletions app/scripts/directives/buildHooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

angular.module('openshiftConsole')
.directive('buildHooks',
function() {
return {
restrict: 'E',
templateUrl: 'views/directives/build-hooks.html',
scope: {
build: '=' // build or build config
}
};
}
);
8 changes: 8 additions & 0 deletions app/scripts/filters/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -1412,4 +1412,12 @@ angular.module('openshiftConsole')
var revision = annotationFilter(deployment, 'deployment.kubernetes.io/revision');
return revision ? "#" + revision : 'Unknown';
};
})
.filter('hasPostCommitHook', function() {
// Check if a build or build config has a post commit hook.
return function(build) {
return _.has(build, 'spec.postCommit.command') ||
_.has(build, 'spec.postCommit.script') ||
_.has(build, 'spec.postCommit.args');
};
});
4 changes: 4 additions & 0 deletions app/views/browse/_build-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ <h3>Configuration <span class="small" ng-if="buildConfigName">created from <a hr
}
}" readonly ng-model="build.spec.strategy.jenkinsPipelineStrategy.jenkinsfile" class="ace-bordered ace-inline ace-read-only"></div>
</dl>
<div ng-if="build | hasPostCommitHook">
<h3>Post-Commit Hooks</h3>
<build-hooks build="build"></build-hooks>
</div>
</div>
</div>
<annotations annotations="build.metadata.annotations"></annotations>
Expand Down
4 changes: 4 additions & 0 deletions app/views/browse/build-config.html
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ <h4>{{imageSource.from | imageObjectRef : buildConfig.metadata.namespace}}</h4>
}" readonly ng-model="buildConfig.spec.strategy.jenkinsPipelineStrategy.jenkinsfile" class="ace-bordered ace-inline ace-read-only"></div>
</div>
</dl>
<div ng-if="buildConfig | hasPostCommitHook">
<h3>Post-Commit Hooks</h3>
<build-hooks build="buildConfig"></build-hooks>
</div>
</div>
<div class="col-lg-6">
<h3>Triggers</h3>
Expand Down
46 changes: 46 additions & 0 deletions app/views/directives/build-hooks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!--
Use `dl-horizontal left` style unless there's a script.
Otherwise use the default `dl` style because it looks strange with the block editor.
-->
<dl ng-class="{ 'dl-horizontal left': !build.spec.postCommit.script }">
<dt ng-if-start="build.spec.postCommit.command">Command:</dt>
<dd ng-if-end>
<code class="command">
<truncate-long-text
content="build.spec.postCommit.command.join(' ')"
limit="80"
newline-limit="1"
expandable="true"
use-word-boundary="false">
</truncate-long-text>
</code>
</dd>
<dt ng-if-start="build.spec.postCommit.script">Script:</dt>
<dd ng-if-end>
<div
ui-ace="{
mode: 'sh',
theme: 'eclipse',
rendererOptions: {
fadeFoldWidgets: true,
showPrintMargin: false
}
}"
ng-model="build.spec.postCommit.script"
readonly
class="ace-bordered ace-read-only ace-inline mar-top-md mar-bottom-md">
</div>
</dd>
<dt ng-if-start="build.spec.postCommit.args">Args:</dt>
<dd ng-if-end>
<code class="command">
<truncate-long-text
content="build.spec.postCommit.args.join(' ')"
limit="80"
newline-limit="1"
expandable="true"
use-word-boundary="false">
</truncate-long-text>
</code>
</dd>
</dl>
3 changes: 2 additions & 1 deletion app/views/edit/build-config.html
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ <h3 class="with-divider">Run Policy
</div>

<div ng-if="view.advancedOptions && !(updatedBuildConfig | isJenkinsPipelineStrategy)" class="section">
<h3 class="with-divider">Build Hooks
<h3 class="with-divider">
Post-Commit Hooks
<span class="help action-inline">
<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>
</span>
Expand Down
14 changes: 13 additions & 1 deletion dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13516,6 +13516,14 @@ return a;
}, !0);
} ]
};
}), angular.module("openshiftConsole").directive("buildHooks", function() {
return {
restrict:"E",
templateUrl:"views/directives/build-hooks.html",
scope:{
build:"="
}
};
}), angular.module("openshiftConsole").filter("duration", function() {
return function(a, b, c, d) {
function e(a, b, d) {
Expand Down Expand Up @@ -14344,7 +14352,11 @@ if (!b) return "";
var c = a(b, "deployment.kubernetes.io/revision");
return c ? "#" + c :"Unknown";
};
} ]), angular.module("openshiftConsole").filter("canI", [ "AuthorizationService", function(a) {
} ]).filter("hasPostCommitHook", function() {
return function(a) {
return _.has(a, "spec.postCommit.command") || _.has(a, "spec.postCommit.script") || _.has(a, "spec.postCommit.args");
};
}), angular.module("openshiftConsole").filter("canI", [ "AuthorizationService", function(a) {
return function(b, c, d) {
return a.canI(b, c, d);
};
Expand Down
43 changes: 42 additions & 1 deletion dist/scripts/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,10 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
" }\n" +
" }\" readonly=\"readonly\" ng-model=\"build.spec.strategy.jenkinsPipelineStrategy.jenkinsfile\" class=\"ace-bordered ace-inline ace-read-only\"></div>\n" +
"</dl>\n" +
"<div ng-if=\"build | hasPostCommitHook\">\n" +
"<h3>Post-Commit Hooks</h3>\n" +
"<build-hooks build=\"build\"></build-hooks>\n" +
"</div>\n" +
"</div>\n" +
"</div>\n" +
"<annotations annotations=\"build.metadata.annotations\"></annotations>\n" +
Expand Down Expand Up @@ -2128,6 +2132,10 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
" }\" readonly=\"readonly\" ng-model=\"buildConfig.spec.strategy.jenkinsPipelineStrategy.jenkinsfile\" class=\"ace-bordered ace-inline ace-read-only\"></div>\n" +
"</div>\n" +
"</dl>\n" +
"<div ng-if=\"buildConfig | hasPostCommitHook\">\n" +
"<h3>Post-Commit Hooks</h3>\n" +
"<build-hooks build=\"buildConfig\"></build-hooks>\n" +
"</div>\n" +
"</div>\n" +
"<div class=\"col-lg-6\">\n" +
"<h3>Triggers</h3>\n" +
Expand Down Expand Up @@ -6052,6 +6060,38 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
);


$templateCache.put('views/directives/build-hooks.html',
" <dl ng-class=\"{ 'dl-horizontal left': !build.spec.postCommit.script }\">\n" +
"<dt ng-if-start=\"build.spec.postCommit.command\">Command:</dt>\n" +
"<dd ng-if-end>\n" +
"<code class=\"command\">\n" +
"<truncate-long-text content=\"build.spec.postCommit.command.join(' ')\" limit=\"80\" newline-limit=\"1\" expandable=\"true\" use-word-boundary=\"false\">\n" +
"</truncate-long-text>\n" +
"</code>\n" +
"</dd>\n" +
"<dt ng-if-start=\"build.spec.postCommit.script\">Script:</dt>\n" +
"<dd ng-if-end>\n" +
"<div ui-ace=\"{\n" +
" mode: 'sh',\n" +
" theme: 'eclipse',\n" +
" rendererOptions: {\n" +
" fadeFoldWidgets: true,\n" +
" showPrintMargin: false\n" +
" }\n" +
" }\" ng-model=\"build.spec.postCommit.script\" readonly=\"readonly\" class=\"ace-bordered ace-read-only ace-inline mar-top-md mar-bottom-md\">\n" +
"</div>\n" +
"</dd>\n" +
"<dt ng-if-start=\"build.spec.postCommit.args\">Args:</dt>\n" +
"<dd ng-if-end>\n" +
"<code class=\"command\">\n" +
"<truncate-long-text content=\"build.spec.postCommit.args.join(' ')\" limit=\"80\" newline-limit=\"1\" expandable=\"true\" use-word-boundary=\"false\">\n" +
"</truncate-long-text>\n" +
"</code>\n" +
"</dd>\n" +
"</dl>"
);


$templateCache.put('views/directives/build-pipeline.html',
"<div>\n" +
"<div ng-if=\"expandOnlyRunning\">\n" +
Expand Down Expand Up @@ -9117,7 +9157,8 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
"</div>\n" +
"</div>\n" +
"<div ng-if=\"view.advancedOptions && !(updatedBuildConfig | isJenkinsPipelineStrategy)\" class=\"section\">\n" +
"<h3 class=\"with-divider\">Build Hooks\n" +
"<h3 class=\"with-divider\">\n" +
"Post-Commit Hooks\n" +
"<span class=\"help action-inline\">\n" +
"<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>\n" +
"</span>\n" +
Expand Down